-
Notifications
You must be signed in to change notification settings - Fork 725
Description
Terminal.Gui provides default key bindings, but those defaults are not configurable by the user.
ConfigurationManager should allow users to redefine key bindings for the system, a user, or an application.
All built-in view subclasses should use ConfigurationManger to specify the default keybindings.
For example, TextField currently has code like this in it's constructor:
KeyBindings.Add (KeyCode.DeleteChar, Command.DeleteCharRight);
KeyBindings.Add (KeyCode.D | KeyCode.CtrlMask, Command.DeleteCharRight);
KeyBindings.Add (KeyCode.Delete, Command.DeleteCharLeft);
KeyBindings.Add (KeyCode.Backspace, Command.DeleteCharLeft);This should be replaced with configuration in .\Terminal.Gui\Resources\config.json like this:
"TextField.DefaultKeyBindings": {
"DeleteCharRight" : {
"Key" : "DeleteChar"
},
"DeleteCharRight" : {
"Key" : "Ctrl+D"
},
"DeleteCharLeft" : {
"Key" : "Delete"
},
"DeleteCharLeft" : {
"Key" : "Backspace"
}
...For this to work, View and any subclass that defines default keybindings should have a member like this:
public partial class View : Responder, ISupportInitializeNotification {
[SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
public static Dictionary<Command, Key> DefaultKeyBindings { get; set; }(This requires more thought - because CM requires config properties to be static it's not possible to inherit defualt keybindings!)
Default KeyBinding mappings should be platform specific
The above config.json example includes both the Windows (DeleteChar) and Linux (Ctrl-D) idioms. When a user is on Linux, only the Linux binding should work and vice versa.
We need to figure out a way of enabling this. Current best ideas:
- Have each View specify all possibilities in
config.json, but have a flag that indicates platform. Like this (roughly):
"TextField.DefaultKeyBindings": {
"DeleteCharRight" : {
"Windows" : true,
"Linux": false,
"Key" : "DeleteChar",
"Modifiers": [
]
},
"DeleteCharRight" : {
"Windows" : false,
"Linux": true,
"Key" : "D",
"Modifiers": [
"Ctrl"
]
}
}
...- Have some way for
ConsoleDriversto have mappings within them. This may not be a good idea given some drivers (esp Netdriver) run on all platforms.
The codebase should be scoured for cases where code is looking at Keys and not using KeyBindings.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status