gBoards Common (#8921)

Co-Authored-By: Drashna Jaelre <drashna@live.com>
This commit is contained in:
Jeremy Bernhardt
2020-05-04 10:49:47 -06:00
committed by GitHub
parent 6f30b402a2
commit 15e84f79f1
57 changed files with 11774 additions and 0 deletions

View File

@ -0,0 +1,99 @@
{
"the ":"TH",
"of ":"OF",
"and ":"ND",
"to ":"TO",
"in ":"IN",
"for ":"FR",
"is ":"IS",
"on ":"ON",
"that ":"TA",
"by ":"BY",
"this ":"TS",
"with ":"WT",
"you ":"YU",
"it ":"IT",
"not ":"NT",
"or ":"OR",
"be ":"BE",
"are ":"AR",
"from ":"FE",
"at ":"AD",
"as ":"AS",
"your ":"UR",
"all ":"AL",
"have ":"HV",
"new ":"NU",
"more ":"MR",
"an ":"AN",
"was ":"WS",
"we ":"WI",
"will ":"WL",
"home ":"HM",
"can ":"CN",
"us ":"US",
"about ":"AB",
"if ":"IF",
"page ":"PG",
"my ":"MK",
"has ":"HS",
"search ":"SR",
"free ":"FH",
"but ":"BU",
"our ":"OU",
"one ":"WU",
"other ":"OH",
"do ":"DO",
"no ":"NK",
"information ":"IR",
"time ":"TM",
"they ":"TY",
"site ":"SY",
"he ":"HE",
"up ":"UP",
"may ":"MA",
"what ":"WA",
"which ":"WH",
"their ":"TR",
"news ":"NS",
"out ":"OG",
"use ":"UE",
"any ":"NE",
"there ":"TE",
"see ":"SE",
"only ":"LY",
"so ":"SO",
"his ":"HI",
"when ":"WN",
"contact ":"KT",
"here ":"HR",
"business ":"BS",
"who ":"WO",
"web ":"WB",
"also ":"LS",
"now ":"NQ",
"help ":"HL",
"get ":"GT",
"view ":"VU",
"online ":"LN",
"first ":"FS",
"been ":"BN",
"would ":"WD",
"how ":"HU",
"were ":"WR",
"me ":"ME",
"some ":"SM",
"these ":"TZ",
"click ":"CL",
"its ":"IZ",
"like ":"LK",
"service ":"SV",
"than ":"HN",
"find ":"FN",
"price ":"PR",
"date ":"DT",
"back ":"BK",
"top ":"TP",
"people ":"PE",
"had ":"HD"
}

View File

@ -0,0 +1,60 @@
// Package for taking a mapping of words to keys and outputing a
// combo engine commpatible def
package main
import (
"io/ioutil"
"fmt"
"encoding/json"
"os"
"sort"
"strings"
"hash/crc64"
//"encoding/base64"
)
func main() {
// Show Usage
if len(os.Args) < 3 {
fmt.Println("Usage: ./keymap-gen inputfile outfile")
fmt.Println("Outputs dict in current dir")
return
}
// Read the source
data, err := ioutil.ReadFile(os.Args[1])
if err != nil {
panic(err)
}
// Unbundle Data
var FullDict map[string]string
var output []string
json.Unmarshal(data, &FullDict)
// Loop over entries and store
for i,v := range FullDict {
// This checks for colllisions, Generates hash
hash := crc64.Checksum([]byte(v), crc64.MakeTable(crc64.ECMA))
hashStr := fmt.Sprintf("txt_%x", hash)[:10]
// Format keys into combo
var keys string
for _, k := range(v) {
keys += fmt.Sprintf("KC_%v, ", string(k))
}
keys = keys[:len(keys)-2]
// Append to output
spacer := strings.Repeat(" ", 15-len(i))
output = append(output, fmt.Sprintf("SUBS(%v, %v\"%v\", %v)\n", hashStr, spacer, i, keys))
}
sort.Slice(output, func (i,j int) bool {
return strings.Count(output[i], " ") > strings.Count(output[j], " ")
})
ioutil.WriteFile(os.Args[2], []byte(strings.Join(output, "")), 0555)
}

View File

@ -0,0 +1,97 @@
SUBS(txt_eaff0b, "me ", KC_M, KC_E)
SUBS(txt_c96f2b, "as ", KC_A, KC_S)
SUBS(txt_ff3afa, "we ", KC_W, KC_I)
SUBS(txt_d94d16, "is ", KC_I, KC_S)
SUBS(txt_7f6b3b, "he ", KC_H, KC_E)
SUBS(txt_377110, "by ", KC_B, KC_Y)
SUBS(txt_8d5585, "to ", KC_T, KC_O)
SUBS(txt_888e33, "at ", KC_A, KC_D)
SUBS(txt_ad11fe, "do ", KC_D, KC_O)
SUBS(txt_285619, "us ", KC_U, KC_S)
SUBS(txt_e537af, "it ", KC_I, KC_T)
SUBS(txt_9b89bf, "in ", KC_I, KC_N)
SUBS(txt_b11346, "so ", KC_S, KC_O)
SUBS(txt_8bab82, "an ", KC_A, KC_N)
SUBS(txt_6f31f3, "no ", KC_N, KC_K)
SUBS(txt_f32605, "on ", KC_O, KC_N)
SUBS(txt_2cce07, "or ", KC_O, KC_R)
SUBS(txt_48782c, "of ", KC_O, KC_F)
SUBS(txt_c69bf5, "be ", KC_B, KC_E)
SUBS(txt_6c2838, "if ", KC_I, KC_F)
SUBS(txt_6ffc63, "up ", KC_U, KC_P)
SUBS(txt_920a79, "my ", KC_M, KC_K)
SUBS(txt_f31a7f, "his ", KC_H, KC_I)
SUBS(txt_da994d, "use ", KC_U, KC_E)
SUBS(txt_b12f3c, "the ", KC_T, KC_H)
SUBS(txt_4607a4, "for ", KC_F, KC_R)
SUBS(txt_a4eacd, "and ", KC_N, KC_D)
SUBS(txt_6a5f20, "new ", KC_N, KC_U)
SUBS(txt_bb0054, "but ", KC_B, KC_U)
SUBS(txt_7a4167, "are ", KC_A, KC_R)
SUBS(txt_765d98, "you ", KC_Y, KC_U)
SUBS(txt_ed01f2, "one ", KC_W, KC_U)
SUBS(txt_b236f7, "see ", KC_S, KC_E)
SUBS(txt_3eb659, "our ", KC_O, KC_U)
SUBS(txt_2f09ac, "how ", KC_H, KC_U)
SUBS(txt_706e0f, "who ", KC_W, KC_O)
SUBS(txt_9dba28, "get ", KC_G, KC_T)
SUBS(txt_3b151a, "top ", KC_T, KC_P)
SUBS(txt_17c481, "any ", KC_N, KC_E)
SUBS(txt_227971, "can ", KC_C, KC_N)
SUBS(txt_4f3107, "web ", KC_W, KC_B)
SUBS(txt_7f2fb4, "all ", KC_A, KC_L)
SUBS(txt_8184ea, "was ", KC_W, KC_S)
SUBS(txt_8da46f, "has ", KC_H, KC_S)
SUBS(txt_cc4577, "had ", KC_H, KC_D)
SUBS(txt_b7a9ce, "out ", KC_O, KC_G)
SUBS(txt_9dc2dd, "its ", KC_I, KC_Z)
SUBS(txt_d9716c, "not ", KC_N, KC_T)
SUBS(txt_118fe3, "now ", KC_N, KC_Q)
SUBS(txt_912fc8, "may ", KC_M, KC_A)
SUBS(txt_769008, "been ", KC_B, KC_N)
SUBS(txt_43dc12, "site ", KC_S, KC_Y)
SUBS(txt_c6e300, "like ", KC_L, KC_K)
SUBS(txt_bdfe53, "with ", KC_W, KC_T)
SUBS(txt_c34043, "when ", KC_W, KC_N)
SUBS(txt_b7ed41, "find ", KC_F, KC_N)
SUBS(txt_f5a0f7, "that ", KC_T, KC_A)
SUBS(txt_3be4f0, "help ", KC_H, KC_L)
SUBS(txt_32aaa6, "were ", KC_W, KC_R)
SUBS(txt_4cd926, "also ", KC_L, KC_S)
SUBS(txt_be6e87, "back ", KC_B, KC_K)
SUBS(txt_5a3966, "view ", KC_V, KC_U)
SUBS(txt_89b7d9, "what ", KC_W, KC_A)
SUBS(txt_4ffc97, "only ", KC_L, KC_Y)
SUBS(txt_e50bd5, "news ", KC_N, KC_S)
SUBS(txt_7cbf60, "this ", KC_T, KC_S)
SUBS(txt_ab1e13, "more ", KC_M, KC_R)
SUBS(txt_459770, "some ", KC_S, KC_M)
SUBS(txt_37c475, "will ", KC_W, KC_L)
SUBS(txt_88cabc, "home ", KC_H, KC_M)
SUBS(txt_38b9b4, "free ", KC_F, KC_H)
SUBS(txt_7f9ad1, "they ", KC_T, KC_Y)
SUBS(txt_79d1b3, "time ", KC_T, KC_M)
SUBS(txt_6081a2, "date ", KC_D, KC_T)
SUBS(txt_bb894b, "page ", KC_P, KC_G)
SUBS(txt_455ae0, "have ", KC_H, KC_V)
SUBS(txt_cf60c6, "than ", KC_H, KC_N)
SUBS(txt_3e8a23, "here ", KC_H, KC_R)
SUBS(txt_9b7855, "your ", KC_U, KC_R)
SUBS(txt_7e6bc5, "from ", KC_F, KC_E)
SUBS(txt_d6fd47, "click ", KC_C, KC_L)
SUBS(txt_7c72f0, "other ", KC_O, KC_H)
SUBS(txt_f529e8, "first ", KC_F, KC_S)
SUBS(txt_c065f2, "would ", KC_W, KC_D)
SUBS(txt_3830ab, "these ", KC_T, KC_Z)
SUBS(txt_cf912c, "their ", KC_T, KC_R)
SUBS(txt_4c14b6, "which ", KC_W, KC_H)
SUBS(txt_eec659, "price ", KC_P, KC_R)
SUBS(txt_7dac6e, "about ", KC_A, KC_B)
SUBS(txt_8e7034, "there ", KC_T, KC_E)
SUBS(txt_e1d8f7, "online ", KC_L, KC_N)
SUBS(txt_4f0d7d, "people ", KC_P, KC_E)
SUBS(txt_f3d7ef, "search ", KC_S, KC_R)
SUBS(txt_4ce55c, "contact ", KC_K, KC_T)
SUBS(txt_88072c, "service ", KC_S, KC_V)
SUBS(txt_3454a1, "business ", KC_B, KC_S)
SUBS(txt_6a635a, "information ", KC_I, KC_R)

View File

@ -0,0 +1,2 @@
COMB(gbClick, KC_BTN1, KC_G, KC_B)
COMB(fvClick, KC_BTN2, KC_F, KC_V)

View File

@ -0,0 +1,10 @@
// Vim-Mode combos
COMB(weEsc, KC_ESC, KC_W, KC_E)
COMB(sdBspc, KC_BSPC, KC_S, KC_D)
COMB(dfTab, KC_TAB, KC_D, KC_F)
COMB(cvEnt, KC_ENT, KC_C, KC_V)
COMB(uiEsc, KC_ESC, KC_U, KC_I)
COMB(jkCol, KC_COLN, KC_J, KC_K)
COMB(hnEnt, KC_ENT, KC_H, KC_N)

View File

@ -0,0 +1,7 @@
# Combo library!
This is a list of all the currently available dictionaries that are available for inclusion.
Please submit a PR with yours! If you have a bunch prepend your username to the front. i.e.
`germ-vim-helpers`
Thanks!

View File

@ -0,0 +1,298 @@
package main
import (
"io/ioutil"
"fmt"
"encoding/json"
"os"
"path/filepath"
"strings"
"sort"
"hash/crc64"
//"encoding/base64"
)
func main() {
// Show Usage
if len(os.Args) < 3 {
fmt.Println("Usage: ./keymap-gen src-dir out-dir")
fmt.Println("Outputs c files in out-dir")
fmt.Println("Make sure the dirs exist.")
return
}
files, err := filepath.Glob(os.Args[1] + "/*.json")
if err != nil {
fmt.Printf("Could not open src-dir: %v\n", err)
return
}
for _, fname := range(files) {
fmt.Println("Processing: ", fname)
// Read the source
data, err := ioutil.ReadFile(fname)
if err != nil {
panic(err)
}
// Unbundle Data
var FullDict map[string]Entry
json.Unmarshal(data, &FullDict)
// Loop over entries and store
var output []string
for i,v := range FullDict {
if i == "0" {
continue
}
// Special handling for numbermap
var entry string
if strings.Contains(fname, "num") {
entry = v.toKeymap("NUM|")
} else {
entry = v.toKeymap("")
}
if entry != "" {
output = append(output, entry)
}
}
// Sort by length, then amount of whitespace lol
sort.Slice(output, func (i,j int) bool {
var maxLen int
if len(output[i]) > len(output[j]) {
maxLen = len(output[i])
} else {
maxLen = len(output[j])
}
return maxLen-strings.Count(output[i][:40], " ") < maxLen-strings.Count(output[j][:40], " ")
})
// Whack a disclaimer
output = append([]string{"// This file is automatically generated. Do not edit it!\n\n"}, output...)
// Write all data out
outName := filepath.Base(fname)
outName = os.Args[2] + outName[:len(outName)-5]+".def"
fmt.Println("Saving: ", outName)
ioutil.WriteFile(outName, []byte(strings.Join(output, "")), 0755)
}
}
func (e Entry) toKeymap(prefix string) (string) {
// storage for parts
var command, chord, arg string
wordInfo := parseWords(e)
// Handle prefix
if prefix != "" {
chord = prefix
}
// Format the chord
keys := []string{"AA", "AS", "AE", "AT", "AN", "AI", "AO", "AP"}
for i, v := range e.Input {
chord += keys[v-1]
if i != len(e.Input)-1 {
chord += "|"
}
}
// Handle specials/base first
var ok bool
var v []string
if e.Special != "" {
v, ok = QMKLookup[e.Special]
}
if !ok && e.Base != "" {
v, ok = QMKLookup[e.Base]
}
if ok {
// Determine way to send key
if len(v) == 1 {
command = "PRES("
} else {
command = "KEYS("
}
}
if ok {
if len(v) > 1 {
arg += "{"
}
// String together args
for ii, vv := range(v) {
arg += vv
if ii == len(v)-1 && len(v) > 1 {
arg += ", COMBO_END}"
} else if ii != len(v)-1 {
arg += ", "
}
}
hash := crc64.Checksum([]byte(fmt.Sprintf("%v%v", arg, chord)), crc64.MakeTable(crc64.ECMA))
hashStr := fmt.Sprintf("cmb_%x", hash)
wordSpacer := strings.Repeat(" ", 42-len(arg))
if command == "KEYS(" {
arg = fmt.Sprintf("%v, %v %v", hashStr, wordSpacer, arg)
} else {
arg = fmt.Sprintf("%65v", arg)
}
goto Found
}
// Parse out word info
if wordInfo.LRank == 0 && wordInfo.RRank == 0 {
goto Blank
}
if wordInfo.LRank != 0 || wordInfo.RRank != 0 {
if wordInfo.LRank != 0 && wordInfo.RRank != 0 {
// Just blank the structure and recall
left, right := e, e
left.Trw = nil
right.Tlw = nil
return fmt.Sprintf("%v%v", left.toKeymap("LFT|"), right.toKeymap("RGT|"))
}
var word string
if wordInfo.LRank > wordInfo.RRank {
word = wordInfo.LWord
} else {
word = wordInfo.RWord
}
// Add in thumb
chord = "AR|" + chord
// generate function name
hash := crc64.Checksum([]byte(word), crc64.MakeTable(crc64.ECMA))
hashStr := fmt.Sprintf("str_%016X", hash)
command = "SUBS("
wordSpacer := strings.Repeat(" ", 40-len(word))
arg = fmt.Sprintf("%v, %v \"%v \"", hashStr, wordSpacer, word)
goto Found
}
panic(e.String())
Found:
chord += ","
return fmt.Sprintf("%v%-35v%v)\n", command, chord, arg)
Blank:
return ""
}
type Entry struct {
Input []int
Base string
Tlw []interface{}
Trw []interface{}
Special string
}
type Word struct {
LWord string
LRank float64
RWord string
RRank float64
}
func parseWords(e Entry) (ret Word) {
if len(e.Tlw) > 0 {
ret.LWord = e.Tlw[0].(string)
ret.LRank= e.Tlw[1].(float64)
}
if len(e.Trw) > 0 {
ret.RWord = e.Trw[0].(string)
ret.RRank= e.Trw[1].(float64)
}
return ret
}
func (e Entry) String() (ret string) {
ret = fmt.Sprintln("Input: ", e.Input)
ret += fmt.Sprintln("Base: ", e.Base)
ret += fmt.Sprintln("Left: ", e.Tlw)
ret += fmt.Sprintln("Right: ", e.Trw)
ret += fmt.Sprintln("Special: ", e.Special)
return ret
}
var QMKLookup = map[string][]string {
"!":[]string{"KC_LSFT", "KC_1"},
"'":[]string{"KC_QUOT"},
"(":[]string{"KC_LSFT", "KC_9"},
")":[]string{"KC_LSFT", "KC_0"},
",":[]string{"KC_COMM"},
"-":[]string{"KC_MINS"},
".":[]string{"KC_DOT"},
";":[]string{"KC_SCLN"},
"?":[]string{"KC_QUOT"},
"a":[]string{"KC_A"},
"b":[]string{"KC_B"},
"c":[]string{"KC_C"},
"d":[]string{"KC_D"},
"e":[]string{"KC_E"},
"f":[]string{"KC_F"},
"g":[]string{"KC_G"},
"h":[]string{"KC_H"},
"i":[]string{"KC_I"},
"j":[]string{"KC_J"},
"k":[]string{"KC_K"},
"l":[]string{"KC_L"},
"m":[]string{"KC_M"},
"n":[]string{"KC_N"},
"o":[]string{"KC_O"},
"p":[]string{"KC_P"},
"q":[]string{"KC_Q"},
"r":[]string{"KC_R"},
"s":[]string{"KC_S"},
"t":[]string{"KC_T"},
"u":[]string{"KC_U"},
"v":[]string{"KC_V"},
"w":[]string{"KC_W"},
"x":[]string{"KC_X"},
"y":[]string{"KC_Y"},
"z":[]string{"KC_Z"},
//specials
"bksp":[]string{"KC_BSPC"},
"enter":[]string{"KC_ENT"},
//"numsym":[]string{"NUM)"}, //TODO: Sticky
//"LETTERS":[]string{"KC_SPC"},
//symbols
"[":[]string{"KC_LBRC"},
"]":[]string{"KC_RBRC"},
" ":[]string{"KC_SPC"},
"1":[]string{"KC_1"},
"2":[]string{"KC_2"},
"3":[]string{"KC_3"},
"4":[]string{"KC_4"},
"5":[]string{"KC_5"},
"6":[]string{"KC_6"},
"7":[]string{"KC_7"},
"8":[]string{"KC_8"},
"9":[]string{"KC_9"},
"0":[]string{"KC_0"},
"=":[]string{"KC_EQL"},
"Fn":[]string{"KC_NO"},
"SPACE":[]string{"KC_SPC"},
"Home":[]string{"KC_HOME"},
"End":[]string{"KC_END"},
" ":[]string{"KC_TAB"},
" ":[]string{"KC_TAB"},
"\t":[]string{"KC_TAB"},
"`":[]string{"KC_GRV"},
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,28 @@
PRES(CMD | AA, KC_LCTL)
PRES(CMD | AS, KC_LSFT)
PRES(CMD | AE, KC_LALT)
PRES(CMD | AT, KC_LGUI)
PRES(CMD | AN, KC_LEFT)
PRES(CMD | AI, KC_DOWN)
PRES(CMD | AO, KC_UP)
PRES(CMD | AP, KC_RIGHT)
PRES(CMD | AR, KC_PGUP)
PRES(CMD | AL, KC_PGDN)
PRES(CMD | AA | AP, KC_F1)
PRES(CMD | AA | AO, KC_F2)
PRES(CMD | AA | AO | AP, KC_F3)
PRES(CMD | AA | AI, KC_F4)
PRES(CMD | AA | AI | AP, KC_F5)
PRES(CMD | AA | AI | AO, KC_F6)
PRES(CMD | AA | AI | AO | AP, KC_F7)
PRES(CMD | AA | AN, KC_F8)
PRES(CMD | AA | AN | AP, KC_F9)
PRES(CMD | AA | AN | AO, KC_F10)
PRES(CMD | AA | AN | AO | AP, KC_F11)
PRES(CMD | AA | AN | AI, KC_F12)
PRES(CMD | AS | AN, KC_HOME)
PRES(CMD | AS | AP, KC_END)
PRES(CMD | AS | AI, KC_INS)
PRES(CMD | AS | AO, KC_DEL)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More