Implement input (command) history with categories
Closed this issue · 0 comments
chros73 commented
Implement input (command) history for input prompts (e.g. with ^X
), as in bash (without searching capability) with categories (mainly because of temp-filter):
- 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) asrtorrent.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 categorydown arrow
,^n
: next in history categoryESC
,^[
,^g
(latter was already defined): exit from input promptESC
was "used" to mimicALT
at input prompt back in the days but it isn't used there anymore, hence the removal of the code fromTextInput
.
Added commands:
ui.input.history.size.set
: set size of every history category to this value- default is:
99
- default is:
ui.input.history.size
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 shutdownTAB
: path completion atchange_directory
promptBACKSPACE
,^H
DEL
left arrow
,^B
: move 1 char to leftright arrow
,^F
: move 1 char to rightHOME
,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