Beispiel #1
0
char *format_binding( LYKeymap_t *table, int i )
{
  LYKeymapCode the_key = table[ i ];
  char *buf = 0;
  char *formatted;
  Kcmd *rmap = LYKeycodeToKcmd( the_key );
  if ( rmap && rmap->name && rmap->doc )
  {
    formatted = pretty_html( i + -1 );
    if ( formatted )
    {
      HTSprintf0( &buf, "%-*s %-13s %s\n", 11, formatted, rmap->name );
      return buf;
    }
  }
  return 0;
}
static char *format_binding(LYKeymap_t *table, int i)
{
    LYKeymap_t the_key = table[i];
    char *buf = 0;
    char *formatted;
    Kcmd *rmap = LYKeycodeToKcmd((LYKeymapCode) the_key);

    if (rmap != 0
	&& rmap->name != 0
	&& rmap->doc != 0
	&& (formatted = pretty_html(i - 1)) != 0) {
	HTSprintf0(&buf, "%-*s %-13s %s\n",
		   PRETTY_LEN, formatted,
		   rmap->name,
		   rmap->doc);
	return buf;
    }
    return 0;
}
Beispiel #3
0
/*
 * This function was useful in converting the hand-crafted key-bindings to
 * their reusable form in 2.8.8 -TD
 */
static void checkEditMap(LYEditConfig * table)
{
    unsigned j, k;
    char comment[80];
    int first = TRUE;

    for (j = 0; table->init[j].code >= 0; ++j) {
	int code = table->init[j].code;

	if (table->init[j].edit != table->used[code]) {
	    if (first) {
		printf("TABLE %s\n", table->name);
		first = FALSE;
	    }
	    printf("%u: init %d vs used %d\n",
		   j,
		   table->init[j].edit,
		   table->used[code]);
	}
    }
    for (j = 0; j < KEYMAP_SIZE; ++j) {
	int code = (int) j;
	BOOL found = FALSE;

	for (k = 0; table->init[k].code >= 0; ++k) {
	    if (code == table->init[k].code) {
		found = TRUE;
		break;
	    }
	}
	if (!found) {
	    if (table->used[j] != 0) {
		int edit = table->used[j];
		int has_DF = (edit & LYE_DF);
		int has_LAC = (edit & LYE_FORM_LAC);
		const char *prefix = "LYE_";
		const char *name = 0;

		edit &= 0x7f;
		if (has_LAC) {
		    Kcmd *cmd = LYKeycodeToKcmd(edit);

		    if (cmd != 0) {
			prefix = "LYK_";
			name = cmd->name;
		    }
		} else {
		    name = lec_to_lecname(edit);
		}

		if (j < 32) {
		    char temp[80];
		    const char *what = 0;

		    switch (j) {
		    case 0:
			what = "nul";
			break;
		    case 17:
			what = "XON";
			break;
		    case 19:
			what = "XOFF";
			break;
		    default:
			sprintf(temp, "^%c", j + 'A');
			what = temp;
			break;
		    }
		    sprintf(comment, "\t/* %s */", what);
		} else if (j < 127) {
		    sprintf(comment, "\t/* %c */", j);
		} else {
		    const char *what = LYextraKeysToName(j);

		    if (Non_Empty(what)) {
			sprintf(comment, "\t/* %s%s */", what,
				((StrChr(what, '_') != 0)
				 ? ""
				 : "_KEY"));
		    } else {
			strcpy(comment, "");
		    }
		}
		if (name == 0) {
		    name = "XXX";
		} else if (!strcasecomp(name, "PASS")) {
		    name = "FORM_PASS";
		}
		if (first) {
		    printf("TABLE %s\n", table->name);
		    first = FALSE;
		}
		printf("\t{ %d, %s%s%s%s },%s\n", code, prefix, name,
		       has_DF ? "|LYE_DF" : "",
		       has_LAC ? "|LYE_FORM_LAC" : "",
		       comment);
	    }
	}
    }
}