diff options
| author | Jules Aguillon | 2023-06-10 10:59:25 +0200 |
|---|---|---|
| committer | Jules Aguillon | 2023-06-22 20:14:20 +0200 |
| commit | 5fc68373d3ee0ce61cfb819f0e623e3a3f63c374 (patch) | |
| tree | 9468f7650e11254adf51c3b8fdb26a5cc85b0fcb /srcs/juloo.keyboard2 | |
| parent | 9f90b807f8bd57e6cff4257a9d842a831193faf6 (diff) | |
| download | unexpected-keyboard-5fc68373d3ee0ce61cfb819f0e623e3a3f63c374.tar.gz unexpected-keyboard-5fc68373d3ee0ce61cfb819f0e623e3a3f63c374.zip | |
Allow to specify a layout script
Add the `script` attribute, which will be used to implement
script-specific extra keys.
Diffstat (limited to 'srcs/juloo.keyboard2')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyboardData.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java index bc78f23..e66f1c7 100644 --- a/srcs/juloo.keyboard2/KeyboardData.java +++ b/srcs/juloo.keyboard2/KeyboardData.java @@ -23,13 +23,15 @@ class KeyboardData public final float keysHeight; /** Might be null. */ public final Modmap modmap; + /** Might be null. */ + public final String script; public KeyboardData mapKeys(MapKey f) { ArrayList<Row> rows_ = new ArrayList<Row>(); for (Row r : rows) 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 @@ -49,7 +51,7 @@ class KeyboardData for (int c = 1; c <= 4; c++) addExtraKeys_to_row(rows, k, r, c); } - return new KeyboardData(rows, keysWidth, modmap); + return new KeyboardData(rows, keysWidth, modmap, script); } public KeyboardData addNumPad() @@ -73,14 +75,14 @@ class KeyboardData extendedRows.add(new Row(keys, row.height, row.shift)); } return new - KeyboardData(extendedRows, compute_max_width(extendedRows), modmap); + KeyboardData(extendedRows, compute_max_width(extendedRows), modmap, script); } public KeyboardData addNumberRow() { ArrayList<Row> rows_ = new ArrayList<Row>(this.rows); 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) @@ -175,6 +177,7 @@ class KeyboardData throw new Exception("Empty layout file"); boolean add_bottom_row = attribute_bool(parser, "bottom_row", true); float specified_kw = attribute_float(parser, "width", 0f); + String script = parser.getAttributeValue(null, "script"); ArrayList<Row> rows = new ArrayList<Row>(); Modmap modmap = null; while (next_tag(parser)) @@ -194,7 +197,7 @@ class KeyboardData float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows); if (add_bottom_row) 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) @@ -212,13 +215,14 @@ class KeyboardData 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; for (Row r : rows_) kh += r.height + r.shift; rows = rows_; modmap = mm; + script = sc; keysWidth = kw; keysHeight = kh; } |
