Unryu Documentation
The user manual of Unryu, a source code editor for X11 that understands the code it shows. This page says what Unryu is, how to build and install it, and what happens the first time it runs. Then it takes you on a short tour, and lists the other pages of the manual.
What Unryu is
Unryu is a light, fast editor with tabs, panels, a terminal and build commands, in the style of Geany. What makes it different is that it reads your code the way a compiler would, instead of coloring it with patterns. The reading is done by Kami, a library built into Unryu, and it runs in a sandbox so that a hostile file cannot reach your files.
- Braces you can trust. The brace at the cursor and its partner come from the parse, so they stay right in broken code. A missing brace is drawn faded where it most likely belongs, and one key writes it in.
- Names colored by what they are: functions, types, macros, parameters, members, enumerators, labels and variables each have their own color, and every use of the name at the cursor is highlighted.
- Every symbol at hand. Hover over a name for its declaration and documentation; press F12 or Ctrl+click to go to its definition, even in a header of another project. The Outline lists the file's symbols, and Details explains the one at the cursor.
- Many languages, from files. Each language is described in a plain text file that you can read and change. 86 language files come with Unryu.
- Your work is safe. A save either replaces the file completely or leaves it as it was. Unsaved text is copied aside every few seconds, so it survives a crash or a lost display.
- The compiler only when you ask. Unryu never runs a compiler by itself. Only Ctrl+Shift+B does, in a sandbox, to find which repair of a doubtful brace compiles.
Building Unryu
Unryu is built from source with make. Everything it needs from Kami (the code reader), xtk (the
toolkit that draws the window) and Hosho (the terminal) is already in the source tree and is compiled straight
into the program, so there are no other projects to install first.
You need a C compiler that understands -std=gnu17 (GCC or Clang), make,
pkg-config, and the development files of these X11 libraries: X11, Xrender, Xft, fontconfig, freetype,
Xcursor, Xext and Xpm. On Debian and Ubuntu, for example:
sudo apt install build-essential pkg-config libx11-dev libxrender-dev libxft-dev \
libfontconfig-dev libfreetype-dev libxcursor-dev libxext-dev libxpm-dev
Then, in the source folder:
| Command | What it does |
|---|---|
make | Builds the program ./unryu. The build treats every warning as an error. |
make install | Installs the program to /usr/bin/unryu and its files to /usr/share/unryu
(see below). Use PREFIX=/usr/local to install elsewhere, and DESTDIR=... to stage the
install for a package. |
make clean | Removes the build folder and the program. |
Installing and running
You can run Unryu straight from the source folder with ./unryu, or install it with
make install. An installed Unryu finds its files in <prefix>/share/unryu:
| Folder | What is in it |
|---|---|
languages/ | The language files (.lang), one for each language. |
editor_themes/ | The editor themes: the colors of the text. |
templates/ | The file templates used by File > New (with Template). |
icons/ | The icons of the toolbar, the sidebar and the menus. |
doc/ | This manual, which Help > Help (F1) opens in your browser. |
shell/ | The shell integration scripts of the terminal (bash, zsh, fish, ksh and others). |
There is no folder for the window themes (the colors of menus, panels and dialogs). Their 14 built-in themes are part
of the program, and Unryu writes each one into ~/.config/unryu/themes/ when it is not there, so that you can
change it. Unryu also reads window themes from ~/.themes/NAME/xtk/,
~/.local/share/themes/NAME/xtk/ (or $XDG_DATA_HOME/themes/NAME/xtk/) and /usr/share/themes/NAME/xtk/. See
Themes.
Run from the source folder, Unryu finds the same folders beside the program or one folder up.
make install does not add Unryu to your desktop's application menu. To do that, copy
unryu.desktop to ~/.local/share/applications/, and put the icon from artwork/
(for example unryu-icon-48.png) in your icon theme as unryu.png.
To start Unryu with files:
unryu file.c other.h ...
- A name that does not exist yet opens as a new, empty document with that name; saving it creates the file.
- There is one Unryu for each display. Starting it again with files hands them to the Unryu that is already running, which opens them and comes to the front. Starting it again without files only brings the running one to the front, unless "Open a new window when Unryu already runs" is on in Preferences > General.
-ior--new-instancestarts a separate Unryu even when one is running. When another Unryu is running, the files of the last session stay with that one.
Help > About shows the version of Unryu and of the libraries built into it.
The first run
The first time it runs, Unryu makes its configuration folder, ~/.config/unryu (or
$XDG_CONFIG_HOME/unryu), and fills some of it with copies of its own files, so that you have your own
copy to change:
| In ~/.config/unryu | What it is |
|---|---|
languages/ | A copy of each language file. Your copy wins over the installed one with the same name. |
editor_themes/ | A copy of each editor theme, yours to change. |
themes/ | The window themes. |
templates/ | A copy of each file template, made the first time you open the File menu. |
Unryu copies each file that comes with it into languages/, editor_themes/ and
templates/ once, and notes it in a list in that folder (.shipped). A file you delete stays
deleted, and a file new in a later version of Unryu is copied in the first time that version runs. To get the
installed files back, delete or rename the whole folder and start Unryu again. themes/ is different: at
every start Unryu writes each built-in window theme that is missing from it, so a built-in theme you delete comes
back.
Other files appear in the same folder as you use Unryu:
| File | What it keeps |
|---|---|
unryu.conf | Your settings from Preferences and the View menu. |
keybindings.conf | The keys you changed in Preferences > Keybindings. |
build.conf | Your build commands. |
terminal.conf | The terminal's settings. |
snippets.conf | Your own snippets, made when you open it from Tools > Configuration Files. |
documentation.conf | Your own commands for Help > Look Up Documentation. |
words.txt | The words you added to the spelling dictionary. |
projects.conf | The project corrections from the Tools menu, and the project build commands you approved. |
dock_layout.txt | Where the panels are. |
window.txt | The window's size and place. |
open_files.txt | The files of the last session, opened again at the next start when "Load files from the last session" is on. |
recent_files.txt, recent_projects.txt | File > Recent Files and Recent Projects. |
workbenches.txt | File > Workbench: each workbench's projects, folders, open files and bookmarks. |
debug.conf | Each project's debug session: the program, its arguments and folder, the breakpoints and the watches. |
marked-folders.txt | The Files tab's marked folders. |
file_settings.txt | Each file's own Document menu settings (wrapping, indentation, read only ...). |
Tools > Configuration Files opens unryu.conf, keybindings.conf, build.conf,
snippets.conf and each language file in a tab. After you change one by hand, Tools > Reload Configuration
reads them all again.
Unryu also uses ~/.cache/unryu (or $XDG_CACHE_HOME/unryu), a private folder that only
you can read: recovery/ holds the copies of unsaved text, and backup/ holds the short-lived copy
of a file that a save makes while it overwrites the file in place. See Files and Recovery.
Starting with no file, Unryu offers back the newest unsaved text that was left behind, if there is any. Opening a file that has a recovery copy offers that copy. Nothing is lost by choosing Keep for Later.
A short tour
The window has a menu bar and a toolbar at the top, a status bar at the bottom, and four panels in between. The editor is in the middle, with a tab for each document. The Sidebar on the left holds the Outline (the file's functions, types, variables and macros), the list of open documents and the project's files. Details on the right explains the name or the brace at the cursor. The Message Window at the bottom holds the status messages, search results, the compiler's messages and a terminal. Every panel can be moved, floated, resized and closed, except the editor itself; View > Reset Layout puts them back.
- Open a C file with Ctrl+O. After a moment its names take their colors, and the Outline fills with its symbols. Click a symbol in the Outline to go to it.
- Put the cursor on a brace. It and its partner take the theme's brace-good color (green in the default Dark theme); a brace with no partner takes brace-bad (red in Dark). Delete a closing brace and watch the faded "ghost" brace that shows where it belongs; Ctrl+Shift+J writes it back.
- Rest the pointer on a function name to see its declaration and documentation. F12 goes to its definition, and Alt+Left brings you back.
- Ctrl+F finds text, Ctrl+H replaces it, and Ctrl+Shift+F searches a whole folder. The results go to the Message Window; click one to go there.
- Save the file and press F8 to compile it, or F5 to run the program. The Terminal tab of the Message Window is a full terminal with your shell.
- Open Edit > Preferences (Ctrl+Alt+P) to choose fonts, themes, indentation and keys. View > Change Color Scheme... changes the colors of the text at once.
Help > Keyboard Shortcuts lists the main keys in the Details panel; Keyboard Shortcuts has every key, with explanations.
The parts of Unryu
The pages of the manual
- The Window
The layout of the window and how to arrange it: document tabs, the Sidebar (Outline, Documents, Files, Debug), Details, the tooltip over a name, the Message Window, the status bar, the toolbar, the View menu, full screen, a Markdown document, the menus, and a second window.
- Files and Recovery
New documents and templates, opening files, saving safely, encodings and line endings, files changed on disk, recovery copies of unsaved text, sessions and recent files, printing and Page Setup.
- Editing
The Edit and Document menus: undo, the editing commands, indentation, typing help such as auto-indent and closing brackets, word and snippet completion, folding, markers, change history, drag and drop and block selection, Go to Line, Back and Forward, and the Tools menu.
- Find and Replace
The Find and Replace dialogs and their options, regular expressions and multi-line search, Find All and Replace All, Find Usage, Mark All, and Find in Files.
- Build and Run
The Build menu and its commands, setting build commands for a language or a project, Execute, the terminal in the Message Window, the compiler's messages, the compiler check (Ctrl+Shift+B), and projects.
- Debugging
GDB in the Terminal tab and Unryu around it: breakpoints in the margin, stepping, the stack, locals and watches, values on hover, and each project's debug session.
- Git
The git mode of a repository (off, read or full), the change bar against the last commit, blame, the status, commit, revert, pull and push, and Set Up Git.
- Analysis
What Unryu understands about your code: the colors of names and tokens, brace matching and missing braces, definitions and declarations, the Outline, and what Details shows.
- Safety
Why opening a file runs nothing: the sandbox that reads your code, the checks on what comes back, and the limits on the compiler that Ctrl+Shift+B runs.
- Languages in Files
The language files: where they are, what each part of one means, and how to change a language or add a new one.
- Themes
The window theme and the editor theme, how to choose them, the editor theme file and its keys, and how to write your own color scheme.
- Preferences
Every page of Edit > Preferences, each setting on it, and its key in
unryu.conf. - Keyboard Shortcuts
Every default key, grouped by menu and by part of the window, the keys of the dialogs and the terminal, and how to change keys in Preferences > Keybindings.