Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | README.md | 35 | ||||
| -rw-r--r-- | mapScore.c | 8 |
3 files changed, 44 insertions, 9 deletions
@@ -7,9 +7,11 @@ mapScore: mapScore.c $(CC) mapScore.c -o mapScore docs: swipeGuess.1 mapScore.1 swipeGuess.1: swipeGuess.1.scd - scdoc < swipeGuess.1.scd > swipeGuess.1 + scdoc < swipeGuess.1.scd > $@.tmp + mv $@.tmp $@ mapScore.1: mapScore.1.scd - scdoc < mapScore.1.scd > mapScore.1 + scdoc < mapScore.1.scd > $@.tmp + mv $@.tmp $@ words-qwerty-en: /usr/share/dict/american-english mapScore grep .. /usr/share/dict/american-english | ./mapScore map.qwerty.noapos.tsv bee | sort -nr | cut -f2 > words-qwerty-en @@ -17,8 +19,8 @@ words-qwerty-en: /usr/share/dict/american-english mapScore apk add words-en test: words-qwerty-en swipeGuess - test `echo "asdfghjkl" | ./swipeGuess words-qwerty-en` = "all" - test `echo "dfghuiokmnhyt" | ./swipeGuess words-qwerty-en 1 "'"` = "don't" + test "`echo "asdfghjkl" | ./swipeGuess words-qwerty-en`" = "all" + test "`echo "dfghuiokmnhyt" | ./swipeGuess words-qwerty-en 1 "'"`" = "don't" test "`echo "tyuiopoiuytrewertyuiuytrer" | ./swipeGuess words-qwerty-en 2`" = "`printf "typewriter\ttorturer"`" install: all @@ -12,7 +12,7 @@ swipeGuess also provides options for returning multiple results and ignoring cer The input program should output a stream of letters "swiped through", then a newline. -This is supported by [wvkbd](https://github.com/proycon/wvkbd) since version 0.6. +This is supported by [wvkbd](https://github.com/proycon/wvkbd) since version 0.6 and [phosh-osk-stub](https://gitlab.gnome.org/guidog/phosh-osk-stub) since 0.28.0. ## wordlist @@ -64,6 +64,39 @@ If your keys are in a hexagonal layout, use mapScore like 3. `wvkbd-mobintl -O | swipeGuess /path/to/words.txt | completelyTypeWord.sh` * In SXMO, `KEYBOARD_ARGS='-O | swipeGuess /path/to/words.txt | completelyTypeWord.sh'` can be added to your ~/.profile to enable this (effective on restart). +# Usage with phosh-osk-stub + +``` +gsettings set sm.puri.phosh.osk osk-features "['key-drag']" +gsettings set sm.puri.phosh.osk.Completers.Pipe command 'swipeGuess /usr/share/swipeGuess/words/words-qwerty-en 5 | tr "\t" "\n"' +gsettings set sm.puri.phosh.osk.Completers default pipe +gsettings set sm.puri.phosh.osk completion-mode "['manual','hint']" +``` + +## Multiple suggestions + +phosh-osk-stub's pipe completer accepts multiple suggestions, newline separated. This can be scripted like + +``` +gsettings set sm.puri.phosh.osk.Completers.Pipe command 'sh -c "swipeGuess /usr/share/swipeGuess/words/words-qwerty-en 5 | tr \"\t\" \"\n\""' +``` + # Extended information [SwipeBehaviors](https://git.sr.ht/~earboxer/SwipeBehaviors) is a project that uses swipeGuess and provides more advanced functionality, like presenting several choices that can be picked with [suggpicker](https://git.sr.ht/~earboxer/suggpicker). + +# Contributing + +swipeGuess is maintained by [Zach DeCook](https://zachdecook.com/), who may or may not be reached directly for related inquiries. + +Patches and long-form discussions for this project are also accepted on my swipeKeyboard mailing list on sourcehut: ([email](mailto:~earboxer/swipeKeyboard@lists.sr.ht)/[archive](https://lists.sr.ht/~earboxer/swipeKeyboard)). + +e.g. + +``` +git config sendemail.to '~earboxer/swipeKeyboard@lists.sr.ht' +git config format.subjectPrefix 'PATCH swipeGuess' +git send-email HEAD~1 +``` + +(See `man git-send-email` or https://git-send-email.io for more information) @@ -20,7 +20,7 @@ void makeMap(FILE *f) { map[c][1] = y; map[c][2] = 1; c = toupper(c); - if (map[toupper(c)][2] == 0) goto explicit_label; + if (c < 256 && map[c][2] == 0) goto explicit_label; break; } } @@ -33,8 +33,8 @@ int scoreWord(char *word, int (*fun)(int*,int*)) { for (c++;*c;c++) { if (*c == '\n') break; // pass over ignore unset chars. - if(map[(unsigned)*c][3] == 0) continue; - score += (*fun)(map[(unsigned)*p],map[(unsigned)*c]); + if(map[(unsigned char)*c][3] == 0) continue; + score += (*fun)(map[(unsigned char)*p],map[(unsigned char)*c]); p=c; } return score; @@ -62,7 +62,7 @@ int beeDist(int *p1, int *p2) { int main(int argc, char **argv) { if (argc < 2) { - fprintf(stderr, "Usage: mapScore map.tsv <words.txt >scoredWords.tsv"); + fprintf(stderr, "Usage: mapScore map.tsv <words.txt >scoredWords.tsv\n"); return 1; } |