chros73/rtorrent-ps-ch

Implement input (command) history with categories

Closed this issue · 0 comments

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) 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: 99
  • 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 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