vonshednob / pter

Manage your todo.txt in a commandline user interface (TUI)
https://vonshednob.cc/pter/
MIT License
102 stars 6 forks source link

Patch to improve line editing some more #53

Closed andrei-a-papou closed 5 months ago

andrei-a-papou commented 6 months ago

I've been using this patch to enable two "standard" bash-like bindings in pter -- Alt + d for del-word-right and Alt + Backspace for del-word-left.

For now these are treated specially, in the future perhaps pter could have full Alt-based bindings support. However, they are trickier than Ctrl-based ones, so for me just these two are enough. Plus we already have chain-based bindings, so no prob.

91-alt-backspace-alt-d.diff.gz

In addition, I've adjusted the patch from #36 to check if we're running under xterm-256color. The values for Ctrl + arrows/Delete seem to be specific to that terminfo config. (Alt-based ones from above seem to work with other terminfo configurations, such as screen-256color.)

30-ctrl-combos-should-be-conditional.diff.gz

vonshednob commented 5 months ago

I made the check for xterm a bit more generic and added a configuration option for the curses timeout. It defaults to 200ms, so you might want to update your configuration file, I assume based on the 100ms you used in the patch :)

andrei-a-papou commented 5 months ago

I made the check for xterm a bit more generic and added a configuration option for the curses timeout.

Awesome!

I made the check for xterm a bit more generic

Yes, good idea, since pter also supports terminals with no color. I forgot about that.

andrei-a-papou commented 5 months ago

I've pulled the latest changes and re-built the Docker image. With esc-timeout still unset in the config, pter errors out:

[CRITICAL] Pter crashed with exception: 'int' object has no attribute 'isnumeric'
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2.dev0-py3.11.egg/pter/curses.py", line 3119, in run_cursesui
    window.run()
  File "/usr/local/lib/python3.11/dist-packages/cursedspace-1.5.2-py3.11.egg/cursedspace/application.py", line 59, in run
    raise exception
  File "/usr/local/lib/python3.11/dist-packages/cursedspace-1.5.2-py3.11.egg/cursedspace/application.py", line 52, in run
    self.main()
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2.dev0-py3.11.egg/pter/curses.py", line 1655, in main
    curses.set_escdelay(self.conf.number(common.SETTING_GROUP_GENERAL,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pter-3.15.2.dev0-py3.11.egg/pter/configuration.py", line 152, in number
    if value.isnumeric():
       ^^^^^^^^^^^^^^^
andrei-a-papou commented 5 months ago

When esc-timeout is set, the crash goes away.

vonshednob commented 5 months ago

Yeah, should not have pushed that change 5 minutes before falling asleep, I suppose. It’s fixed!

andrei-a-papou commented 5 months ago

Works great, thank you!