Files
RedBear-OS/local/recipes/shells/brush/source/brush-interactive/src/input_backend.rs
T
vasilito 25fb843c40 brush: vendor the source tree (un-ignore) to complete the local fork
The prior commit switched the recipe to `[source] path = "source"`, but
.gitignore:77 still listed `local/recipes/shells/brush/source` (a leftover from
when brush was a transient upstream git fetch), so the vendored tree was not
tracked — a fresh clone would have no brush source and the build would fail.
Drop that ignore line and commit the vendored working tree (reubeno/brush @
897b373e, with the Redox port patches pre-applied). brush is now a durable
local fork like the other path=source recipes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-26 23:34:31 +09:00

52 lines
1.6 KiB
Rust

use crate::ShellError;
/// Represents an input backend for reading lines of input.
pub trait InputBackend: Send {
/// Reads a line of input, using the given prompt.
///
/// # Arguments
///
/// * `shell` - The shell instance for which input is being read.
/// * `prompt` - The prompt to display to the user.
fn read_line(
&mut self,
shell: &crate::ShellRef<impl brush_core::ShellExtensions>,
prompt: InteractivePrompt,
) -> Result<ReadResult, ShellError>;
/// Returns the current contents of the read buffer and the current cursor
/// position within the buffer; None is returned if the read buffer is
/// empty or cannot be read by this implementation.
fn get_read_buffer(&self) -> Option<(String, usize)> {
None
}
/// Updates the read buffer with the given string and cursor. Considered a
/// no-op if the implementation does not support updating read buffers.
fn set_read_buffer(&mut self, _buffer: String, _cursor: usize) {
// No-op by default.
}
}
/// Result of a read operation.
pub enum ReadResult {
/// The user entered a line of input.
Input(String),
/// A bound key sequence yielded a registered command.
BoundCommand(String),
/// End of input was reached.
Eof,
/// The user interrupted the input operation.
Interrupted,
}
/// Represents an interactive prompt.
pub struct InteractivePrompt {
/// Prompt to display.
pub prompt: String,
/// Alternate-side prompt (typically right) to display.
pub alt_side_prompt: String,
/// Prompt to display on a continuation line of input.
pub continuation_prompt: String,
}