Mercurial > urwid-satext
annotate urwid_satext/keys.py @ 146:4d6a29358f32
Added tag v0.8.0b1 for changeset d505d9ee792e
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 18 Jun 2021 13:22:17 +0200 |
parents | 144bdf877d21 |
children |
rev | line source |
---|---|
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 # Urwid SàT extensions |
122 | 5 # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Lesser General Public License as published by |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 # GNU Lesser General Public License for more details. |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Lesser General Public License |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 """This module manage action <==> key mapping and can be extended to add new actions""" |
143 | 21 from functools import reduce |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 class ConflictError(Exception): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 pass |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 class ActionMap(dict): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 """Object which manage mapping betwwen actions and keys""" |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 def __init__(self, source_dict=None): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 """ Initialise the map |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 @param source_dict: dictionary-like object with actions to import |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 """ |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 self._namespaces_actions = {} # key = namespace, values (set) = actions |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 self._close_namespaces = tuple() |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 self._alway_check_namespaces = None |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 if source_dict is not None: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 self.update(source_dict) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 def __setitem__(self, action, shortcut): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 """set an action avoiding conflicts |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 @param action (str,tuple): either an action (str) or a (namespace, action) tuple. action without namespace will not be checked by cbeck_namespaces(). namespace can also be a tuple itself, the action will the be assigned to several namespaces. |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 @param shortcut (str): key shortcut for this action |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 @raise: ConflictError if the action already exists |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 """ |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 if isinstance(action, tuple): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 namespaces, action = action |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 if not isinstance(namespaces, tuple): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 namespaces = (namespaces,) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 for namespace in namespaces: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 namespace_map = self._namespaces_actions.setdefault(namespace.lower(), set()) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 namespace_map.add(action) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 if action in self: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 raise ConflictError("The action [{}] already exists".format(action)) |
129
2a1880d5d450
keys: don't lower() shortcuts anymore
Goffi <goffi@goffi.org>
parents:
122
diff
changeset
|
59 return super(ActionMap, self).__setitem__(action, shortcut) |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 def __delitem__(self, action): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 # we don't want to delete actions |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 raise NotImplementedError |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 |
85 | 65 def replace_shortcut(self, action, shortcut): |
66 """Replace an existing action | |
67 | |
68 @param action: name of an existing action | |
69 @param shortcut: new shortcut to use | |
70 @raise KeyError: action doesn't exists | |
71 """ | |
143 | 72 assert isinstance(action, str) |
85 | 73 if action not in self: |
74 raise ValueError("Action [{}] doesn't exist".format(action)) | |
75 super(ActionMap, self).__setitem__(action, shortcut) | |
76 | |
77 def update(self, new_actions): | |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 """Update actions with an other dictionary |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 |
85 | 80 @param new_actions: dictionary object to update actions |
81 @raise ValueError: something else than a dictionary is used | |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 @raise: ConflictError if at least one of the new actions already exists |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 """ |
85 | 84 if not isinstance(new_actions, dict): |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 raise ValueError("only dictionary subclasses are accepted for update") |
143 | 86 conflict = new_actions.keys() & self.keys() |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 if conflict: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 raise ConflictError("The actions [{}] already exists".format(','.join(conflict))) |
143 | 89 for action, shortcut in new_actions.items(): |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 self[action] = shortcut |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 |
85 | 92 def replace(self, action_shortcuts_map): |
93 """Replace shortcuts with an other dictionary | |
94 | |
95 @param action_shortcuts_map: dictionary like object to update shortcuts | |
96 @raise ValueError: something else than a dictionary is used | |
97 @raise KeyError: action doesn't exists | |
98 """ | |
99 if not isinstance(action_shortcuts_map, dict): | |
100 raise ValueError("only dictionary subclasses are accepted for replacing shortcuts") | |
143 | 101 for action, shortcut in action_shortcuts_map.items(): |
85 | 102 self.replace_shortcut(action, shortcut) |
103 | |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 def set_close_namespaces(self, close_namespaces, always_check=None): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 """Set namespaces where conflicting shortcut should not happen |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 used by check_namespaces to see if the same shortcut is not used in two close namespaces (e.g. 'tab' used in edit_bar and globally) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 @param close_namespaces (tuple of tuples): tuple indicating namespace where shortcut should not conflict. e.g.: (('global', 'edit'), ('confirm', 'popup', 'global')) indicate that shortcut in 'global' and 'edit' should not be the same, nor the ones between 'confirm', 'popup' and 'global'. |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 @param always_check (tuple): if not None, these namespaces will be close to every other ones (useful for global namespace) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 """ |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 assert isinstance(close_namespaces, tuple) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 if always_check is not None: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 assert isinstance(always_check, tuple) |
86
ea5b9a211bbb
added namespace check in keys.ActionMap.set_close_namespaces
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
114 to_check = reduce(lambda ns1, ns2: ns1.union(ns2), close_namespaces, set(always_check) or set()) |
ea5b9a211bbb
added namespace check in keys.ActionMap.set_close_namespaces
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
115 if not to_check.issubset(self._namespaces_actions): |
ea5b9a211bbb
added namespace check in keys.ActionMap.set_close_namespaces
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
116 raise ValueError("Unkown namespaces: {}".format(', '.join(to_check.difference(self._namespaces_actions)))) |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 self._close_namespaces = close_namespaces |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 self._alway_check_namespaces = always_check |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 def check_namespaces(self): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
121 """Check that shortcuts are not conflicting in close namespaces""" |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 # we first check each namespace individually |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 checked = set() |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 def check_namespaces(namespaces): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 # for each namespace which save keys used |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 # if 1 key is used several times, we raise |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 # a ConflictError |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 set_shortcuts = {} |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 to_check = set(namespaces + self._alway_check_namespaces) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
133 for namespace in to_check: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 checked.add(namespace) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 for action in self._namespaces_actions[namespace]: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
136 shortcut = self[action] |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 if shortcut in set_shortcuts: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 set_namespace = set_shortcuts[shortcut] |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 if set_namespace == namespace: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 msg = 'shortcut [{}] is not unique in namespace "{}"'.format(shortcut, namespace) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 else: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 msg = 'shortcut [{}] is used both in namespaces "{}" and "{}"'.format(shortcut, set_namespace, namespace) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 raise ConflictError(msg) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
144 set_shortcuts[shortcut] = namespace |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 # we first check close namespaces |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 for close_namespaces in self._close_namespaces: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 check_namespaces(close_namespaces) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 # then the remaining ones |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 for namespace in set(self._namespaces_actions.keys()).difference(checked): |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 check_namespaces((namespace,)) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 keys = { |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 ("edit", "EDIT_HOME"): 'ctrl a', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 ("edit", "EDIT_END"): 'ctrl e', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 ("edit", "EDIT_DELETE_TO_END"): 'ctrl k', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 ("edit", "EDIT_DELETE_LAST_WORD"): 'ctrl w', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 ("edit", "EDIT_ENTER"): 'enter', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 ("edit", "EDIT_COMPLETE"): 'shift tab', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 (("edit", "modal"), "MODAL_ESCAPE"): 'esc', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 ("selectable", "TEXT_SELECT"): ' ', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 ("selectable", "TEXT_SELECT2"): 'enter', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 ("menu_box", "MENU_BOX_UP"): 'up', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 ("menu_box", "MENU_BOX_LEFT"): 'left', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 ("menu_box", "MENU_BOX_RIGHT"): 'right', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 ("menu", "MENU_DOWN"): 'down', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 ("menu", "MENU_UP"): 'up', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 ("menu_roller", "MENU_ROLLER_UP"): 'up', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 ("menu_roller", "MENU_ROLLER_DOWN"): 'down', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 ("menu_roller", "MENU_ROLLER_RIGHT"): 'right', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 ("columns_roller", "COLUMNS_ROLLER_LEFT"): 'left', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 ("columns_roller", "COLUMNS_ROLLER_RIGHT"): 'right', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 ("focus", "FOCUS_SWITCH"): 'tab', |
87
a0dbf973befa
keys: added FOCUS_UP FOCUS_DOWN FOCUS_LEFT and FOCUS_RIGHT
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
176 ('focus', "FOCUS_UP"): 'ctrl up', |
a0dbf973befa
keys: added FOCUS_UP FOCUS_DOWN FOCUS_LEFT and FOCUS_RIGHT
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
177 ('focus', "FOCUS_DOWN"): 'ctrl down', |
a0dbf973befa
keys: added FOCUS_UP FOCUS_DOWN FOCUS_LEFT and FOCUS_RIGHT
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
178 ('focus', "FOCUS_LEFT"): 'ctrl left', |
a0dbf973befa
keys: added FOCUS_UP FOCUS_DOWN FOCUS_LEFT and FOCUS_RIGHT
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
179 ('focus', "FOCUS_RIGHT"): 'ctrl right', |
92
fdd0543677d4
use of new keys module in files_management
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
180 ('files_management', "FILES_HIDDEN_HIDE"): 'meta h', |
fdd0543677d4
use of new keys module in files_management
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
181 ('files_management', "FILES_JUMP_DIRECTORIES"): 'meta d', |
fdd0543677d4
use of new keys module in files_management
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
182 ('files_management', "FILES_JUMP_FILES"): 'meta f', |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 } |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 action_key_map = ActionMap(keys) |