abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/KeyboardData.java
diff options
context:
space:
mode:
authorJules Aguillon2024-01-10 23:39:19 +0100
committerJules Aguillon2024-01-10 23:39:19 +0100
commit148f3dfc052bc6a4161073e59505bd547ab347c3 (patch)
tree28d612844a0769af77b48b2080f6ca3c10c88ced /srcs/juloo.keyboard2/KeyboardData.java
parent6725d3057bc64a317d3d6ea38def15553ba01f0c (diff)
downloadunexpected-keyboard-148f3dfc052bc6a4161073e59505bd547ab347c3.tar.gz
unexpected-keyboard-148f3dfc052bc6a4161073e59505bd547ab347c3.zip
prefs: Show custom layout names if provided
Show the name of custom layouts in the list if it's provided using the `name` attribute. This should make managing several custom layouts easier.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyboardData.java')
-rw-r--r--srcs/juloo.keyboard2/KeyboardData.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/srcs/juloo.keyboard2/KeyboardData.java b/srcs/juloo.keyboard2/KeyboardData.java
index ed5aa9a..557e42f 100644
--- a/srcs/juloo.keyboard2/KeyboardData.java
+++ b/srcs/juloo.keyboard2/KeyboardData.java
@@ -27,6 +27,8 @@ class KeyboardData
public final String script;
/** Might be different from [script]. Might be null. */
public final String numpad_script;
+ /** The [name] attribute. Might be null. */
+ public final String name;
/** Position of every keys on the layout, see [getKeys()]. */
private Map<KeyValue, KeyPos> _key_pos = null;
@@ -229,6 +231,7 @@ class KeyboardData
String numpad_script = parser.getAttributeValue(null, "numpad_script");
if (numpad_script == null)
numpad_script = script;
+ String name = parser.getAttributeValue(null, "name");
ArrayList<Row> rows = new ArrayList<Row>();
Modmap modmap = null;
while (next_tag(parser))
@@ -248,7 +251,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, script, numpad_script);
+ return new KeyboardData(rows, kw, modmap, script, numpad_script, name);
}
private static float compute_max_width(List<Row> rows)
@@ -266,7 +269,8 @@ class KeyboardData
return Row.parse(parser);
}
- protected KeyboardData(List<Row> rows_, float kw, Modmap mm, String sc, String npsc)
+ protected KeyboardData(List<Row> rows_, float kw, Modmap mm, String sc,
+ String npsc, String name_)
{
float kh = 0.f;
for (Row r : rows_)
@@ -275,6 +279,7 @@ class KeyboardData
modmap = mm;
script = sc;
numpad_script = npsc;
+ name = name_;
keysWidth = kw;
keysHeight = kh;
}
@@ -282,7 +287,8 @@ class KeyboardData
/** Copies the fields of an other keyboard, with rows changed. */
protected KeyboardData(KeyboardData src, List<Row> rows)
{
- this(rows, compute_max_width(rows), src.modmap, src.script, src.numpad_script);
+ this(rows, compute_max_width(rows), src.modmap, src.script,
+ src.numpad_script, src.name);
}
public static class Row