Browse Source

Added more words. Fixed sorting bug

master
dirkson 6 months ago
parent
commit
546995144c
2 changed files with 45 additions and 40 deletions
  1. +35
    -35
      dict
  2. +10
    -5
      kbd.c

+ 35
- 35
dict View File

@@ -15,7 +15,7 @@
"?": "on",
"?": "by",
"wt": "with",
"m": "from",
"fm": "from",
"?": "or",
"ts": "this",
"ty": "they",
@@ -26,7 +26,7 @@
"?": "not",
"l": "also",
"?": "has",
"wh": "were",
"we": "were",
"wc": "which",
"ha": "have",
"pl": "people",
@@ -36,11 +36,11 @@
"tr": "there",
"?": "first",
"o": "other",
"?": "many",
"m": "many",
"te": "their",
"wn": "when",
"?": "had",
"?": "who",
"hd": "had",
"wo": "who",
"cl": "called",
"?": "used",
"ab": "about",
@@ -53,11 +53,11 @@
"al": "all",
"?": "city",
"?": "two",
"?": "more",
"mo": "more",
"?": "time",
"?": "new",
"bn": "been",
"?": "her",
"hr": "her",
"bc": "because",
"vy": "very",
"br": "born",
@@ -67,16 +67,16 @@
"?": "into",
"k": "known",
"ol": "only",
"?": "these",
"ths": "these",
"?": "world",
"?": "states",
"?": "league",
"?": "found",
"?": "if",
"?": "part",
"p": "part",
"?": "them",
"?": "up",
"?": "than",
"ta": "than",
"?": "so",
"?": "such",
"?": "name",
@@ -85,8 +85,8 @@
"?": "years",
"wu": "would",
"?": "then",
"we": "where",
"?": "during",
"wh": "where",
"du": "during",
"?": "music",
"?": "north",
"?": "over",
@@ -96,7 +96,7 @@
"?": "france",
"?": "make",
"?": "football",
"?": "between",
"bw": "between",
"?": "do",
"u": "you",
"?": "often",
@@ -116,9 +116,9 @@
"?": "later",
"?": "played",
"?": "war",
"?": "before",
"bf": "before",
"?": "english",
"?": "usually",
"usu": "usually",
"?": "each",
"?": "same",
"?": "area",
@@ -142,9 +142,9 @@
"?": "both",
"?": "commune",
"?": "while",
"?": "important",
"?": "example",
"?": "through",
"imp": "important",
"ex": "example",
"tru": "through",
"?": "famous",
"?": "department",
"?": "another",
@@ -153,38 +153,38 @@
"?": "town",
"?": "water",
"?": "until",
"?": "sometimes",
"?": "game",
"sti": "sometimes",
"gm": "game",
"?": "said",
"?": "series",
"?": "person",
"per": "person",
"?": "named",
"?": "much",
"mu": "much",
"?": "large",
"?": "several",
"?": "place",
"?": "country",
"sv": "several",
"pla": "place",
"?" "country",
"?": "main",
"?": "government",
"?": "century",
"?": "means",
"?": "university",
"?": "life",
"?": "system",
"sys": "system",
"?": "died",
"?": "get",
"ge": "get",
"?": "family",
"?": "album",
"?": "released",
"rel": "released",
"?": "won",
"?": "band",
"?": "good",
"gd": "good",
"?": "british",
"?": "we",
"?": "see",
"?": "even",
"?": "things",
"?": "day",
"tng": "things",
"d": "day",
"?": "show",
"?": "live",
"?": "county",
@@ -218,7 +218,7 @@
"?": "movie",
"?": "does",
"?": "january",
"?": "should",
"shu": "should",
"?": "former",
"?": "season",
"?": "march",
@@ -240,8 +240,8 @@
"?": "times",
"?": "june",
"?": "species",
"?": "become",
"?": "president",
"bec": "become",
"pres": "president",
"?": "began",
"?": "common",
"?": "built",
@@ -251,7 +251,7 @@
"?": "april",
"?": "japanese",
"?": "page",
"?": "went",
"wnt": "went",
"?": "play",
"?": "together",
"?": "center",


+ 10
- 5
kbd.c View File

@@ -67,7 +67,7 @@ void kbd_add_chord(kbd_chord_tree_t *node, int depth, char *chord, int chordlen,
{
node->result = strndup(result, resultlen);
node->len = resultlen;
//printf("%*.*s %s \n", resultlen, resultlen, result, node->result);
//printf("%*.*s %s %*.*s\n", resultlen, resultlen, result, node->result, chordlen, chordlen, chord);
return;
}

@@ -95,8 +95,13 @@ char kbd_keysym(int f, int key)
//printf("%i %i %i %i %i %i %i %i \n", x.kb_index, KTYP(x.kb_value), KVAL(x.kb_value), 't', x.kb_value, KEY_T, K_HOLE, K_NOSUCHMAP);
}

int kbd_compare_int(const void * a, const void * b) {
//printf("%i %i \n",*(char*)a,*(char*)b);
return ( *(char*)a < *(char*)b );
}
int kbd_compare (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
//printf("%i %i \n",*(char*)a,*(char*)b);
return ( *(char*)a < *(char*)b );
}

char *kbd_find_result(kbd_chord_tree_t *node, int ftty, int depth, int *chord, int chordlen, int *resultlen)
@@ -161,7 +166,9 @@ void kbd_load_json(kbd_chord_tree_t *root)
if (str[t[0].start] != '?')
{
if (t[0].end-t[0].start > 8) kbd_err("chord for squid detected. You are not a squid.");
//printf("%*.*s \n", t[0].end-t[0].start, t[0].end-t[0].start, &str[t[0].start]);
qsort(&str[t[0].start], t[0].end-t[0].start, sizeof(char), kbd_compare);
//printf("%*.*s \n", t[0].end-t[0].start, t[0].end-t[0].start, &str[t[0].start]);
kbd_add_chord(root, 0, &str[t[0].start], t[0].end-t[0].start, &str[t[1].start], t[1].end-t[1].start);
//printf("Found one! \n");
}
@@ -275,7 +282,6 @@ void kbd_event(int *letters, struct input_event ev, int fdo, int ftty, kbd_state
case KEY_RIGHTMETA:
if (ev.value == 1)
{
//printf("caught meta press\n");
kbd_state->chord = 1;
if (kbd_state->lshift)
{
@@ -325,7 +331,6 @@ void kbd_event(int *letters, struct input_event ev, int fdo, int ftty, kbd_state
case KEY_LEFTMETA:
case KEY_LEFTCTRL:
case KEY_RIGHTCTRL:
//printf("Caught right meta\n");
if(write(fdo, &ev, sizeof(struct input_event)) < 0) kbd_err("cannot write to fake keyboard");
kbd_emit(fdo, EV_SYN, SYN_REPORT, 0);
break;
@@ -359,7 +364,7 @@ void kbd_event(int *letters, struct input_event ev, int fdo, int ftty, kbd_state
kbd_state->chord = 0;
for (j = 0; j < kbd_state->num; j++)
kbd_state->key[j] = kbd_keysym(ftty, kbd_state->key[j]);
qsort(kbd_state->key, kbd_state->num, sizeof(int), kbd_compare);
qsort(kbd_state->key, kbd_state->num, sizeof(int), kbd_compare_int);
result = kbd_find_result(root, ftty, 0, kbd_state->key, kbd_state->num, &resultlen);
if (result != NULL && resultlen > 1)
{


Loading…
Cancel
Save