Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
Diffstat (limited to 'swipeGuess.c')
| -rw-r--r-- | swipeGuess.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/swipeGuess.c b/swipeGuess.c index 41fb29c..b13e5b5 100644 --- a/swipeGuess.c +++ b/swipeGuess.c @@ -6,6 +6,7 @@ #define BUFSIZE 1024 char wordBuff[BUFSIZE]; char swipeBuff[BUFSIZE]; +bool ignorechars[256] = {false}; // fgets, but without the newline. char *fgetst(char *restrict s, int size, FILE *restrict stream) { @@ -35,7 +36,7 @@ bool swipeCompare(char *swipe, char *word) { bool lastMatch = false; for(swipeP++; swipeP[0]; swipeP++) { lastMatch = false; - while (charcmp(swipeP[0], wordP[0])) { + while (charcmp(swipeP[0], wordP[0]) || ignorechars[wordP[0]]) { wordP++; lastMatch = true; } @@ -63,13 +64,18 @@ void query(FILE *wordFile, char *swipe, int n) { int main(int argc, char **argv) { if (argc < 2) { - fprintf(stderr, "Usage: swipeGuess words.txt [n]"); + fprintf(stderr, "Usage: swipeGuess words.txt [n]\n"); exit(1); } int n = 1; if (argc >= 3) { n = atoi(argv[2]); } + if (argc >= 4) { + for(int i=0; argv[3][i];i++){ + ignorechars[(int)argv[3][0]] = true; + } + } FILE *wordFile = fopen(argv[1], "r"); while (fgetst(swipeBuff, BUFSIZE, stdin)) { query(wordFile, swipeBuff, n); |