summaryrefslogtreecommitdiffstats
path: root/tools/gen_keyboard_overlay_data
diff options
context:
space:
mode:
authormazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 07:36:46 +0000
committermazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-21 07:36:46 +0000
commit7418430c1685aed1ac0025580f0bc6fc59a506eb (patch)
tree72e42fc7643e85956fd8fbd31ab9147a2c7e2f63 /tools/gen_keyboard_overlay_data
parent75070ced8f28a2746688383cbe0942a05d204f8f (diff)
downloadchromium_src-7418430c1685aed1ac0025580f0bc6fc59a506eb.zip
chromium_src-7418430c1685aed1ac0025580f0bc6fc59a506eb.tar.gz
chromium_src-7418430c1685aed1ac0025580f0bc6fc59a506eb.tar.bz2
Clean up the keyboard overlay code.
- Sort the entries in .cc and .grd files. - Change the way of mapping the i18n-content string to the message ID. BUG=none TEST=manually checked on chromebook Review URL: http://codereview.chromium.org/7189032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89799 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gen_keyboard_overlay_data')
-rwxr-xr-xtools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py
index dd40249..ff2c031 100755
--- a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py
+++ b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py
@@ -89,8 +89,7 @@ GRD_SNIPPET_TEMPLATE=""" <message name="%s" desc="%s">
"""
# A snippet for C++ file
-CC_SNIPPET_TEMPLATE=""" localized_strings.SetString("%s",
- l10n_util::GetStringUTF16(%s));
+CC_SNIPPET_TEMPLATE=""" { "%s", %s },
"""
ALTGR_TEMPLATE="""// These are the overlay names of layouts that shouldn't
@@ -341,15 +340,9 @@ def GenerateCopyrightHeader():
def UniqueBehaviors(hotkey_data):
- """Retrieves a list of unique behaviors from |hotkey_data|."""
- behaviors = []
- added = set()
- for (behavior, _) in hotkey_data:
- if behavior in added:
- continue
- behaviors.append(behavior)
- added.add(behavior)
- return behaviors
+ """Retrieves a sorted list of unique behaviors from |hotkey_data|."""
+ return sorted(set(behavior for (behavior, _) in hotkey_data),
+ cmp=lambda x, y: cmp(ToMessageName(x), ToMessageName(y)))
def OutputJson(keyboard_glyph_data, hotkey_data, layouts, var_name, outfile):
@@ -385,12 +378,11 @@ def OutputCC(hotkey_data, outfile):
out = file(outfile, 'w')
for behavior in UniqueBehaviors(hotkey_data):
message_name = ToMessageName(behavior)
- # Indent the line if message_name is longer than 45 characters, which means
- # the second line in the generated code is longer than 80 characters.
- if len(message_name) > 45:
- message_name = '\n %s' % message_name
- out.write(CC_SNIPPET_TEMPLATE % (Toi18nContent(behavior),
- message_name))
+ output = CC_SNIPPET_TEMPLATE % (Toi18nContent(behavior), message_name)
+ # Break the line if the line is longer than 80 characters
+ if len(output) > 80:
+ output = output.replace(' ' + message_name, '\n %s' % message_name)
+ out.write(output)
def OutputAltGr(keyboard_glyph_data, outfile):