diff --git a/BUGS.md b/BUGS.md index fe7551772..f6ac7d870 100644 --- a/BUGS.md +++ b/BUGS.md @@ -16,9 +16,10 @@ Currently, performance is poor because, most of the time, we refresh the whole l We would like to transform events on prompt/line/hint into partial repaint. See `termwiz` design (`Surface`). -See `replxx` refresh delay (`_lastRefreshTime`) +See `replxx` refresh delay (`_lastRefreshTime`) or `python-prompt-toolkit` max_render_postpone_time. https://docs.rs/xi-unicode/0.3.0/xi_unicode/struct.LineBreakIterator.html https://github.com/xi-editor/xi-editor/blob/master/rust/core-lib/src/linewrap.rs +[vt100](https://docs.rs/vt100/0.12.0/vt100/struct.Screen.html#method.contents_diff) ## Action / Command diff --git a/History.md b/History.md index 0e9d6f6c1..bbb6efd4c 100644 --- a/History.md +++ b/History.md @@ -17,14 +17,17 @@ - if path used to save history is the same: + if timestamp is still the same => we can append only new lines if history has not been truncated. +``` HistoryInfo first_add_index: Option, // first line inserted by this session truncated: bool // path_info: Option, - +``` +``` PathInfo path: Path, modified: SystemTime, +``` --- With `termwiz`, you can define your own `History` backend. diff --git a/TODO.md b/TODO.md index 0223526cb..c56198d50 100644 --- a/TODO.md +++ b/TODO.md @@ -42,6 +42,7 @@ History each line input session. - [X] append_history - [ ] history_truncate_file +- [ ] custom persistent storage Input - [ ] Password input (#58) (https://github.com/conradkdotcom/rpassword) (https://github.com/antirez/linenoise/issues/125) diff --git a/src/completion.rs b/src/completion.rs index 7cf279467..c31d5a94c 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -7,11 +7,6 @@ use crate::line_buffer::LineBuffer; use crate::{Context, Result}; use memchr::memchr; -// TODO: let the implementers choose/find word boundaries ??? -// (line, pos) is like (rl_line_buffer, rl_point) to make contextual completion -// ("select t.na| from tbl as t") -// TODO: make &self &mut self ??? - /// A completion candidate. pub trait Candidate { /// Text to display when listing alternatives. @@ -69,18 +64,23 @@ impl Candidate for Pair { } } +// TODO: let the implementers customize how the candidate(s) are displayed +// https://github.com/kkawakam/rustyline/issues/302 + /// To be called for tab-completion. pub trait Completer { /// Specific completion candidate. type Candidate: Candidate; + // TODO: let the implementers choose/find word boundaries ??? => Lexer + /// Takes the currently edited `line` with the cursor `pos`ition and /// returns the start position and the completion candidates for the /// partial word to be completed. /// /// ("ls /usr/loc", 11) => Ok((3, vec!["/usr/local/"])) fn complete( - &self, + &self, // FIXME should be `&mut self` line: &str, pos: usize, ctx: &Context<'_>, diff --git a/src/highlight.rs b/src/highlight.rs index c46401b0a..95577fc3d 100644 --- a/src/highlight.rs +++ b/src/highlight.rs @@ -42,7 +42,7 @@ pub trait Highlighter { /// Currently, used only with `CompletionType::List`. fn highlight_candidate<'c>( &self, - candidate: &'c str, + candidate: &'c str, // FIXME should be Completer::Candidate completion: CompletionType, ) -> Cow<'c, str> { let _ = completion; @@ -94,6 +94,8 @@ impl<'r, H: ?Sized + Highlighter> Highlighter for &'r H { const OPENS: &[u8; 3] = b"{[("; const CLOSES: &[u8; 3] = b"}])"; +/// TODO versus https://python-prompt-toolkit.readthedocs.io/en/master/pages/reference.html?highlight=HighlightMatchingBracketProcessor#prompt_toolkit.layout.processors.HighlightMatchingBracketProcessor + /// Highlight matching bracket when typed or cursor moved on. #[derive(Default)] pub struct MatchingBracketHighlighter { diff --git a/src/history.rs b/src/history.rs index 4d521d5aa..1bde43751 100644 --- a/src/history.rs +++ b/src/history.rs @@ -34,6 +34,12 @@ pub struct SearchResult<'a> { pub pos: usize, } +/// HistoryEntry: text + timestamp +/// TODO Make possible to customize how history is stored / loaded. +/// https://github.com/kkawakam/rustyline/issues/442 +/// https://github.com/kkawakam/rustyline/issues/127 +/// See https://python-prompt-toolkit.readthedocs.io/en/master/pages/reference.html#prompt_toolkit.history.History abstract methods + /// Current state of the history. #[derive(Default)] pub struct History { diff --git a/src/keymap.rs b/src/keymap.rs index 05ac67187..80fe6afb9 100644 --- a/src/keymap.rs +++ b/src/keymap.rs @@ -45,11 +45,11 @@ pub enum Cmd { EndOfFile, /// end-of-history EndOfHistory, - /// forward-search-history + /// forward-search-history (incremental search) ForwardSearchHistory, - /// history-search-backward + /// history-search-backward (common prefix search) HistorySearchBackward, - /// history-search-forward + /// history-search-forward (common prefix search) HistorySearchForward, /// Indent current line Indent(Movement), @@ -79,7 +79,7 @@ pub enum Cmd { ReplaceChar(RepeatCount, char), /// vi-change-to, vi-substitute Replace(Movement, Option), - /// reverse-search-history + /// reverse-search-history (incremental search) ReverseSearchHistory, /// self-insert SelfInsert(RepeatCount, char), diff --git a/src/line_buffer.rs b/src/line_buffer.rs index 9c99bc352..f14abba36 100644 --- a/src/line_buffer.rs +++ b/src/line_buffer.rs @@ -52,6 +52,8 @@ pub(crate) trait ChangeListener: DeleteListener { fn replace(&mut self, idx: usize, old: &str, new: &str); } +// TODO split / cache lines ? + /// Represent the current input (text and cursor position). /// /// The methods do text manipulations or/and cursor movements. diff --git a/src/tty/unix.rs b/src/tty/unix.rs index 6faa2c5e3..00fa7b8ca 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -986,7 +986,7 @@ impl Renderer for PosixRenderer { } let col = read_digits_until(rdr, 'R')?; debug!(target: "rustyline", "initial cursor location: {:?}", col); - if col.is_some() && col != Some(1) { + if col != Some(1) { self.write_and_flush(b"\n")?; } Ok(())