abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authordzaima2025-02-08 22:52:41 +0200
committerGitHub2025-02-08 21:52:41 +0100
commit8f729bb90a5dcfc4d01a325438ae5815624faac1 (patch)
treeab96a76c6c8641cd3f9c032de59716f8c3d64eff
parentaaf0a9a24999769a0bba9ec45968368ff0019012 (diff)
downloadunexpected-keyboard-8f729bb90a5dcfc4d01a325438ae5815624faac1.tar.gz
unexpected-keyboard-8f729bb90a5dcfc4d01a325438ae5815624faac1.zip
Add embedded_number_row keyboard attribute (#891)
-rw-r--r--doc/Custom-layouts.md2
-rw-r--r--srcs/juloo.keyboard2/KeyboardData.java10
-rw-r--r--srcs/juloo.keyboard2/LayoutModifier.java2
3 files changed, 10 insertions, 4 deletions
diff --git a/doc/Custom-layouts.md b/doc/Custom-layouts.md
index 13f68e5..d4e8341 100644
--- a/doc/Custom-layouts.md
+++ b/doc/Custom-layouts.md
@@ -47,6 +47,8 @@ The `<keyboard>`...`</keyboard>` pair follows the declaration tag and encloses t
+ We recommend your layout use the built-in bottom row, because it is still evolving and your layout will incorporate innovations in future versions. However, to define your own, the current definition of the bottom row is in [bottom_row.xml](https://github.com/Julow/Unexpected-Keyboard/res/xml/bottom_row.xml). You can copypaste this XML into your custom layout as a starting point.
+ Likewise, the current definition of the top (number) row is in [number_row.xml](https://github.com/Julow/Unexpected-Keyboard/res/xml/number_row.xml).
+* `embedded_number_row`: Whether the layout has an embedded number row, and thus the "Show number row" setting shouldn't add another one. It accepts `true` or `false`, and defaults to `false`.
+
* `locale_extra_keys`: Whether Unexpected should add language-dependent extra keys from [method.xml](../res/xml/method.xml) to this layout. It accepts `true` or `false`, and defaults to `true`. To disable these automatic additions, specify `locale_extra_keys="false"`.
## Row
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java
index 0c54291..9450c9e 100644
--- a/srcs/juloo.keyboard2/KeyboardData.java
+++ b/srcs/juloo.keyboard2/KeyboardData.java
@@ -31,6 +31,8 @@ public final class KeyboardData
public final String name;
/** Whether the bottom row should be added. */
public final boolean bottom_row;
+ /** Whether the number row is included in the layout and thus another one shouldn't be added. */
+ public final boolean embedded_number_row;
/** Whether extra keys from [method.xml] should be added to this layout. */
public final boolean locale_extra_keys;
/** Position of every keys on the layout, see [getKeys()]. */
@@ -239,6 +241,7 @@ public final class KeyboardData
if (!expect_tag(parser, "keyboard"))
throw error(parser, "Expected tag <keyboard>");
boolean bottom_row = attribute_bool(parser, "bottom_row", true);
+ boolean embedded_number_row = attribute_bool(parser, "embedded_number_row", false);
boolean locale_extra_keys = attribute_bool(parser, "locale_extra_keys", true);
float specified_kw = attribute_float(parser, "width", 0f);
String script = parser.getAttributeValue(null, "script");
@@ -269,7 +272,7 @@ public final class KeyboardData
}
}
float kw = (specified_kw != 0f) ? specified_kw : compute_max_width(rows);
- return new KeyboardData(rows, kw, modmap, script, numpad_script, name, bottom_row, locale_extra_keys);
+ return new KeyboardData(rows, kw, modmap, script, numpad_script, name, bottom_row, embedded_number_row, locale_extra_keys);
}
private static float compute_max_width(List<Row> rows)
@@ -288,7 +291,7 @@ public final class KeyboardData
}
protected KeyboardData(List<Row> rows_, float kw, Modmap mm, String sc,
- String npsc, String name_, boolean bottom_row_, boolean locale_extra_keys_)
+ String npsc, String name_, boolean bottom_row_, boolean embedded_number_row_, boolean locale_extra_keys_)
{
float kh = 0.f;
for (Row r : rows_)
@@ -301,6 +304,7 @@ public final class KeyboardData
keysWidth = Math.max(kw, 1f);
keysHeight = kh;
bottom_row = bottom_row_;
+ embedded_number_row = embedded_number_row_;
locale_extra_keys = locale_extra_keys_;
}
@@ -308,7 +312,7 @@ public final class KeyboardData
protected KeyboardData(KeyboardData src, List<Row> rows)
{
this(rows, compute_max_width(rows), src.modmap, src.script,
- src.numpad_script, src.name, src.bottom_row, src.locale_extra_keys);
+ src.numpad_script, src.name, src.bottom_row, src.embedded_number_row, src.locale_extra_keys);
}
public static class Row
diff --git a/srcs/juloo.keyboard2/LayoutModifier.java b/srcs/juloo.keyboard2/LayoutModifier.java
index f37be25..830a50c 100644
--- a/srcs/juloo.keyboard2/LayoutModifier.java
+++ b/srcs/juloo.keyboard2/LayoutModifier.java
@@ -42,7 +42,7 @@ public final class LayoutModifier
added_numpad = modify_numpad(num_pad, kw);
remove_keys.addAll(added_numpad.getKeys().keySet());
}
- else if (globalConfig.add_number_row) // The numpad removes the number row
+ else if (globalConfig.add_number_row && !kw.embedded_number_row) // The numpad removes the number row
{
added_number_row = modify_number_row(number_row, kw);
remove_keys.addAll(added_number_row.getKeys(0).keySet());