Implement a soft key binding mechanism for keyboard input.

Project:JNode Core
Component:Code
Category:feature request
Priority:normal
Assigned:Stephen Crawley
Status:active
Description

There is currently no way to customize the key bindings used in input line editing, history and so on. We need a mechanism to support this, together with a shell command to drive it.

An ideal solution would support arbitrary future shell functionality (e.g. interrupts, job control), GUI accelerators, application specific bindings and user-defined soft keys. And bindings should be persistent if the user wants this.

#1

Assigned to:Anonymous» Stephen Crawley

#2

I've checked in changes to the Console and KeyboardReader APIs to support getting and setting the bindings. The key bindings are expressed using a new KeyEventBindings class that is designed to be reusable in other places where we need to do keyboard event to action mapping with soft bindings. For example, the CommandShell could use it to map ^C, ^Z etc to job control actions. For maximal reusability, "actions" are simply represented as integers.

I'm now working on the corresponding user command.

#3

Implemented a 'bindkeys' command. At the moment it just displays the bindings. More functionality is on the way ...

#4

The bindkeys command now also supports adding and removing bindings and reseting them to the defaults. However, there are some problems:

The first problem is that adding or removing a binding for a character typically requires the user to enter the character in quotes with the quotation marks escaped; e.g.

   JNode> bindkeys --add KR_REDRAW \'?\'

I think it is possible to fix this.

The bigger problem is that there are two ways to create a binding; by binding a virtual key (with modifiers) to an action (like KR_REDRAW), or by binding a character to an action. And it may matter which way the user does this, because keyboard layouts emit virtual keys or characters or both in rather opaque and undocumented ways! And the KeyboardReader code historically uses a combination of the characters and virtual keys to decide what to do.

So there is more work to be done to simplify the soft key bindings mechanisms, but I cannot make progress on this issue until some other problems are sorted out. I'll create a separate issue to describe / address those issues.