mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
Folderize hinter
This commit is contained in:
parent
804f31d181
commit
56ea39ec32
@ -1,31 +1,9 @@
|
||||
use {
|
||||
crate::History,
|
||||
nu_ansi_term::{Color, Style},
|
||||
};
|
||||
use crate::{Hinter, History};
|
||||
use nu_ansi_term::{Color, Style};
|
||||
|
||||
/// A trait that's responsible for returning the hint for the current line and position
|
||||
/// Hints are often shown in-line as part of the buffer, showing the user text they can accept or ignore
|
||||
pub trait Hinter: Send {
|
||||
/// Handle the hinting duty by using the line, position, and current history
|
||||
///
|
||||
/// Returns the formatted output to show the user
|
||||
fn handle(
|
||||
&mut self,
|
||||
line: &str,
|
||||
pos: usize,
|
||||
history: &dyn History,
|
||||
use_ansi_coloring: bool,
|
||||
) -> String;
|
||||
|
||||
/// Return the current hint unformatted to perform the completion of the full hint
|
||||
fn complete_hint(&self) -> String;
|
||||
|
||||
/// Return the first semantic token of the hint
|
||||
/// for incremental completion
|
||||
fn next_hint_token(&self) -> String;
|
||||
}
|
||||
|
||||
/// A default example hinter that use the completions or the history to show a hint to the user
|
||||
/// A hinter that use the completions or the history to show a hint to the user
|
||||
///
|
||||
/// Similar to `fish` autosuggestins
|
||||
pub struct DefaultHinter {
|
||||
style: Style,
|
||||
current_hint: String,
|
25
src/hinter/mod.rs
Normal file
25
src/hinter/mod.rs
Normal file
@ -0,0 +1,25 @@
|
||||
mod default;
|
||||
pub use default::DefaultHinter;
|
||||
|
||||
use crate::History;
|
||||
/// A trait that's responsible for returning the hint for the current line and position
|
||||
/// Hints are often shown in-line as part of the buffer, showing the user text they can accept or ignore
|
||||
pub trait Hinter: Send {
|
||||
/// Handle the hinting duty by using the line, position, and current history
|
||||
///
|
||||
/// Returns the formatted output to show the user
|
||||
fn handle(
|
||||
&mut self,
|
||||
line: &str,
|
||||
pos: usize,
|
||||
history: &dyn History,
|
||||
use_ansi_coloring: bool,
|
||||
) -> String;
|
||||
|
||||
/// Return the current hint unformatted to perform the completion of the full hint
|
||||
fn complete_hint(&self) -> String;
|
||||
|
||||
/// Return the first semantic token of the hint
|
||||
/// for incremental completion
|
||||
fn next_hint_token(&self) -> String;
|
||||
}
|
Loading…
Reference in New Issue
Block a user