Repository navigation
Releases: lichdotdev/godemirror
Releases · lichdotdev/godemirror
Release list
v0.8.0
Added
New,NewSplitandNewDiffViewwork without fontconfig, on Windows,
macOS and a Linux that lacks it: they read the fonts in the platform's font
directories (%WINDIR%\Fontsand the user's on Windows;/System/Library/Fonts,
/Library/Fontsand~/Library/Fontson macOS; the XDG ones on Linux), match
the family by the name each font carries, and fall back to those fonts for a
character the family lacks, CJK included."monospace"is the platform's
own (Cascadia Mono or Consolas on Windows, Menlo on macOS). Where fontconfig
is installed nothing changes.ErrFontNotFound, whatNewfails with, without fontconfig, when no
installed font is of the family asked for.
Changed
Newno longer fails withErrNoFontconfigwhere fontconfig is missing.
A caller that tested for it to fall back toNewFromFontstests for
ErrFontNotFoundinstead.
Deprecated
ErrNoFontconfig:Newnever returns it.
Fixed
- A family whose styles live in one collection file (
.ttc) draws each
style from its own font. fontconfig names a font in a collection by file
and index, and the index was dropped: every style came from the file's first
font, so bold or italic text could come out regular, or in another family
the collection holds. - A character the family lacks is drawn from the font fontconfig ranks
first, also when that font is in a collection. The fallback took the
collection's first font instead: drawn bold or in another family the file
holds, or as a box when that font lacked the character.
v0.7.1
Fixed
- CJK text no longer stalls a view, and views no longer hold a copy of each
font apiece. A character the family lacks asked fontconfig for a fallback
once per distinct character, two subprocesses each inside a frame, so a diff
full of CJK text froze for seconds; a fallback already loaded now answers for
the characters it covers, and the monospace ranking is read once per process.
Every view, and aDiffViewhas one per file, read the font files on its
own: they are now read once per process and shared, 50DiffViews holding
about 1 MB where they held 61 MB.
v0.7.0
Changed
DarkThemeandLightThemestyle parameters and builtins: a
parameter's declaration,definition(local(variableName)), is italic in the
text color, andstandard(variableName)takes the type color, as
standard(typeName)andstandard(className)already did. A called builtin,
function(standard(variableName)), keeps the function color.
v0.6.0
Added
RicherGoTags,RicherJavaScriptTags(JavaScript and TypeScript),
RicherPythonTagsandRicherRustTags, opt-in rules like
RicherJavaTags: a parameter's declaration is
definition(local(variableName)), which a theme coloring
definition(variableName)still colors; Go'smakeis
function(standard(variableName))where@lezer/goleft it untagged.StyleRule.Nameslimits a rule to nodes whose text is one of them, which
CodeMirror's styleTags cannot say: a node with any other text falls through
to the next rule, and a rule with Names is tried before one as deep without.GoBuiltinTags,JavaScriptBuiltinTags,PythonBuiltinTagsand
RustBuiltinTagstag builtins by name with it: Go's predeclared types and
functions, Python's built-in functions, ECMAScript's globals and
TypeScript's primitive types, and Rust's primitive types, as
standard(typeName),standard(className),standard(variableName)or,
called,function(standard(variableName)).
Changed
RicherJavaTagsalso tags a method's, constructor's or lambda's
parameterdefinition(local(variableName)), as the new Richer sets do.
v0.5.0
Added
StyleTagsadd styleTags rules to a Lezer grammar, as a CodeMirror
caller does withlanguage.configure({props: [styleTags({...})]}): set them
onContent.StyleTagsorDiffOptions.StyleTags, naming the grammar
("java","javascript", ...) and the paths and tags of eachStyleRule.
They combine with the grammar's own rules as Lezer combines them. Rules for
a language that has no Lezer grammar, or a path that does not parse, make
Layoutreturn an error.RicherJavaTags, opt-in rules that tag Java finer than@lezer/java
does: enum constants asconstant(variableName), annotations as
annotation, fields asdefinition(propertyName), and package and import
paths asnamespace.
v0.4.0
Changed
- CSS, Go, HTML, Java, JavaScript, TypeScript, Python and Rust are
highlighted by a port of CodeMirror's own Lezer parser. A file of one of
them is parsed with its@lezer/*grammar and tagged by itsstyleTags, as
CodeMirror tags it: a call and a declaration, a type and a variable, are told
apart where chroma could not, and HTML's scripts, styles andstyle/on*
attributes are highlighted as JavaScript and CSS. Code a grammar cannot
parse is left as CodeMirror leaves it. - Kotlin and shell scripts are highlighted as CodeMirror highlights them,
by a port of the@codemirror/legacy-modesmodes (kotlin,shell) that
CodeMirror runs through itsStreamLanguage:.kt,.kts,.sh,.ksh,
.bashand a file namedPKGBUILD. Every other language is still read by
chroma. - New content in a Lezer language is reparsed incrementally.
SetContent
andUpdateContentreuse the tree of the content before, as CodeMirror
reparses after an edit, nested scripts and styles included: a one-character
edit to 13,000 lines of Java reparses in about 1.2 ms instead of 50 ms, and
the whole update takes about 28 ms instead of 78; in a 13,000-line HTML page,
0.4 ms instead of 71, and 30 ms instead of 102. Highlighting now runs one
content at a time, in order, skipping one replaced before its turn. - A token can carry several tags, and its style merges theirs. Each tag
takes the spec of its most specific styled tag, and the specs apply in
their order in theHighlightStyle, a later one's color, bold, italic,
underline or line-through winning, as CSS cascades CodeMirror's classes. A
chroma token still has one tag, and draws as before.
v0.3.0
Added
tags.Parsereads a tag back from the nameStringprints, modifiers
included ("function(definition(variableName))"), so a theme kept in JSON or
TOML can name the tags itsTagStyles style.
Fixed
- A line-through sits across the text in every font. With fonts whose
x-heightx/imagereports negative (DejaVu Sans Mono), aStrikethrough
token was ruled below the baseline instead of across its letters.
v0.2.0
Added
- CodeMirror's highlighting tags. The new
tagspackage is
@lezer/highlight's vocabulary: every standard tag and theDefinition,
Constant,Function,Standard,LocalandSpecialmodifiers, falling
back from specific to general the way CodeMirror's do. chroma's tokens are
tagged with them, punctuation down to parens, braces and separators. HighlightStyle, as in CodeMirror.NewHighlightStyletakesTagStyle
specs (tags, color, bold, italic, underline, line-through) and resolves a
token's style likeHighlightStyle.define: the most specific styled tag
wins, and a later spec for a tag replaces an earlier one.Specsgives
back a style's specs, so a theme can extend another's with specs of its own.- Ported CodeMirror themes:
OneDark(@codemirror/theme-one-dark), and
Dracula,GitHubLight,GitHubDarkandNord(@uiw/codemirror-themes),
spec for spec. The demo takes-theme.
Changed
- Breaking: themes style tags, not classes.
Theme.Syntax,TokenStyleand
TokenClassare gone. A theme of your own setsTheme.Foreground(what
Syntax[Plain].Colorwas) andTheme.Highlight, a*HighlightStylebuilt
fromTagStylespecs namingtags.DarkThemeandLightThemekeep their
colors, and a few tokens move with the finer tags:self/thistake the
keyword color, HTML entities the string color, exception names the type
color, symbols and atoms the literal color; markdown headings and strong text
are bold, emphasis italic, links underlined.
Fixed
- Resizing a view no longer redraws every row. A
View,Splitor
DiffViewwhose width changed every frame (a pane edge being dragged)
composed every visible row again each frame; now a row is composed again
only when the cells it shows change.
v0.1.0
Added
- A read-only code view for Gio.
Viewshows one document: monospace rows
highlighted by chroma from the file name, a line-number gutter (or labels of
your own), wrapping or sideways scrolling, and one image per visible row, so
a full screen of code costs a handful of quads. Highlighting runs off the UI
goroutine;SetContentshows a new document from its top and
UpdateContentswaps in a new version of it without moving the scroll. - Side by side.
Splitshows two documents row for row, scrolling down
together and sideways each on its own, and it can wrap: a pair of lines takes
the taller side's rows. - Decorations and widgets.
LineDecorationtints a line and its gutter
cell, puts a strip down the gutter, rules a separator, hatches a filler row,
tints spans of characters, and lights a whole hover group under the pointer.
LineWidgetputs a Gio widget on a line (after its text or at the right
edge, optionally only while hovered);BlockWidgetopens space between lines
for any widget, such as a review thread. - Selection. Drag, double and triple click, Shift+click, Ctrl+A and Ctrl+C,
with tabs copied as written. From code:Select,SelectLines,
Selection,SelectedTextandSelectedLines, plusScrollToLinewith
AlignNearest,AlignCenterandAlignTop,LineCountandLineText.
A selection dragged past the view's edge scrolls it, faster the farther the
pointer is beyond (sideways too when unwrapped), and keeps going on frames
where the pointer does not move. - A diff view.
DiffViewdiffs two documents itself (SetDocs, line by
line with Myers' algorithm) or shows a file of agit diffpatch
(ParsePatch,SetPatch). Unified, with an old | new line-number gutter,
or side by side, with deletions and additions paired and fillers hatched.
Unchanged runs collapse behind an expander (Collapse, or the gaps of the
patch, filled throughDiffOptions.ExpandandFillGap, in parts if need
be). Each chunk can be reverted throughDiffOptions.Revert;Chunks,
SelectedRangeandSelectedChangesread the diff in file line numbers,
andSetBlocksanchors widgets to file lines.HighlightChangestints the
words that changed within a line. The expander and revert affordances are
drawn by the library and can be replaced. - Search.
View.SetSearchtakes aSearchQuery(literal or regexp, case
sensitivity, whole word) and highlights every match, beneath the text, in
Theme.SearchMatch; the selected match is the current one, in
Theme.SearchCurrent.Matcheslists them andFindNextandFindPrevious
select the one after or before the selection, wrapping, and scroll it into
view, sideways too when lines do not wrap. A match never spans lines, and a
bad regexp is the only error.DiffView.SetSearch,Matches,FindNext
andFindPreviousdo the same across its unified view and both sides of the
split. - Themes.
DarkThemeandLightTheme, with the diff colors in
Theme.Diff. A theme change shows on the next frame. - Fonts without fontconfig.
Newresolves a family through fontconfig and
fails withErrNoFontconfigwhere it is missing;NewFromFonts(and
NewDiffViewFromFonts) take the font files' contents instead. A character no
font covers is drawn as a box. - Wide characters take two cells. CJK, fullwidth forms and emoji are laid
out on the monospace grid as a terminal lays them out, so the columns after
them line up; a click on either half lands before or after the character,
wrapping never splits one, and a gutter label's width counts them too.
Pos.ColandSpanstill count runes.