Table of Contents
- Build and Run
- 1. Two different things that run a compiler
- 2. The Build menu
- 3. What happens when you run a build command
- 4. Make Custom Target
- 5. The Compiler tab and the errors
- 6. Execute and the terminal
- 7. Set Build Commands
- 8. Placeholders
- 9. Where the commands are saved
- 10. The default commands
- 11. Projects
- How Unryu finds the project
- Correcting it
- Commands only for one project
- A settings file in the project's folder
- 12. The built-in terminal
- Using it
- The right-click menu
- The terminal's keys
- Shell integration
- The color of the Terminal tab's label
- The terminal's settings
- 13. Other commands that send text out
- 14. The compiler check (Ctrl+Shift+B)
- 15. Compiler flags from the project
- 16. Code tools
- 17. Known limitations
Build and Run
How to compile, build, lint and run your files from the Build menu, how to change the commands it runs, how Unryu reads the compiler's errors and takes you to them, how Execute uses the built-in terminal, how projects change the commands, and how the sandboxed compiler check (Ctrl+Shift+B) works.
1. Two different things that run a compiler
Unryu has two separate features that involve a compiler, and they behave very differently:
- The Build menu runs the commands you set up (by default
gcc,makeand so on) exactly as if you typed them in a shell. They run as you, with all your permissions, in a folder you choose, and they can write files. Their output goes to the Compiler tab of the message window, and Execute runs your program in the Terminal tab. Sections 2 to 11 describe this. - The compiler check (Navigate > Suggest Repairs,
Ctrl+Shift+B) is for C and C++ only. It asks a compiler whether your text compiles and which brace repairs would make it compile. It never builds anything, it only works on temporary copies, and it runs in a locked-down sandbox. Its errors go to the Messages tab. Section 14 describes it.
Unryu never runs either of them by itself: not when a file opens, not while you type. Only the menu items, their keys and the toolbar buttons start them.
2. The Build menu
The Build menu is made from your build commands, so its rows change with the language of the current document and with your settings. From top to bottom it holds:
- The language's commands (three by default: Compile, Build, Lint; for a Makefile, Make, Make Custom Target... and Make Clean).
- The independent commands, the same for every language. They are yours to fill in: there are none by default (Rust has Cargo Build, Cargo Test and Cargo Bench).
- Next Error and Previous Error.
- The Execute commands of the language (two by default: Execute and a second one).
- Package, when Debwright is installed (see below).
- Set Build Commands.
A separator stands between the groups. The labels are the ones you (or the defaults) gave each command, so for a LaTeX file the first row reads "LaTeX -> DVI", for a Makefile the first rows read "Make", "Make Custom Target..." and "Make Clean", and for Rust the independent rows read "Cargo Build", "Cargo Test" and "Cargo Bench".
| Item | Default key | What it does |
|---|---|---|
| Compile (the first language command) | F8 |
For C: gcc -Wall -c "%f", which compiles the current file to an object file. |
| Build (the second language command) | F9 |
For C: gcc -Wall -o "%e" "%f", which compiles and links the current file into a program. |
| Lint (the third language command) | none | For C: cppcheck with warnings and style checks. Some languages use this row for something else (Go: Test, LaTeX: Bibtex, Pascal: Run script). |
| For a Makefile: Make, Make Custom Target..., Make Clean (its three language commands) | F8, F9, none |
Make runs make; Make Custom Target... asks you for a target or options first, then runs make with them (section 4); Make Clean runs make clean. They run in the Makefile's folder. Geany has no commands for a Makefile; these are Unryu's. |
| The independent commands | Shift+F9, Ctrl+Shift+F9, Shift+F8, none |
Whatever you set in Set Build Commands (section 7). There are none by default, so these rows are not in the menu until you add one. For example, to run make at the top of your project from any of its files, set the first one to the label "Make" and the command make. |
| Next Error | none | Goes to the next line of the Compiler tab that names a file and a line, selects it, and opens that place in the editor. It beeps when there is none after the selected line. |
| Previous Error | none | The same, backwards. |
| Execute (the first Execute command) | F5 |
For C: "./%e", which runs the program that Build made. It runs in the Terminal tab (section 6). While the program runs, this row reads Stop, and choosing it (or pressing F5) stops the program. |
| The second Execute command | none | Empty for most languages. Some have one: Rust "Cargo Run", Swift "Execute as Script", Kotlin "Execute Script", LaTeX "View DVI File". |
| Package | none | Makes the project's Debian packages with Debwright: see Packaging with Debwright below. |
| Set Build Commands | none | Opens Preferences on its Build page, at the tab of the language's commands (or at the independent commands when the document has no language). See section 7. |
When a row is greyed. A command row cannot be chosen when it has no command line, when the document has never been saved (the commands need its file name), or while a build is already running (for the language and independent commands) or while a program of Execute is running (for the Execute commands). An Execute command whose program is a path ("./%e", "./%t") is greyed until that program exists and can run: next to the file, or at the top of the project (section 6). Next Error and Previous Error are greyed until a build has found at least one line that names a file. Set Build Commands is always available.
When a row is missing. A command with neither a label nor a command line has no row at all. A command with a command line but no label shows its usual name (Compile, Make, Execute, "Execute (2)"), or its command line when it has no usual name.
The keys follow the place, not the label. F8 always runs the first language command, whatever you call it, F9 the second, and so on. You can change each key in Preferences > Keybindings, group Build, where the actions are named Compile, Build, Lint, Make all, Make custom target, Make object, Make clean, Next error, Previous error, Run and Build options (Set Build Commands). The menu shows each row's current key. See Keyboard Shortcuts.
The toolbar. The toolbar's Build and Execute buttons run the second language command and the first Execute command (for a Makefile, Build is Make Custom Target..., which asks for a target first). A Compile button, for the first language command, can be added in Preferences > Interface > Toolbar; it is not on the toolbar at first, because for one file Build does what Compile does and links the program too. The buttons are greyed whenever their menu rows are.
Packaging with Debwright
Debwright makes Debian packages (.deb) of a program, for this system and for other releases of Debian, Devuan and Ubuntu: a package for an older release is built against that release's own C library, so it installs and runs there. A project is set up once in Debwright's window, which keeps it in a .debwright file in the program's folder. When the debwright program is installed, the Build menu has a Package row for the project's folder (or, with no project, the file's folder). When that folder has no .debwright file yet, its flyout holds Make a Package in Debwright, which opens Debwright on the folder and starts its New Project there; once the project is saved, the flyout holds:
| Item | What it does |
|---|---|
| All Releases | Makes a package for each release ticked in the project (Build the Package when none is ticked: one for this system). |
| This System Only | Makes the package for this system's release alone. |
| Each release, such as Devuan 5 Daedalus | Makes that release's package alone. |
| Open in Debwright | Opens the project in Debwright's window, to change it: the releases, the build dependencies, the description, the files and the rest. |
Like a build command, a Package row saves your changed documents first, then runs Debwright (debwright --build) in the folder of the .debwright file, its output in the Compiler tab. A compiler's error lines are marked in your files and Next Error goes to them, as for any build. While it runs, its row reads Stop. The first build for a release downloads that release's files, so it needs the network; Debwright's manual explains what is downloaded and kept. The Package row is not there when Debwright is not installed: Unryu's package suggests it.
3. What happens when you run a build command
- Unryu saves every open document with unsaved changes that has a file, so the command sees the text you see: a compile reads the file's headers too, and Make builds the whole project. A document that has never been saved is left as it is. Lint looks at the one file, so for a command labelled "Lint" only the current document is saved; Execute also saves only the current document. If a save fails or you cancel it, nothing runs.
- If the document has never been saved, nothing runs, and the status bar says "The file is not saved: the build commands use its name."
- The placeholders (
%f,%eand the others, section 8) in the command and in its working directory are replaced. - The working directory is checked. An empty working directory means the folder of the file for the language's commands, and the project's folder (
%p, the file's folder outside a project) for the independent commands, so that Make runs at the top of the project from any file in it. If the folder does not exist, nothing runs and the Status tab says "Invalid working directory". - The command runs with
/bin/sh -cin that folder, so you can use pipes,&&, redirections and anything else the shell understands. It gets no input (its standard input is/dev/null); its output and its error output both go to the Compiler tab. - The Compiler tab is cleared and brought to the front. Its first line shows the full command and the folder, as
gcc -Wall -c "main.c" (in directory: /home/me/code). The error marks of the last build are removed from every document. - Each line of output appears as it comes. The editor never waits for the command: you can keep typing while it runs.
- When it ends, the last line says "Compilation finished successfully." (exit status 0) or "Compilation failed." (any other status). The same words go to the Status tab, and Unryu beeps when Preferences > General > "Beep on errors or when compilation has finished" is on (it is by default).
Stopping a build. While a build runs, its own row in the Build menu reads Stop, and its key and toolbar button stop it too (for example F9 again, while Build runs). Unryu ends the command and every program it started; the Compiler tab ends with "Compilation stopped.", and so does the Status tab. The Compiler tab's label turns red, as for a failed build. Unryu does not beep.
Only one build runs at a time. While one runs, the other build rows are greyed, and their keys only show "A build is running already." in the status bar. Execute is separate: a program can run in the terminal while a build runs.
A build command is not sandboxed. It runs as you and can do anything you can do, which is what a build needs (it has to write its files). Only run commands you trust, and see section 11 for commands that come with a project's folder.
4. Make Custom Target
A build command whose label ends in "..." asks a question before it runs, as a menu row ending in "..." does everywhere. For a Makefile that is Make Custom Target... (F9). A small dialog titled with the label (without the dots) says "Enter custom options here, all entered text is passed to the command" and the command. Type a target or options, such as install or -j8 test, and press OK. Unryu adds your text directly after the command line and runs the result. When the command line does not already end with a space (make does), Unryu puts one between them. Cancel runs nothing; OK with an empty field runs the command as it is. Placeholders (section 8) in your text are replaced as well.
The field starts with the text you typed last time, until Unryu quits.
It is the label that decides, whatever the command's place: to be asked for a test's name before cargo test runs, label that command "Cargo Test...". A command whose label has no dots never asks.
5. The Compiler tab and the errors
The Compiler tab of the message window (see The Window) shows everything a build command writes, one line each.
How Unryu recognizes an error line
Each line is checked for a file name and a line number:
- If the language has an error regular expression (a pattern, set in Set Build Commands, section 7), Unryu uses it. It is a POSIX extended regular expression. Of its groups in parentheses, the first one that matched only digits is the line number, and the first other one is the file name. Some languages have one by default; see the table in section 10.
- Otherwise Unryu uses the form that gcc, clang and most other tools write:
file:line:orfile:line:column:at the start of the line (spaces in front are allowed). The lines "In file included from x.c:3," and "from x.h:2:" that gcc writes are recognized too, with the file name after the words. "file:line," and "file:line)" count too. A file name with a space in it is not recognized by this form; use an error regular expression for such names. - The independent commands (Make and the others) have an error regular expression of their own. When it is empty, they use the language's.
A file name that is not absolute is taken from the working directory of the command, so src/main.c:12: from make run in your project folder finds the right file.
A recognized line is a warning when it contains "warning" or "Warning", a note when it contains "note:" or "Note:" (and the "In file included from" lines are notes), and an error otherwise. Lines that name no file and line are shown as plain text. In the built-in form these words are looked for only in the text after the line number; with an error regular expression, in the whole line.
What you see
- Each error, warning and note line has an icon in its own color. The colors come from the editor theme (
compiler-error,compiler-warning,compiler-note, andcompiler-successfor "Compilation finished successfully."). See Themes. - Click a recognized line to go there: Unryu opens the file if it is not open yet and puts the cursor at the start of that line. Back (
Alt+Left) returns to where you were. - Build > Next Error and Previous Error step through the recognized lines in order, from the selected line, and skip the plain ones.
- While the list is scrolled to its bottom, it follows new output. Scroll up, and it stays where you put it.
- Error indicators. Each error and warning line gets a red wavy underline in the editor (notes do not). This needs Preferences > Editor > Features > "Use indicators to show compile errors", which is on by default; switching it off removes all of them at once. Document > Remove Error Indicators removes them from the current document. A new build removes the old ones.
- The popup. Hover the mouse over a line that the last build reported: the popup shows "Error:", "Warning:" or "Note:" with the compiler's words, in the same colors, above the usual information about the name under the pointer.
- The file lists. In the sidebar's Documents list and Files list, a file in which the last build found an error is shown in the error color, and one with only warnings in the warning color.
- The tab label. While the Compiler tab is not the one in view, its label is blue while a build runs, then green when it ended well, amber when it ended well with warnings, and red when it failed. The color goes away when you look at the tab. The colors are the editor theme's
tab-running,tab-success,tab-attentionandtab-failure.
The error indicators are set in each open file when the build reports the line. A file you open after the build gets them when it opens, as long as it has not changed since the build started. If it has changed, its lines may have moved, so it gets no underlines rather than underlines on the wrong lines; its lines are still in the Compiler tab and a click still goes there.
6. Execute and the terminal
Execute runs your program so that you can see its output and type its input. How it does this depends on whether the Terminal tab is on (Preferences > General > Startup > "Load virtual terminal support", on by default; a change takes effect when Unryu starts again).
With the Terminal tab (the usual case)
- Unryu saves the document if needed and replaces the placeholders, as for a build.
- When the command's program is a path such as
"./%e", Unryu looks for it in the working directory (the file's folder, unless you set one), then at the top of the project, and runs it where it found it. Sosrc/main.cruns./mainthat the project's Makefile built at the top. When it is in neither place, Execute is greyed; its key only says "Nothing to run yet: build the program first." - It writes a small script in your private runtime folder (
$XDG_RUNTIME_DIR, or/tmp) that changes to the working directory, runs your command, and then prints a line of dashes and "(program exited with code: N)". - It brings up the Terminal tab (starting the shell if it is not running) and types
/bin/shand the script's name into the shell, with a space in front so that shells which skip such lines keep it out of your history. - The terminal gets the keyboard, so you can type into your program at once.
- While the program runs, Build > Execute reads Stop. Stop (or
F5) sendsCtrl+Cto the terminal, as if you pressed it there. Execute is free again at once, even if the program ignoresCtrl+C; such a program is yours to end in the terminal. - Pressing
Ctrl+Cyourself in the terminal ends only your program: the script still prints how it ended. When the script ends (or the shell ends), Execute is free again.
With shell integration on (section 12), Unryu refuses to type the line while text you typed is still waiting at the prompt ("The terminal has text at its prompt that was not sent. Send it or erase it first.") or while a command is running in the terminal ("A command runs in the terminal. Wait for it or stop it first."), because the line would land after your text or inside that program. Send or erase the text, or end the command, and try again.
The output of Execute is not read for errors; it stays in the terminal. To jump to a file:line that your program prints, hold Ctrl and click it in the terminal (section 12).
Without the Terminal tab
Unryu opens a terminal window with the Terminal command of Preferences > Tools (by default xterm -e "/bin/sh %c"). %c is replaced by the name of a script that changes to the working directory, runs your command, prints "(program exited with code: N)" and then waits for "Press return to continue". If the Terminal command is empty or has no %c, the Status tab says "Set a Terminal with %c in Preferences > Tools." While that window is open, Execute reads Stop, and Stop ends the terminal and the program in it.
7. Set Build Commands
Build > Set Build Commands opens Preferences at its Build page (you can also reach it with Edit > Preferences, Ctrl+Alt+P). The page shows the commands for the language of the current document, so open a file of the language you want to set up first. It has three tabs:
| Tab | What it holds |
|---|---|
| Language commands (for example "C commands") | The commands of the document's language: Compile, Build, Lint by default. They are kept separately for each language. |
| Independent commands | Commands that are the same for every language. They are yours: none by default (Rust has Cargo Build, Cargo Test and Cargo Bench). |
| Execute commands | The language's commands that run a program in the terminal. |
If the document has no language (plain text), the language tab and the Execute tab only say that the document has no language, and only the independent commands can be changed.
The controls on each tab
| Control | What it does |
|---|---|
| Only for the project "name" | Shown only when the document belongs to a project (section 11). When it is checked, the rows show and change the commands that apply only to the files of this project, instead of the commands for every project. The switch is shared by the three tabs: checking it on one tab checks it on all. The page opens with it checked when the project already has commands of its own. |
| Number of commands | How many commands of this group the Build menu shows, from 1 to 9. The rows below show or hide as soon as you change it. When you lower the number, the commands that go out of view are not deleted: they come back when you raise it again. |
| Error regular expression | On the language tab and the independent tab, not on the Execute tab. The pattern that finds the file name and the line number in the output (section 5). Empty on the language tab means the built-in gcc form; empty on the independent tab means "use the language's". |
| Label | The command's name in the Build menu. |
| Command | The command line to run with /bin/sh -c. The placeholders of section 8 are replaced. |
| Working directory | The folder the command runs in. Empty: the folder of the file for the language's commands and Execute, and the project's folder for the independent commands (section 3). Placeholders work here too, so %d/.. is the folder above the file's. |
| Reset | Puts the row back to its default. With "Only for the project" checked, it puts the row back to the command for every project instead. |
The note under the rows repeats the main rules: the placeholders that are replaced, that a command with no label and no command line does not show in the menu, and that a project's own command replaces the one for every project.
Apply or OK saves the changes to build.conf (section 9) and remakes the Build menu at once. If nothing on the page changed, the file is not written. "Could not save the build commands." in the Status tab means the file could not be written.
8. Placeholders
These are replaced in the command line and in the working directory just before the command runs:
| Placeholder | Becomes | For /home/me/code/main.c, cursor on line 42 |
|---|---|---|
%f |
The file's name | main.c |
%e |
The file's name without its last extension | main |
%d |
The folder of the file | /home/me/code |
%p |
The project's folder (section 11). When the file belongs to no project: the folder of the file, as %d |
/home/me/code (when /home/me/code is the project) |
%l |
The line number of the cursor, from 1 | 42 |
%t |
The program the Makefile builds: the Makefile in the file's folder, or the file itself when it is one. It is the first rule's target, or for all (and default) the first thing that rule needs; $(NAME) of a variable set above it is replaced. Unryu's own; empty when the Makefile names it in a way Unryu does not follow |
unryu (for all: unryu) |
%% |
A single % |
% |
Any other % sequence is left as it is. The values are put in as they are, without quotes, so keep the quotes the defaults have ("%f") for file names with spaces. A command that becomes too long after the replacement does not run ("The build command is too long.").
9. Where the commands are saved
Your commands are kept in ~/.config/unryu/build.conf. Only what differs from the defaults is written there; a command you put back to its default disappears from the file. You can open the file with Tools > Configuration Files > build.conf (Unryu creates it with an explanation at its top if it does not exist yet) and edit it by hand; Tools > Reload Configuration reads it again. Do this before you change the Build page in Preferences, or the Build page writes over your edits.
| Section | What it holds |
|---|---|
[build] |
The independent commands, and their error_regex. |
[c], [python], ... |
The commands of one language, by the language's short name (the name of its file in Languages), and its error_regex. |
[none] |
Language and Execute commands for documents with no language. Set them by hand here; Preferences cannot. |
[build-menu] |
The number of commands in each group: number_ft_menu_items (language), number_non_ft_menu_items (independent), number_exec_menu_items (Execute). |
[project:/home/me/code/thing] |
The independent commands only for that project. |
[project:/home/me/code/thing:c] |
A language's commands only for that project. |
The keys are named as in Geany: FT_00_LB, FT_00_CM and FT_00_WD are the label, the command and the working directory of the first language command; NF_ keys are the independent commands and EX_ keys the Execute commands; the number counts from 00. For example:
[c]
FT_01_CM=gcc -Wall -O2 -o "%e" "%f" -lm
EX_00_WD=%d/build
[build-menu]
number_exec_menu_items=1
Because the key names are Geany's, you can copy the command lines of a Geany filetype file's [build-menu] section into the language's section here. Unryu does not read Geany's own files.
10. The default commands
Unryu has these defaults built in (taken from Geany's filetype definitions). The number in front is the command's place in its group: in the language column, 1 is Compile (F8), 2 is Build (F9) and 3 is Lint; in the Execute column, 1 is Execute (F5). A language that is not in the table has no default commands. The independent commands have no defaults, except where the table lists some.
| Language | Language commands | Execute commands | Error regular expression |
|---|---|---|---|
| Abaqus | 1. Datacheck: abaqus job="%f" interactive datacheck2. Run Job: abaqus job="%f" interactive |
1. Execute: abaqus job="%f" interactive datacheck |
|
| Ada | 1. Compile: gcc -Wall -c "%f"2. Build: gnatmake "%e" |
1. Execute: "./%e" |
|
| Arduino | 1. Build: arduino --verify "%d/%f" --board arduino:avr:uno2. Build (Verbose): arduino --verify --verbose-build "%d/%f" --board arduino:avr:uno |
1. Upload: arduino --upload "%d/%f" --board arduino:avr:uno2. Upload (Verbose): arduino --upload --verbose-upload "%d/%f" --board arduino:avr:uno |
|
| Assembly | 1. Compile: nasm "%f" |
||
| AutoIt | 1. Compile: Aut2exe.exe /in "%f" |
1. Execute: AutoIt3.exe "%f" |
|
| C | 1. Compile: gcc -Wall -c "%f"2. Build: gcc -Wall -o "%e" "%f"3. Lint: cppcheck --language=c --enable=warning,style --template=gcc "%f" |
1. Execute: "./%e" |
|
| C# | 1. Compile: mcs /t:winexe "%f" /r:System,System.Drawing |
1. Execute: mono "%e.exe" |
|
| C++ | 1. Compile: g++ -Wall -c "%f"2. Build: g++ -Wall -o "%e" "%f"3. Lint: cppcheck --language=c++ --enable=warning,style --template=gcc "%f" |
1. Execute: "./%e" |
|
| Clojure | 1. Execute: clj "%f" |
||
| CoffeeScript | 1. Compile into Javascript: coffee --compile "%f"2. View compiled Javascript: coffee -p "%f" |
1. Run: coffee "%f" |
|
| CUDA | 1. Compile: nvcc -c "%f"2. Build: nvcc -o "%e" "%f" |
1. Execute: "./%e" |
^(.+)\(([0-9]+)\) |
| Cython | 1. Compile: cython "%f" |
||
| D | 1. Compile: dmd -w -c "%f"2. Build: dmd -w -of"%e" "%f" |
1. Execute: "./%e" |
|
| Erlang | 1. Compile: erlc "%f" |
1. Execute: erl "%f" |
|
| Fortran | 1. Compile: gfortran -Wall -c "%f"2. Build: gfortran -Wall -o "%e" "%f" |
1. Execute: "./%e" |
|
| Fortran 77 | 1. Compile: gfortran -Wall -c "%f"2. Build: gfortran -Wall -o "%e" "%f" |
1. Execute: "./%e" |
|
| FreeBasic | 1. Compile: fbc -w all "%f" |
1. Execute: "./%e" |
|
| GDScript | 1. Compile: (no command) 3. Lint: (no command) |
1. Execute: (no command) | (.+):([0-9]+):([0-9]+) |
| Genie | 1. Compile: valac -c "%f"2. Build: valac "%f" |
||
| Go | 1. Build: go build %f3. Test: go test |
1. Run: go run %f |
|
| Graphviz | 1. Graphviz -> SVG: dot -Tsvg -O "%f"2. Graphviz -> EPS: dot -Teps -O "%f" |
1. View SVG File: exo-open "%f.svg"2. View EPS File: exo-open "%f.eps" |
|
| Groovy | 1. Compile: groovyc "%f" |
1. Execute Script: groovy "%f" |
|
| Haskell | 1. Compile: ghc --make "%f"3. Lint: hlint "%f" |
1. Execute: "./%e" |
|
| Haxe | 1. Compile: haxe -neko "%e.n" -cp . "%f" |
1. Execute: neko "%e" |
|
| HTML | 1. Compile: tidy %f >/dev/null |
||
| Java | 1. Compile: javac "%f" |
1. Execute: java "%e" |
|
| JavaScript | 3. Lint: jshint "%f" |
([^:]+): line ([0-9]+), col ([0-9]+) |
|
| Kotlin | 1. Compile: kotlinc "%f" |
1. Execute: kotlin "%eKt"2. Execute Script: kotlinc -script "%f" |
|
| LaTeX | 1. LaTeX -> PDF: pdflatex -file-line-error -interaction=nonstopmode "%f" (one pass)2. LaTeX -> PDF (latexmk): latexmk -pdf -file-line-error -interaction=nonstopmode "%f" (as many passes, and BibTeX runs, as it takes)3. Bibtex: bibtex "%e" |
1. View PDF File: evince "%e.pdf"2. View DVI File: evince "%e.dvi" |
|
| Lisp | 1. Execute: clisp "%f" |
||
| Lua | 1. Execute: lua "%f" |
||
| Makefile | 1. Make: make2. Make Custom Target...: make (asks for a target first, section 4)3. Make Clean: make clean |
1. Execute: "./%t" (the program the Makefile builds; greyed until it exists) |
|
| Matlab/Octave | 1. Execute: octave -q "%f" |
||
| Nim | 1. nim c: nim c "%f"2. nim r: nim r "%f"3. Lint: nimpretty --maxLineLen:80 "%f" |
(.+)\(([0-9]+),\s+([0-9]+)\)\s+Error |
|
| NSIS | 1. Compile: makensis "%f" |
1. Execute: "./%e" |
|
| Objective-C | 1. Compile: gcc -Wall -c "%f"2. Build: gcc -Wall -o "%e" "%f" -lobjc |
1. Execute: "./%e" |
|
| OCaml | 1. Compile: ocamlc -c "%f"2. Build: ocamlc -o "%e" "%f" |
1. Execute: "./%e" |
|
| Pascal | 1. Compile: fpc -s "%f"2. Build: fpc "%f"3. Run script: instantfpc "%f" |
1. Execute: "./%e" |
|
| Perl | 1. Compile: perl -cw "%f" |
1. Execute: perl "%f" |
.+ at (.+) line ([0-9]+).* |
| PHP | 1. Compile: php -l "%f" |
1. Execute: php "%f" |
|
| Po | 1. Compile: msgfmt --check --check-accelerators=_ "%f" |
||
| PowerShell | 1. Execute: powershell -file "%f" |
||
| Python | 1. Compile: python3 -m py_compile "%f"3. Lint: pycodestyle --max-line-length=80 "%f" |
1. Execute: python3 "%f" |
(.+):([0-9]+):([0-9]+) |
| R | 1. Execute: Rscript "%f" |
||
| Ruby | 1. Compile: ruby -wc "%f" |
1. Execute: ruby "%f" |
|
| Rust | 1. Compile: rustc "%f"Independent: 1. Cargo Build: cargo build2. Cargo Test: cargo test3. Cargo Bench: cargo bench4. Make Clean: make clean (the usual default) |
1. Run: "./%e"2. Cargo Run: cargo run |
--> (.+):([0-9]+):([0-9]+) |
| SCSS | 1. Compile: sass -c "%f"2. Build: sass --style expanded "%f" "%e.dev.css" |
||
| Shell | 3. Lint: shellcheck --format=gcc "%f" |
1. Execute: "./%f" |
|
| Swift | 1. Compile: swiftc "%f"2. Build: swift build |
1. Execute: "./%e"2. Execute as Script: swift "%f" |
|
| Tcl | 1. Compile: tclsh "%f" |
1. Execute: tclsh "%f" |
|
| Vala | 1. Compile: valac -c "%f"2. Build: valac "%f" |
1. Execute: ./"%e" |
|
| XML | 3. Lint: xmllint --noout "%f" |
(.+):([0-9]+): |
|
| Zephir | 1. Compile: zephir build |
Most of these programs are not part of Unryu: cppcheck, pycodestyle, shellcheck and the others must be installed for their commands to work. A row with "(no command)" has a label but nothing to run, so it shows greyed in the menu until you give it a command.
11. Projects
A project is a folder that Unryu treats as the home of a file. It decides three things: which project-only build commands apply (section 7), which folder the sidebar's Files list shows, and which name appears in the window title (/home/me/code/thing/src/main.c - thing - Unryu) and in the File section of Details. A project also gives %p its value (section 8), and decides where the independent commands (Make, Make Custom Target, Make Object, Make Clean, when you set them) run when their working directory is empty: in the project's folder. The language's commands still run in the file's folder unless you set one, and Execute runs in the file's folder or, when its program is only there, at the top of the project.
Where a build command comes from. Layers 3 and 4 apply only to files inside a project.
How Unryu finds the project
Starting at the file's folder and going up, Unryu looks for:
- The nearest folder that contains
.git. That is the project. - If there is none, the highest folder that contains a build file:
Makefile,makefile,GNUmakefile,CMakeLists.txt,meson.build,configure,Cargo.toml,package.json,compile_commands.jsonorcompile_flags.txt.
For a file inside your home folder the search stops there: your home folder is never a project. / is never a project. For a file elsewhere the search goes up to /. A file with neither a repository nor a build file above it has no project. Unryu writes nothing into your source folders to find or remember a project.
Correcting it
| Tools menu item | What it does |
|---|---|
| Set Project Folder... | Opens a folder chooser (at the current project, or the file's folder). The folder you choose becomes the project of every file inside it. |
| No Project for This Folder | The file's folder, and every folder inside it, has no project. |
| Find Project Again | Forgets the nearest correction at or above the file's folder, so the project is found again as described above. If there was none, the status bar says so. |
The nearest correction above a file wins over what Unryu would find. The corrections are kept in ~/.config/unryu/projects.conf. The status bar tells you the document's project after each change. These items need a saved file.
Commands only for one project
In Set Build Commands, check "Only for the project" and change a row. That command is then used for the files of this project instead of the one for every project. A project command that you leave unchanged keeps following the command for every project, also when you change that one later. Setting a project command back to the same value as the one for every project (or pressing Reset) makes it follow again.
A settings file in the project's folder
A project can carry its own settings in a file named .unryu.conf in its folder, so they travel with the code. Tools > Save Project Settings in Folder writes it: it contains your project-only build commands (and any approved commands the file already had) and the indentation of the current document. The status bar says "Wrote path (N build command keys)." While the file has build commands you have not approved, it writes nothing, so they are not lost, and the status bar says "The project's file has build commands you have not approved: approve them first (Tools > Approve Project Build Commands), or edit the file." The file looks like this:
# Unryu: this project's own settings. ...
[project]
indent-type = spaces
indent-width = 4
hide = *.o build
[build]
NF_00_CM=make -j8
[c]
FT_00_CM=gcc -Wall -std=c11 -c "%f"
[project]holdsindent-type(tabs,spacesorboth),indent-width(1 to 32) andhide(patterns that the Files list leaves out), anddescription(the text a template's {description} becomes). Unryu uses these as soon as it reads the file: the indentation applies to files of the project when they open. Save Project Settings in Folder keeps the hide and description the file already has.- Every other section holds build commands, with the same sections and keys as
build.conf.
Approving a project's commands. A build command runs as you, and a .unryu.conf can arrive with a repository someone else wrote. So Unryu does not use the build commands of a project's file until you approve them. When it finds unapproved ones, the Status tab says "The project name has build commands of its own in its folder (.unryu.conf). They are not used until you approve them: Tools > Approve Project Build Commands." Tools > Approve Project Build Commands... shows the commands in the file (each cut to its first 90 characters, and the list to about 2400 characters) with a warning, and two buttons, Cancel and Approve. Read the file itself before you approve long commands. After Approve they are used. If the commands in the file change in any way, they are unapproved again and Unryu asks again. A file written by Save Project Settings in Folder counts as approved, because you wrote it. Approvals are kept in projects.conf.
Your own project-only commands (layer 4 in the picture) are used before the folder's commands.
Recent projects. File > Recent Projects lists the projects that had open files. Choosing one opens the files that were last open in it; it closes nothing. See Files and Recovery.
12. The built-in terminal
The message window's last tab, Terminal, holds Unryu's own terminal (called Hosho), built into Unryu: no other terminal program is needed. It runs your shell ($SHELL) on a terminal device of its own. Preferences > General > Startup > "Load virtual terminal support" turns the tab on or off; the change takes effect the next time Unryu starts.
Using it
- The shell starts the first time you show the tab (or when Execute or Send Selection to Terminal needs it), in the folder of the current document, or your home folder when the document has no file.
- Click in the terminal to give it the keyboard. Click anywhere else in Unryu to take the keyboard back. While the terminal has the keyboard, Unryu's own shortcuts do not work: every key goes to the program in the terminal.
- The terminal follows the size of the tab, and the programs in it are told the new size.
- Links. Hold
Ctrland click a file name in the output to open it in the editor. A name followed by a line and a column, as compilers write it (src/main.c:120:8), puts the cursor there; a name without a folder is taken from the shell's current folder. Only names of files that exist are links. A web address, and amailto:mail address, opens with the Browser command of Preferences > Tools (orxdg-open). - Emoji, flags, emoji with a skin tone and emoji joined into one picture each take one place in the line, as one character, so the cursor and the selection step over them whole.
- When the shell ends after running for more than 3 seconds while the tab is shown, a new one starts. When it ends sooner, the next time you show the tab starts it again.
- When Unryu quits, the shell gets the hangup signal and ends.
- The terminal keeps running while a dialog of Unryu is open: you see its output as it comes. Keys and the mouse go to the dialog until it closes.
- A program that asks for your attention, and a long command that ended while you worked elsewhere (with shell integration, below), each add a line to the Status tab.
- Pictures. A program can show pictures in the terminal: sixel, iTerm2's inline images and the Kitty graphics protocol (PNG, JPEG, GIF and BMP files, raw pixels, compressed data). What a program prints can come from anyone (a file you
cat, a server yousshinto), so every picture file, sixel picture and compressed picture is taken apart in Unryu's jailed worker, never in the editor (see Safety). Raw pixels (the Kitty protocol's RGB and RGBA forms) need no taking apart: the editor copies them itself, after checking their size. Without the jail on your system, only those raw-pixel pictures are shown. A sixel or iTerm2 picture can be up to 64 MiB. The theme's background picture (background-image) is read in the worker too.
The right-click menu
Copy, Copy as HTML, Paste, Select All; Find...; Open Link and Copy Link (over a link); Copy Command Output and Hide or Show Command Output (over a command, with shell integration); Larger Text, Smaller Text, Normal Text Size; Clear Scrollback and Reset Terminal.
The terminal's keys
| Key | What it does |
|---|---|
Ctrl+Shift+C / Ctrl+Shift+V |
Copy the selection / paste the clipboard. |
Shift+Insert, middle mouse button |
Paste the primary selection (the text last selected anywhere). |
Ctrl+Shift+F |
Find in the scrollback; press it again to close the search. While searching, Alt+C switches matching upper and lower case, Alt+R treats the text as a pattern. |
Shift+Page Up / Shift+Page Down |
Scroll back and forward a page. |
Ctrl+Shift+Up / Ctrl+Shift+Down |
Go to the previous or next prompt (with shell integration). |
Ctrl+Shift+Space |
Select with the keyboard: move with the arrow keys or h j k l, w and b by words, 0/Home and $/End in the line, g and G to the top and the bottom, Page Up and Page Down. v starts a selection by characters, V by lines. y or Enter copies it and ends; Esc or q ends without copying. |
Ctrl+Shift+O |
Puts a letter on each link in view; type a letter to open that link. Any other key ends it. |
Ctrl++, Ctrl+-, Ctrl+0 |
Larger, smaller and normal text size, for this run only. |
Ctrl+Break |
Sends the Answerback text (see the settings). |
A key pressed with Alt always goes to the program, never to the terminal itself, except Alt+C and Alt+R while the search is open.
Shell integration
With Preferences > Terminal > Programs > "Shell integration" (on by default), the shell tells the terminal where each prompt starts and ends, where each command's output starts, and how each command ended. Then:
- A mark in the left margin sits beside each prompt: green after a command that succeeded, red after one that failed, grey while there is no result yet.
- Click a mark to select that command's output. Double-click it to hide the output, or to show it again.
Ctrl+Shift+UpandCtrl+Shift+Downgo from prompt to prompt.- A command that ran for at least "Notify after" seconds and ended while the terminal did not have the keyboard adds a line to the Status tab.
- The Terminal tab's label shows what the shell is doing (below), and Execute and Send Selection to Terminal know when it is safe to type into the shell (section 6).
Unryu ships small files for this in its shell folder (installed: share/unryu/shell). Each one reads your own shell files first, so your shell behaves as you know it, and none of your files is changed.
| Shell | How it works |
|---|---|
| bash, zsh, fish, ksh93 | Automatic, with everything above. ksh93 reads your ~/.kshrc when ENV names no other file. |
| mksh, the ksh of OpenBSD, dash, the sh of FreeBSD and NetBSD | Automatic, but these shells cannot report that a command starts: the terminal takes Enter after text at the prompt as the start. |
| tcsh | Add source /path/to/shell/hosho.tcsh at the end of ~/.tcshrc. Everything works except the end of the prompt. The shell also tells the terminal its current folder, so file names in its output are links as in the other shells. |
Another shell starts normally, without marks. A shell you start inside the terminal (or one at the other end of ssh) counts as a running command. Switching the setting off removes the marks, their margin and the tab colors at once; switching it on applies to the next shell that starts.
The color of the Terminal tab's label
| Color | Meaning | When | Editor theme key |
|---|---|---|---|
| Amber | Text you typed waits at the prompt, not sent yet. | Always, also while the terminal is in view, until the text is sent or erased. | tab-attention |
| Blue | A command is running. | Only while the terminal is not in view. | tab-running |
| Green | A command ended with status 0. | When it ended while the terminal was not in view, until you look at it. | tab-success |
| Red | A command ended with another status. | As green. | tab-failure |
"In view" means its tab is selected and the message window is shown. Blue wins over green and red, and those win over amber. These colors need shell integration. Remember that a command can end with a non-zero status even when it did its work: find returns 1 when it could not read one folder.
The terminal's settings
Preferences > Terminal has three tabs. A change shows in the terminal when you press Apply or OK. The settings are kept in ~/.config/unryu/terminal.conf (a [terminal-widget] section with a comment above each key), and they are used instead of the same section of a theme file.
| Tab | Setting | What it does |
|---|---|---|
| Appearance | Colors | Where the colors come from. "As the editor theme" (the default) takes the background, text, selection and cursor of the editor theme, with a set of 16 program colors that suits a dark or a light background. Or one of the built-in terminal themes Hosho Dark, Hosho Light, Sumi and Washi. Or "A theme file" of your own. |
| Theme file | Used with "A theme file": a full path, a path starting with ~/, or a plain file name in ~/.config/unryu. If it cannot be read, the Status tab says so and the editor theme's colors are used. |
|
| Family, Size | The terminal's font and its size in pixels. Default and 0 use the editor's font and size. | |
| Line spacing | Extra pixels between lines. | |
| Ligatures | Draw sequences such as -> and != as one symbol, if the font has them. |
|
| Bold text in bright colors | Show bold text in the bright version of its color, as older terminals did. | |
| Cursor Shape, Blink | Block, Underline or Bar, and whether it blinks while the terminal has the keyboard. A program can choose its own shape while it runs. | |
| View | Padding | Empty pixels between the terminal's edge and its text. |
| Prompt mark margin | The width of the margin for the prompt marks; 0 means no margin. Needs shell integration. | |
| Scrollback lines | How many lines of earlier output are kept. | |
| Minimum contrast | Lightens or darkens text that is hard to read on its background. 1 leaves colors alone, 4.5 is comfortable, 21 is the most. | |
| Background Picture, Tint | A picture file behind the text (PNG, JPEG, GIF, BMP or XPM; a full path, or a path starting with ~/), and how strongly the background color covers it in percent (100 hides it, 0 shows it untouched). When the file changes, the terminal shows the new picture within a second. |
|
| Programs | Shell integration | See above. |
| Notify after (seconds) | The long-command notice; 0 turns it off. Needs shell integration. | |
| Keyboard | Which terminal the function keys imitate: PC (suits nearly everything), VT220, Sun, HP, SCO, rxvt or Linux console. With Sun, HP, SCO, rxvt or Linux console, the programs are told that terminal's name (TERM) when your system has a description of it, so they read the keys right; this applies to the next shell that starts. F13 to F20 work with every keyboard. |
|
| Bell | What a program's bell does: Sound, Visual (a frame flashes around the terminal), Sound and visual, or None. | |
| Answerback | Text sent back when a program sends the ENQ character (and on Ctrl+Break). Almost nothing uses it. |
|
| Confirm a paste of several lines | Before pasting several lines into a program that would run them at once, ask ("Paste 3 lines?") and wait for Enter (Esc cancels). |
|
| Programs can read the clipboard | Lets programs in the terminal, including ones on other machines over ssh, read what you last copied. Off is safer. | |
| Programs can set the clipboard | Lets programs put text on the clipboard, as tmux and vim can over ssh. | |
| Log file, Print command | A file (a full path, or a path starting with ~/) that gets everything the programs display from the moment the terminal starts, and a shell command (for example lpr) that gets what a program sends to the printer. Empty: none. |
A program in the terminal cannot move or resize Unryu's window.
Making your own terminal theme. A theme file is a text file with the sections [terminal], [palette], [attributes] and [rules]. A theme can be short: a missing key gets a color made from the others, so a file with only [terminal], background and text is complete. Unryu reads the file when you press Apply or OK and at each start.
13. Other commands that send text out
Edit > Commands > Send Selection to Terminal
Types the selection, or the line of the cursor when nothing is selected, into the Terminal tab's shell, followed by a line end, as if you typed it there. The Terminal tab comes to the front. With shell integration it refuses while text waits at the prompt or a command runs, as Execute does (section 6). With nothing to send, Unryu beeps. It has no key.
When the Terminal tab is off, Unryu writes the text to a script and runs it with the Terminal command of Preferences > Tools (%c is the script). The script runs the text, waits for "(press return to continue)", and removes itself.
Edit > Format > Send Selection to
This submenu holds your custom commands, filters that change text. Choose one, and Unryu runs it with sh -c, gives it the selection (or the cursor's line, with its line end, when nothing is selected) on its input, and replaces that text with what the command prints. The replacement is one Undo step. If the command fails (an exit status other than 0) or takes longer than 10 seconds, the text stays as it was and the Status tab says which command failed. What the command writes to its error output is thrown away.
Set Custom Commands, the last item of the submenu, asks for the commands in one line, with ;; between two of them, up to ten. For example: sort ;; tr a-z A-Z ;; column -t. Each command then has its own row in the submenu, labeled with (the start of) its command line. They are saved in unryu.conf as custom-command-1 to custom-command-10.
Context Action
The last item of the editor's right-click menu runs the Context action command of Preferences > Tools, with %s replaced by the selection or the word at the cursor, in single quotes so that the word cannot add shell commands. With the field empty, the status bar says "No context action set." See Preferences.
14. The compiler check (Ctrl+Shift+B)
Navigate > Suggest Repairs (Runs the Compiler), Ctrl+Shift+B, works on C and C++ files. Unryu finds braces whose place it is unsure about without any compiler (see Highlighting, Braces and Definitions). The check asks a real compiler for help:
- It compiles the text as it is on screen, once, to find its errors.
- For each brace that is in doubt, it tries the brace in each place it could belong, and asks the compiler which of those versions compile.
- It shows what it found.
Press Ctrl+Shift+B again while it runs to stop it. The check also stops when you switch to another file. It is limited to 60 seconds in all.
What you see
- The status bar says what happened: "The compiler accepts this text as it is.", "The compiler settled N answers (until the next edit).", "The compiler accepts the repairs listed in Details.", or "No repair compiles, or too many to try. It may need this file's headers or flags: see Help > Compiler."
- Errors. Each error the compiler reports in this file (errors in headers do not count) goes into the Messages tab as
main.c:12: error: ...; a click on it goes to the line, and Search > Next Message and Previous Message step through them. With "Use indicators to show compile errors" on, each of those lines gets the red wavy underline. Document > Remove Error Indicators removes them. The check first removes the error indicators of this document (also those of the last build) and, when it found errors, clears the Messages tab. - Settled braces. A brace in doubt that only one placement makes compile becomes certain, until your next edit.
- Repairs. Details gets a section "The compiler accepts" with numbered repairs, the most likely first, such as "1. Insert
}at line 6, column 1", "Move{from line 3 to line 4, column 9" or "Delete}at line 20". Up to nine are listed, with "and N more" after them.Ctrl+Alt+1toCtrl+Alt+9applies that repair as one edit ("Repair applied (Ctrl+Z takes it back)."). An inserted}goes on its own line, indented like the line of its{. The list is valid until the text changes. - The Compiler section of Details says which compiler would run or is running, a compiler the project named that Unryu refused, and how many of the project's flags were left out.
Help > Compiler shows a short explanation of all this in Details.
When it does not run
| Status bar message | Why |
|---|---|
| Open a file first: Ctrl+Shift+B asks the compiler about the open file. | The document has never been saved. |
| Ctrl+Shift+B asks a C or C++ compiler: this file is not C or C++. | Another language. |
| Still reading the latest edit: try again in a moment. | The analysis of your last edit is not finished. |
| No compiler to run: none named cc or c++ was found. | No usable compiler in your PATH. |
| Not running the compiler: this system cannot sandbox it. | The sandbox needs Linux 5.13 or newer with Landlock enabled, on x86-64 or ARM64. Without it the check never runs; everything else in Unryu works. |
| The text changed during the check: press Ctrl+Shift+B again. | You edited while it ran; its answers were for the old text. |
| The check took too long, and was stopped. | It reached its time limit. |
Why it is safe
The compiler only ever sees temporary copies in a private folder that is removed afterwards, and it only checks the syntax (-fsyntax-only), so it writes nothing and your file is never touched. It runs in a sandbox: it can read only the system's files, this project and the folders you name (below), write nothing, reach no network, cannot trace other programs, and (on Linux 6.12 or newer) cannot send them signals. Of your environment variables it gets only CPATH, C_INCLUDE_PATH and CPLUS_INCLUDE_PATH, which name folders of headers; besides those, PATH=/usr/bin:/bin and LC_ALL=C are set by Unryu. It runs at low priority, at most four at a time, each limited to 2 GB of memory, 30 seconds of CPU and 15 seconds per round. A project cannot choose which program runs or open the sandbox to the rest of your home folder. The details are on the Safety page.
The popup over a type or variable in C can also ask the compiler for its size ("ask the compiler"); this runs the same compiler in the same sandbox, once, on a copy. See Highlighting, Braces and Definitions.
15. Compiler flags from the project
For the check, Unryu needs to know how your project compiles a file: its include folders, its macros, its language standard. It reads them from files that build tools write, and runs nothing to find them:
- Starting in the file's folder and going up, it looks in each folder for
compile_commands.json(written by CMake, Meson or bear), thenbuild/compile_commands.json, thencompile_flags.txt(clangd's format: one flag per line). The first one that has an entry for the file (or, forcompile_commands.json, for a file in the same folder) is used. - From
compile_commands.jsonit takes the file's own entry; for a header, an entry of a file in the same folder. - It keeps only the flags that decide whether code compiles:
-I,-D,-U,-std=,-include,-isystem,-iquote, most-fand-mflags, and the folder the compiler runs in. Flags that could load code or write files (-fplugin,-wrapper,-B,-specs,-Xclang,@fileand others), output flags and warning flags are dropped. - The
-Dand-Umacros are also used by the highlighting, so the#ifbranches that are greyed out match your build. - The include folders are opened to the sandbox for reading.
When a file opens, the status bar tells you what was found: "Compiler flags from path", "(N ignored as unsafe or unknown)", or "No compile_commands.json or compile_flags.txt found: plain cc".
Which compiler. The compiler that compile_commands.json names runs only if it is named like a compiler (cc, gcc, c++, g++, clang, clang++, with any target in front and version after, such as arm-none-eabi-gcc or clang-19) and it and its folder are owned by root and writable by nobody else. Otherwise Unryu uses the system's cc (or c++ for C++) and tells you: "Will not run x, the compiler file names". To allow your own toolchain, add its full path to trusted-compilers in Preferences > Various (or in unryu.conf), with colons between paths:
trusted-compilers = /home/me/x-tools/bin/arm-gcc:/opt/mine/bin/icx
A script listed in trusted-compilers (a wrapper of your own that starts the compiler) may also start the system's own compilers (cc, gcc, c++, g++, clang, clang++).
Compiler wrappers. A compiler wrapper such as ccache, sccache, distcc, icecc or buildcache is never run by the check: it starts another program and writes its cache or sends the work away, which the sandbox does not allow. When compile_commands.json says ccache gcc ..., the check runs gcc itself. When it names a wrapper's link named like a compiler (/usr/lib/ccache/gcc), the check runs the compiler of that name found after it on your PATH. Details says which wrapper was skipped. This is true even for a wrapper listed in trusted-compilers.
Headers outside the project. If the check finds nothing for a file outside a set-up project, it is often because the compiler cannot find the file's headers. Add a compile_flags.txt or compile_commands.json, naming any folder outside the project with -I. A project's files can come from anyone, so a folder they name is never opened to the sandbox when it holds your whole home folder, or when it is a hidden folder of your home (.ssh, .config, .local ...). For a file lying directly in your home folder, only the visible folders and source files of home are opened.
Headers in your home folder. The folders that you name yourself are opened even when they are hidden:
check-foldersin Preferences > Various (or inunryu.conf): folders separated by colons,~for your home folder. At first it is~/.local/include, where a library installed withmake PREFIX=~/.local installkeeps its headers. The compiler looks for headers in these folders after all others (-idirafter), so a library installed there is found with no flags file:
check-folders = ~/.local/include:~/opt/mylib/include
CPATH,C_INCLUDE_PATHandCPLUS_INCLUDE_PATHfrom the environment Unryu was started in: the compiler gets them as they are, and their folders are opened.
Your home folder itself is never opened, even when you name it. The check only asks whether the text compiles, so it needs headers only, never the libraries in ~/.local/lib.
These flags are only for the check. The Build menu commands do not use them; they run exactly the command lines you set.
16. Code tools
Tools > Code Tools runs the programs you use on code besides the build: checkers, formatters and git. Each tool is a command line of yours, with the same placeholders as the build commands (section 8), and one of four kinds:
| Kind | What happens |
|---|---|
| Check | The output goes to the Compiler tab and is read as a build's (section 5): a line that names a file and a line can be clicked, gets its underline, and Next Error and Previous Error step through them. Choosing the tool again while it runs stops it ("Stop: name" in the menu). It cannot run while a build runs. |
| Format | The selection, or the whole document when nothing is selected, goes to the program's standard input, and what the program prints takes its place as one edit: Edit > Undo takes it back. The file on disk is not touched until you save. If the program fails or prints nothing, the text stays as it is and the Status tab says why. A program that takes more than 10 seconds is stopped. |
| Show | The output goes to the Messages tab (which loses the rows of an earlier Find All), followed by "Done." or how it ended. Choosing the tool again while it runs stops it. |
| Terminal | The command runs in the Terminal tab, as Execute does (section 6), so you can type to it. |
Before a Check, Show or Terminal tool runs, every changed document that has a file is saved, as for a build. A tool runs in the file's folder or in the project's folder (section 10), as you set. A tool that needs the file (one that runs in its folder, or uses %f, %d or %e) is greyed for a text that has never been saved.
The menu lists only the tools whose program is installed (the first word of the command line must be a program on your PATH) and that are for the language of the document in front: each tool lists its languages by name (C C++), and a tool with no list is for every file. When none is left, the menu says "No code tool for this language (Preferences > Tools)".
Format the document (Ctrl+Alt+F) runs the first Format tool, in the menu's order, that is installed and lists the document's language: clang-format, astyle or uncrustify for C, jq for JSON, xmllint for XML. With nothing selected the whole document goes through it; with a selection, the selection. When there is none, the status bar says so.
The tools Unryu comes with
| Name | Kind | Runs in | Command | Languages |
|---|---|---|---|---|
| cppcheck: this file | Check | File's folder | cppcheck --enable=warning,style,performance,portability --inconclusive --quiet --suppress=missingIncludeSystem --template='{file}:{line}:{column}: {severity}: {message} [{id}]' "%f" |
C C++ |
| cppcheck: the project | Check | Project folder | The same, with . in place of "%f" |
C C++ |
| clang-tidy: this file | Check | File's folder | clang-tidy --quiet "%f" (it reads the project's compile_commands.json when there is one) |
C C++ Objective-C |
| scan-build: the project | Check | Project folder | scan-build make (this builds the project, under clang's static analyzer) |
C C++ Objective-C |
| Strict warnings: this file | Check | File's folder | gcc -fsyntax-only -Wall -Wextra -Wpedantic -Wconversion -Wshadow "%f" |
C |
| Unsafe C functions: the project | Check | Project folder | grep for strcpy, strcat, sprintf, vsprintf and gets in the .c and .h files |
C C++ |
| Line counts: the project | Show | Project folder | The lines of each .c and .h file (not under build/), the largest last |
C C++ |
| Format with astyle | Format | File's folder | astyle --mode=c (your style in ~/.astylerc) |
C C++ C# Java Objective-C |
| Format with uncrustify | Format | File's folder | uncrustify -q -l C (your style in ~/.uncrustify.cfg or $UNCRUSTIFY_CONFIG) |
C C++ C# D Java Objective-C Vala |
| Format with clang-format | Format | File's folder | clang-format --assume-filename="%f" (the project's .clang-format) |
C C++ Objective-C Java JavaScript TypeScript C# Proto |
| Format JSON with jq | Format | File's folder | jq . |
JSON |
| Format XML with xmllint | Format | File's folder | xmllint --format - |
XML DocBook |
| git status | Show | Project folder | git status |
every one |
| git diff: this file | Show | File's folder | git --no-pager diff -- "%f" |
every one |
| git log: this file | Show | File's folder | git --no-pager log --oneline -n 100 -- "%f" |
every one |
| git blame: this file | Show | File's folder | git --no-pager blame -- "%f" |
every one |
| valgrind: run the program | Terminal | File's folder | valgrind --leak-check=full "./%e" (the program Build made) |
C C++ |
None of them changes a file on disk or a git repository: the git tools only read, and a formatter changes the text in the editor. You run git's other commands yourself, or add a tool for them.
Changing the tools
Preferences > Tools > Code tools has a row for each of the 24 places of the menu: Name, Kind, Runs in ("File's folder" or "Project folder"), Command and Languages (by name, as Document > Set Filetype shows them, a space between; empty for every file). A row with no name is not used. A code_tools.conf from before languages: a tool that has a default's name takes that default's languages. Apply writes them to ~/.config/unryu/code_tools.conf; until you change them, no file is written and a later version's defaults reach you. To get the defaults back, empty every row and press Apply.
Each place has a key action in Preferences > Keybindings, group Code Tools: "Code tool 1" runs the tool in the first row, and so on. They have no keys at first.
17. Known limitations
- In dash and tcsh, text typed while a command is still running is not recognized as waiting text. These shells give the terminal no way to tell: it is a limitation of the shells, not of Unryu.
- The integration files for the ksh of OpenBSD and the sh of FreeBSD and NetBSD were written from the source of those shells and have not been tried on those systems. This limitation may go away once they have been tested there.
