composetable: Accept short compose sequences
authorMatthias Clasen <mclasen@redhat.com>
Mon, 28 Aug 2023 20:38:47 +0000 (16:38 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 19 Sep 2023 19:19:35 +0000 (15:19 -0400)
Followup to 8931169e0026b2db. That commit did
not do enough work to actually accept sequences
of lenth 1, as pointed by Mike Fabian.

gtk/gtkcomposetable.c
gtk/gtkcomposetable.h

index b8842d9731a451b052acfa0dfa8af50cb546b7f8..538003923a657c9e21b3d06dbafa865b287a54ac 100644 (file)
@@ -1331,10 +1331,27 @@ gtk_compose_table_check (const GtkComposeTable *table,
   if (!seq_index)
     return FALSE;
 
+  match = FALSE;
+
   if (n_compose == 1)
-    return TRUE;
+    {
+      if (seq_index[2] - seq_index[1] > 0)
+        {
+          seq = table->data + seq_index[1];
 
-  match = FALSE;
+          value = seq[0];
+
+          if ((value & (1 << 15)) != 0)
+            g_string_append (output, &table->char_data[value & ~(1 << 15)]);
+          else
+            g_string_append_unichar (output, value);
+
+          if (compose_match)
+            *compose_match = TRUE;
+        }
+
+      return TRUE;
+    }
 
   for (i = n_compose - 1; i < table->max_seq_len; i++)
     {
index f6665e63c0cf6ff6194e44423382c7eb29676f9d..4597858f45c1d76686d7a0da9c5ae78f5603b065 100644 (file)
@@ -30,12 +30,13 @@ typedef struct _GtkComposeTableCompact GtkComposeTableCompact;
  * The first part of the data contains rows of length max_seq_len + 1,
  * where the first element is the item of the sequence, and the
  * following elements are offsets to the data for sequences that
- * start with the first item of length 2, ..., max_seq_len.
+ * start with the first item of length 1, ..., max_seq_len.
  *
  * The second part of the data contains the rest of the sequence
  * data. It does not have a fixed stride. For each sequence, we
  * put seq[2], ..., seq[len - 1], followed by the encoded value
- * for this sequence.
+ * for this sequence. In particular for a sequence of length 1,
+ * the offset points directly to the value.
  *
  * The values are encoded as follows:
  *