Change 'indicator' to 'led' everywhere possible
authorRan Benita <ran234@gmail.com>
Sun, 17 Feb 2013 20:18:57 +0000 (22:18 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Mon, 18 Mar 2013 22:20:02 +0000 (22:20 +0000)
The code currently uses the two names interchangeably.
Settle on 'led', because it is shorter, more recognizable, and what we
use in our API (though of course the parser still uses 'indicator').

In camel case we make it 'Led'.
We change 'xkb_indicator_map' to just 'xkb_led' and the variables of
this type are 'led'. This mimics 'xkb_key' and 'key'.
IndicatorNameInfo and LEDInfo are changed to 'LedNameInfo' and
'LedInfo', and the variables are 'ledi' (like 'keyi' etc.). This is
instead of 'ii' and 'im'.

This might make a few places a bit confusing, but less than before I
think. It's also shorter.

Signed-off-by: Ran Benita <ran234@gmail.com>
13 files changed:
src/keymap-dump.c
src/keymap.c
src/keymap.h
src/state.c
src/text.c
src/text.h
src/xkbcomp/ast-build.c
src/xkbcomp/ast-build.h
src/xkbcomp/ast.h
src/xkbcomp/compat.c
src/xkbcomp/keycodes.c
src/xkbcomp/keymap.c
src/xkbcomp/parser.y

index 5bf0774..c868e3f 100644 (file)
@@ -154,7 +154,7 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf)
     struct xkb_key *key;
     struct xkb_key_alias *alias;
     xkb_led_index_t i;
-    const struct xkb_indicator_map *im;
+    const struct xkb_led *led;
 
     if (keymap->keycodes_section_name)
         write_buf(buf, "\txkb_keycodes \"%s\" {\n",
@@ -170,10 +170,10 @@ write_keycodes(struct xkb_keymap *keymap, struct buf *buf)
                   KeyNameText(keymap->ctx, key->name), key->keycode);
     }
 
-    darray_enumerate(i, im, keymap->indicators)
-        if (im->name != XKB_ATOM_NONE)
+    darray_enumerate(i, led, keymap->leds)
+        if (led->name != XKB_ATOM_NONE)
             write_buf(buf, "\t\tindicator %d = \"%s\";\n",
-                      i + 1, xkb_atom_text(keymap->ctx, im->name));
+                      i + 1, xkb_atom_text(keymap->ctx, led->name));
 
 
     darray_foreach(alias, keymap->key_aliases)
@@ -248,8 +248,8 @@ write_types(struct xkb_keymap *keymap, struct buf *buf)
 }
 
 static bool
-write_indicator_map(struct xkb_keymap *keymap, struct buf *buf,
-                    const struct xkb_indicator_map *led)
+write_led_map(struct xkb_keymap *keymap, struct buf *buf,
+              const struct xkb_led *led)
 {
     write_buf(buf, "\t\tindicator \"%s\" {\n",
               xkb_atom_text(keymap->ctx, led->name));
@@ -257,7 +257,7 @@ write_indicator_map(struct xkb_keymap *keymap, struct buf *buf,
     if (led->which_groups) {
         if (led->which_groups != XKB_STATE_LAYOUT_EFFECTIVE) {
             write_buf(buf, "\t\t\twhichGroupState= %s;\n",
-                      IndicatorStateText(keymap->ctx, led->which_groups));
+                      LedStateText(keymap->ctx, led->which_groups));
         }
         write_buf(buf, "\t\t\tgroups= 0x%02x;\n",
                   led->groups);
@@ -266,7 +266,7 @@ write_indicator_map(struct xkb_keymap *keymap, struct buf *buf,
     if (led->which_mods) {
         if (led->which_mods != XKB_STATE_MODS_EFFECTIVE) {
             write_buf(buf, "\t\t\twhichModState= %s;\n",
-                      IndicatorStateText(keymap->ctx, led->which_mods));
+                      LedStateText(keymap->ctx, led->which_mods));
         }
         write_buf(buf, "\t\t\tmodifiers= %s;\n",
                   ModMaskText(keymap, led->mods.mods));
@@ -425,7 +425,7 @@ static bool
 write_compat(struct xkb_keymap *keymap, struct buf *buf)
 {
     struct xkb_sym_interpret *interp;
-    const struct xkb_indicator_map *led;
+    const struct xkb_led *led;
 
     if (keymap->compat_section_name)
         write_buf(buf, "\txkb_compatibility \"%s\" {\n\n",
@@ -464,10 +464,10 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf)
         write_buf(buf, "\t\t};\n");
     }
 
-    darray_foreach(led, keymap->indicators)
+    darray_foreach(led, keymap->leds)
         if (led->which_groups || led->groups || led->which_mods ||
             led->mods.mods || led->ctrls)
-            write_indicator_map(keymap, buf, led);
+            write_led_map(keymap, buf, led);
 
     write_buf(buf, "\t};\n\n");
 
index 87694cf..e5bc2e6 100644 (file)
@@ -110,7 +110,7 @@ xkb_keymap_unref(struct xkb_keymap *keymap)
     darray_free(keymap->key_aliases);
     free(keymap->group_names);
     darray_free(keymap->mods);
-    darray_free(keymap->indicators);
+    darray_free(keymap->leds);
     free(keymap->keycodes_section_name);
     free(keymap->symbols_section_name);
     free(keymap->types_section_name);
@@ -242,7 +242,7 @@ xkb_keymap_num_levels_for_key(struct xkb_keymap *keymap, xkb_keycode_t kc,
 XKB_EXPORT xkb_led_index_t
 xkb_keymap_num_leds(struct xkb_keymap *keymap)
 {
-    return darray_size(keymap->indicators);
+    return darray_size(keymap->leds);
 }
 
 /**
@@ -251,11 +251,10 @@ xkb_keymap_num_leds(struct xkb_keymap *keymap)
 XKB_EXPORT const char *
 xkb_keymap_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx)
 {
-    if (idx >= darray_size(keymap->indicators))
+    if (idx >= darray_size(keymap->leds))
         return NULL;
 
-    return xkb_atom_text(keymap->ctx,
-                         darray_item(keymap->indicators, idx).name);
+    return xkb_atom_text(keymap->ctx, darray_item(keymap->leds, idx).name);
 }
 
 /**
@@ -266,12 +265,12 @@ xkb_keymap_led_get_index(struct xkb_keymap *keymap, const char *name)
 {
     xkb_atom_t atom = xkb_atom_lookup(keymap->ctx, name);
     xkb_led_index_t i;
-    const struct xkb_indicator_map *led;
+    const struct xkb_led *led;
 
     if (atom == XKB_ATOM_NONE)
         return XKB_LED_INVALID;
 
-    darray_enumerate(i, led, keymap->indicators)
+    darray_enumerate(i, led, keymap->leds)
         if (led->name == atom)
             return i;
 
index cb035b0..1744b41 100644 (file)
@@ -281,7 +281,7 @@ struct xkb_sym_interpret {
     bool repeat;
 };
 
-struct xkb_indicator_map {
+struct xkb_led {
     xkb_atom_t name;
     enum xkb_state_component which_groups;
     xkb_layout_mask_t groups;
@@ -395,7 +395,7 @@ struct xkb_keymap {
     xkb_layout_index_t num_group_names;
     xkb_atom_t *group_names;
 
-    darray(struct xkb_indicator_map) indicators;
+    darray(struct xkb_led) leds;
 
     char *keycodes_section_name;
     char *symbols_section_name;
index cf5d1e8..30538b8 100644 (file)
@@ -614,39 +614,39 @@ xkb_state_get_keymap(struct xkb_state *state)
 static void
 xkb_state_led_update_all(struct xkb_state *state)
 {
-    xkb_led_index_t led;
-    const struct xkb_indicator_map *map;
+    xkb_led_index_t idx;
+    const struct xkb_led *led;
 
     state->components.leds = 0;
 
-    darray_enumerate(led, map, state->keymap->indicators) {
+    darray_enumerate(idx, led, state->keymap->leds) {
         xkb_mod_mask_t mod_mask = 0;
         xkb_layout_mask_t group_mask = 0;
 
-        if (map->which_mods & XKB_STATE_MODS_EFFECTIVE)
+        if (led->which_mods & XKB_STATE_MODS_EFFECTIVE)
             mod_mask |= state->components.mods;
-        if (map->which_mods & XKB_STATE_MODS_DEPRESSED)
+        if (led->which_mods & XKB_STATE_MODS_DEPRESSED)
             mod_mask |= state->components.base_mods;
-        if (map->which_mods & XKB_STATE_MODS_LATCHED)
+        if (led->which_mods & XKB_STATE_MODS_LATCHED)
             mod_mask |= state->components.latched_mods;
-        if (map->which_mods & XKB_STATE_MODS_LOCKED)
+        if (led->which_mods & XKB_STATE_MODS_LOCKED)
             mod_mask |= state->components.locked_mods;
-        if (map->mods.mask & mod_mask)
-            state->components.leds |= (1 << led);
+        if (led->mods.mask & mod_mask)
+            state->components.leds |= (1 << idx);
 
-        if (map->which_groups & XKB_STATE_LAYOUT_EFFECTIVE)
+        if (led->which_groups & XKB_STATE_LAYOUT_EFFECTIVE)
             group_mask |= (1 << state->components.group);
-        if (map->which_groups & XKB_STATE_LAYOUT_DEPRESSED)
+        if (led->which_groups & XKB_STATE_LAYOUT_DEPRESSED)
             group_mask |= (1 << state->components.base_group);
-        if (map->which_groups & XKB_STATE_LAYOUT_LATCHED)
+        if (led->which_groups & XKB_STATE_LAYOUT_LATCHED)
             group_mask |= (1 << state->components.latched_group);
-        if (map->which_groups & XKB_STATE_LAYOUT_LOCKED)
+        if (led->which_groups & XKB_STATE_LAYOUT_LOCKED)
             group_mask |= (1 << state->components.locked_group);
-        if (map->groups & group_mask)
-            state->components.leds |= (1 << led);
+        if (led->groups & group_mask)
+            state->components.leds |= (1 << idx);
 
-        if (map->ctrls & state->keymap->enabled_ctrls)
-            state->components.leds |= (1 << led);
+        if (led->ctrls & state->keymap->enabled_ctrls)
+            state->components.leds |= (1 << idx);
     }
 }
 
@@ -1059,8 +1059,8 @@ xkb_state_layout_name_is_active(struct xkb_state *state, const char *name,
 XKB_EXPORT int
 xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
 {
-    if (idx >= darray_size(state->keymap->indicators) ||
-        darray_item(state->keymap->indicators, idx).name == XKB_ATOM_NONE)
+    if (idx >= darray_size(state->keymap->leds) ||
+        darray_item(state->keymap->leds, idx).name == XKB_ATOM_NONE)
         return -1;
 
     return !!(state->components.leds & (1 << idx));
index 8edc0e3..57f065f 100644 (file)
@@ -318,7 +318,7 @@ SIMatchText(enum xkb_match_operation type)
 } while (0)
 
 const char *
-IndicatorStateText(struct xkb_context *ctx, enum xkb_state_component mask)
+LedStateText(struct xkb_context *ctx, enum xkb_state_component mask)
 {
     unsigned int i;
     char *ret;
index 74b6a96..98945fb 100644 (file)
@@ -70,7 +70,7 @@ const char *
 SIMatchText(enum xkb_match_operation type);
 
 const char *
-IndicatorStateText(struct xkb_context *ctx, enum xkb_state_component mask);
+LedStateText(struct xkb_context *ctx, enum xkb_state_component mask);
 
 const char *
 ControlMaskText(struct xkb_context *ctx, enum xkb_action_controls mask);
index ad249ad..a650b05 100644 (file)
@@ -273,14 +273,14 @@ ModMapCreate(uint32_t modifier, ExprDef * keys)
     return def;
 }
 
-IndicatorMapDef *
-IndicatorMapCreate(xkb_atom_t name, VarDef * body)
+LedMapDef *
+LedMapCreate(xkb_atom_t name, VarDef * body)
 {
-    IndicatorMapDef *def;
+    LedMapDef *def;
 
     def = malloc_or_die(sizeof(*def));
 
-    def->common.type = STMT_INDICATOR_MAP;
+    def->common.type = STMT_LED_MAP;
     def->common.next = NULL;
     def->merge = MERGE_DEFAULT;
     def->name = name;
@@ -288,14 +288,14 @@ IndicatorMapCreate(xkb_atom_t name, VarDef * body)
     return def;
 }
 
-IndicatorNameDef *
-IndicatorNameCreate(int ndx, ExprDef * name, bool virtual)
+LedNameDef *
+LedNameCreate(int ndx, ExprDef * name, bool virtual)
 {
-    IndicatorNameDef *def;
+    LedNameDef *def;
 
     def = malloc_or_die(sizeof(*def));
 
-    def->common.type = STMT_INDICATOR_NAME;
+    def->common.type = STMT_LED_NAME;
     def->common.next = NULL;
     def->merge = MERGE_DEFAULT;
     def->ndx = ndx;
@@ -639,10 +639,10 @@ FreeStmt(ParseCommon *stmt)
         case STMT_GROUP_COMPAT:
             FreeStmt(&u.groupCompat->def->common);
             break;
-        case STMT_INDICATOR_MAP:
+        case STMT_LED_MAP:
             FreeStmt(&u.ledMap->body->common);
             break;
-        case STMT_INDICATOR_NAME:
+        case STMT_LED_NAME:
             FreeStmt(&u.ledName->name->common);
             break;
         default:
@@ -717,8 +717,8 @@ static const char *stmt_type_strings[_STMT_NUM_VALUES] = {
     [STMT_SYMBOLS] = "key symbols definition",
     [STMT_MODMAP] = "modifier map declaration",
     [STMT_GROUP_COMPAT] = "group declaration",
-    [STMT_INDICATOR_MAP] = "indicator map declaration",
-    [STMT_INDICATOR_NAME] = "indicator name declaration",
+    [STMT_LED_MAP] = "indicator map declaration",
+    [STMT_LED_NAME] = "indicator name declaration",
 };
 
 const char *
index b600389..0ecd124 100644 (file)
@@ -70,11 +70,11 @@ GroupCompatCreate(int group, ExprDef *def);
 ModMapDef *
 ModMapCreate(uint32_t modifier, ExprDef *keys);
 
-IndicatorMapDef *
-IndicatorMapCreate(xkb_atom_t name, VarDef *body);
+LedMapDef *
+LedMapCreate(xkb_atom_t name, VarDef *body);
 
-IndicatorNameDef *
-IndicatorNameCreate(int ndx, ExprDef *name, bool virtual);
+LedNameDef *
+LedNameCreate(int ndx, ExprDef *name, bool virtual);
 
 ExprDef *
 ActionCreate(xkb_atom_t name, ExprDef *args);
index 1e267ed..c9b801f 100644 (file)
@@ -85,8 +85,8 @@ enum stmt_type {
     STMT_SYMBOLS,
     STMT_MODMAP,
     STMT_GROUP_COMPAT,
-    STMT_INDICATOR_MAP,
-    STMT_INDICATOR_NAME,
+    STMT_LED_MAP,
+    STMT_LED_NAME,
 
     _STMT_NUM_VALUES
 };
@@ -263,14 +263,14 @@ typedef struct {
     int ndx;
     ExprDef *name;
     bool virtual;
-} IndicatorNameDef;
+} LedNameDef;
 
 typedef struct {
     ParseCommon common;
     enum merge_mode merge;
     xkb_atom_t name;
     VarDef *body;
-} IndicatorMapDef;
+} LedMapDef;
 
 enum xkb_map_flags {
     MAP_IS_DEFAULT = (1 << 0),
index ddd7583..30a9377 100644 (file)
  *
  *   Set whether the key should repeat or not. Must be a boolean value.
  *
- * Indicator map statements
+ * Led map statements
  * ------------------------
  * Statements of the form:
  *      indicator "Shift Lock" { ... }
  *
- *   This statement specifies the behavior and binding of the indicator
- *   with the given name ("Shift Lock" above). The name should have been
- *   declared previously in the xkb_keycodes section (see Indicator name
- *   statement), and given an index there. If it wasn't, it is created
+ *   This statement specifies the behavior and binding of the LED (a.k.a
+ *   indicator) with the given name ("Shift Lock" above). The name should
+ *   have been declared previously in the xkb_keycodes section (see Led
+ *   name statement), and given an index there. If it wasn't, it is created
  *   with the next free index.
  *   The body of the statement describes the conditions of the keyboard
- *   state which will cause the indicator to be lit. It may include the
- *   following statements:
+ *   state which will cause the LED to be lit. It may include the following
+ *   statements:
  *
  * - modifiers statment:
  *      modifiers = ScrollLock;
  *          modifiers = NumLock;
  *          whichModState = Locked;
  *      };
- *   Whenever the NumLock modifier is locked, the Num Lock indicator
- *   will light up.
+ *   Whenever the NumLock modifier is locked, the Num Lock LED will light
+ *   up.
  *
  * - groups statment:
  *      groups = All - group1;
  * After all of the xkb_compat sections have been compiled, the following
  * members of struct xkb_keymap are finalized:
  *      darray(struct xkb_sym_interpret) sym_interprets;
- *      darray(struct xkb_indicator_map) indicators;
+ *      darray(struct xkb_led) leds;
  *      char *compat_section_name;
  * TODO: virtual modifiers.
  */
@@ -253,8 +253,8 @@ typedef struct {
     unsigned file_id;
     enum merge_mode merge;
 
-    struct xkb_indicator_map im;
-} LEDInfo;
+    struct xkb_led led;
+} LedInfo;
 
 typedef struct {
     char *name;
@@ -262,8 +262,8 @@ typedef struct {
     int errorCount;
     SymInterpInfo dflt;
     darray(SymInterpInfo) interps;
-    LEDInfo ledDflt;
-    darray(LEDInfo) leds;
+    LedInfo ledDflt;
+    darray(LedInfo) leds;
     ActionsInfo *actions;
     struct xkb_keymap *keymap;
 } CompatInfo;
@@ -300,20 +300,19 @@ ReportSIBadType(CompatInfo *info, SymInterpInfo *si, const char *field,
 }
 
 static inline bool
-ReportIndicatorBadType(CompatInfo *info, LEDInfo *led,
-                       const char *field, const char *wanted)
+ReportLedBadType(CompatInfo *info, LedInfo *ledi, const char *field,
+                 const char *wanted)
 {
     return ReportBadType(info->keymap->ctx, "indicator map", field,
-                         xkb_atom_text(info->keymap->ctx, led->im.name),
+                         xkb_atom_text(info->keymap->ctx, ledi->led.name),
                          wanted);
 }
 
 static inline bool
-ReportIndicatorNotArray(CompatInfo *info, LEDInfo *led,
-                        const char *field)
+ReportLedNotArray(CompatInfo *info, LedInfo *ledi, const char *field)
 {
     return ReportNotArray(info->keymap, "indicator map", field,
-                          xkb_atom_text(info->keymap->ctx, led->im.name));
+                          xkb_atom_text(info->keymap->ctx, ledi->led.name));
 }
 
 static void
@@ -469,7 +468,7 @@ ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,
 /***====================================================================***/
 
 static bool
-UseNewLEDField(enum led_field field, LEDInfo *old, LEDInfo *new,
+UseNewLEDField(enum led_field field, LedInfo *old, LedInfo *new,
                bool report, enum led_field *collide)
 {
     if (!(old->defined & field))
@@ -487,9 +486,9 @@ UseNewLEDField(enum led_field field, LEDInfo *old, LEDInfo *new,
 }
 
 static bool
-AddIndicatorMap(CompatInfo *info, LEDInfo *new)
+AddLedMap(CompatInfo *info, LedInfo *new)
 {
-    LEDInfo *old;
+    LedInfo *old;
     enum led_field collide;
     struct xkb_context *ctx = info->keymap->ctx;
     int verbosity = xkb_context_get_log_verbosity(ctx);
@@ -497,14 +496,14 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
     darray_foreach(old, info->leds) {
         bool report;
 
-        if (old->im.name != new->im.name)
+        if (old->led.name != new->led.name)
             continue;
 
-        if (old->im.mods.mods == new->im.mods.mods &&
-            old->im.groups == new->im.groups &&
-            old->im.ctrls == new->im.ctrls &&
-            old->im.which_mods == new->im.which_mods &&
-            old->im.which_groups == new->im.which_groups) {
+        if (old->led.mods.mods == new->led.mods.mods &&
+            old->led.groups == new->led.groups &&
+            old->led.ctrls == new->led.ctrls &&
+            old->led.which_mods == new->led.which_mods &&
+            old->led.which_groups == new->led.which_groups) {
             old->defined |= new->defined;
             return true;
         }
@@ -517,24 +516,24 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
                 log_warn(info->keymap->ctx,
                          "Map for indicator %s redefined; "
                          "Earlier definition ignored\n",
-                         xkb_atom_text(ctx, old->im.name));
+                         xkb_atom_text(ctx, old->led.name));
             *old = *new;
             return true;
         }
 
         collide = 0;
         if (UseNewLEDField(LED_FIELD_MODS, old, new, report, &collide)) {
-            old->im.which_mods = new->im.which_mods;
-            old->im.mods = new->im.mods;
+            old->led.which_mods = new->led.which_mods;
+            old->led.mods = new->led.mods;
             old->defined |= LED_FIELD_MODS;
         }
         if (UseNewLEDField(LED_FIELD_GROUPS, old, new, report, &collide)) {
-            old->im.which_groups = new->im.which_groups;
-            old->im.groups = new->im.groups;
+            old->led.which_groups = new->led.which_groups;
+            old->led.groups = new->led.groups;
             old->defined |= LED_FIELD_GROUPS;
         }
         if (UseNewLEDField(LED_FIELD_CTRLS, old, new, report, &collide)) {
-            old->im.ctrls = new->im.ctrls;
+            old->led.ctrls = new->led.ctrls;
             old->defined |= LED_FIELD_CTRLS;
         }
 
@@ -542,7 +541,7 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
             log_warn(info->keymap->ctx,
                      "Map for indicator %s redefined; "
                      "Using %s definition for duplicate fields\n",
-                     xkb_atom_text(ctx, old->im.name),
+                     xkb_atom_text(ctx, old->led.name),
                      (new->merge == MERGE_AUGMENT ? "first" : "last"));
         }
 
@@ -558,7 +557,7 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
                         enum merge_mode merge)
 {
     SymInterpInfo *si;
-    LEDInfo *led;
+    LedInfo *ledi;
 
     if (from->errorCount > 0) {
         into->errorCount += from->errorCount;
@@ -576,9 +575,9 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
             into->errorCount++;
     }
 
-    darray_foreach(led, from->leds) {
-        led->merge = (merge == MERGE_DEFAULT ? led->merge : merge);
-        if (!AddIndicatorMap(into, led))
+    darray_foreach(ledi, from->leds) {
+        ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge);
+        if (!AddLedMap(into, ledi))
             into->errorCount++;
     }
 }
@@ -697,45 +696,44 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
 }
 
 static bool
-SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
-                     const char *field, ExprDef *arrayNdx, ExprDef *value)
+SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field,
+               ExprDef *arrayNdx, ExprDef *value)
 {
     bool ok = true;
     struct xkb_keymap *keymap = info->keymap;
 
     if (istreq(field, "modifiers") || istreq(field, "mods")) {
         if (arrayNdx)
-            return ReportIndicatorNotArray(info, led, field);
+            return ReportLedNotArray(info, ledi, field);
 
-        if (!ExprResolveModMask(keymap, value, MOD_BOTH, &led->im.mods.mods))
-            return ReportIndicatorBadType(info, led, field, "modifier mask");
+        if (!ExprResolveModMask(keymap, value, MOD_BOTH, &ledi->led.mods.mods))
+            return ReportLedBadType(info, ledi, field, "modifier mask");
 
-        led->defined |= LED_FIELD_MODS;
+        ledi->defined |= LED_FIELD_MODS;
     }
     else if (istreq(field, "groups")) {
         unsigned int mask;
 
         if (arrayNdx)
-            return ReportIndicatorNotArray(info, led, field);
+            return ReportLedNotArray(info, ledi, field);
 
         if (!ExprResolveMask(keymap->ctx, value, &mask, groupMaskNames))
-            return ReportIndicatorBadType(info, led, field, "group mask");
+            return ReportLedBadType(info, ledi, field, "group mask");
 
-        led->im.groups = mask;
-        led->defined |= LED_FIELD_GROUPS;
+        ledi->led.groups = mask;
+        ledi->defined |= LED_FIELD_GROUPS;
     }
     else if (istreq(field, "controls") || istreq(field, "ctrls")) {
         unsigned int mask;
 
         if (arrayNdx)
-            return ReportIndicatorNotArray(info, led, field);
+            return ReportLedNotArray(info, ledi, field);
 
         if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
-            return ReportIndicatorBadType(info, led, field,
-                                          "controls mask");
+            return ReportLedBadType(info, ledi, field, "controls mask");
 
-        led->im.ctrls = mask;
-        led->defined |= LED_FIELD_CTRLS;
+        ledi->led.ctrls = mask;
+        ledi->defined |= LED_FIELD_CTRLS;
     }
     else if (istreq(field, "allowexplicit")) {
         log_dbg(info->keymap->ctx,
@@ -747,27 +745,27 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
         unsigned int mask;
 
         if (arrayNdx)
-            return ReportIndicatorNotArray(info, led, field);
+            return ReportLedNotArray(info, ledi, field);
 
         if (!ExprResolveMask(keymap->ctx, value, &mask,
                              modComponentMaskNames))
-            return ReportIndicatorBadType(info, led, field,
-                                          "mask of modifier state components");
+            return ReportLedBadType(info, ledi, field,
+                                    "mask of modifier state components");
 
-        led->im.which_mods = mask;
+        ledi->led.which_mods = mask;
     }
     else if (istreq(field, "whichgroupstate")) {
         unsigned mask;
 
         if (arrayNdx)
-            return ReportIndicatorNotArray(info, led, field);
+            return ReportLedNotArray(info, ledi, field);
 
         if (!ExprResolveMask(keymap->ctx, value, &mask,
                              groupComponentMaskNames))
-            return ReportIndicatorBadType(info, led, field,
-                                          "mask of group state components");
+            return ReportLedBadType(info, ledi, field,
+                                    "mask of group state components");
 
-        led->im.which_groups = mask;
+        ledi->led.which_groups = mask;
     }
     else if (istreq(field, "driveskbd") ||
              istreq(field, "driveskeyboard") ||
@@ -789,7 +787,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
         log_err(info->keymap->ctx,
                 "Unknown field %s in map for %s indicator; "
                 "Definition ignored\n",
-                field, xkb_atom_text(keymap->ctx, led->im.name));
+                field, xkb_atom_text(keymap->ctx, ledi->led.name));
         ok = false;
     }
 
@@ -808,8 +806,7 @@ HandleGlobalVar(CompatInfo *info, VarDef *stmt)
     else if (elem && istreq(elem, "interpret"))
         ret = SetInterpField(info, &info->dflt, field, ndx, stmt->value);
     else if (elem && istreq(elem, "indicator"))
-        ret = SetIndicatorMapField(info, &info->ledDflt, field, ndx,
-                                   stmt->value);
+        ret = SetLedMapField(info, &info->ledDflt, field, ndx, stmt->value);
     else
         ret = SetActionField(info->keymap, elem, field, ndx, stmt->value,
                              info->actions);
@@ -885,19 +882,18 @@ HandleInterpDef(CompatInfo *info, InterpDef *def, enum merge_mode merge)
 }
 
 static bool
-HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def,
-                      enum merge_mode merge)
+HandleLedMapDef(CompatInfo *info, LedMapDef *def, enum merge_mode merge)
 {
-    LEDInfo led;
+    LedInfo ledi;
     VarDef *var;
     bool ok;
 
     if (def->merge != MERGE_DEFAULT)
         merge = def->merge;
 
-    led = info->ledDflt;
-    led.merge = merge;
-    led.im.name = def->name;
+    ledi = info->ledDflt;
+    ledi.merge = merge;
+    ledi.led.name = def->name;
 
     ok = true;
     for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
@@ -916,13 +912,12 @@ HandleIndicatorMapDef(CompatInfo *info, IndicatorMapDef *def,
             ok = false;
         }
         else {
-            ok = SetIndicatorMapField(info, &led, field, arrayNdx,
-                                      var->value) && ok;
+            ok = SetLedMapField(info, &ledi, field, arrayNdx, var->value) && ok;
         }
     }
 
     if (ok)
-        return AddIndicatorMap(info, &led);
+        return AddLedMap(info, &ledi);
 
     return false;
 }
@@ -952,8 +947,8 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
                     "Ignored\n");
             ok = true;
             break;
-        case STMT_INDICATOR_MAP:
-            ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge);
+        case STMT_LED_MAP:
+            ok = HandleLedMapDef(info, (LedMapDef *) stmt, merge);
             break;
         case STMT_VAR:
             ok = HandleGlobalVar(info, (VarDef *) stmt);
@@ -992,54 +987,54 @@ CopyInterps(CompatInfo *info, bool needSymbol, enum xkb_match_operation pred)
 }
 
 static void
-CopyIndicatorMapDefs(CompatInfo *info)
+CopyLedMapDefs(CompatInfo *info)
 {
-    LEDInfo *led;
+    LedInfo *ledi;
     xkb_led_index_t i;
-    struct xkb_indicator_map *im;
+    struct xkb_led *led;
     struct xkb_keymap *keymap = info->keymap;
 
-    darray_foreach(led, info->leds) {
+    darray_foreach(ledi, info->leds) {
         /*
-         * Find the indicator with the given name, if it was already
-         * declared in keycodes.
+         * Find the LED with the given name, if it was already declared
+         * in keycodes.
          */
-        darray_enumerate(i, im, keymap->indicators)
-            if (im->name == led->im.name)
+        darray_enumerate(i, led, keymap->leds)
+            if (led->name == ledi->led.name)
                 break;
 
         /* Not previously declared; create it with next free index. */
-        if (i >= darray_size(keymap->indicators)) {
+        if (i >= darray_size(keymap->leds)) {
             log_dbg(keymap->ctx,
                     "Indicator name \"%s\" was not declared in the keycodes section; "
                     "Adding new indicator\n",
-                    xkb_atom_text(keymap->ctx, led->im.name));
+                    xkb_atom_text(keymap->ctx, ledi->led.name));
 
-            darray_enumerate(i, im, keymap->indicators)
-                if (im->name == XKB_ATOM_NONE)
+            darray_enumerate(i, led, keymap->leds)
+                if (led->name == XKB_ATOM_NONE)
                     break;
 
-            if (i >= darray_size(keymap->indicators)) {
+            if (i >= darray_size(keymap->leds)) {
                 /* Not place to put it; ignore. */
                 if (i >= XKB_MAX_LEDS) {
                     log_err(keymap->ctx,
                             "Too many indicators (maximum is %d); "
                             "Indicator name \"%s\" ignored\n",
                             XKB_MAX_LEDS,
-                            xkb_atom_text(keymap->ctx, led->im.name));
+                            xkb_atom_text(keymap->ctx, ledi->led.name));
                     continue;
                 }
-                /* Add a new indicator. */
-                darray_resize(keymap->indicators, i + 1);
-                im = &darray_item(keymap->indicators, i);
+                /* Add a new LED. */
+                darray_resize(keymap->leds, i + 1);
+                led = &darray_item(keymap->leds, i);
             }
         }
 
-        *im = led->im;
-        if (im->groups != 0 && im->which_groups == 0)
-            im->which_groups = XKB_STATE_LAYOUT_EFFECTIVE;
-        if (im->mods.mods != 0 && im->which_mods == 0)
-            im->which_mods = XKB_STATE_MODS_EFFECTIVE;
+        *led = ledi->led;
+        if (led->groups != 0 && led->which_groups == 0)
+            led->which_groups = XKB_STATE_LAYOUT_EFFECTIVE;
+        if (led->mods.mods != 0 && led->which_mods == 0)
+            led->which_mods = XKB_STATE_MODS_EFFECTIVE;
     }
 }
 
@@ -1062,7 +1057,7 @@ CopyCompatToKeymap(struct xkb_keymap *keymap, CompatInfo *info)
         CopyInterps(info, false, MATCH_ANY_OR_NONE);
     }
 
-    CopyIndicatorMapDefs(info);
+    CopyLedMapDefs(info);
 
     return true;
 }
index c05f799..6b1d686 100644 (file)
  * Allows to refer to a previously defined key (here <COMP>) by another
  * name (here <MENU>). Conflicts are handled similarly.
  *
- * Indicator name statements
+ * LED name statements
  * -------------------------
  * Statements of the form:
  *      indicator 1 = "Caps Lock";
  *      indicator 2 = "Num Lock";
  *      indicator 3 = "Scroll Lock";
  *
- * Assigns a name the indicator (i.e. keyboard LED) with the given index.
- * The amount of possible indicators is predetermined (XKB_NUM_INDICATORS).
- * The indicator may be referred by this name later in the compat section
+ * Assigns a name to the keyboard LED (a.k.a indicator) with the given index.
+ * The led may be referred by this name later in the compat section
  * and by the user.
  *
  * Effect on the keymap
@@ -94,8 +93,8 @@
  *      xkb_keycode_t max_key_code;
  *      darray(struct xkb_key_alias) key_aliases;
  *      char *keycodes_section_name;
- * The 'name' field of indicators declared in xkb_keycodes:
- *      darray(struct xkb_indicator_map) indicators;
+ * The 'name' field of leds declared in xkb_keycodes:
+ *      darray(struct xkb_led) leds;
  * Further, the array of keys:
  *      struct xkb_key *keys;
  * had been resized to its final size (i.e. all of the xkb_key objects are
@@ -121,7 +120,7 @@ typedef struct {
     unsigned file_id;
 
     xkb_atom_t name;
-} IndicatorNameInfo;
+} LedNameInfo;
 
 typedef struct {
     char *name;     /* e.g. evdev+aliases(qwerty) */
@@ -132,7 +131,7 @@ typedef struct {
     xkb_keycode_t min_key_code;
     xkb_keycode_t max_key_code;
     darray(KeyNameInfo) key_names;
-    darray(IndicatorNameInfo) indicator_names;
+    darray(LedNameInfo) led_names;
     darray(AliasInfo) aliases;
 
     struct xkb_context *ctx;
@@ -149,17 +148,17 @@ InitAliasInfo(AliasInfo *info, enum merge_mode merge, unsigned file_id,
     info->real = real;
 }
 
-static IndicatorNameInfo *
-FindIndicatorByName(KeyNamesInfo *info, xkb_atom_t name,
-                    xkb_led_index_t *idx_out)
+static LedNameInfo *
+FindLedByName(KeyNamesInfo *info, xkb_atom_t name,
+              xkb_led_index_t *idx_out)
 {
-    IndicatorNameInfo *led;
+    LedNameInfo *ledi;
     xkb_led_index_t idx;
 
-    darray_enumerate(idx, led, info->indicator_names) {
-        if (led->name == name) {
+    darray_enumerate(idx, ledi, info->led_names) {
+        if (ledi->name == name) {
             *idx_out = idx;
-            return led;
+            return ledi;
         }
     }
 
@@ -167,21 +166,20 @@ FindIndicatorByName(KeyNamesInfo *info, xkb_atom_t name,
 }
 
 static bool
-AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
-                 IndicatorNameInfo *new, xkb_led_index_t new_idx)
+AddLedName(KeyNamesInfo *info, enum merge_mode merge,
+           LedNameInfo *new, xkb_led_index_t new_idx)
 {
     xkb_led_index_t old_idx;
-    IndicatorNameInfo *old;
-    bool replace;
+    LedNameInfo *old;
+    const bool replace = (merge == MERGE_REPLACE || merge == MERGE_OVERRIDE);
     int verbosity = xkb_context_get_log_verbosity(info->ctx);
 
-    replace = (merge == MERGE_REPLACE || merge == MERGE_OVERRIDE);
 
     /* Inidicator with the same name already exists. */
-    old = FindIndicatorByName(info, new->name, &old_idx);
+    old = FindLedByName(info, new->name, &old_idx);
     if (old) {
-        bool report = ((old->file_id == new->file_id && verbosity > 0) ||
-                       verbosity > 9);
+        const bool report = ((old->file_id == new->file_id && verbosity > 0) ||
+                             verbosity > 9);
 
         if (old_idx == new_idx) {
             log_warn(info->ctx,
@@ -205,11 +203,11 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
         return true;
     }
 
-    if (new_idx >= darray_size(info->indicator_names))
-        darray_resize0(info->indicator_names, new_idx + 1);
+    if (new_idx >= darray_size(info->led_names))
+        darray_resize0(info->led_names, new_idx + 1);
 
     /* Inidicator with the same index already exists. */
-    old = &darray_item(info->indicator_names, new_idx);
+    old = &darray_item(info->led_names, new_idx);
     if (old->name != XKB_ATOM_NONE) {
         bool report = ((old->file_id == new->file_id && verbosity > 0) ||
                        verbosity > 9);
@@ -217,8 +215,8 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
         /* Same name case already handled above. */
 
         if (report) {
-            xkb_atom_t use = (replace ? new->name : old->name);
-            xkb_atom_t ignore = (replace ? old->name : new->name);
+            const xkb_atom_t use = (replace ? new->name : old->name);
+            const xkb_atom_t ignore = (replace ? old->name : new->name);
             log_warn(info->ctx, "Multiple names for indicator %d; "
                      "Using %s, ignoring %s\n", new_idx + 1,
                      xkb_atom_text(info->ctx, use),
@@ -231,7 +229,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
         return true;
     }
 
-    darray_item(info->indicator_names, new_idx) = *new;
+    darray_item(info->led_names, new_idx) = *new;
     return true;
 }
 
@@ -241,7 +239,7 @@ ClearKeyNamesInfo(KeyNamesInfo *info)
     free(info->name);
     darray_free(info->key_names);
     darray_free(info->aliases);
-    darray_free(info->indicator_names);
+    darray_free(info->led_names);
 }
 
 static void
@@ -382,7 +380,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
 {
     xkb_keycode_t i;
     xkb_led_index_t idx;
-    IndicatorNameInfo *led;
+    LedNameInfo *ledi;
 
     if (from->errorCount > 0) {
         into->errorCount += from->errorCount;
@@ -406,12 +404,12 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
             into->errorCount++;
     }
 
-    darray_enumerate(idx, led, from->indicator_names) {
-        if (led->name == XKB_ATOM_NONE)
+    darray_enumerate(idx, ledi, from->led_names) {
+        if (ledi->name == XKB_ATOM_NONE)
             continue;
 
-        led->merge = (merge == MERGE_DEFAULT ? led->merge : merge);
-        if (!AddIndicatorName(into, led->merge, led, idx))
+        ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge);
+        if (!AddLedName(into, ledi->merge, ledi, idx))
             into->errorCount++;
     }
 
@@ -560,10 +558,10 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt)
 }
 
 static int
-HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def,
-                       enum merge_mode merge)
+HandleLedNameDef(KeyNamesInfo *info, LedNameDef *def,
+                 enum merge_mode merge)
 {
-    IndicatorNameInfo ii;
+    LedNameInfo ledi;
     xkb_atom_t name;
 
     if (def->ndx < 1 || def->ndx > XKB_MAX_LEDS) {
@@ -582,10 +580,10 @@ HandleIndicatorNameDef(KeyNamesInfo *info, IndicatorNameDef *def,
                              "string");
     }
 
-    ii.merge = info->merge;
-    ii.file_id = info->file_id;
-    ii.name = name;
-    return AddIndicatorName(info, merge, &ii, def->ndx - 1);
+    ledi.merge = info->merge;
+    ledi.file_id = info->file_id;
+    ledi.name = name;
+    return AddLedName(info, merge, &ledi, def->ndx - 1);
 }
 
 static void
@@ -612,9 +610,8 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge)
         case STMT_VAR:
             ok = HandleKeyNameVar(info, (VarDef *) stmt);
             break;
-        case STMT_INDICATOR_NAME:
-            ok = HandleIndicatorNameDef(info, (IndicatorNameDef *) stmt,
-                                        merge);
+        case STMT_LED_NAME:
+            ok = HandleLedNameDef(info, (LedNameDef *) stmt, merge);
             break;
         default:
             log_err(info->ctx,
@@ -694,7 +691,7 @@ CopyKeyNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
 {
     xkb_keycode_t kc;
     xkb_led_index_t idx;
-    IndicatorNameInfo *led;
+    LedNameInfo *ledi;
 
     keymap->keys = calloc(info->max_key_code + 1, sizeof(*keymap->keys));
     if (!keymap->keys)
@@ -710,12 +707,12 @@ CopyKeyNamesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
 
     keymap->keycodes_section_name = strdup_safe(info->name);
 
-    darray_resize0(keymap->indicators, darray_size(info->indicator_names));
-    darray_enumerate(idx, led, info->indicator_names) {
-        if (led->name == XKB_ATOM_NONE)
+    darray_resize0(keymap->leds, darray_size(info->led_names));
+    darray_enumerate(idx, ledi, info->led_names) {
+        if (ledi->name == XKB_ATOM_NONE)
             continue;
 
-        darray_item(keymap->indicators, idx).name = led->name;
+        darray_item(keymap->leds, idx).name = ledi->name;
     }
 
     ApplyAliases(info, keymap);
index a3503b8..1d69245 100644 (file)
@@ -180,7 +180,7 @@ static bool
 UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
 {
     struct xkb_mod *mod;
-    struct xkb_indicator_map *im;
+    struct xkb_led *led;
     unsigned int i, j;
     struct xkb_key *key;
 
@@ -213,9 +213,9 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap)
                 UpdateActionMods(keymap, &key->groups[i].levels[j].action,
                                  key->modmap);
 
-    /* Update vmod -> indicator maps. */
-    darray_foreach(im, keymap->indicators)
-        ComputeEffectiveMask(keymap, &im->mods);
+    /* Update vmod -> led maps. */
+    darray_foreach(led, keymap->leds)
+        ComputeEffectiveMask(keymap, &led->mods);
 
     /* Find maximum number of groups out of all keys in the keymap. */
     xkb_foreach_key(key, keymap)
index 5d10a4b..53b7ca6 100644 (file)
@@ -142,8 +142,8 @@ _xkbcommon_error(struct YYLTYPE *loc, struct parser_param *param, const char *ms
         SymbolsDef      *syms;
         ModMapDef       *modMask;
         GroupCompatDef  *groupCompat;
-        IndicatorMapDef *ledMap;
-        IndicatorNameDef *ledName;
+        LedMapDef       *ledMap;
+        LedNameDef      *ledName;
         KeycodeDef      *keyCode;
         KeyAliasDef     *keyAlias;
         void            *geom;
@@ -171,8 +171,8 @@ _xkbcommon_error(struct YYLTYPE *loc, struct parser_param *param, const char *ms
 %type <syms>    SymbolsDecl
 %type <modMask> ModMapDecl
 %type <groupCompat> GroupCompatDecl
-%type <ledMap>  IndicatorMapDecl
-%type <ledName> IndicatorNameDecl
+%type <ledMap>  LedMapDecl
+%type <ledName> LedNameDecl
 %type <keyCode> KeyNameDecl
 %type <keyAlias> KeyAliasDecl
 %type <geom>    ShapeDecl SectionDecl SectionBody SectionBodyItem RowBody RowBodyItem
@@ -315,12 +315,12 @@ Decl            :       OptMergeMode VarDecl
                             $2->merge = $1;
                             $$ = &$2->common;
                         }
-                |       OptMergeMode IndicatorMapDecl
+                |       OptMergeMode LedMapDecl
                         {
                             $2->merge = $1;
                             $$ = &$2->common;
                         }
-                |       OptMergeMode IndicatorNameDecl
+                |       OptMergeMode LedNameDecl
                         {
                             $2->merge = $1;
                             $$ = &$2->common;
@@ -425,14 +425,14 @@ ModMapDecl      :       MODIFIER_MAP Ident OBRACE ExprList CBRACE SEMI
                         { $$ = ModMapCreate($2, $4); }
                 ;
 
-IndicatorMapDecl:       INDICATOR String OBRACE VarDeclList CBRACE SEMI
-                        { $$ = IndicatorMapCreate($2, $4); }
+LedMapDecl:             INDICATOR String OBRACE VarDeclList CBRACE SEMI
+                        { $$ = LedMapCreate($2, $4); }
                 ;
 
-IndicatorNameDecl:      INDICATOR Integer EQUALS Expr SEMI
-                        { $$ = IndicatorNameCreate($2, $4, false); }
+LedNameDecl:            INDICATOR Integer EQUALS Expr SEMI
+                        { $$ = LedNameCreate($2, $4, false); }
                 |       VIRTUAL INDICATOR Integer EQUALS Expr SEMI
-                        { $$ = IndicatorNameCreate($3, $5, true); }
+                        { $$ = LedNameCreate($3, $5, true); }
                 ;
 
 ShapeDecl       :       SHAPE String OBRACE OutlineList CBRACE SEMI
@@ -455,7 +455,7 @@ SectionBodyItem :       ROW OBRACE RowBody CBRACE SEMI
                         { FreeStmt(&$1->common); $$ = NULL; }
                 |       DoodadDecl
                         { $$ = NULL; }
-                |       IndicatorMapDecl
+                |       LedMapDecl
                         { FreeStmt(&$1->common); $$ = NULL; }
                 |       OverlayDecl
                         { $$ = NULL; }