Mercurial > urwid-satext
annotate urwid_satext/keys.py @ 86:ea5b9a211bbb
added namespace check in keys.ActionMap.set_close_namespaces
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 04 Sep 2014 18:43:39 +0200 |
parents | e0c8274f9b1c |
children | a0dbf973befa |
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 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org) |
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""" |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
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 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
|
24 pass |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 |
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 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
|
28 """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
|
29 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 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
|
31 """ 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
|
32 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 @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
|
34 """ |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 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
|
39 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
|
40 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 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
|
42 """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
|
43 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 @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
|
45 @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
|
46 @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
|
47 """ |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 namespaces = (namespaces,) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 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
|
57 raise ConflictError("The action [{}] already exists".format(action)) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 return super(ActionMap, self).__setitem__(action, shortcut.lower()) |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 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
|
61 # 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
|
62 raise NotImplementedError |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 |
85 | 64 def replace_shortcut(self, action, shortcut): |
65 """Replace an existing action | |
66 | |
67 @param action: name of an existing action | |
68 @param shortcut: new shortcut to use | |
69 @raise KeyError: action doesn't exists | |
70 """ | |
71 assert isinstance(action, basestring) | |
72 if action not in self: | |
73 raise ValueError("Action [{}] doesn't exist".format(action)) | |
74 super(ActionMap, self).__setitem__(action, shortcut) | |
75 | |
76 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
|
77 """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
|
78 |
85 | 79 @param new_actions: dictionary object to update actions |
80 @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
|
81 @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
|
82 """ |
85 | 83 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
|
84 raise ValueError("only dictionary subclasses are accepted for update") |
85 | 85 conflict = new_actions.viewkeys() & self.viewkeys() |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 if conflict: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 raise ConflictError("The actions [{}] already exists".format(','.join(conflict))) |
85 | 88 for action, shortcut in new_actions.iteritems(): |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 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
|
90 |
85 | 91 def replace(self, action_shortcuts_map): |
92 """Replace shortcuts with an other dictionary | |
93 | |
94 @param action_shortcuts_map: dictionary like object to update shortcuts | |
95 @raise ValueError: something else than a dictionary is used | |
96 @raise KeyError: action doesn't exists | |
97 """ | |
98 if not isinstance(action_shortcuts_map, dict): | |
99 raise ValueError("only dictionary subclasses are accepted for replacing shortcuts") | |
100 for action, shortcut in action_shortcuts_map.iteritems(): | |
101 self.replace_shortcut(action, shortcut) | |
102 | |
84
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 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
|
104 """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
|
105 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 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
|
107 @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
|
108 @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
|
109 """ |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 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
|
111 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
|
112 assert isinstance(always_check, tuple) |
86
ea5b9a211bbb
added namespace check in keys.ActionMap.set_close_namespaces
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 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
|
120 """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
|
121 # 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
|
122 checked = set() |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 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
|
125 # 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
|
126 # 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
|
127 # a ConflictError |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 set_shortcuts = {} |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 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
|
131 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 else: |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 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
|
142 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
|
143 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
|
144 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 # 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
|
146 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
|
147 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
|
148 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 # 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
|
150 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
|
151 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
|
152 |
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 keys = { |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 ("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
|
156 ("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
|
157 ("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
|
158 ("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
|
159 ("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
|
160 ("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
|
161 (("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
|
162 ("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
|
163 ("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
|
164 ("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
|
165 ("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
|
166 ("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
|
167 ("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
|
168 ("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
|
169 ("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
|
170 ("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
|
171 ("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
|
172 ("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
|
173 ("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
|
174 ("focus", "FOCUS_SWITCH"): 'tab', |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 } |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 |
9f683df69a4c
shortcut keys are now managed in separate module, with a class checking for conflicts
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 action_key_map = ActionMap(keys) |