typioca
typioca copied to clipboard
Layout generation
Layouts are currently generated with this script. Currently thinking if there is a way to automate it. The script as pasted below currently should generate the Dvorak Layout.
Steps to add a new layout:
- Add the layout json file into the
layouts
folder and push - Add a new
defaultLayoutFile
intocmd/config.go
- Update
currentConfigVersion
incmd/config.go
Can refer https://github.com/bloznelis/typioca/tree/master/words for example of where to put the generation code so it lives alongside the repo but is not included in the binary
type Layout struct {
Name string `json:"name"`
Mappings map[rune]rune `json:"mappings"`
}
func FWriteStructToYaml[T any](stuff T) error {
f, err := os.OpenFile(fileLocation, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
defer f.Close()
if err != nil {
panic(err)
}
enc := json.NewEncoder(f)
if err := enc.Encode(stuff); err != nil {
panic(err)
}
return nil
}
func main() {
thing := Layout{
Name: "Dvorak",
Mappings: map[rune]rune{
'q': '\'',
'w': ',',
'e': '.',
'r': 'p',
't': 'y',
'y': 'f',
'u': 'g',
'i': 'c',
'o': 'r',
'p': 'l',
'[': '/',
']': '=',
'a': 'a',
's': 'o',
'd': 'e',
'f': 'u',
'g': 'i',
'h': 'd',
'j': 'h',
'k': 't',
'l': 'n',
';': 's',
'\'': '-',
'z': ';',
'x': 'q',
'c': 'j',
'v': 'k',
'b': 'x',
'n': 'b',
'm': 'm',
',': 'w',
'.': 'v',
'/': 'z',
},
}
FWriteStructToYaml(thing)
}