mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
fish_config: group bindings by command, show raw binding commands on click
This commit is contained in:
parent
4e2d2c125c
commit
bfee664af3
3 changed files with 32 additions and 10 deletions
|
@ -220,6 +220,11 @@ body {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.raw_binding {
|
||||||
|
padding-left: 20px;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
|
||||||
.history_text {
|
.history_text {
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
|
|
|
@ -6,8 +6,13 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="data_table_row" ng-repeat="binding in bindings | filterBinding:query">
|
<tr class="data_table_row" ng-repeat="binding in bindings | filterBinding:query">
|
||||||
<td ng-class="{ data_table_cell: true, no_overflow: !binding._is_selected }" style="text-align: right; padding-right: 30px;" ng-click="binding._is_selected = !binding._is_selected">{{ binding.command }}</td>
|
<td ng-class="{ data_table_cell: true, no_overflow: !binding._is_selected }" style="text-align: right; padding-right: 30px;" ng-click="binding._is_selected = !binding._is_selected">{{ binding.command }}</td>
|
||||||
<!-- Some bindings are listed multiple times for e.g. function backward-char is bound to \e\[D as well as key left. Users may want to know why some bindings are listed twice, so the actual binding is shown in next line on a click -->
|
<!-- Raw binding commands are shown in next line on a click -->
|
||||||
<td ng-class="{ data_table_cell: true, no_overflow: !binding._is_selected }" style="text-align: left; padding-right: 30px;" ng-click="binding._is_selected = !binding._is_selected">{{ binding.readable_binding }} <div ng-show="binding._is_selected"> {{ binding.binding }} </div> </td>
|
<td ng-class="{ data_table_cell: true, no_overflow: !binding._is_selected }" style="text-align: left; padding-right: 30px;" ng-click="binding._is_selected = !binding._is_selected">
|
||||||
|
<div ng-repeat="variety in binding.bindings">
|
||||||
|
{{ variety.readable_binding }}
|
||||||
|
<div class="raw_binding" ng-repeat="raw in variety.raw_bindings" ng-show="binding._is_selected" > {{ raw }} </div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -284,17 +284,23 @@ class FishVar:
|
||||||
class FishBinding:
|
class FishBinding:
|
||||||
"""A class that represents keyboard binding """
|
"""A class that represents keyboard binding """
|
||||||
|
|
||||||
def __init__(self, command, binding, readable_binding, description=None):
|
def __init__(self, command, raw_binding, readable_binding, description=None):
|
||||||
self.command = command
|
self.command = command
|
||||||
self.binding = binding
|
self.bindings = []
|
||||||
self.readable_binding = readable_binding
|
|
||||||
self.description = description
|
self.description = description
|
||||||
|
self.add_binding(raw_binding, readable_binding)
|
||||||
|
|
||||||
|
def add_binding(self, raw_binding, readable_binding):
|
||||||
|
for i in self.bindings:
|
||||||
|
if i['readable_binding'] == readable_binding:
|
||||||
|
i['raw_bindings'].append(raw_binding)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.bindings.append({'readable_binding':readable_binding, 'raw_bindings':[raw_binding]})
|
||||||
|
|
||||||
def get_json_obj(self):
|
def get_json_obj(self):
|
||||||
return {"command" : self.command, "binding": self.binding, "readable_binding": self.readable_binding, "description": self.description }
|
return {"command" : self.command, "bindings": self.bindings, "description": self.description}
|
||||||
|
|
||||||
def get_readable_binding(command):
|
|
||||||
return command
|
|
||||||
|
|
||||||
class BindingParser:
|
class BindingParser:
|
||||||
""" Class to parse codes for bind command """
|
""" Class to parse codes for bind command """
|
||||||
|
@ -564,6 +570,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
|
|
||||||
# Put all the bindings into a list
|
# Put all the bindings into a list
|
||||||
bindings = []
|
bindings = []
|
||||||
|
command_to_binding = {}
|
||||||
binding_parser = BindingParser()
|
binding_parser = BindingParser()
|
||||||
|
|
||||||
for line in out.split('\n'):
|
for line in out.split('\n'):
|
||||||
|
@ -581,8 +588,13 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
binding_parser.set_buffer(comps[1])
|
binding_parser.set_buffer(comps[1])
|
||||||
|
|
||||||
readable_binding = binding_parser.get_readable_binding()
|
readable_binding = binding_parser.get_readable_binding()
|
||||||
fish_binding = FishBinding(command, key_name, readable_binding)
|
if command in command_to_binding:
|
||||||
bindings.append(fish_binding)
|
fish_binding = command_to_binding[command]
|
||||||
|
fish_binding.add_binding(line, readable_binding)
|
||||||
|
else:
|
||||||
|
fish_binding = FishBinding(command, line, readable_binding)
|
||||||
|
bindings.append(fish_binding)
|
||||||
|
command_to_binding[command] = fish_binding
|
||||||
|
|
||||||
return [ binding.get_json_obj() for binding in bindings ]
|
return [ binding.get_json_obj() for binding in bindings ]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue