Generates keyboard layouts for various languages targetting a variety of input backends.
If you have multiple programs that can handle custom keyboard layouts, genkeyboard will be able to generate the same keyboard layout in many different formats for these programs.
Genkeyboard can also be used to help make writing your keyboard layout easier by using tools in the rust programming language rather than writing everything by hand.
Genkeyboard fundamentally does two things:
- Generate a mapping from a sequence of input letters to an output string
- ie: generate an input method for a language
- Take this mapping and output it in the format of a common keyboard layout config
- ie: save the input method as a config for your favourite keyboard layout program
- OR: save it as a list for reference
- OR: save it as a diagram for visual reference
The following example generates a greek polytonic keyboard layout that works with emacs.
genkeyboard generate --layout greek --format emacs-quail
Each of the following subheaders is a subcommand in genkeyboard, alternatively try genkeyboard --help
for more information.
Generates a keyboard layout in the specified format and prints it to the console (or saves it to a file)
Go in the format: generate <OPTIONAL> <REQUIRED>
--layout <LAYOUT>
--format <FORMAT>
-o / --output-file <PATH>
--subgraph <SUBGRAPH NAME>
The automaton can be used to test a keyboard layout
Go in the format: automaton <OPTIONAL> <REQUIRED> <SUBCOMMAND>
--layout <LAYOUT>
--subgraph <SUBGRAPH NAME>
repl - run an interactive automaton that takes in input strings and returns mappings
test - test one string on the automaton
codegen - output the automaton DFA as a javascript array
Lists all the available sections in a keyboard layout.
--layout <LAYOUT>
- The names of sections can be used as arguments to
generate
andautomaton
commands. - Isolating subgraphs is useful for debugging or trying only certain parts of the keyboard layout at a time.
- Use
--subgraph
in combination withgenerate --format graph-viz
to see a diagram of one section of the keyboard alone.
Lists the available keyboard layouts that can be generated by the program.
- greek: Polytonic greek, phonetic layout.
- latin: Adds macrons and breve marks.
List the available output formats that can be generate by the program
- list: A human-readable mapping
- emacs-quail: An emacs-compatible keyboard layout
- vim-fn: A vim function which toggles the keyboard layout
- graph-viz: Export to Graphviz definitions to preview the layout visually
This is by no means comprehensive and is only intended to give some intuition to those who are interested.
- see
src/kbdlayout/latin.rs
for an example.
- Start in
src/kbdlayout/<MYLAYOUT>.rs
- Make a function which takes in a
keyboard: &mut KbdWriter
- Set the metadata of your new
keyboard
layout - Create various mapping sections called
KbdMap
s and write these sections tokeyboard
- Add a new enum entry
<MYLAYOUT>
to theLayout
enum insrc/kbdlayout/mod.rs
- In
src/main.rs
make the match statement onargs.layout
call your new layout function.
- see
src/kbdwriter/list.rs
for an example.
- Start in
src/kbdwriter/<MYFORMAT>.rs
- Create a new struct with a
RefCell
to aKbdWriter
- Implement
Display
for the struct and use theKbdWriter
- Print the metadata in a suitable way for your format
- Print each mapping section in a suitable way for your format
- Add a new enum entry
<MYFORMAT>
to theFormat
enum insrc/kbdwriter/mod.rs
- In
src/main.rs
make the match statement onargs.format
format with your new struct.
- GPL 3.0 or later
- See LICENSE