1 |
|
# Orca |
2 |
|
# |
3 |
|
# Copyright 2006-2007 Sun Microsystems Inc. |
4 |
|
# |
5 |
|
# This library is free software; you can redistribute it and/or |
6 |
|
# modify it under the terms of the GNU Library General Public |
7 |
|
# License as published by the Free Software Foundation; either |
8 |
|
# version 2 of the License, or (at your option) any later version. |
9 |
|
# |
10 |
|
# This library is distributed in the hope that it will be useful, |
11 |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 |
|
# Library General Public License for more details. |
14 |
|
# |
15 |
|
# You should have received a copy of the GNU Library General Public |
16 |
|
# License along with this library; if not, write to the |
17 |
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
|
# Boston, MA 02111-1307, USA. |
19 |
|
|
20 |
|
"""Exposes a dictionary, keynames, that maps key events |
21 |
1 |
into localized words.""" |
22 |
|
|
23 |
1 |
__id__ = "$Id: keynames.py 2254 2007-04-05 13:21:02Z wwalker $" |
24 |
1 |
__version__ = "$Revision: 2254 $" |
25 |
1 |
__date__ = "$Date: 2007-04-05 09:21:02 -0400 (Thu, 05 Apr 2007) $" |
26 |
1 |
__copyright__ = "Copyright (c) 2006-2007 Sun Microsystems Inc." |
27 |
1 |
__license__ = "LGPL" |
28 |
|
|
29 |
1 |
import chnames |
30 |
|
|
31 |
1 |
from orca_i18n import _ # for gettext support |
32 |
|
|
33 |
|
# __keynames is a dictionary where the keys represent a UTF-8 |
34 |
|
# string for a keyboard key and the values represent the common |
35 |
|
# phrase used to describe the key. |
36 |
|
# |
37 |
1 |
__keynames = {} |
38 |
|
|
39 |
|
# Translators: this is how someone would speak the name of the left shift key |
40 |
|
# |
41 |
1 |
__keynames["Shift_L"] = _("left shift") |
42 |
|
|
43 |
|
# Translators: this is how someone would speak the name of the left alt key |
44 |
|
# |
45 |
1 |
__keynames["Alt_L"] = _("left alt") |
46 |
|
|
47 |
|
# Translators: this is how someone would speak the name of the left ctrl key |
48 |
|
# |
49 |
1 |
__keynames["Control_L"] = _("left control") |
50 |
|
|
51 |
|
# Translators: this is how someone would speak the name of the right shift key |
52 |
|
# |
53 |
1 |
__keynames["Shift_R"] = _("right shift") |
54 |
|
|
55 |
|
# Translators: this is how someone would speak the name of the right alt key |
56 |
|
# |
57 |
1 |
__keynames["Alt_R"] = _("right alt") |
58 |
|
|
59 |
|
# Translators: this is how someone would speak the name of the right ctrl key |
60 |
|
# |
61 |
1 |
__keynames["Control_R"] = _("right control") |
62 |
|
|
63 |
|
# Translators: this is how someone would speak the name of the left meta key |
64 |
|
# |
65 |
1 |
__keynames["Meta_L"] = _("left meta") |
66 |
|
|
67 |
|
# Translators: this is how someone would speak the name of the right meta key |
68 |
|
# |
69 |
1 |
__keynames["Meta_R"] = _("right meta") |
70 |
|
|
71 |
|
# Translators: this is how someone would speak the name of the num lock key |
72 |
|
# |
73 |
1 |
__keynames["Num_Lock"] = _("num lock") |
74 |
|
|
75 |
|
# Translators: this is how someone would speak the name of the caps lock key |
76 |
|
# |
77 |
1 |
__keynames["Caps_Lock"] = _("caps lock") |
78 |
|
|
79 |
|
# Translators: this is how someone would speak the name of the scroll lock key |
80 |
|
# |
81 |
1 |
__keynames["Scroll_Lock"] = _("scroll lock") |
82 |
|
|
83 |
|
# Translators: this is how someone would speak the name of the page up key |
84 |
|
# |
85 |
1 |
__keynames["Page_Up"] = _("page up") |
86 |
|
|
87 |
|
# Translators: this is how someone would speak the name of the page down key |
88 |
|
# |
89 |
1 |
__keynames["Page_Down"] = _("page down") |
90 |
|
|
91 |
|
# Translators: this is how someone would speak the name of the left tab key |
92 |
|
# |
93 |
1 |
__keynames["ISO_Left_Tab"] = _("left tab") |
94 |
|
|
95 |
|
# Translators: this is how someone would speak the name of the F11 key |
96 |
|
# |
97 |
1 |
__keynames["SunF36"] = _("F 11") |
98 |
|
|
99 |
|
# Translators: this is how someone would speak the name of the F12 key |
100 |
|
# |
101 |
1 |
__keynames["SunF37"] = _("F 12") |
102 |
|
|
103 |
1 |
def getKeyName(key): |
104 |
|
"""Given a keyboard key, return its name as people might refer to it |
105 |
|
in ordinary conversation. |
106 |
|
|
107 |
|
Arguments: |
108 |
|
- key: the key to get the name for |
109 |
|
|
110 |
|
Returns a string representing the name for the key |
111 |
|
""" |
112 |
|
|
113 |
0 |
if isinstance(key, unicode): |
114 |
0 |
key = key.encode("UTF-8") |
115 |
|
|
116 |
0 |
try: |
117 |
0 |
return __keynames[key] |
118 |
0 |
except: |
119 |
0 |
return chnames.getCharacterName(key) |