Esempio n. 1
0
static int
putKeyName (ListGenerationData *lgd, const KeyValue *value) {
  const KeyNameEntry *kne = findKeyNameEntry(lgd, value);
  if (kne) return putUtf8String(lgd, kne->name);

  if (value->key != KTB_KEY_ANY) {
    const KeyValue anyKey = {
      .set = value->set,
      .key = KTB_KEY_ANY
    };

    if ((kne = findKeyNameEntry(lgd, &anyKey))) {
      if (!putUtf8String(lgd, kne->name)) return 0;
      if (!putCharacter(lgd, WC_C('.'))) return 0;
      if (!putNumber(lgd, value->key+1)) return 0;
      return 1;
    }
  }

  return putUtf8String(lgd, "?");
}

static int
putKeyCombination (ListGenerationData *lgd, const KeyCombination *combination) {
  wchar_t delimiter = 0;

  {
    unsigned char index;
    for (index=0; index<combination->modifierCount; index+=1) {
      if (!delimiter) {
        delimiter = WC_C('+');
      } else if (!putCharacter(lgd, delimiter)) {
        return 0;
      }

      if (!putKeyName(lgd, &combination->modifierKeys[combination->modifierPositions[index]])) return 0;
    }
  }

  if (combination->flags & KCF_IMMEDIATE_KEY) {
    if (delimiter)
      if (!putCharacter(lgd, delimiter))
        return 0;

    if (!putKeyName(lgd, &combination->immediateKey)) return 0;
  }

  return 1;
}
Esempio n. 2
0
static int
putNumber (ListGenerationData *lgd, int number) {
  char buffer[0X10];

  snprintf(buffer, sizeof(buffer), "%d", number);
  return putUtf8String(lgd, buffer);
}
Esempio n. 3
0
size_t
formatKeyName (KeyTable *table, char *buffer, size_t size, const KeyValue *value) {
  const KeyNameEntry *kne = findKeyNameEntry(table, value);

  size_t length;
  STR_BEGIN(buffer, size);

  if (kne) {
    STR_PRINTF("%s", kne->name);
  } else if (value->number != KTB_KEY_ANY) {
    const KeyValue anyKey = {
      .group = value->group,
      .number = KTB_KEY_ANY
    };

    if ((kne = findKeyNameEntry(table, &anyKey))) {
      STR_PRINTF("%s.%u", kne->name, value->number+1);
    }
  }

  if (STR_LENGTH == 0) STR_PRINTF("?");
  length = STR_LENGTH;
  STR_END;
  return length;
}

static int
putKeyName (ListGenerationData *lgd, const KeyValue *value) {
  char name[0X100];

  formatKeyName(lgd->keyTable, name, sizeof(name), value);
  return putUtf8String(lgd, name);
}
Esempio n. 4
0
static int
putCommandDescription (ListGenerationData *lgd, int command, int details) {
  char description[0X60];

  describeCommand(command, description, sizeof(description),
                  details? (CDO_IncludeOperand | CDO_DefaultOperand): 0);
  return putUtf8String(lgd, description);
}
Esempio n. 5
0
static int
doListKeyTable (ListGenerationData *lgd) {
  if (!putUtf8String(lgd, gettext("Key Table"))) return 0;
  if (lgd->keyTable->title) {
    if (!putCharacterString(lgd, WS_C(": "))) return 0;
    if (!putCharacterString(lgd, lgd->keyTable->title)) return 0;
    if (!endLine(lgd)) return 0;
  }

  if (lgd->keyTable->noteCount) {
    unsigned int noteIndex;

    if (!endLine(lgd)) return 0;

    for (noteIndex=0; noteIndex<lgd->keyTable->noteCount; noteIndex+=1) {
      if (!putCharacterString(lgd, lgd->keyTable->noteTable[noteIndex])) return 0;
      if (!endLine(lgd)) return 0;
    }
  }

  {
    static const unsigned char contexts[] = {
      KTB_CTX_DEFAULT,
      KTB_CTX_MENU
    };

    const unsigned char *context = contexts;
    unsigned int count = ARRAY_COUNT(contexts);

    while (count) {
      const KeyContext *ctx = getKeyContext(lgd->keyTable, *context);

      if (ctx) {
        lgd->sectionTitle = ctx->title;
        if (!listKeyContext(lgd, ctx, NULL)) return 0;
      }

      context += 1, count -= 1;
    }
  }

  {
    unsigned int context;

    for (context=KTB_CTX_DEFAULT+1; context<lgd->keyTable->keyContextCount; context+=1) {
      const KeyContext *ctx = getKeyContext(lgd->keyTable, context);

      if (ctx && !isTemporaryKeyContext(lgd->keyTable, ctx)) {
        lgd->sectionTitle = ctx->title;
        if (!listKeyContext(lgd, ctx, NULL)) return 0;
      }
    }
  }

  return 1;
}
Esempio n. 6
0
static int
listHotkeyEvent (ListGenerationData *lgd, const KeyValue *keyValue, const char *event, int command) {
  if (command != BRL_CMD_NOOP) {
    if ((command & BRL_MSK_BLK) == BRL_BLK_CONTEXT) {
      const KeyContext *c = getKeyContext(lgd->keyTable, (KTB_CTX_DEFAULT + (command & BRL_MSK_ARG)));
      if (!c) return 0;
      if (!putUtf8String(lgd, "switch to ")) return 0;
      if (!putCharacterString(lgd, c->title)) return 0;
    } else {
      if (!putCommandDescription(lgd, command, (keyValue->key != KTB_KEY_ANY))) return 0;
    }

    if (!putCharacterString(lgd, WS_C(": "))) return 0;
    if (!putUtf8String(lgd, event)) return 0;
    if (!putCharacter(lgd, WC_C(' '))) return 0;
    if (!putKeyName(lgd, keyValue)) return 0;
    if (!endLine(lgd)) return 0;
  }

  return 1;
}
Esempio n. 7
0
static int
listKeyboardFunctions (ListGenerationData *lgd, const KeyContext *ctx) {
  const char *prefix = "braille keyboard ";

  {
    unsigned int index;

    for (index=0; index<ctx->mappedKeyCount; index+=1) {
      const MappedKeyEntry *map = &ctx->mappedKeyTable[index];
      const KeyboardFunction *kbf = map->keyboardFunction;

      if (!putUtf8String(lgd, prefix)) return 0;
      if (!putUtf8String(lgd, kbf->name)) return 0;
      if (!putCharacterString(lgd, WS_C(": "))) return 0;
      if (!putKeyName(lgd, &map->keyValue)) return 0;
      if (!endLine(lgd)) return 0;
    }
  }

  {
    const KeyboardFunction *kbf = keyboardFunctionTable;
    const KeyboardFunction *end = kbf + keyboardFunctionCount;

    while (kbf < end) {
      if (ctx->superimposedBits & kbf->bit) {
        if (!putUtf8String(lgd, prefix)) return 0;
        if (!putUtf8String(lgd, kbf->name)) return 0;
        if (!putCharacterString(lgd, WS_C(": superimposed"))) return 0;
        if (!endLine(lgd)) return 0;
      }

      kbf += 1;
    }
  }

  return 1;
}