This is a tiny plugin for Xournal++, version 1.1.x.
To set the plugin up on Linux, run
cd /usr/share/xournalpp/plugins
sudo git clone https://github.com/raw-bacon/vi-xournalpp
In Xournal++, activate the plugin using the Plugin Manager in the menu bar under Plugin.
vi-xournalpp is inspired by the modal editing popularized by the text editor vi. The two basic principles of the default keybindings of vi-xournalpp are
- They should be easy to remember mnemonically,
- They should be accessible by the left hand on a QWERTY/QWERTZ/AZERTY keyboard.
The second principle is broken for certain colors (e.g. o
range).
vi-xournalpp is centered around so-called modes. They give access to different sets of keybindings. This makes it possible for way more commands to be easily accessible from a limited region on the keyboard.
The default mode is tool mode.
Tool mode is used for switching between the different tools, tool thicknesses,
modes, and history operations. Available tools are pen, eraser,
selection, highlighter, tex, delete, file.
Available thicknesses are
very fine, fine, medium, thick, very thick.
Available modes are color, shape, linestyle, page, navigation, visual.
Pressing any key in any mode other than tool automatically
returns the user to tool mode, unless the mode was made "sticky"
by pressing <Shift>
. E.g., to enter sticky color mode, press
<Shift>c
.
Available history operations are undo, redo.
The color mode is used to switch between the different colors, black, white, pink, red, orange, yellow, green, cyan, blue, purple.
The shape mode is used to select the different shapes, ruler, arrow, rectangle, and ellipse.
The linestyle mode switches between the different kinds of linestyles, namely plain, dashed, dotted, dashDotted.
The page mode can manipulate pages and the canvas position. Available actions are copy, delete, moveUp, moveDown. The somewhat ambiguously named moveUp and moveDown actually move the page around in the document and are not to be confused with the scrolling commands.
The navigation mode is responsible for scrolling. Available actions are goToFirstPage, goToLastPage, goToTop, goToBottom, scrollPageDown, scrollPageUp.
The file mode can open and write files. Available actions are annotatePDF, exportAsPDF.
The visual mode is responsible for the selection of objects. Available actions are lasso, selectRectangle, selectObject.
Keybindings are defined in the file keybindings.lua
.
One keybinding looks something like this:
selection = {
description = "Selection",
buttons = {"s"},
modes = {"tool"},
call = clickSelectRegion
}
The description
field is the menu
entry, and also what is logged into the terminal
if Xournal++ is started using the command xournalpp
.
The characters in the buttons
list are
the accelerators of the keybinding.
Modes present in the modes
list listen
for the accelerators.
The function assigned call
gets executed
when a valid accelerator is pressed
in a valid mode. In this case,
clickSelectRegion
is a function
defined in api.lua
.
The colors can be changed in colors.lua
.
They require RGB like so:
yellowColor = 0xe9f23a
A mode newMode
needs the following
- An entry
"newMode"
in theALL_MODES
list inkeybindings.lua
, - A
newMode
keybinding in thekeybindings
list.
vi-xournalpp currently does not cover the full API. To add another entry, follow the following steps.
- Make a function in
api.lua
wrapping the API call. - Create a new keybinding for it in
keybindings.lua
.
If the entry is a color, also update colors.lua
accordingly.