layouts format: Add 'c' as a synonym for 'key0'

The attribute 'c' specifies the symbol in the center of a key, just like
'key0'. This adds consistency with the cardinal direction attributes and
is intended to make layouts more readable.
This commit is contained in:
Jules Aguillon 2024-11-24 10:56:19 +01:00
parent ed36098439
commit 6b1551d103
4 changed files with 40 additions and 41 deletions

View File

@ -10,9 +10,8 @@ KNOWN_NOT_LAYOUT = set([
"clipboard_bottom_row" ])
KEY_ATTRIBUTES = set([
"key0",
"key1", "key2", "key3", "key4", "key5", "key6", "key7", "key8",
"nw", "ne", "sw", "se", "w", "e", "n", "s"
"key0", "key1", "key2", "key3", "key4", "key5", "key6", "key7", "key8",
"c", "nw", "ne", "sw", "se", "w", "e", "n", "s"
])
def warn(msg):

View File

@ -20,7 +20,7 @@ A layout XML file comprises tags that start with `<` and end with `>`.
* An optional `<modmap>`...`</modmap>` pair contains instructions if you want to change the behavior of a modifier key such as Shift.
* Stand-alone tags include `<key`...`/>`, which defines a single key.
A tag can have properties, defined using an equals sign and a pair of ASCII double quotes. For example, `<key key0="a" />` defines the "a" key. The `key0` property of the `key` tag says which key you are defining, and the tag's location inside `<row>`...`</row>` specifies where it will go in the row.
A tag can have properties, defined using an equals sign and a pair of ASCII double quotes. For example, `<key c="a" />` defines the "a" key. The `c` property of the `key` tag says which key you are defining, and the tag's location inside `<row>`...`</row>` specifies where it will go in the row.
### Example
Here is a complete keyboard file with a single row containing an "a" key on the left and a "b" key on the right:
@ -28,8 +28,8 @@ Here is a complete keyboard file with a single row containing an "a" key on the
<?xml version="1.0" encoding="utf-8"?>
<keyboard name="Simple example" script="latin">
<row>
<key key0="a" />
<key key0="b" />
<key c="a" />
<key c="b" />
</row>
</keyboard>
@ -59,7 +59,7 @@ A row's default height is 1.0 (one quarter of the keyboard height specified on t
The `<key />` tag defines a key on the keyboard. Its position in the sequence of keys inside `<row>`...`</row>` indicates its position in the row from left to right. What the key does is defined by optional properties.
### Taps
What the key does when tapped is defined by the optional `key0` property. For example, `<key key0="a" />` defines the "a" key. Unexpected Keyboard provides a legend in the middle of the key.
What the key does when tapped is defined by the optional `c` property. For example, `<key c="a" />` defines the "a" key. Unexpected Keyboard provides a legend in the middle of the key.
When the Shift modifier is tapped, the "a" key becomes the "A" key and the legend temporarily changes. The Fn modifier makes a different change. You can override this behavior with a modmap (see below).
@ -71,7 +71,7 @@ The following optional properties define the effects of swipes:
<TD STYLE="width: 6em;">nw</TD><TD>n</TD><TD>ne</TD>
</TR>
<TR ALIGN=CENTER>
<TD>w</TD><TD>&nbsp;</TD><TD>e</TD>
<TD>w</TD><TD>c</TD><TD>e</TD>
</TR>
<TR>
<TD>sw</TD><TD>s</TD><TD>se</TD>
@ -84,7 +84,7 @@ The following optional properties define the effects of swipes:
<TD>key1</TD><TD>key7</TD><TD>key2</TD>
</TR>
<TR>
<TD>key5</TD><TD>&nbsp;</TD><TD>key6</TD>
<TD>key5</TD><TD>key0</TD><TD>key6</TD>
</TR>
<TR>
<TD>key3</TD><TD>key8</TD><TD>key4</TD>
@ -104,10 +104,10 @@ A key may have the following properties to control the row's layout:
Normally, a key's width is 1.0 unit. Unexpected Keyboard occupies the full width of the screen, and the row defining the highest number of units (in widths plus shifts) is as wide as the screen. A row whose width is a smaller number of units has empty space on the right.
### Extra legend
* `indication`: An optional extra legend to show under the main label. For example, `<key key0="2" indication="ABC" />` displays ABC at the bottom of the 2 key, as on a pinpad or some telephones. If the key also defines a downward swipe with `s` or `key8`, the legends overlap.
* `indication`: An optional extra legend to show under the main label. For example, `<key c="2" indication="ABC" />` displays ABC at the bottom of the 2 key, as on a pinpad or some telephones. If the key also defines a downward swipe with `s` or `key8`, the legends overlap.
### Possible key values
Built-in strings that assign a special function to a key are described in [this page](Possible-key-values.md). For example, `se="copy"` means a southeasterly swipe produces the Copy key. If a key value does not match any of the built-in strings, it outputs that text _verbatim_. For example, `key0="a"` simply outputs the letter a.
Built-in strings that assign a special function to a key are described in [this page](Possible-key-values.md). For example, `se="copy"` means a southeasterly swipe produces the Copy key. If a key value does not match any of the built-in strings, it outputs that text _verbatim_. For example, `c="a"` simply outputs the letter a.
In a layout, a key value can also start with the `loc` prefix. These are place-holders; the tap or swipe does nothing unless enabled through the "Add keys to keyboard" option in the Settings menu, or implicitly enabled by the language the device is set to use. For example, `ne="loc accent_aigu"` says that a northeast swipe produces the acute accent combinatorial key—if enabled.

View File

@ -473,7 +473,7 @@ public final class KeyboardData
{
KeyValue[] ks = new KeyValue[9];
int keysflags = 0;
keysflags |= parse_key_attr(parser, parser.getAttributeValue(null, "key0"), ks, 0);
keysflags |= parse_key_attr(parser, get_key_attr(parser, "key0", "c"), ks, 0);
/* Swipe gestures (key1-key8 diagram above), with compass-point synonyms. */
keysflags |= parse_key_attr(parser, get_key_attr(parser, "key1", "nw"), ks, 1);
keysflags |= parse_key_attr(parser, get_key_attr(parser, "key2", "ne"), ks, 2);

View File

@ -8,7 +8,7 @@ symbols to the corners of a key, they are arranged following the cardinal
directions:
nw n ne
w key0 e
w c e
sw s se
Symbols prefixed with 'loc ' are not visible on the keyboard. They are used to
@ -23,37 +23,37 @@ doc/Possible-key-values.md for the keys that have a special meaning.
-->
<keyboard name="QWERTY (US)" script="latin">
<row>
<key key0="q" ne="1" se="loc esc"/>
<key key0="w" nw="~" ne="2" sw="\@"/>
<key key0="e" nw="!" ne="3" sw="\#" se="loc €"/>
<key key0="r" ne="4" sw="$"/>
<key key0="t" ne="5" sw="%"/>
<key key0="y" ne="6" sw="^"/>
<key key0="u" ne="7" sw="&amp;"/>
<key key0="i" ne="8" sw="*"/>
<key key0="o" ne="9" sw="(" se=")"/>
<key key0="p" ne="0"/>
<key c="q" ne="1" se="loc esc"/>
<key c="w" nw="~" ne="2" sw="\@"/>
<key c="e" nw="!" ne="3" sw="\#" se="loc €"/>
<key c="r" ne="4" sw="$"/>
<key c="t" ne="5" sw="%"/>
<key c="y" ne="6" sw="^"/>
<key c="u" ne="7" sw="&amp;"/>
<key c="i" ne="8" sw="*"/>
<key c="o" ne="9" sw="(" se=")"/>
<key c="p" ne="0"/>
</row>
<row>
<key shift="0.5" key0="a" nw="loc tab" ne="`"/>
<key key0="s" ne="loc §" sw="loc ß"/>
<key key0="d"/>
<key key0="f"/>
<key key0="g" ne="-" sw="_"/>
<key key0="h" ne="=" sw="+"/>
<key key0="j" se="}" sw="{"/>
<key key0="k" sw="[" se="]"/>
<key key0="l" ne="|" sw="\\"/>
<key shift="0.5" c="a" nw="loc tab" ne="`"/>
<key c="s" ne="loc §" sw="loc ß"/>
<key c="d"/>
<key c="f"/>
<key c="g" ne="-" sw="_"/>
<key c="h" ne="=" sw="+"/>
<key c="j" se="}" sw="{"/>
<key c="k" sw="[" se="]"/>
<key c="l" ne="|" sw="\\"/>
</row>
<row>
<key width="1.5" key0="shift" ne="loc capslock"/>
<key key0="z"/>
<key key0="x" ne="loc †"/>
<key key0="c" ne="&lt;" sw="."/>
<key key0="v" ne="&gt;" sw=","/>
<key key0="b" ne="\?" sw="/"/>
<key key0="n" ne=":" sw=";"/>
<key key0="m" ne="&quot;" sw="'"/>
<key width="1.5" key0="backspace" ne="delete"/>
<key width="1.5" c="shift" ne="loc capslock"/>
<key c="z"/>
<key c="x" ne="loc †"/>
<key c="c" ne="&lt;" sw="."/>
<key c="v" ne="&gt;" sw=","/>
<key c="b" ne="\?" sw="/"/>
<key c="n" ne=":" sw=";"/>
<key c="m" ne="&quot;" sw="'"/>
<key width="1.5" c="backspace" ne="delete"/>
</row>
</keyboard>