- C 97.8%
- Python 1.7%
- Shell 0.1%
- A Markdown document reloaded (File > Reload, or the file changed on the disk) showed its new text in Plain Text only: the formatted view kept the old text until it was switched to Plain Text and back. Loading the text did not mark the view as out of date. Reload now also counts the last typing in the formatted view as unsaved before it asks. - xtk_richtext.c from xtk: in a code block a click, a drag, Up and Down measured the line in the body font while it is drawn in the monospace one, so the caret and the selection landed on other characters than the ones under the pointer. A drag whose button release went elsewhere now ends when the button is up, so the selection no longer follows the pointer afterwards. - xtk_entry.c from xtk: the right-click menu of a text field (the toolbar's search, Find and Replace) closed as soon as it opened. The menu's own keyboard grab sends the field a FocusOut, and the field hid its menu on it. - doc/window.html: the formatted view shows the new text when the file is read again; the wiki made again from the docs. - The version is 1.14 (xtk 1.13). |
||
|---|---|---|
| artwork | ||
| doc | ||
| editor_themes | ||
| hosho | ||
| icons | ||
| kami | ||
| languages | ||
| screenshots | ||
| shell | ||
| src | ||
| templates | ||
| test | ||
| tools | ||
| xtk | ||
| LICENSE | ||
| logo.png | ||
| Makefile | ||
| README.md | ||
| unryu.desktop | ||
Unryu
A source code editor that understands the code it shows: a light editor with real parsing underneath instead of pattern matching.
Unryu (雲龍紙, "cloud dragon" paper) is a Japanese paper whose long fibers show through the sheet — as the editor shows the structure of the code. It is made from Kami (紙, paper), the library that does the understanding.
What it does
Braces you can trust. Braces are text. The one beside the
cursor and its partner turn the theme's "brace good" color (green), with a
tint for how sure Kami is of the pair; one with no partner turns "brace bad"
(red). The pairs are Kami's, from the parse, so they hold in broken code too.
A missing brace is drawn faded (or flashing) where it most likely goes, and
Ctrl+Shift+J writes it in. Details says why, with the partner in other #if
configurations too. ( ) and [ ] work the same way, and so does every other
pair the language file declares: a string's quotes, a comment's ends, HTML and
XML tags (not <br>, nor a </li> HTML lets you leave out), the < > of
generics, block words (def … end, if … fi, \begin{x} … \end{x}), an
#if … #else … #endif chain, and « » or “ ” in prose. A string left
open, an end tag or a fi that is missing shows as a ghost too.
Go to anything. Ctrl+Alt+O opens any file of the project by typing part of
its name; > runs any command (Ctrl+Shift+P), @ goes to a symbol of the
document, # to anything the project defines in any language (Ctrl+Alt+G).
Unryu indexes every file of the project in a jail and keeps the index, so F12
goes to a definition in any file.
Workbenches. File > Workbench keeps named sets of projects, each with its
own tabs and bookmarks. Every project of the open workbench is indexed, so F12,
Find Usage, Rename Symbol and Go to Anything reach all of them. A workbench can
also hold a folder such as ~/Projects that only shows its files: the projects
in it are the ones you add, and each shows once, in its place in that tree. The Files tab also filters, follows the document in
front, makes, renames and deletes files, and keeps marked folders at the top.
Two views, and Compare. View > Split Window shows a second view beside the document or under it: the same document (type in either; Undo is the document's), or another one to read or edit beside it. The Compare menu sets the document beside the file on disk, the last commit or another open document, in the manner of Meld: the changed lines tinted, the characters that changed darker, bands joining each change's lines on the two sides with arrows that copy it across, the changes on one scrollbar that scrolls both sides (or one in each, as you choose), and Alt+arrows to step through the changes and copy them.
Git, read in a jail. Unryu reads a repository's .git itself, packs and
deltas too, in a jail and without running git: a bar in the margin beside
each line added, changed or deleted since the last commit, Next Change and
Previous Change, a popup with the old text and Undo This Change, blame for the
cursor's line, and "+N −M on branch" in the status bar. It asks once per
repository; with Full it also commits, reverts a file, pulls, pushes and
resolves conflicts through git (Tools > Git). See doc/git.html.
A debugger. Debug > Start (Ctrl+F5) runs the program under GDB, with GDB's
own console in the Terminal tab, where the program reads and writes too.
Breakpoints are dots in the margin (Ctrl+F9, or Shift+click) that move with
their lines; F6, F7 and Shift+F7 step, Ctrl+F7 runs to the cursor; an arrow
and a tinted line show where it stopped. The sidebar's Debug page has the
stack, the locals, watches and the breakpoints, and the popup over a name says
its value now. Each project keeps its breakpoints and watches. See
doc/debug.html.
Help while you write. Snippets with places to fill (Tab goes to the next),
in the completion list too, and a call's parameters filled in from its
declaration. Edit > Insert Comments writes a documentation comment in the
language's style. Tools > Check Spelling waves a line under misspelled words in
comments and strings (the language file says where), with a word list of your
own. Shift+F1 looks a name up (man pages, pydoc3 and others, in a jail). A
color value in the text gets a swatch in its popup; Ctrl+click opens the color
chooser. LaTeX gets \ref and \cite completion from its labels and .bib
files, and a wave under a missing label. Tools > Translation steps through a
.po file's untranslated and fuzzy messages and checks its % directives.
Marks and an overview. Bookmarks, and numbered ones (Ctrl+Shift+0–9 sets,
Ctrl+0–9 goes). View > Show Minimap draws the whole document beside the
scroll bar, its marks with it. The Message Window's Tasks tab lists every
TODO, FIXME, XXX, HACK and BUG in the project's comments. Code
Tools run a checker or formatter for each language (Ctrl+Alt+F formats the
document). Unryu can sit in the tray, and tells there when a build or the
debugger stops while the window is hidden.
Names colored by what they are. Functions, types, macros, parameters, members, enumerators, labels, file-scope variables — each its own color, from the parse, not from a word list. The place a name is declared is tinted, and every use of the name at the cursor is highlighted (scopes respected: a local that hides a global is a different name).
Any language, from a file. Kami reads a language from a language file in
languages/ (copied to ~/.config/unryu/languages/ at the first start, where
you can change it): its file names, comments, strings, numbers, operators,
words by class, declarations, blocks and comment marker. One lexer reads every
language, C and C++ too (their files are built into Kami). The names come from
Kami's C grammar, its C++ reader (namespaces, classes, methods, templates), or
the file's patterns; the Outline shows each class with its methods. 83
languages, 80 of them with a sample in test/languages/ (make -f maint.mk languages writes
them from tools/languages*.py). HTML holds its CSS and JavaScript, Markdown
its fenced code, PHP its markup. Document > Set Filetype... changes the
language of the open document. See doc/languages.html.
Every symbol at hand.
- Hover over a name: its kind, declaration and documentation comment.
- Ctrl+click or F12: go to its definition (a function's body, not its prototype).
- Details panel: the symbol at the cursor — declaration, documentation, where it is declared and defined, how often it is used.
- Outline panel: the file's functions, types, variables and macros; click one to go there.
The compiler, only when you ask. Unryu understands code without a
compiler and never runs one by itself: not when a file opens, not while you
type. Ctrl+Shift+B is the only thing that does. It tries a brace in doubt in each
place it could go and asks the project's compiler (from
compile_commands.json or compile_flags.txt) which of those compile;
Ctrl+Alt+1..9 applies one, Ctrl+Shift+B again stops it. Help > Compiler explains it.
Your work is safe. Quitting, closing the window, reloading and opening
another file all ask first when there is anything unsaved, and the title marks
it with a *. Undo goes back through everything you typed, by words and runs,
up to 64 MB of edits; undoing back to what was saved clears the mark. A save
either fully replaces the file or leaves it exactly as it was, whatever goes
wrong, and the file stays what it was: permissions, symlinks, hard links,
extended attributes. A read-only file is refused, and a file changed on disk
since it was read is not overwritten without asking.
Unsaved text outlives the program. Two seconds after you stop typing (every
30 seconds if you do not stop), and before any dialog, a private copy goes to
~/.cache/unryu/recovery. So it does at once when the display goes away or the
program is told to end. Opening that file afterwards offers the text back, and
starting with no file offers the newest one left behind. Recover puts it in as
an edit over the text on disk: it counts as unsaved, Undo shows what differs, and
Save still asks if the file has changed since. Keep for Later (or Escape) leaves
it for next time; only Discard removes it. A real crash loses at most what was
typed since the last copy.
A tab per file. Each has its own undo and its own understanding of its code, and each asks about its own unsaved work. A file that is not text (one with NUL bytes in it, whatever it is called) is refused, not opened.
It follows what your code uses. A name from a header, your own, another
project's or the system's, shows that header's declaration and documentation in
Details and in a tooltip, in its color, and F12 or Ctrl+click opens the header in
its own tab at that name, so the way back is the tab you came from. Struct members
follow the type they are taken from, through a->b.c, casts, indexes and function
results, so two structs can share a member name. Headers are found through the project's flags, beside the file, in the
system's include folders, and anywhere in the file's project, with no flags needed:
the project is its repository, or the highest folder with a build file.
Search. Find and Replace have the usual options, keys and history,
the question when a search gets to the end, Find All and Replace in all open
files, and Find Usage. Find in Files searches a folder itself, without grep.
Results go to the Message Window at the bottom; a click goes to the match.
doc/find_replace.html shows the design.
Editing. The usual keys (Help > Keyboard Shortcuts lists
them all), Go to Line, Back and Forward through jumps, and Edit >
Commands and Format: duplicate, move and delete lines, comment toggling, indent,
reflow. Typing gets auto-indent, a } put back in place, smart Home, line
breaking, and brackets and quotes that close themselves where Kami says no
partner is waiting (never in a string or comment), go around a selection, are
stepped over, and give { } blocks and struct S { };. Code folds by the brace pairs Kami is
certain of, so a fold never hides the wrong lines. Each document has its own Document menu
settings — wrapping, indentation, read only, BOM, line endings — kept for the
file between sessions, and keeps a file's CRLF and BOM when saving. A file
changed or deleted on disk is noticed when the window gets the focus.
doc/editing.html shows the
design.
Packages with Debwright. For a program with a Debwright project (a
.debwright file in its folder), Build > Package makes its Debian packages
with Debwright: for every release the project names, one of them, or this
system's alone, the output in the Compiler tab with its errors marked in the
files. Open in Debwright opens the project in Debwright's window. A folder
with no Debwright project yet (a Makefile's, say) gets Build > Package > Make
a Package in Debwright, which starts Debwright's New Project for the folder.
A terminal. The Message Window has a Terminal tab with Unryu's own
terminal: Hosho, compiled in. Your shell starts in the folder of the current
document the first time the tab shows. Control and a click on a file name in
the output opens that file in the editor, at the line and column after the
name; on a web or mailto: address it opens the browser. Edit > Commands > Send Selection to
Terminal types the selection into the shell, and Build > Execute runs the
program there. With shell integration (bash, zsh, fish, ksh, dash and
others), a mark beside each prompt shows its command's result, and the tab's
label tells what the shell does: amber for text that waits at the prompt,
blue for a running command and green or red for its result while the
terminal does not show. Emoji, flags and joined emoji are one character
each, and programs can show pictures (sixel, iTerm2 and Kitty). The right button has Copy, Paste, Find and
the font size. Edit > Preferences > Terminal sets its colors (as the editor
theme, one of Hosho's themes, or a theme file), its font and each of its
settings.
Yours to arrange. Panels dock, float, resize and pin. Fourteen window
themes; the editor themes give a key to every color of a document (the
view, each kind of token and name, the marks), and are made with
make -f maint.mk editor-themes (View > Change Color Scheme...). Edit > Preferences has a page
for each part; what Unryu does not do yet is there greyed. It sets the
themes, a font for each part of the window (interface, editor, Details,
Outline — any installed font for any of them) and for printing, line numbers,
wrapping, highlighting, wrapping searches and the Outline's order. Printing
draws every character from its font's outlines, any script, with a fallback
font for what the chosen one lacks; a PDF keeps the text searchable.
Screenshots
The file in most of these pictures is the build demo, test/demo/demo.c; the
picture of the terminal has a file of Hosho, the one of Git a file of Unryu.
Keys
Help > Keyboard Shortcuts lists every key. The ones Unryu adds:
| Key | Does |
|---|---|
| F3 / Shift+F3, Ctrl+F3 / Ctrl+Shift+F3 | Find next / previous; the selection or word |
| F12, Ctrl+click | Go to definition (Ctrl+T works too) |
| Ctrl+Alt+Down / Ctrl+Alt+Up | Next / previous brace that is not certain |
| Ctrl+Shift+J | Insert the missing brace |
| Ctrl+Alt+B / Ctrl+Alt+Shift+B | Select inside the pair / with its ends; again: the next pair out |
| Ctrl+Shift+B | Run the compiler to suggest repairs; again to stop |
| Ctrl+Alt+1 .. Ctrl+Alt+9 | Apply a repair the compiler accepts |
| Ctrl+F5 / Ctrl+Shift+F5 | Debug: start or continue / stop |
| F6 / F7 / Shift+F7 / Ctrl+F7 | Debug: step over / into / out; run to the cursor |
| Ctrl+F9, Shift+click in the margin | Debug: a breakpoint on the line, or off |
| Ctrl+Shift+0 .. 9 / Ctrl+0 .. 9 | Set a numbered bookmark / go to it |
| Shift+F1 | Look up the name at the cursor in the documentation |
| Ctrl+Alt+F | Format the document with its language's code tool |
Building
make # ./unryu
make install # the program to $(PREFIX)/bin, its files to $(PREFIX)/share/unryu (PREFIX=/usr/local)
make clean
make -f maint.mk check # the tests: what a hostile project or file, a save, a recovery copy or undo must never do
The Makefile only builds, installs and cleans. maint.mk holds the tests and the
tools that remake files kept with the source (languages, kami-builtin,
editor-themes, fit-themes, artwork); building Unryu needs none of them.
Needs X11, Xrender, Xft, fontconfig, freetype, Xcursor, Xext and Xpm (development packages). Unryu compiles in only what it uses:
src/— Unryu's own source (unryu.cand its dialogs)kami/— the files it uses from Kami (the Kami project'ssrc/)xtk/— the files it uses from xtk (the Xtk project'ssrc/)hosho/— the terminal of the message window: Hosho's library (the Hosho project'ssrc/) and its widget (that project'sdemo/)
All are listed file by file in the Makefile; when Unryu starts using
another one, copy it in and add it to the list. Built with
-Wall -Wextra -Wpedantic -Wconversion -Wshadow -Werror under
-std=gnu17.
Running
./unryu file.c other.h ...
The program's files (languages/, editor_themes/, icons/, doc/) are
found beside the program or one folder up, and for an installed Unryu in
<prefix>/share/unryu. Help > About shows the version. Settings, the
dock layout, the window's place and the open tabs are kept in
~/.config/unryu; copies of unsaved text, for recovery, in ~/.cache/unryu.
Brace answers come from the text alone each time a file opens: nothing
remembered from an earlier session decides them.
Opening code you do not trust
Opening a file runs nothing, and the code that reads it runs in a sandbox of its
own, a separate process for each open file. So that an API anywhere can be followed,
it can read the file's own folder and the one above, the system's folders, and
everything visible in your home folder, but nothing hidden there (.ssh, .gnupg,
.config) unless the file you opened is itself in such a folder. It can answer the
editor down one socket. It can write nothing, open no socket, start no
program and signal nothing. If a hostile file found a bug in it, your files, your
display and your unsaved text would all be out of reach, and its answers are checked
before the editor uses them. If it crashes or hangs, you lose the colors until the
next edit and nothing else, and Details says so. The window never waits for it, so a
big file stays editable while it is read. With no sandbox on the system it does not
run at all: the file can still be edited and saved, as plain text.
The brace repairs that Ctrl+Shift+B tries are parsed in the same kind of sandbox,
in a process of its own. That process cannot run a program, so it hands each batch
of texts to the editor, which compiles them in the compiler's own sandbox (below);
everything it sends back is checked. A project's compile_commands.json and
compile_flags.txt, the images a Markdown document names and every picture a program
sends to the terminal (PNG, JPEG, GIF, BMP, sixel, compressed data) are taken apart in
one more process in the same kind of sandbox, xtk's worker, which may read no file at
all: the editor reads the bytes and hands them over.
Ctrl+Shift+B runs a compiler, and even then the
project does not get to choose a program. The compiler named in
compile_commands.json runs only if it is named like a compiler (cc, gcc,
clang, with any target or version) and it and its directory are owned by root
and writable by nobody else. Any other falls back to the system's cc or c++,
and Details says so. To allow your own toolchain, list it in
~/.config/unryu/unryu.conf, with colons between paths:
trusted-compilers = /home/me/x-tools/bin/arm-gcc:/opt/mine/bin/icx
Only flags that change whether code compiles reach the compiler; those that
could load code or write files (-fplugin, -wrapper, -B, -specs,
-Xclang, @file ...) are dropped, and Details counts them.
A compiler wrapper such as ccache or distcc never runs: for ccache gcc ...
the check runs gcc itself, and Details names the wrapper it skipped.
Headers of a library you installed in your home folder are found through
check-folders (at first ~/.local/include) and CPATH: folders you name
yourself, which are let in even when hidden. A project's own files can never
name a hidden folder of your home.
A check runs in a sandbox and cannot touch your file. It compiles copies in a
private temporary folder with -fsyntax-only, without a shell. Using Landlock
and seccomp, with no root and no extra library:
- It can read only the system's headers and shared libraries, its own toolchain and this project: the rest of your home folder is out of reach, and a project cannot name its way in. A folder holding your whole home is never let in.
- It can write nothing, create nothing, delete nothing, empty nothing.
- It can open no socket of any kind, so no network, no X server, no D-Bus.
- It can run nothing but the compiler and the parts of it the compiler starts
(
cc1). No shell, nopython3, nocurl, nogit, nomake. It cannot read the folders those live in either, so they cannot be loaded another way. It cannot inspect other programs, nor signal them (on Linux 6.12 and later; before, it can still signal one process by its number, never all of them or a group). - Of your environment variables it gets only CPATH, C_INCLUDE_PATH and CPLUS_INCLUDE_PATH, beside PATH and LC_ALL.
No sandbox means no compile: on a kernel without Landlock (before Linux 5.13, or with it turned off) or a processor other than x86-64 or ARM64, Ctrl+Shift+B says so and runs nothing. Everything else in Unryu works the same there.
It is also kept small: low priority, at most 4 at once and never more than half
the processors, each limited to 2 GB of memory, 30 seconds of CPU and 15 seconds
of waiting, 60 seconds for the whole check. If Unryu is killed, the compilers go
with it. make -f maint.mk check tries to break out of all of this.
License
Artistic License 2.0.









