Skip to content
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

Implement input (command) history with categories #18

Open
chros73 opened this issue Jun 6, 2017 · 1 comment
Open

Implement input (command) history with categories #18

chros73 opened this issue Jun 6, 2017 · 1 comment

Comments

@chros73
Copy link
Owner

chros73 commented Jun 6, 2017

Implement input (command) history for input prompts (e.g. with ^X), as in bash (without searching capability) with categories (mainly because of the upcoming temp-filter feature rakshasa#519):

  • all the different input types have their own history:
    • load_default, load_modified, change_directory, command, filter

Functionality:

  • entry won't be added to a category history if it's:
    • empty
    • the same as the previous entry
  • earlier entry will be updated if it's changed while moving "away" from it and not "applying" it
  • last (temp) entry is remembered (until the next prompt)
  • history is saved during session.save into session directory (if it exists) as rtorrent.input_history
  • history is loaded at startup (if it's available)
  • latest entries are kept during resizing history categories if it's smaller than original

Added keyboard shortcuts at input prompt:

  • up arrow, ^p : prev in history category
  • down arrow, ^n : next in history category
  • ESC, ^[, ^g (latter was already defined): exit from input prompt
    • ESC was "used" to mimic ALT at input prompt back in the days but it isn't used there anymore, hence the removal of the code from TextInput.

Added commands:

  • ui.input.history.size.set : set size of every history category to this value
    • default is: 30
  • ui.input.history.clear : clear all the history categories

Sample rtorrent.input_history file:

1|301
1|302
1|303
3|/mnt/rtorrent/various/
3|/mnt/rtorrent/unsafe/
4|session.save=
4|uptime=
4|print=ok
4|method.insert = try_to_print, simple|const, "print=9"
5|book.*pdf

Existing keyboard shortcuts at input prompt (for reference):

  • ^L : force redraw display
  • ^Q : normal shutdown
  • TAB : path completion at change_directory prompt
  • BACKSPACE, ^H
  • DEL
  • left arrow, ^B : move 1 char to left
  • right arrow, ^F : move 1 char to right
  • HOME, END
  • ^U : erase from cursor to beginning
  • ^K : erase from cursor to end

Implementation notes:

  • use prefilled ring buffers for each category in history
  • keep track of insert pointers for each category in history
  • it's enough to store one last (temp) entry and get pointer for all the categories in history
@chros73
Copy link
Owner Author

chros73 commented Mar 3, 2018

  • change default ui.input.history.size.set to 99 (30 was small in practice)
  • add ui.input.history.size as a getter command for the sake of completeness

Note: original post is also changed.

chros73 pushed a commit that referenced this issue Mar 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant