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.

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:

CommandWhat it does
makeBuilds the program ./unryu. The build treats every warning as an error.
make installInstalls 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 cleanRemoves 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:

FolderWhat 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 ...

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/unryuWhat 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:

FileWhat it keeps
unryu.confYour settings from Preferences and the View menu.
keybindings.confThe keys you changed in Preferences > Keybindings.
build.confYour build commands.
terminal.confThe terminal's settings.
snippets.confYour own snippets, made when you open it from Tools > Configuration Files.
documentation.confYour own commands for Help > Look Up Documentation.
words.txtThe words you added to the spelling dictionary.
projects.confThe project corrections from the Tools menu, and the project build commands you approved.
dock_layout.txtWhere the panels are.
window.txtThe window's size and place.
open_files.txtThe 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.txtFile > Recent Files and Recent Projects.
workbenches.txtFile > Workbench: each workbench's projects, folders, open files and bookmarks.
debug.confEach project's debug session: the program, its arguments and folder, the breakpoints and the watches.
marked-folders.txtThe Files tab's marked folders.
file_settings.txtEach 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.

  1. 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.
  2. 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.
  3. Rest the pointer on a function name to see its declaration and documentation. F12 goes to its definition, and Alt+Left brings you back.
  4. 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.
  5. 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.
  6. 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 editor (unryu) The Window tabs, sidebar, Details, messages, View menu Files and Recovery open, save, encodings, recovery, sessions, print Editing Edit, Document menus, completion, folding Find and Replace Find, Replace, Find in Files Build and Run commands, Execute, terminal, projects Themes window themes and editor themes Preferences every page and setting, its key in unryu.conf Keyboard Shortcuts every key, and how to change them This page building, installing, the first run, a tour Safety the sandbox (jail) around the code reader, the checks on its answers, and the compiler that runs only when you ask (Ctrl+Shift+B) Analysis a sandboxed reader for each document: colors, braces, definitions, the Outline and Details Languages in Files the .lang file of each language: words, comments, strings, blocks and declarations text answers
Each box links to its page. The boxes with a red border run in a sandbox: Unryu reads each file there, in a separate process, and not in the editor itself. The editor sends the text and gets back only checked answers.

The pages of the manual