-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mutable Helper
in functions
#809
base: master
Are you sure you want to change the base?
Conversation
Thank you for all your proposals. |
@@ -482,7 +492,7 @@ fn apply_backspace_direct(input: &str) -> String { | |||
fn readline_direct( | |||
mut reader: impl BufRead, | |||
mut writer: impl Write, | |||
validator: &Option<impl Validator>, | |||
mut validator: Option<&mut impl Validator>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why you need the mut validator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The match
block requires the input validator
is mutable. And when we call it, use readline_direct(io::stdin().lock(), io::stderr(), self.helper.as_mut())
, it is almost same as before
Lines 519 to 523 in 77e7d3d
match validator { | |
None => return Ok(input), | |
Some(ref mut v) => { | |
let mut ctx = input.as_str(); | |
let mut ctx = validate::ValidationContext::new(&mut ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
src/edit.rs
Outdated
self.line.as_str() | ||
} | ||
} | ||
// We only use `self.line` to create `impl Invoke`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See
Lines 44 to 47 in ceafb7f
// TODO | |
//fn invoke(&mut self, cmd: Cmd) -> Result<?> { | |
// self.i.invoke(cmd) | |
//} |
rustyline-derive/src/lib.rs
Outdated
@@ -102,32 +102,42 @@ pub fn highlighter_macro_derive(input: TokenStream) -> TokenStream { | |||
quote! { | |||
#[automatically_derived] | |||
impl #impl_generics ::rustyline::highlight::Highlighter for #name #ty_generics #where_clause { | |||
fn highlight<'l>(&self, line: &'l str, pos: usize) -> ::std::borrow::Cow<'l, str> { | |||
::rustyline::highlight::Highlighter::highlight(&self.#field_name_or_index, line, pos) | |||
#[cfg(any(not(feature = "split-highlight"), feature = "ansi-str"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No split-highlight
in this PR please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry for that, I directly copy rustyline-derive/src/lib.rs
for the old version. I only copy this single file and I will remove those :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worry !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all Parser
/ split-highlight
related code
See Line 9 in ceafb7f
InputEdit impl (except for Begin / End )
|
Understand, and since the |
Here is the update under your suggestions. I haven't fixed |
Parser
trait & mutable Helper
in functionsHelper
in functions
You need the Lines 102 to 105 in ceafb7f
|
Or at least use a part of Lines 250 to 253 in 8fc0037
Now I am not sure which |
See gwenn#4
And I add a new
example/bracket_parser.rs
to demoParser
trait.btw, rightnow I have no idea how to represent
change: InputEdit
.