Commit 193583a1 authored by mazda@chromium.org's avatar mazda@chromium.org

Remove the part of generating xkeyboard_data.h from gen_keyboard_overlay_data.py.

xkeyboard_data.h is no longer necessary.

BUG=None
TEST=The scripts runs as before


Review URL: https://chromiumcodereview.appspot.com/10823020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148501 0039d316-1c4b-4281-b951-d872f2087c98
parent 92c37663
...@@ -17,9 +17,6 @@ and output the data depending on the option. ...@@ -17,9 +17,6 @@ and output the data depending on the option.
--js: Rewrites the entire JavaScript code in --js: Rewrites the entire JavaScript code in
chrome/browser/resources/keyboard_overlay/keyboard_overlay_data.js chrome/browser/resources/keyboard_overlay/keyboard_overlay_data.js
--altgr: Rewrites a list of layouts in
chrome/browser/chromeos/input_method/xkeyboard.cc
These options can be specified at the same time. These options can be specified at the same time.
e.g. e.g.
...@@ -27,8 +24,8 @@ python gen_keyboard_overlay_data.py --cc --grd --js ...@@ -27,8 +24,8 @@ python gen_keyboard_overlay_data.py --cc --grd --js
The output directory of the generated files can be changed with --outdir. The output directory of the generated files can be changed with --outdir.
e.g. (This will generate tmp/xkeyboard.cc) e.g. (This will generate tmp/keyboard_overlay.js)
python gen_keyboard_overlay_data.py --outdir=tmp --altgr python gen_keyboard_overlay_data.py --outdir=tmp --js
""" """
import cStringIO import cStringIO
...@@ -53,8 +50,6 @@ GRD_OUTDIR = 'chrome/app' ...@@ -53,8 +50,6 @@ GRD_OUTDIR = 'chrome/app'
GRD_FILENAME = 'generated_resources.grd' GRD_FILENAME = 'generated_resources.grd'
JS_OUTDIR = 'chrome/browser/resources/chromeos' JS_OUTDIR = 'chrome/browser/resources/chromeos'
JS_FILENAME = 'keyboard_overlay_data.js' JS_FILENAME = 'keyboard_overlay_data.js'
ALTGR_OUTDIR = 'chrome/browser/chromeos/input_method'
ALTGR_FILENAME = 'xkeyboard_data.h'
CC_START = r'IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_HIDE },' CC_START = r'IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_HIDE },'
CC_END = r'};' CC_END = r'};'
GRD_START = """Escape to hide GRD_START = """Escape to hide
...@@ -176,30 +171,6 @@ GRD_SNIPPET_TEMPLATE=""" <message name="%s" desc="%s"> ...@@ -176,30 +171,6 @@ GRD_SNIPPET_TEMPLATE=""" <message name="%s" desc="%s">
CC_SNIPPET_TEMPLATE=""" { "%s", %s }, CC_SNIPPET_TEMPLATE=""" { "%s", %s },
""" """
ALTGR_TEMPLATE=(
"""// This file was generated by 'gen_keyboard_overlay_data.py --altgr'
#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_DATA_H_
#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_DATA_H_
namespace chromeos {
namespace input_method {
// These are the input method IDs that shouldn't remap the right alt key.
const char* kKeepRightAltInputMethods[] = {
%s
};
// These are the overlay names with caps lock remapped
const char* kCapsLockRemapped[] = {
%s
};
} // input_method
} // chromeos
#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_DATA_H_
""")
def SplitBehavior(behavior): def SplitBehavior(behavior):
"""Splits the behavior to compose a message or i18n-content value. """Splits the behavior to compose a message or i18n-content value.
...@@ -285,8 +256,6 @@ def ParseOptions(): ...@@ -285,8 +256,6 @@ def ParseOptions():
help='Output resource file.') help='Output resource file.')
parser.add_option('--cc', dest='cc', default=False, action='store_true', parser.add_option('--cc', dest='cc', default=False, action='store_true',
help='Output cc file.') help='Output cc file.')
parser.add_option('--altgr', dest='altgr', default=False, action='store_true',
help='Output altgr file.')
parser.add_option('--outdir', dest='outdir', default=None, parser.add_option('--outdir', dest='outdir', default=None,
help='Specify the directory files are generated.') help='Specify the directory files are generated.')
(options, unused_args) = parser.parse_args() (options, unused_args) = parser.parse_args()
...@@ -295,8 +264,8 @@ def ParseOptions(): ...@@ -295,8 +264,8 @@ def ParseOptions():
print 'google.com account is necessary to use this script.' print 'google.com account is necessary to use this script.'
sys.exit(-1) sys.exit(-1)
if (not (options.js or options.grd or options.cc or options.altgr)): if (not (options.js or options.grd or options.cc)):
print 'Either --js, --grd, --cc or --altgr needs to be specified.' print 'Either --js, --grd, or --cc needs to be specified.'
sys.exit(-1) sys.exit(-1)
# Get the password from the terminal, if needed. # Get the password from the terminal, if needed.
...@@ -535,43 +504,12 @@ def OutputCC(hotkey_data, outdir): ...@@ -535,43 +504,12 @@ def OutputCC(hotkey_data, outdir):
outdir) outdir)
def OutputAltGr(keyboard_glyph_data, outdir):
"""Outputs the keyboard overlay data as a JSON file."""
altgr_output = []
caps_lock_output = []
for input_method_id, layout in INPUT_METHOD_ID_TO_OVERLAY_ID.iteritems():
try:
# If left and right alt have different values, this layout to the list of
# layouts that don't remap the right alt key.
right_alt = keyboard_glyph_data[layout]["keys"]["E0 38"]["label"].strip()
left_alt = keyboard_glyph_data[layout]["keys"]["38"]["label"].strip()
if right_alt.lower() != left_alt.lower():
altgr_output.append(' "%s",' % input_method_id)
except KeyError:
pass
try:
caps_lock = keyboard_glyph_data[layout]["keys"]["E0 5B"]["label"].strip()
if caps_lock.lower() != "search":
caps_lock_output.append(' "%s",' % input_method_id)
except KeyError:
pass
if not outdir:
outdir = ALTGR_OUTDIR
outpath = GetPath(os.path.join(outdir, ALTGR_FILENAME))
snippet = ALTGR_TEMPLATE % ("\n".join(sorted(altgr_output)),
"\n".join(sorted(caps_lock_output)))
OutputFile(outpath, snippet)
def main(): def main():
options = ParseOptions() options = ParseOptions()
client = InitClient(options) client = InitClient(options)
hotkey_data = FetchHotkeyData(client) hotkey_data = FetchHotkeyData(client)
if options.js or options.altgr: if options.js:
keyboard_glyph_data = FetchKeyboardGlyphData(client) keyboard_glyph_data = FetchKeyboardGlyphData(client)
if options.js: if options.js:
...@@ -582,8 +520,6 @@ def main(): ...@@ -582,8 +520,6 @@ def main():
OutputGrd(hotkey_data, options.outdir) OutputGrd(hotkey_data, options.outdir)
if options.cc: if options.cc:
OutputCC(hotkey_data, options.outdir) OutputCC(hotkey_data, options.outdir)
if options.altgr:
OutputAltGr(keyboard_glyph_data, options.outdir)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment