Skip to main content

line_editor/
lib.rs

1// Copyright 2026 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5//! A line editing library providing an idiomatic Rust interface (`Editor`, `History`, `Config`,
6//! `Color`, `Hint`, autocompletion, and multiline mode) derived from `linenoise`.
7
8mod config;
9mod control;
10mod editor;
11mod history;
12mod io;
13mod state;
14mod types;
15
16#[cfg(test)]
17mod tests;
18
19pub use config::{
20    ColumnWidth, Config, DEFAULT_COLUMN_COUNT, DEFAULT_MAX_HISTORY_LEN, DEFAULT_MAX_LINE_LEN,
21    OperatingMode, TerminalCapability, TerminalMode, terminal_capability_from_name,
22};
23pub use editor::Editor;
24pub use history::History;
25pub use io::UnbufferedStdout;
26pub use types::{Color, CompletionHandler, Hint, HintHandler, ReadlineError};
27
28use bstr::BStr;
29
30/// Reads a line from stdin using default configuration.
31pub fn readline(prompt: impl AsRef<BStr>) -> Result<bstr::BString, ReadlineError> {
32    let mut editor = Editor::new();
33    editor.readline(prompt)
34}