vonshednob / pter

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

Editor:Keys cannot be redefined or unset #35

Closed andrei-a-papou closed 6 months ago

andrei-a-papou commented 6 months ago

IMO, a great appeal of pter is that it's entirely keyboard-driven and the shortcuts can be redefined to fit the end-users preferences. However, right now doesn't seem to be possible to redefine or unset the editor keys.

For example, I'd like to change select-file shortcut, but pter seems to ignore my Editor:Keys section. Enabling debug logging shows that pter applies the keys from the Keys section while ignoring Editor:Keys.

vonshednob commented 6 months ago

Hm, this is strange, I’ll look into it while looking into #33.

Do you have a specific case, i.e. an example key that you want to bind to select-file?

andrei-a-papou commented 6 months ago

Sure, how about ^F = select-file. It would also be great to do ^A = go-bol and ^E = go-eol (a-la Emacs) -- but these are also ignored.

vonshednob commented 6 months ago

Wow, apparently nobody ever tried to do this before. Looks like [Editor:Keys] is pretty much ignored, but you can add ^A = go-bol in the regular [Keys] section to make that work… :zany_face:

I’m fixing it now to be in line with the documentation.

vonshednob commented 6 months ago

This should work fine now in the new version 3.15.0; please let me know if something’s still strange or functionality for the edit fields is missing!

andrei-a-papou commented 6 months ago

@vonshednob thanks for the quick response, I've installed 3.15.0 and I can now assign new shortcuts under [Editor:Keys]. However, I still cannot remove any bindings there via the nop command.

Here's the relevant portion of the config file:

[Editor:Keys]
^C = cancel
<escape> = cancel

<return> = submit-input

<left> = go-left
<right> = go-right

<home> = go-bol
<end> = go-eol
^A = go-bol
^E = go-eol

<backspace> = del-left
<del> = del-right

^U = del-to-bol

<f6> = nop
^F = select-file

# unbind `comp-next` and `comp-prev`:
^N = nop
^P = nop

And here's what the log file says:

[ERROR] nop is not a function of editor or completion
[ERROR] nop is not a function of editor or completion
[ERROR] nop is not a function of editor or completion

This new release now also produces the following warnings in the log:

[WARNING] Cannot bind <down> to 'next-item': no such function
[WARNING] Cannot bind <up> to 'prev-item': no such function
[WARNING] Cannot bind <pgup> to 'page-up': no such function
[WARNING] Cannot bind <pgdn> to 'page-down': no such function
[WARNING] Cannot bind <home> to 'first-item': no such function
[WARNING] Cannot bind <end> to 'last-item': no such function
[WARNING] Cannot bind <return> to 'select-item': no such function

The warnings definitely weren't there with 3.14.0

vonshednob commented 6 months ago

Yeah, because next-item, prev-item, page-up, etc (all "no such function") belong in the [Keys] section. It was part of the bug that they were taken from [Editor:Keys]. Sorry for the confusion!

andrei-a-papou commented 6 months ago

Hmm... but I don't have next-item, prev-item, page-up, etc under [Editor:Keys], only under [Keys]. So why is pter printing warnings about the above bindings in 3.15.0?

Here's the relevant portion of my [Keys] section:

[Keys]
<down> = next-item
<up> = prev-item
<pgup> = page-up
<pgdn> = page-down
<home> = first-item
<end> = last-item

<colon> = nop

^F = search
^K = clear-search
vonshednob commented 6 months ago

Hm, that’s a bug alright! Maybe related to this fix, maybe already broken earlier, but broken either way.

Sorry for the inconvenience…

andrei-a-papou commented 6 months ago

No problem! There's also the issue of nop not working under [Editor:Keys]. I'll be happy to test the fix and then we can properly close it!

vonshednob commented 6 months ago

Alright, version 3.15.1 is out -- give it a spin!

andrei-a-papou commented 6 months ago

Thank you, the nop problem is gone, nice!

I'm still getting a bunch of warnings in the log though:

image

In my pter.conf all these functions are in Keys, not Editor:Keys, so I'm not sure why pter is complaining. Any ideas?

vonshednob commented 6 months ago

Yeah, as with most of these things: I wrote the code, I introduced a bug :unamused:

I’ll fix it later today. Sorry for the constant bouncing around between bugs and failed attempts at fixing.

andrei-a-papou commented 6 months ago

Thanks, I'll be happy to test the fix.

vonshednob commented 6 months ago

Well, let's see. Maybe third time's the charm. 3.15.2 should do the trick!

andrei-a-papou commented 6 months ago

Third time's the charm, precisely!