Skip to content

Commit

Permalink
CLDR-17141 kbd: drop transform=no
Browse files Browse the repository at this point in the history
- expand documentation about use of markers to inhibit transforms
  • Loading branch information
srl295 committed Oct 9, 2023
1 parent 24f19c8 commit f7efe77
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 70 deletions.
112 changes: 52 additions & 60 deletions docs/ldml/tr35-keyboards.md
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ This element defines a mapping between an abstract key and its output. This elem
stretch="true"
layerId="{switch layer id}"
output="{the output}"
transform="no"
width="{key width}"
/>
```
Expand Down Expand Up @@ -736,65 +735,6 @@ _Attribute:_ `output`
>
> The `output` attribute may also contain the `\m{…}` syntax to insert a marker. See the definition of [markers](#markers).
_Attribute:_ `transform="no"` (optional)
> The `transform` attribute is used to define a key that does not participate in a transform (until the next keystroke). This attribute value must be `"no"` if the attribute is present.
> This attribute is useful where it is desired to output where two different keys could output the same characters (with different key or modifier combinations) but only one of them is intended to participate in a transform.
> When the next keystroke is pressed, the prior output may then combine using other transforms.
>
> Note that a more flexible way of solving this problem may be to use special markers which would inhibit matching.
>
> For example, suppose there are the following keys, their output and one transform:
```xml
<keys>
<key id="X" output="^" transform="no"/>
<key id="OptX" output="^"/>
</keys>
<transforms …>
<transform from="^e" to="ê"/>
</transforms>
```
* **X** outputs `^` (caret)
* Option-**X** outputs `^` but is intended to be the first part of a transform.
* Option-**X** + `e``ê`

> Without the `transform="no"` on the base key **X**, it would not be possible to
> type the sequence `^e` (caret+e) as it would turn into `ê` per the transform.
> However, since there is `transform="no`" on **X**, if the user types **X** + `e` the sequence remains `^e`.
* **X** + `e``^e`

> Using markers, the same results can be obtained without need of `transform="no"` using:
```xml
<keys>
<key id="X" output="^\m{no_transform}"/>
<key id="OptX" output="^"/>
</keys>
<transforms …>
<!-- this wouldn't match the key X output because of the marker -->
<transform from="^e" output="ê"/>
</transforms>
```

Even better is to use a marker to indicate where transforms are desired:

```xml
<keys>
<key id="X" output="^"/>
<key id="OptX" output="^\m{transform}"/>
</keys>
<transforms …>
<!-- again, this wouldn't match the key X output because of the missing marker -->
<transform from="^\m{transform}e" output="ê"/>
</transforms>
```

_Attribute:_ `width="1.2"` (optional, default "1.0")
> The `width` attribute indicates that this key has a different width than other keys, by the specified number of key widths.
Expand Down Expand Up @@ -1766,6 +1706,58 @@ Consider the following abbreviated example:
-
- character `ê`

**Using markers to inhibit other transforms**

Sometimes it is desirable to prevent transforms from having an effect.
Perhaps two different keys output the same characters, with different key or modifier combinations, but only one of them is intended to participate in a transform.

Consider the following case, where pressing the keys `X`, `e` results in `^e`, which is transformed into `ê`.

```xml
<keys>
<key id="X" output="^"/>
<key id="e" output="e" />
</keys>
<transforms>
<transform from="^e" output="ê"/>
</transforms>
```

However, what if the user wanted to produce `^e` without the transform taking effect?
One strategy would be to use a marker, which won’t be visible in the output, but will inhibit the transform.

```xml
<keys>
<key id="caret" output="^\m{no_transform}"/>
<key id="X" output="^" />
<key id="e" output="e" />
</keys>
<transforms>
<!-- this wouldn't match the key X output because of the marker -->
<transform from="^e" output="ê"/>
</transforms>
```

Pressing `caret` `e` will result in `^e` (with an invisible _no_transform_ marker — note that any name could be used). The `^e` won’t have the transform applied, at least while the marker’s context remains valid.

Another strategy might be to use a marker to indicate where transforms are desired, instead of where they aren't desired.

```xml
<keys>
<key id="caret" output="^"/>
<key id="X" output="^\m{transform}"/>
<key id="e" output="e" />
</keys>
<transforms …>
<!-- Won't match ^e without marker. -->
<transform from="^\m{transform}e" output="ê"/>
</transforms>
```

In this way, only the `X`, `e` keys will produce `^e` with a _transform_ marker (again, any name could be used) which will cause the transform to be applied. One benefit is that clicking or using the arrow key to navigate existing text with `^e` will never be affected by the transform, because the marker is not or no longer present.

**Effect of markers on final text**

All markers must be removed before text is returned to the application from the input context.
Expand Down
2 changes: 0 additions & 2 deletions keyboards/dtd/ldmlKeyboard3.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ Please view the subcommittee page for the most recent information.
<!ATTLIST key layerId NMTOKEN #IMPLIED >
<!--@MATCH:any-->
<!--@VALUE-->
<!ATTLIST key transform (no) #IMPLIED >
<!--@VALUE-->
<!ATTLIST key width CDATA #IMPLIED >
<!--@MATCH:range/0.01~100.0-->
<!--@VALUE-->
Expand Down
8 changes: 0 additions & 8 deletions keyboards/dtd/ldmlKeyboard3.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,6 @@ Note: DTD @-annotations are not currently converted to .xsd. For full CLDR file
</xs:simpleType>
</xs:attribute>
<xs:attribute name="layerId" type="xs:NMTOKEN"/>
<xs:attribute name="transform">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="width"/>
</xs:complexType>
</xs:element>
Expand All @@ -221,7 +214,6 @@ Note: DTD @-annotations are not currently converted to .xsd. For full CLDR file




<xs:element name="keyLists">
<xs:complexType>
<xs:sequence>
Expand Down

0 comments on commit f7efe77

Please sign in to comment.