# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Generate a C++ header from ibus_input_methods.txt.
+"""Generate a C++ header from input_methods.txt.
This program generates a C++ header file containing the information on
available input methods. It parses input_methods.txt, and then generates a
It will produce output that looks like:
// This file is automatically generated by gen_input_methods.py
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#ifndef CHROMEOS_IME_INPUT_METHODS_H_
+#define CHROMEOS_IME_INPUT_METHODS_H_
namespace chromeos {
namespace input_method {
const char* input_method_id;
const char* language_code;
const char* xkb_keyboard_id;
+ const char* indicator;
bool is_login_keyboard;
};
const InputMethodsInfo kInputMethods[] = {
- {"xkb:us::eng", "en-US", "us", true},
- {"xkb:us:dvorak:eng", "en-US", "us(dvorak)", true},
- {"xkb:be::fra", "fr", "be", true},
- {"xkb:br::por", "pt-BR", "br", true},
- {"xkb:ru::rus", "ru", "ru", false},
+ {"xkb:us::eng", "en-US", "us", "US", true},
+ {"xkb:us:dvorak:eng", "en-US", "us(dvorak)", "DV", true},
+ {"xkb:be::fra", "fr", "be", "BE", true},
+ {"xkb:br::por", "pt-BR", "br", "BR", true},
+ {"xkb:ru::rus", "ru", "ru", "RU", false},
};
} // namespace input_method
} // namespace chromeos
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#endif // CHROMEOS_IME_INPUT_METHODS_H_
"""
import sys
OUTPUT_HEADER = """// Automatically generated by gen_input_methods.py
-#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
-#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#ifndef CHROMEOS_IME_INPUT_METHODS_H_
+#define CHROMEOS_IME_INPUT_METHODS_H_
namespace chromeos {
namespace input_method {
const char* input_method_id;
const char* language_code;
const char* xkb_layout_id;
+ const char* indicator;
bool is_login_keyboard;
};
const InputMethodsInfo kInputMethods[] = {
CPP_FORMAT = '#if %s\n'
ENGINE_FORMAT = (' {"%(input_method_id)s", "%(language_code)s", ' +
- '"%(xkb_layout_id)s", %(is_login_keyboard)s},\n')
+ '"%(xkb_layout_id)s", "%(indicator)s", ' +
+ '%(is_login_keyboard)s},\n')
OUTPUT_FOOTER = """
};
} // namespace input_method
} // namespace chromeos
-#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHODS_H_
+#endif // CHROMEOS_IME_INPUT_METHODS_H_
"""
def CreateEngineHeader(engines):
if not line or re.match(r'#', line):
continue
columns = line.split()
- assert len(columns) == 3 or len(columns) == 4, "Invalid format: " + line
+ assert len(columns) == 4 or len(columns) == 5, "Invalid format: " + line
engine = {}
engine['input_method_id'] = columns[0]
engine['xkb_layout_id'] = columns[1]
engine['language_code'] = columns[2]
+ engine['indicator'] = columns[3]
is_login_keyboard = "false"
- if len(columns) == 4:
- assert columns[3] == "login", "Invalid attribute: " + columns[3]
+ if len(columns) == 5:
+ assert columns[4] == "login", "Invalid attribute: " + columns[4]
is_login_keyboard = "true"
engine['is_login_keyboard'] = is_login_keyboard
engines.append(engine)