forked from extern/Unexpected-Keyboard
Allow to specify a layout script
Add the `script` attribute, which will be used to implement script-specific extra keys.
This commit is contained in:
parent
9f90b807f8
commit
5fc68373d3
@ -1,100 +1,141 @@
|
|||||||
# res/xml/ar_alt.xml
|
# res/xml/ar_alt.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: !, ", ', +, -, /, :, ;, <, =, >, ?, [, \, ], _, |, ~
|
Layout includes some ASCII punctuation but not all, missing: !, ", ', +, -, /, :, ;, <, =, >, ?, [, \, ], _, |, ~
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/ar_pc.xml
|
# res/xml/ar_pc.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: !, ', +, ;, ?, \, |
|
Layout includes some ASCII punctuation but not all, missing: !, ', +, ;, ?, \, |
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/azerty.xml
|
# res/xml/azerty.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/bangla.xml
|
# res/xml/bangla.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: $
|
Layout includes some ASCII punctuation but not all, missing: $
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/bone.xml
|
# res/xml/bone.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: $
|
Layout includes some ASCII punctuation but not all, missing: $
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
Not a layout file: res/xml/bottom_row.xml
|
Not a layout file: res/xml/bottom_row.xml
|
||||||
# res/xml/colemak.xml
|
# res/xml/colemak.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/devanagari_1.xml
|
# res/xml/devanagari_1.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: ", $, ', ^, _, `, |
|
Layout includes some ASCII punctuation but not all, missing: ", $, ', ^, _, `, |
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/devanagari_2.xml
|
# res/xml/devanagari_2.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: #, $, %, &, ', (, ), *, +, ., /, :, <, =, >, @, [, \, ], ^, _, `, {, |, }, ~
|
Layout includes some ASCII punctuation but not all, missing: #, $, %, &, ', (, ), *, +, ., /, :, <, =, >, @, [, \, ], ^, _, `, {, |, }, ~
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/dvorak.xml
|
# res/xml/dvorak.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/greekmath.xml
|
# res/xml/greekmath.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: !, ", #, $, %, &, ', (, ), *, +, ,, -, /, :, ;, <, >, ?, @, [, \, ], _, `, {, |, }, ~
|
Layout includes some ASCII punctuation but not all, missing: !, ", #, $, %, &, ', (, ), *, +, ,, -, /, :, ;, <, >, ?, @, [, \, ], _, `, {, |, }, ~
|
||||||
Layout redefines the bottom row but some important keys are missing, missing: change_method, config, ctrl, switch_emoji, switch_second
|
Layout redefines the bottom row but some important keys are missing, missing: change_method, config, ctrl, switch_emoji, switch_second
|
||||||
2 warnings
|
Layout doesn't specify a script.
|
||||||
|
3 warnings
|
||||||
# res/xml/he_il_1452_1.xml
|
# res/xml/he_il_1452_1.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, }
|
Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, }
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/he_il_1452_2.xml
|
# res/xml/he_il_1452_2.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, }
|
Layout includes some ASCII punctuation but not all, missing: (, ), <, >, [, ], {, }
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/jcuken_ua.xml
|
# res/xml/jcuken_ua.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
|
# res/xml/kurdish.xml
|
||||||
|
Layout includes some ASCII punctuation but not all, missing: ", %, ', +, ,, ., :, ;, <, =, >, ?, `, |, ~
|
||||||
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/local_bgph1.xml
|
# res/xml/local_bgph1.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: ~
|
Layout includes some ASCII punctuation but not all, missing: ~
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/local_ru_jcuken.xml
|
# res/xml/local_ru_jcuken.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
Not a layout file: res/xml/method.xml
|
Not a layout file: res/xml/method.xml
|
||||||
# res/xml/neo2.xml
|
# res/xml/neo2.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
Not a layout file: res/xml/number_row.xml
|
Not a layout file: res/xml/number_row.xml
|
||||||
# res/xml/numeric.xml
|
# res/xml/numeric.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: &, ?, @, `
|
Layout includes some ASCII punctuation but not all, missing: &, ?, @, `
|
||||||
Layout redefines the bottom row but some important keys are missing, missing: change_method, config, switch_emoji, switch_numeric, switch_second
|
Layout redefines the bottom row but some important keys are missing, missing: change_method, config, switch_emoji, switch_numeric, switch_second
|
||||||
2 warnings
|
Layout doesn't specify a script.
|
||||||
|
3 warnings
|
||||||
# res/xml/numpad.xml
|
# res/xml/numpad.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: !, ", #, $, %, &, ', (, ), ,, :, ;, <, >, ?, @, [, \, ], ^, _, `, {, |, }, ~
|
Layout includes some ASCII punctuation but not all, missing: !, ", #, $, %, &, ', (, ), ,, :, ;, <, >, ?, @, [, \, ], ^, _, `, {, |, }, ~
|
||||||
Layout doesn't define some important keys, missing: backspace, delete
|
Layout doesn't define some important keys, missing: backspace, delete
|
||||||
Layout redefines the bottom row but some important keys are missing, missing: action, change_method, config, ctrl, down, enter, fn, left, right, space, switch_emoji, switch_numeric, switch_second, up
|
Layout redefines the bottom row but some important keys are missing, missing: action, change_method, config, ctrl, down, enter, fn, left, right, space, switch_emoji, switch_numeric, switch_second, up
|
||||||
3 warnings
|
Layout doesn't specify a script.
|
||||||
|
4 warnings
|
||||||
# res/xml/persian.xml
|
# res/xml/persian.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: ", $, %, ', *, ,, /, ;, <, =, >, ?, [, \, ], ^, _, `, {, |, }, ~
|
Layout includes some ASCII punctuation but not all, missing: ", $, %, ', *, ,, /, ;, <, =, >, ?, [, \, ], ^, _, `, {, |, }, ~
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/pin.xml
|
# res/xml/pin.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: !, ", $, %, &, ', ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, ~
|
Layout includes some ASCII punctuation but not all, missing: !, ", $, %, &, ', ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, ~
|
||||||
Layout redefines the bottom row but some important keys are missing, missing: change_method, config, ctrl, fn, switch_emoji, switch_second
|
Layout redefines the bottom row but some important keys are missing, missing: change_method, config, ctrl, fn, switch_emoji, switch_second
|
||||||
2 warnings
|
Layout doesn't specify a script.
|
||||||
|
3 warnings
|
||||||
# res/xml/qwerty_el.xml
|
# res/xml/qwerty_el.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_es.xml
|
# res/xml/qwerty_es.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_hu.xml
|
# res/xml/qwerty_hu.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_ko.xml
|
# res/xml/qwerty_ko.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_lv.xml
|
# res/xml/qwerty_lv.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_no.xml
|
# res/xml/qwerty_no.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_pl.xml
|
# res/xml/qwerty_pl.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_pt.xml
|
# res/xml/qwerty_pt.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_sv_se.xml
|
# res/xml/qwerty_sv_se.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_tr.xml
|
# res/xml/qwerty_tr.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwerty_vi.xml
|
# res/xml/qwerty_vi.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: \
|
Layout includes some ASCII punctuation but not all, missing: \
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/qwerty.xml
|
# res/xml/qwerty.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwertz_cs.xml
|
# res/xml/qwertz_cs.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: `
|
Layout includes some ASCII punctuation but not all, missing: `
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/qwertz_de.xml
|
# res/xml/qwertz_de.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwertz_hu.xml
|
# res/xml/qwertz_hu.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
# res/xml/qwertz_sk.xml
|
# res/xml/qwertz_sk.xml
|
||||||
Layout includes some ASCII punctuation but not all, missing: \, `
|
Layout includes some ASCII punctuation but not all, missing: \, `
|
||||||
1 warnings
|
Layout doesn't specify a script.
|
||||||
|
2 warnings
|
||||||
# res/xml/qwertz.xml
|
# res/xml/qwertz.xml
|
||||||
0 warnings
|
Layout doesn't specify a script.
|
||||||
|
1 warnings
|
||||||
Not a layout file: res/xml/settings.xml
|
Not a layout file: res/xml/settings.xml
|
||||||
|
@ -61,6 +61,9 @@ def check_layout(layout):
|
|||||||
unexpected_keys(keys, bottom_row_keys,
|
unexpected_keys(keys, bottom_row_keys,
|
||||||
"Layout contains keys present in the bottom row")
|
"Layout contains keys present in the bottom row")
|
||||||
|
|
||||||
|
if root.get("script") == None:
|
||||||
|
warn("Layout doesn't specify a script.")
|
||||||
|
|
||||||
for fname in sys.argv[1:]:
|
for fname in sys.argv[1:]:
|
||||||
layout = parse_layout(fname)
|
layout = parse_layout(fname)
|
||||||
if layout == None:
|
if layout == None:
|
||||||
|
@ -23,13 +23,15 @@ class KeyboardData
|
|||||||
public final float keysHeight;
|
public final float keysHeight;
|
||||||
/** Might be null. */
|
/** Might be null. */
|
||||||
public final Modmap modmap;
|
public final Modmap modmap;
|
||||||
|
/** Might be null. */
|
||||||
|
public final String script;
|
||||||
|
|
||||||
public KeyboardData mapKeys(MapKey f)
|
public KeyboardData mapKeys(MapKey f)
|
||||||
{
|
{
|
||||||
ArrayList<Row> rows_ = new ArrayList<Row>();
|
ArrayList<Row> rows_ = new ArrayList<Row>();
|
||||||
for (Row r : rows)
|
for (Row r : rows)
|
||||||
rows_.add(r.mapKeys(f));
|
rows_.add(r.mapKeys(f));
|
||||||
return new KeyboardData(rows_, keysWidth, modmap);
|
return new KeyboardData(rows_, keysWidth, modmap, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add keys from the given iterator into the keyboard. Extra keys are added
|
/** Add keys from the given iterator into the keyboard. Extra keys are added
|
||||||
@ -49,7 +51,7 @@ class KeyboardData
|
|||||||
for (int c = 1; c <= 4; c++)
|
for (int c = 1; c <= 4; c++)
|
||||||
addExtraKeys_to_row(rows, k, r, c);
|
addExtraKeys_to_row(rows, k, r, c);
|
||||||
}
|
}
|
||||||
return new KeyboardData(rows, keysWidth, modmap);
|
return new KeyboardData(rows, keysWidth, modmap, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardData addNumPad()
|
public KeyboardData addNumPad()
|
||||||
@ -73,14 +75,14 @@ class KeyboardData
|
|||||||
extendedRows.add(new Row(keys, row.height, row.shift));
|
extendedRows.add(new Row(keys, row.height, row.shift));
|
||||||
}
|
}
|
||||||
return new
|
return new
|
||||||
KeyboardData(extendedRows, compute_max_width(extendedRows), modmap);
|
KeyboardData(extendedRows, compute_max_width(extendedRows), modmap, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardData addNumberRow()
|
public KeyboardData addNumberRow()
|
||||||
{
|
{
|
||||||
ArrayList<Row> rows_ = new ArrayList<Row>(this.rows);
|
ArrayList<Row> rows_ = new ArrayList<Row>(this.rows);
|
||||||
rows_.add(0, number_row.updateWidth(keysWidth));
|
rows_.add(0, number_row.updateWidth(keysWidth));
|
||||||
return new KeyboardData(rows_, keysWidth, modmap);
|
return new KeyboardData(rows_, keysWidth, modmap, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Key findKeyWithValue(KeyValue kv)
|
public Key findKeyWithValue(KeyValue kv)
|
||||||
@ -175,6 +177,7 @@ class KeyboardData
|
|||||||
throw new Exception("Empty layout file");
|
throw new Exception("Empty layout file");
|
||||||
boolean add_bottom_row = attribute_bool(parser, "bottom_row", true);
|
boolean add_bottom_row = attribute_bool(parser, "bottom_row", true);
|
||||||
float specified_kw = attribute_float(parser, "width", 0f);
|
float specified_kw = attribute_float(parser, "width", 0f);
|
||||||
|
String script = parser.getAttributeValue(null, "script");
|
||||||
ArrayList<Row> rows = new ArrayList<Row>();
|
ArrayList<Row> rows = new ArrayList<Row>();
|
||||||
Modmap modmap = null;
|
Modmap modmap = null;
|
||||||
while (next_tag(parser))
|
while (next_tag(parser))
|
||||||
@ -194,7 +197,7 @@ class KeyboardData
|
|||||||
float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows);
|
float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows);
|
||||||
if (add_bottom_row)
|
if (add_bottom_row)
|
||||||
rows.add(bottom_row.updateWidth(kw));
|
rows.add(bottom_row.updateWidth(kw));
|
||||||
return new KeyboardData(rows, kw, modmap);
|
return new KeyboardData(rows, kw, modmap, script);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float compute_max_width(List<Row> rows)
|
private static float compute_max_width(List<Row> rows)
|
||||||
@ -212,13 +215,14 @@ class KeyboardData
|
|||||||
return Row.parse(parser);
|
return Row.parse(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeyboardData(List<Row> rows_, float kw, Modmap mm)
|
protected KeyboardData(List<Row> rows_, float kw, Modmap mm, String sc)
|
||||||
{
|
{
|
||||||
float kh = 0.f;
|
float kh = 0.f;
|
||||||
for (Row r : rows_)
|
for (Row r : rows_)
|
||||||
kh += r.height + r.shift;
|
kh += r.height + r.shift;
|
||||||
rows = rows_;
|
rows = rows_;
|
||||||
modmap = mm;
|
modmap = mm;
|
||||||
|
script = sc;
|
||||||
keysWidth = kw;
|
keysWidth = kw;
|
||||||
keysHeight = kh;
|
keysHeight = kh;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user