Re: [PATCH] kdb: Fix incorrect naming of history arrow keys in code

From: Doug Anderson
Date: Thu Oct 31 2024 - 19:06:32 EST


Hi,

On Thu, Oct 31, 2024 at 12:23 PM Nir Lichtman <nir@xxxxxxxxxxxx> wrote:
>
> Problem: The kdb CLI code that handles the history up and down
> navigation incorrectly names the up and down arrows as ctrl p and n.
>
> Details: This could be some kind of left over legacy.
> (maybe inspired by ddb which only reacts to ctrl p and n for history nav).
> kdb doesn't react to ctrl p and n, and following the code flow with GDB
> reveals that these values map to the up and down arrows.

Really? kdb reacts to "ctrl-P" and "ctrl-N" for me. It also reacts to
"ctrl-F" and "ctrl-B".

I think the code as-is is fine. The arrow key code just converts to
the arrow keys to the (also working) ctrl keys and by the time we're
here we just need to react to Ctrl keys. Ctrl keys are 64 less than
non-ctrl keys and so the definitions of Ctrl-N and Ctrl-P are correct:

>>> ord('N') - 64
14

>>> ord('P') - 64
16

-Doug