Unryu: Analysis
Unryu does not just color words: it reads your code the way a compiler would, and tells you what it finds. This page explains how that works, what the colors and marks mean, how to work with braces and names, and what the Symbols list, the tooltip, the Details panel and the status bar show. The reading is done by Kami, the library inside Unryu that understands code. Languages explains how each language is read, and Safety explains why the reading happens in a locked-down process.
How Unryu understands your code
Each open document has its own analysis process, a second copy of Unryu that runs in the background and does nothing but read that one document. Whenever you change the text, the editor sends the whole text to it. The process reads all of it again from the start and sends back what it found: what each word is, which braces belong together, which names are declared where, and so on. The editor checks the answer and then shows it.
- Every edit is read from scratch. The answers for a text are always the same, no matter which edits led to it. Nothing left over from an earlier version of the file can confuse them.
- Ordinary files answer at once. The window waits up to 30 milliseconds for the answer, so for most files the colors change together with the key you pressed.
- Large files never freeze the window. When the answer takes longer, the window goes on without it, and for a moment the colors and marks can belong to the text as it was just before your last edit. Commands that change the text at a place the analysis named (such as Insert Missing Brace or applying a repair) refuse to run until the answer is up to date, and say "Still reading the latest edit: try again in a moment."
- Only what is on screen is colored. Colors are made for the lines you can see, plus a page above and below. That is why even a very large file scrolls smoothly.
- Headers come a moment later. In C and C++, the analysis also reads the headers that the file
includes, system headers too, to learn what they declare. This can take a second, so it starts only after the
first answer: the colors of the file itself never wait for it. It is done again only when the
#includelines change. Up to 400 headers, 64 MB of text and 1.5 seconds are spent on it; the nearest headers come first, so if a limit is reached, it is the farthest ones that are left out. The index of what the headers declare never changes the answer about the file's braces. But the brace analysis itself follows the file's#includelines into the project's own headers (beside the file, in-Ifolders, and anywhere in the project), so that macros defined there count. - Which headers are found. A quoted
#include "x.h"is looked for beside the file, then in the folders the project's build flags name with-Iand the system folders, and finally anywhere in the file's project. An#include <x.h>is looked for in the same way, without looking beside the file first. A document that has never been saved has no folder, so its quoted names are looked for only in the other places. For finding headers, the project is the nearest folder at or above the file's folder that has a.git, or else the highest one with a build file (Makefile,CMakeLists.txt,meson.build,configure,compile_commands.jsonand similar). It is never less than the folder above the file's own folder, so a file in a repository's top folder also searches the folder above it. This is worked out on its own, and the project chosen in the Tools menu does not change it. When searching a project, hidden folders and folders namedbuild,node_modules,referencesand__pycache__are skipped. Build and Run explains projects and build flags. - The build's macros count. When the project's build flags define or undefine macros
(
-D,-U), the analysis uses them, so#ifsections are read the way your build reads them. - Every language is read. C and C++ are read by Kami's own C reader. Every other language is read by the rules in its language file: its words and strings, braces paired by nesting and indentation, parentheses and brackets checked statement by statement, and the names that its language file says how to find. A language with a grammar is also read into scopes and blocks. A file of no known language (filetype "None") is plain text and gets no syntax colors. See Languages.
When the analysis is slow or stops
The analysis can never damage your text, and it can never stop you from editing or saving. If it cannot do its work, the file simply stays editable as plain text. When something goes wrong, the Analysis section at the top of the Details panel says what happened, and stays there until it is no longer true (the status bar alone would be overwritten by the next message).
| Details says | What happened | What happens next |
|---|---|---|
| Reading the file... | A file was just opened and its first answer is not in yet. | You can edit it meanwhile; the colors appear when the answer comes. |
| Off: this system cannot sandbox the code that reads the file | The system cannot make the jail (see Safety), so nothing reads the file: no colors, no Symbols list, no answers. | You can still edit and save it as plain text. There is no setting that runs the analysis without the jail. |
| Off: the process that reads the file could not be started | The analysis process did not start. | The file stays editable and savable as plain text. |
| Stopped: the process that reads the file crashed on this text | It crashed or ran out of memory (the limit is 8 GB). | What you see is from the last text it understood. The next edit starts a new process and tries again. |
| Stopped: ... was taking too long on this text | It sent nothing for two minutes, so it was stopped. | The same: the last answer stays, the next edit tries again. |
| Stopped: ... gave answers that cannot be right | Its answer failed the editor's checks, so it was thrown away and the process was stopped. This file may be trying to attack the editor. | Your text is safe, and the jailed process could reach nothing. The next edit tries again. |
The file count at the bottom of Details also says when not all of the file could be read: "N symbols; not all of it parses:" followed by where the reading stopped. Everything before that point is still colored and listed. For C, the reason names the line, for example "line 12: not C at "else"", or "line 80: not C: the file ends too early" when the file stops in the middle of something. When the preprocessor reaches one of its limits (macros that grow without end, or headers that include each other too often), the reason is "preprocessing stopped:" and the limit, and the file gets no symbols; its words and strings are still colored.
Very large files are fine: there is no size limit for the analysis below 2 GB of text. A file containing NUL bytes is not text and is not opened at all (Files).
What the colors mean
Every color in the editor comes from the editor theme (View > Change Color Scheme). Kami says what each piece of text is, and the theme says how that kind of thing looks. The theme file has five sections; the tables below say what each key colors. Themes explains the file format and where the files are, and Help > Colors shows a short summary in the Details panel.
View > Syntax Highlighting (also "Syntax and semantic highlighting" in Preferences) turns all text and name colors on or off; the brace marks at the cursor and the missing-brace marks stay. "Invert syntax highlighting colors" in Preferences shows every color of the theme as its opposite (Preferences).
Kinds of text: the [syntax] section
Each key is a style: a text color, a background, and optionally bold and italic.
| Key | What it colors |
|---|---|
comment, comment-line | A block comment; a // comment |
comment-doc, comment-line-doc | A documentation comment: /** or /*!; /// or //! |
number, string, character | A number; a string (also the file name in #include); a character constant |
string-eol | A string or character with no closing quote. Its background is also put under any unterminated comment or literal. |
keyword, type, constant, builtin | Statement words (if, return); type words (int); constant words (true, NULL); built-in words (print, len) |
attribute, regex, variable | Attributes and decorators; regular expression literals; variables written with a sigil ($x) |
preprocessor, operator, brace | A directive line; punctuation; { } ( ) [ ] |
identifier | A name that Kami does not know |
tag, entity | Markup tags and entities (HTML, XML) |
heading, emphasis, strong, link, code | Markdown and other text formats |
inserted, deleted, changed | Lines of a diff |
A word in a language's word lists is colored by its spelling alone, with the key of its class.
Kinds of names: the [names] section
Here Unryu differs from an editor that only colors words: a name is colored by what it is, which Kami learns from the declarations in the file and its headers. The same word can have two colors in two places.
| Key | The name is |
|---|---|
local | A variable declared inside a block |
global | A variable declared at file scope |
parameter | A function's parameter |
function | A function |
type-name | A type name made with typedef |
tag | A struct, union or enum tag |
member | A member of a struct or union |
enumerator | A constant of an enum |
label | A goto label |
macro | A macro |
Where a name is declared: the [declared] section
At the place where a name is declared, a background color is put under it, so declarations stand out from uses.
There is one key for each kind of name above (local, global, function and so
on), and a matching -text key (local-text and so on) for the color of the name on that
background; syntax keeps the name's own color.
Marks: the [marks] section
| Key | What it shows |
|---|---|
brace-good | The brace beside the cursor and its partner. Its background is under a certain pair. |
brace-bad | A brace beside the cursor that has no partner. Its text color is also one half of a flashing missing brace. |
pair-likely, pair-likely-text | Under the brace at the cursor and its partner when the pair is only likely; the color of those braces |
pair-ambiguous, pair-ambiguous-text | The same when the pair is ambiguous |
pair-range, pair-range-text | The stretch of text where the partner of an uncertain brace can be; the text there |
ghost | A missing brace drawn where it certainly goes |
ghost-guess | A missing brace drawn where it most likely goes |
occurrence, occurrence-text | Under every use of the name at the cursor |
open-elsewhere, open-elsewhere-text | Under a name, or an #include file name, that is declared in a file you have open in another tab |
search-mark, search-mark-text | Under each match of Search > Mark All (Find and Replace) |
When the editor theme leaves out a brace color, Unryu takes it from the window theme's brace-certain,
brace-missing, brace-likely and brace-ambiguous keys, and failing those, from
the colors the window theme uses for valid and invalid input. The [editor] section holds the colors of
the view itself (background, selection, cursor line, margins, the tooltip) and is described in
Themes.
Braces
Kami pairs every brace in the file and says how sure it is of each pair:
- Certain: the language itself proves the pairing, or nesting and indentation agree on it.
- Likely: the language cannot prove it, and the indentation points to one answer, which is Kami's best guess. Details lists the reasons.
- Ambiguous: the evidence does not decide between two or more answers.
Only the brace, parenthesis or bracket beside the cursor, and its partner, are marked with these colors; the other
braces keep the theme's brace style.
A brace can also have no partner. Then Kami either says where the missing partner belongs, or that the brace looks extra. The missing brace is called a ghost: Kami knows the range of places where it could go and the most likely place in that range, and Unryu draws it there, faded, as if it were part of the text. A ghost is never part of the text; it is only a mark. A ghost that would sit at the start of a line is drawn at the end of the line before it, so it never covers anything. Parentheses and brackets are checked statement by statement, and get ghosts too.
Other pairs: quotes, comments, tags, blocks and more
Brackets are not the only things that come in pairs. Unryu treats each of these the same way as a brace: with the
cursor on one end (or right after it), both ends are marked in the brace colors, a missing end shows as a ghost, Details
says what it is and where its partner is, Go to Partner jumps to the other end, and Insert Missing Brace writes a
missing end in. Each language file says which of them the language has (the pairs key, see
Language files).
| Pair | Where | What is paired |
|---|---|---|
| Quotes | Every language with strings | A string's opening and closing quotes: " ",
' ', """ """, a C++ raw string's R"x( and )x", Rust's
r#" and "#, also when ${ } or a variable is inside the string. A string with no
end gets a ghost of its quote where it stops. |
| Comments | Languages with block comments | /* and */,
<!-- and -->, {- and -}, (* and *). A
comment with no end gets a ghost at the end of the file. |
| Interpolation | JavaScript, Kotlin, Ruby, Python's f-strings, the shell and others | ${ and
}, #{ and }, { and } inside a string. |
| Tags | HTML, XML, PHP, JSX | A start tag and its end tag, by name: <div> and
</div>. In HTML, an element that has no end tag (br, img, input
...) is not a pair, and one whose end tag may be left out (li, p, td ...) is not
missing anything when its parent ends. Any other element left open gets a ghost of its end tag, before its parent's end
tag. HTML compares names in any case. |
| Angle brackets | C++, Java, C#, Rust, TypeScript, Kotlin, Swift and other languages with generics | The
< > around types: vector<int>, Vec::<u8>. A >>
closes two. Unryu tells them from a comparison by what is between them (types, not && or
;) and by what follows; a < b is never paired. |
| Keyword blocks | Ruby, Lua, Pascal, Ada, Fortran, SQL, the shell, CMake, Makefiles, LaTeX and others | A
block's opening and closing words, as folding pairs them: def ... end, if ...
fi, case ... esac, do ... done, ifeq ...
endif, \begin{itemize} ... \end{itemize}. A block left open gets a ghost of its
closing word where its indentation ends. |
| Conditionals | C, C++, C#, Haxe and others | #if, #elif, #else
and #endif as one chain: all of its lines are marked, and Go to Partner steps along the chain, from
#endif back to #if. An #if with no #endif gets a ghost at the end of the
file. |
| Unicode brackets | Plain text, Markdown, AsciiDoc, reStructuredText, Txt2tags | « »,
“ ”, ‘ ’, 「 」, 【 】, ⟨ ⟩ and others, in prose (not in
code). A ’ between letters is an apostrophe, not a closing quote. These get no ghost: prose leaves quotes
open on purpose. |
An end that has no partner and no place for one (an end tag with no start tag, an #endif with no
#if) is marked in brace-bad when the cursor is on it.
Working with braces
| Command | Default key | What it does |
|---|---|---|
| Navigate > Go to Partner | Ctrl+B | Moves the cursor to the partner of the brace, parenthesis or bracket beside the cursor, or of the quote, comment, tag, block word or #if line the cursor is on. When the partner is inside a macro, it goes to the place where that macro is used. Along an #if chain it goes to the next line of the chain. |
| Navigate > Select Inside Pair | Ctrl+Alt+B | Selects what is inside the pair around the cursor (or the selection): the text between two brackets, the inside of a string, of a comment, of a tag's element, of a block or of an #if chain. Pressed again, it selects the inside of the next pair out, so each press climbs one level. Only a pair Unryu is certain of is selected: when the pair around is likely, ambiguous or missing an end, nothing is selected and the status bar says why. A folded block that holds either end opens. In a block selection it does nothing, and says so. |
| Navigate > Select Pair | Ctrl+Alt+Shift+B | The same, with the pair's own ends: the brackets, the quotes, the tags, the block words or the #if and #endif lines. |
| Navigate > Next Change, Previous Change | The next or previous lines the change bar marks (Git). | |
| Navigate > Next Doubtful Brace | Ctrl+Alt+Down | Moves to the next brace whose answer is not certain: a likely or ambiguous pair, or a missing partner whose place is only a guess. (A brace that Kami is certain has no partner, with a certain place for it, is not doubtful: its ghost already shows where the partner goes.) At the end of the file it continues from the top. When every brace is certain, the status bar says "Every brace is certain." |
| Navigate > Previous Doubtful Brace | Ctrl+Alt+Up | The same, backwards. |
| Navigate > Insert Missing Brace | Ctrl+Shift+J | Writes a ghost into the text as a real brace: the ghost of the brace at the cursor, or else the next ghost after the cursor. A missing } goes on a line of its own, indented like the line with its {; a missing { goes at the end of the line above the block; a missing parenthesis or bracket goes right against what it closes. The other pairs work the same way: a missing quote or comment closer goes right where it stops, and a missing end tag, closing word or #endif goes on a line of its own, indented like its opening line. Undo takes it back. With no ghost after the cursor, the status bar says "No missing brace after the cursor." |
| Navigate > Suggest Repairs (Runs the Compiler) | Ctrl+Shift+B | Asks your compiler which repairs of a doubtful brace compile. See the next section. |
| View > Flash Missing Braces | none | When on, every ghost flashes between the brace-bad color and the dim ghost-guess color, half a second each, so a missing brace is hard to overlook. When off, ghosts are only shown dimmed. The same setting is "Flash missing braces" in Preferences. |
The Details panel tells everything about the brace at the cursor: its confidence, where its partner is, the range where an uncertain partner can be, and the reasons for Kami's answer (see "The Details panel" below).
Code folding uses the analysis too. In C and in other languages with braces, only certain pairs
become fold points, so folding a block always hides exactly that block, never a guess. In a language with a grammar,
the fold points are its scopes and blocks; in a language whose blocks are made by indentation or by words
(def ... end), they are those blocks. Folding itself (the fold margin, Document > Fold
All and Unfold All, and the "Code folding" setting) is described in Editing.
Suggesting repairs with the compiler
Unryu understands code without a compiler and never runs one by itself: not when a file opens, not while you type, and there is no setting that changes this. For C and C++ you can ask for a second opinion with Navigate > Suggest Repairs (Ctrl+Shift+B). Apart from the Build menu's commands, which you run yourself, this is one of only two things in Unryu that run a compiler; the other is the "ask the compiler" link in the tooltip (below).
- The compiler first checks the text as it is, once. The errors it reports are listed in the Messages tab of the message window ("file:line: error: ..."), and, when "Use indicators to show compile errors" is on in Preferences, the lines are underlined in the editor. Document > Remove Error Indicators clears them.
- Then Kami tries the doubtful braces in each place they could go, and the compiler checks which of those versions compile. Everything works on temporary copies in a private folder; your file is never changed.
- When it is done, the status bar says what it found, and the repairs the compiler accepts are listed at the
top of Details under The compiler accepts, most likely first: "Move
}from line 12 to line 15, column 1", "Delete}at line 30" or "Insert{at line 8, column 20". Up to nine are numbered; more are counted ("and N more"). - Press Ctrl+Alt+1 to Ctrl+Alt+9 to apply the repair with
that number. It is applied as one edit, so one Undo (Ctrl+Z) takes it back. A moved or
inserted
}is put on its own line, indented like the line of its{, unless code follows it on the line. The list stays until the text changes.
Sometimes the compiler settles the question without a repair: when exactly one placement compiles, Kami takes the compiler's answer and the pair becomes certain until your next edit. The status bar then says "The compiler settled N answers". Other results: "The compiler accepts this text as it is", "The compiler accepts the repairs listed in Details", or "No repair compiles, or too many to try", which usually means the compiler could not find the file's headers or flags (see Help > Compiler).
Press Ctrl+Shift+B again while it runs to stop it. It also stops by itself when you
switch to another file or quit, and after 15 seconds for one round of compiles or 60 seconds in all. It refuses to
start, with a message in the status bar, when the file has not been saved yet, when it is not C or C++, while the
latest edit is still being read, when no compiler named cc or c++ can be found, or when
the system cannot make a jail. While it runs, the Details panel has a Compiler section that names the
compiler and says it is running; when there are doubtful braces it says what Ctrl+Shift+B would run. It also says
when the compiler the project names will not be run, and how many of the project's flags were refused as unsafe or unknown. Which
compiler runs, with which flags, and how it is locked in, is explained in Safety and
Build and Run. Help > Compiler shows a summary in Details.
Names: declarations and definitions
For every name, Kami knows where it is declared. A declaration says that a name exists (for example a function's prototype); a definition is the one that gives it its body or its storage. Unryu can take you to either.
| Command | Default key | What it does |
|---|---|---|
| Navigate > Go to Definition; also Search > More > Go to Symbol Definition | Ctrl+T, F12, Ctrl+click | Goes to the definition of the name at the cursor (with Ctrl+click: the name you click). For a function with a prototype, that is its body. |
| Search > More > Go to Symbol Declaration | Ctrl+Shift+T | Goes to the declaration of the name, for example the prototype before the body. |
| Navigate > Back, Forward | Alt+Left, Alt+Right | Go to Definition, Go to Declaration, links and clicks in the Symbols list remember where you were and where you went (Go to Partner and the Doubtful Brace moves do not). Back and Forward walk that list, across tabs (Editing). |
| Search > More > Find Usage | Ctrl+Shift+E | With the cursor on a name, lists in the Messages tab every place in the project that means it: in this document by what Kami connects to one declaration, and in the project's other files from the project index. With a selection, a text search of the open documents (Find and Replace). Search > More > Rename Symbol renames the name in all of those places. |
| Search > More > Find Document Usage | Ctrl+Shift+D | The same, in the current document only. |
- Names from other files. When a name is declared in a header, Go to Definition goes to where it is
defined: Unryu also reads the project's other C and C++ source files, the nearest first, so for a function
declared in
draw.hand written indraw.cit opensdraw.cat the function's body. When no source file of the project defines it (a library's function), it opens the header at the declaration. Astaticfunction or variable of another file is that file's own and is never the answer. The file opens in a tab of its own and is then analysed like any other file. Reading the source files takes up to a few seconds after a file opens or its#includelines change; until then, Go to Definition goes to the header. - Names from anywhere in the project. Unryu also reads every file of the project in the background,
in every language it has a language file for: what each file defines (functions, types, classes, macros,
file-level variables) and the names it uses. When the name at the cursor is not the file's own, Go to Definition
goes to where the project defines it, the nearest file first (the most of its folders in common with this one);
the status bar says how many definitions there are when there are several. Reading happens in a jailed process of
its own, as all reading of code does (Safety), and a big project fills in as it is read.
What was read is kept in
~/.cache/unryu/index, so the next start reads only the files that changed; a file you save is read again at once. Hidden folders and the foldersbuild,node_modules,__pycache__,target,dist,outandreferencesare passed over, and a file over 4 MB is not read. The jailed process may read the project's folder and nothing else. While a workbench is open (Files), each of its projects is read the same way, and Go to Definition looks in all of them, the project in front first. A workbench's plain folders are not read. - Imports are links, in every language. Go to Definition on what an import names opens that file: Python's
import a.bopensa/b.py(ora/b/__init__.py), JavaScript'simport x from './y'opensy.js, Rust'smod parser;opensparser.rs, a shell script'ssource ./lib.shopenslib.sh, and so on for each language whose file says how (Language files). On a name afterfrom x import, it opensxat that name. The file is looked for beside this one, then from the project's folder, itssrcand itslib. - Include lines are links. Put the cursor on (or Ctrl+click) the file name of an
#includeand Go to Definition opens that header. If it cannot be found in the project or the system folders, the status bar says "That header was not found, in the project or the system's folders." - Links in Markdown. In a Markdown document, Go to Definition and Ctrl+click follow a link at the
cursor: a web address opens in your browser (Preferences > Tools), a file opens in a tab, and
#headinggoes to that heading. - Web addresses in code. A web or mail address in a comment or a string (
https://...,file://...,mailto:...) is a link too: Go to Definition and Ctrl+click open it in your browser (Preferences > Tools). In plain text, Markdown and the other prose files, an address anywhere is one. An address is found as the terminal finds one: a full stop, a comma or a closing bracket with no opening one at its end belongs to the sentence, not to the address. The editor's right-click menu has Open Link and Copy Link when you right-click on one. - Nothing found. When the name has no known declaration, the status bar says "No declaration found for the name at the cursor." If the headers are still being read, it says "Still reading this file's headers: try again in a moment."
- Uses of the name at the cursor are all highlighted with the
occurrencecolor, so you see at once where a variable is used. Only uses that mean the same thing are marked: a localiin one function is not confused with aniin another. - Names open in another tab. A name or header declared in a file that is open in another tab gets the
open-elsewherebackground.
LaTeX: labels, references and citations
In a LaTeX document, Unryu reads labels, references and citations as names, as it reads a program's:
- Labels.
\label{sec:intro}declares the labelsec:intro(a label's name runs on through digits,_,-and:).\ref,\eqref,\pageref,\autoref,\cref,\Cref,\nameref,\vrefand\labelcrefname it, one label or a list (\cref{a,b}). Go to Definition (F12, Ctrl+click) goes from a reference to its label, in this document or another.texfile of the project; Find Usage lists every reference to it; Rename Symbol renames it everywhere. - Citations.
\cite(and natbib's\citep,\citet, biblatex's\parencite,\textcite,\autocite,\footciteand the others) names a key of a.bibfile of the project, or one that\bibitem{key}declares in the document. Go to Definition opens the.bibfile at the entry. Resting the pointer on a key shows its entry: its type, author, title and year. - Completion. Inside
\ref{...}the completion list offers the labels; inside\cite{...}the keys, each with its first author, title and year (knuth:taocp — Knuth: The Art of Computer Programming (1968); taking one writes the key alone). The list comes from the first letter; Ctrl+Space shows it before one. - Missing ones. A reference to a label that nothing declares, or a citation of a key that no
.bibfile of the project and no\bibitemhas, gets a red wave under it. - Environments. Each
\begin{name}pairs with its\end{name}, as braces do: a missing\endshows as a ghost (see Other pairs, above). - Snippets and building. The LaTeX plugin's menus are snippets (Editing),
and Build runs
latexmk -pdf(Build and Run).
The tooltip over a name
Rest the mouse pointer on a name and, after a short pause, a popup appears that tells you about it, much like the documentation popup of an IDE. You can move the pointer into the popup to read it and click in it; it closes a moment after the pointer leaves both the name and the popup. It shows, from top to bottom, whatever applies:
| Part | What it shows |
|---|---|
| Error, Warning, Note | What the last build said about this line, in the color of its kind (Build and Run). These also show over a line with no name under the pointer. |
| The declaration | The name's declaration as written, on one line, in the editor's font and colors. Every name in it is a link to where that name is declared. |
| The documentation | The comment above or beside the declaration, without its comment markers. Doxygen-style commands are laid out: @brief as the text, each @param as a row under Params, @return as Returns, @note, @warning, @see and the others with their own labels. Both @ and \ forms work; text in backquotes is shown in the code font. |
| Value, Length | What the text says a name is worth: the number of an enum constant or of a #define without arguments, the length of an array, or the value a variable is set to, when it is a whole-number expression Unryu can work out. |
| Members | For a struct, union or enum type: each member as it is declared (up to 24, then "and N more"), with links. |
| Expands to | For a use of a macro: what this use becomes, with the macros inside it expanded too. |
| Size, Offsets | For a type or a file-scope variable in C or C++: a link, ask the compiler. A click runs your compiler once, in its jail, on a temporary copy of the file, and the popup then shows "N bytes, aligned to M (the compiler's, for this build)" and, for a struct, the offset of each member (up to 24). Unryu never guesses a size from the text, because only the compiler knows it for your build. The file must compile as far as its end; if it does not, the popup says "the compiler did not say". The file must be saved first, and it cannot be asked while Suggest Repairs is running. |
| Declared, Defined | The line where the name is declared and, when different, where it is defined, as links. For a name from a header, the header and line. |
| Uses | Up to 12 uses in this file, each with its line as a link and the line's text. With more, a link "all N uses, in Messages" runs Find Document Usage, a text search for the name, which may also list other names spelled the same. When the file belongs to a project, a link "in the project ..., in Messages" searches the whole project folder for the name as a whole word (Find in Files, without its dialog). |
| More: Show in Details | Shows this name in the Details panel, and keeps it there until the cursor moves, the text changes or you switch documents. |
| The footer | The kind of the name and where it is declared: "Function in unryu.c, line 12". For an #include file name, the header's path and "Header: Ctrl+click or F12 opens it". |
Clicking a link leaves the popup open, so you can follow several of its links in turn. If a link takes you to
another document, the popup's other links still work: they bring you back first. In the popup you can scroll with
the mouse wheel or its scrollbar, drag its bottom-right corner to make it larger or smaller, and change its text
size with Ctrl and the wheel. Then a Reset text size link appears in the footer;
Ctrl with the middle mouse button does the same. Unryu remembers the popup's size and text
size. Its colors are the tooltip, tooltip-text and tooltip-border keys of the
editor theme.
The Symbols list (Outline)
The Symbols tab of the sidebar lists what the current file declares at file scope, in groups. Each group shows how many entries it has, and opens when the file is first read.
| Group | What it lists |
|---|---|
| Functions | Each function once: its definition when the file has one, else its declaration |
| Types | typedef names, and struct, union and enum types that have a body. A type with members can be opened to list them; a class lists its methods. |
| Variables | File-scope variables, each once |
| Macros | Macros the file defines |
| Constants | Named constants declared at file scope, such as the constants of an enum |
| Headings | The headings of a Markdown (or similar) document, nested under each other. In a Markdown document all levels are open at the start, so the whole outline shows. |
Each row shows the name in the color of its kind, with () after a function and {}
after a struct, union or enum, followed by its line number. The row of the symbol the cursor is in is highlighted
with the color of the cursor line.
- Click a row to go to that symbol. This counts as a jump, so Back returns to where you were.
- The arrow keys move through the rows and show each symbol in the editor, while the keyboard stays in the list. These moves are not added to the Back list.
- Right-click the list, or open the panel's own menu, for: Sort by Name (letter case ignored first, then as written, then by line), Sort by Appearance (the order in the file), Expand All (every group and every entry that has entries under it) and Collapse All. The sort order is remembered; its starting value is "Default sorting mode" in Preferences.
"Symbol list update frequency" in Preferences (250 milliseconds at first) sets how often the list takes in new symbols while you type; 0 means only when the file is saved, or when you switch to the document. When you only move the cursor, the mark of the symbol at the cursor moves at once; new or changed rows wait for the next update. The list is rebuilt only when what it lists changes. "Show symbol list" in Preferences shows or hides the tab, and the list has a font of its own; see Preferences and, for the sidebar itself, The Window.
Characters that are not what they look like
The status bar shows the code point of the character at the cursor (U+00E9). When that character is past
ASCII, or a control character, Details has a part about it: its name (LATIN SMALL LETTER E WITH ACUTE), its
Unicode block, and its bytes in UTF-8.
Some characters cannot be told apart from others by looking, and Unryu marks them wherever they are:
| Characters | Marked | Why it matters |
|---|---|---|
Bidirectional controls: U+202A to U+202E, U+2066 to U+2069,
U+200E, U+200F, U+061C | By a short name where they are, such as
‹RLO›, in the brace-bad color | They change the order in which the text shows, so code can read differently from how it compiles ("Trojan Source"). |
| Characters that show nothing: a zero-width space, joiners, a word joiner, a soft hyphen, the invisible math operators, a byte order mark anywhere but at the very start | By a short name where they are, such as
‹ZWSP› or ‹BOM›, faded | They are there, yet you cannot see them: a name that looks the same is not the same name. |
| Spaces that look like a plain space: a no-break space, the em and en spaces and the other wide spaces, the ideographic space | Tinted under, in code only (prose uses a no-break space on purpose) | A no-break space in code is an error you cannot see. |
The marks are never part of the text. Put the cursor on such a character to read its name in Details, and what is unusual about it.
The Details panel
Details (View > Show Details) is a read-only panel that explains what the analysis knows about the place where the cursor is, and about the whole file. It changes as you move the cursor. With nothing at the cursor, in a file that has braces, it says "Put the cursor on a name, or right before or after a brace." From top to bottom it can show:
| Section | What it says |
|---|---|
| Analysis | Why the colors and answers are missing or out of date (see "When the analysis is slow or stops"). |
| Unsaved Text | That no recovery copy of your unsaved text could be made, or that the text was recovered and is not saved yet (Files). |
| The compiler accepts | The numbered repairs from Suggest Repairs, applied with Ctrl+Alt+1 to 9. |
| The name at the cursor | A heading with its kind and name in their colors ("Function sum"; a variable inside a function is a "local variable"); its declaration as code, in the editor's colors; its documentation; Declared: the line (marked "definition" when it is one); Defined: the line of the definition when that is elsewhere; and Uses in this file. For a name from a header: its declaration and documentation from the header, and Declared in: the header and line. For an #include file name: a Header section with its path. |
| The brace at the cursor | "Brace { at line 4, column 13" (or Parenthesis, Bracket); whether it is spelled as a digraph or across a line splice; Confidence: certain, likely or ambiguous; Partner: its line and column, or "inside the expansion of" a macro, or "missing; a } most likely goes before line N", or "none; this brace looks extra"; In another #if configuration: where it pairs when other #if branches are taken; Range: the lines where an uncertain partner can be (tinted in the editor); "Deleting it would also be a repair" when that is so; and Why: Kami's reasons, such as "Nesting and indentation agree on this pair" or "The block's indentation ends with no brace there, so one is missing". A brace inside a preprocessor directive is not paired there: Details says it is paired where the macro is used. |
| Markdown | For a Markdown document: words, characters and reading time; headings by level; links (to files, to the web, to headings) and images; code blocks by language; tables, to-do items done, quoted lines, footnotes and front matter. Leads Nowhere lists links and images whose file or heading does not exist, and Contents lists the headings with their lines. |
| Compiler | What Suggest Repairs would run or is running, a compiler that will not be run, and flags that were ignored (see above). |
| File | The number of lines; the project (Build and Run); what the file declares, counted by the Symbols list's groups in their colors; the braces: how many are certain, likely and ambiguous, how many are missing a partner and how many are extra; braces inside directives (not paired); the number of symbols, and whether all of the file could be read. |
| Unterminated | Up to eight comments, strings or character literals that are never closed, with their line and column. |
Help > Colors and Help > Compiler also show their help text in this panel. Details has its own font (Preferences), and its headings take the editor theme's colors. Text that comes from the file is shown so that it can never make the panel load an image or anything else (Safety).
The status bar
After each answer, the status bar shows the file's path, its encoding (for example "UTF-16LE (with BOM)"), and the brace counts: "N braces: N certain, N likely, N ambiguous, N missing a partner, N extra". Commands on this page also report there: a repair applied ("Repair applied (Ctrl+Z takes it back)."), a compiler started or stopped, a name or header that was not found. The next message replaces the last one, which is why the things you must not miss are also kept in Details. With "Suppress status messages in the status bar" on in Preferences, the messages go to the Status tab of the message window instead (The Window).
Inserting standard headers
Edit > Insert "include <...>" writes an #include line at the cursor. Its first item,
#include "...", writes #include "" with the cursor between the quotes. The other items are
submenus of standard headers; choosing one writes #include <name> and a new line:
| Submenu | Headers |
|---|---|
| C Standard Library | assert.h, ctype.h, errno.h, float.h, limits.h, locale.h, math.h, setjmp.h, signal.h, stdarg.h, stddef.h, stdio.h, stdlib.h, string.h, time.h |
| ISO C99 | complex.h, fenv.h, inttypes.h, iso646.h, stdbool.h, stdint.h, tgmath.h, wchar.h, wctype.h |
| C++ (C Standard Library) | cstdio, cstring, cctype, cmath, ctime, cstdlib, cstdarg |
| C++ Standard Library | iostream, fstream, iomanip, sstream, exception, stdexcept, memory, locale |
| C++ STL | bitset, deque, list, map, set, queue, stack, vector, algorithm, iterator, functional, string, complex, valarray |
Once the line is in, the analysis reads that header and its declarations become known in the file, with their colors, tooltips and links.
Settings and keys on this page
| Setting | Where | What it does |
|---|---|---|
| Syntax and semantic highlighting | Preferences; View > Syntax Highlighting | Colors text and names by what they are |
| Flash missing braces | Preferences; View > Flash Missing Braces | Ghosts flash instead of only showing dimmed |
| Invert syntax highlighting colors | Preferences | Every theme color shown as its opposite |
| Code folding | Preferences | Fold points from the analysis (Editing) |
| Use indicators to show compile errors | Preferences | Underlines the lines the compiler reported |
| Show symbol list; Default sorting mode; Symbol list update frequency | Preferences | The Symbols list (above) |
| Editor theme | View > Change Color Scheme | All the colors on this page (Themes) |
trusted-compilers | Preferences > Various, or unryu.conf | Compilers you allow besides the system's own (Safety) |
The keys on this page are the defaults. Most can be changed in Preferences > Keybindings; the full list is in Keys.
| Key | Command |
|---|---|
| Ctrl+B | Go to Partner |
| Ctrl+Alt+Down, Ctrl+Alt+Up | Next, Previous Doubtful Brace |
| Ctrl+Shift+J | Insert Missing Brace |
| Ctrl+Shift+B | Suggest Repairs; again to stop |
| Ctrl+Alt+1 to Ctrl+Alt+9 | Apply a repair |
| Ctrl+T, F12, Ctrl+click | Go to Definition |
| Ctrl+Shift+T | Go to Symbol Declaration |
| Ctrl+Shift+E, Ctrl+Shift+D | Find Usage, Find Document Usage |
| Alt+Left, Alt+Right | Back, Forward |
| Ctrl+wheel, Ctrl+middle button | In the tooltip: text size, reset text size |