Skip to content

Commit

Permalink
made build process better
Browse files Browse the repository at this point in the history
  • Loading branch information
ajusa committed Sep 29, 2017
1 parent 5436e56 commit 79cd930
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nimcache/
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# sanictype

autocomplete for windows, written in nim

### Usage
Download it by clicking the download from zip button. Unzip it to whatever directory you want.

Next, double click on sanic.exe. A window should pop up with nothing in it. You are now good to go!

To use, start typing a word, and hit tab. Continue hitting tab to cycle through words based on frequency. If it glitches out, delete the word, and make sure to press space before rewriting it. The program uses spaces and newlines to keep track of new words. Backspacing can be weird.
Binary file added sanic.exe
Binary file not shown.
84 changes: 42 additions & 42 deletions test.nim → sanic.nim
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
import os
import winim
import strutils
var frag = ""
var lastString = ""
var db = newSeq[string](0)
var tabs = 0
for str in readFile("db.txt").split:
if len(str) > 3:
db.add(str)
proc complete(frag:string, i: int): string =
var counter = 0
for str in db:
if str.startsWith(frag):
if counter == i:
return str.replace(frag, "")
counter += 1
proc writeString(input: string) =
for c in input:
keybd_event(VkKeyScan(c.BYTE).BYTE,0x9e.BYTE,0,0);
keybd_event(VkKeyScan(c.BYTE).BYTE,0x9e.BYTE,KEYEVENTF_KEYUP,0);
proc main() =
while true:
Sleep(50)
for i in 8..190:
if GetAsyncKeyState(cint(i)) == -32767:
if VK_SPACE == i or VK_RETURN == i:
frag = ""
tabs = 0
lastString = ""
elif VK_BACK == i:
frag.delete(frag.len-2, frag.len-1)
elif chr(i) in Letters: frag = frag & toLowerAscii($chr(i))
if VK_TAB == i:
keybd_event(VK_BACK,0x9e.BYTE,0,0);
keybd_event(VK_BACK,0x9e.BYTE,KEYEVENTF_KEYUP,0);
for ch in lastString:
keybd_event(VK_BACK,0x9e.BYTE,0,0);
keybd_event(VK_BACK,0x9e.BYTE,KEYEVENTF_KEYUP,0);
lastString = complete(frag.strip, tabs)
writeString(lastString)
tabs += 1
import os
import winim
import strutils
var frag = ""
var lastString = ""
var db = newSeq[string](0)
var tabs = 0
for str in readFile("db.txt").split:
if len(str) > 3:
db.add(str)
proc complete(frag:string, i: int): string =
var counter = 0
for str in db:
if str.startsWith(frag):
if counter == i:
return str.replace(frag, "")
counter += 1
proc writeString(input: string) =
for c in input:
keybd_event(VkKeyScan(c.BYTE).BYTE,0x9e.BYTE,0,0);
keybd_event(VkKeyScan(c.BYTE).BYTE,0x9e.BYTE,KEYEVENTF_KEYUP,0);
proc main() =
while true:
Sleep(50)
for i in 8..190:
if GetAsyncKeyState(cint(i)) == -32767:
if VK_SPACE == i or VK_RETURN == i:
frag = ""
tabs = 0
lastString = ""
elif VK_BACK == i:
frag.delete(frag.len-2, frag.len-1)
elif chr(i) in Letters: frag = frag & toLowerAscii($chr(i))
if VK_TAB == i:
keybd_event(VK_BACK,0x9e.BYTE,0,0);
keybd_event(VK_BACK,0x9e.BYTE,KEYEVENTF_KEYUP,0);
for ch in lastString:
keybd_event(VK_BACK,0x9e.BYTE,0,0);
keybd_event(VK_BACK,0x9e.BYTE,KEYEVENTF_KEYUP,0);
lastString = complete(frag.strip, tabs)
writeString(lastString)
tabs += 1
main()

0 comments on commit 79cd930

Please sign in to comment.