summaryrefslogtreecommitdiff
path: root/src/face_registry.cc
AgeCommit message (Collapse)Author
2024-08-14Merge remote-tracking branch 'arrufat/support-double-underline'Maxime Coste
2024-08-12Extract format implementation to its own fileMaxime Coste
Split it to avoid pulling all string_utils dependencies for just format.
2024-08-04Add support for double underlineAdrià Arrufat
2024-03-27Add -indent option to show-whitespace highlighterTobias Pisani
A couple of semi-opinionated choices were made in this implementation: 1. The guide is hidden in the first column. 2. The indent guides are highlighted using a new `WhitespaceIndent` face. 3. Nothing is done to continue the guide through empty lines. I believe this to be the correct approach, at least as long as it is kept as a part of the show-whitespaces highlighter. However some people's oppinion may differ, and if so, that could be implemented. 4. The guides default to on, like the other show-whitespace options. Default character is "│". 5. Spaces between the indent guides are currently highlighted as other spaces. Other reasonable options would be no replacement, -tabpad, or a similar -indentpad. 6. Guides are disabled by passing `-indent ""`. 7. Indent guides are separate from tab highlighting. Additionally, we could consider adding a separate face for the "current" indent level as many editors do, but this is a bit harder in kakoune because of multiple selections. Closes #2323
2023-09-28Add an InlineInformation face distinct from InformationLoric Brevet
2023-06-10Pre-parse face specs in HighlightersMaxime Coste
Re-parsing face specs can be expensive as highlighters can be called many times during a redraw with nested regions.
2022-02-11Faces: Check that underline colour comes before base/attributes markersQeole
Parsing a (non-valid) font with a comma in the name of the base colour makes Kakoune crash. It is not a valid face, but Kakoune should just return an error message instead. Reproducer: :set-face global foo ,red@,blue Note the comma "," after the "@". This is not a valid base name, and it leads to a crash. Let's see what happens. At the beginning of parse_face(), we have the following code: auto bg_it = find(facedesc, ','); auto underline_it = bg_it == facedesc.end() ? bg_it : std::find(bg_it+1, facedesc.end(), ','); auto attr_it = find(facedesc, '+'); auto base_it = find(facedesc, '@'); [...] auto colors_end = std::min(attr_it, base_it); After this: - bg_it points to ",red@,blue" - bg_it != facedesc.end(), so we have underline_it pointing to the first comma after bg_it. This means that underline_it points to ",blue" - base_it points to "@,blue" - attr_it points to the end of facedesc (no "+" marker), so colors_end points to base_it, "@,blue" Later in the code, just after parsing the foreground and background colours, we have: if (underline_it != facedesc.end()) face.underline = parse_color({underline_it+1, colors_end}); When passing {underline_it+1, colors_end} to parse_color(), we pass in fact iterators pointing to {",blue", "@,blue"}. Because the second one starts _before_ the first one in the string, this means that the resulting string is considered to have a _negative_ length. parse_color() passes the string to str_to_color(), who fails to turn up the colour, and attempts to throw: throw runtime_error(format("unable to parse color: '{}'", color)); The variable "color" still has this negative length, and this goes all the way down to an assert in src/units.hh where we expect that string to be >= 0, and we crash on the assertion failure. For similar reasons, we also get a crash if the comma comes after the marker for the face attributes: :set-face global foo ,red+,a To fix both cases, let's add a check to make sure that the underline_it, marked with a comma, never gets detected as present and pointing after colors_end, be it "@" or "+".
2021-09-07Add standard DiagnosticError and DiagnosticWarning faces.Tim Allen
kak-lsp uses these faces to mark errors inside the buffer, instead of the Error face which is much more jarring, and which does not have an associated warning face. Since the :spell command marks errors inside the buffer, it's also updated to use this new face. Adding these faces to Kakoune makes it more likely that colorschemes will automatically do the right thing when used with kak-lsp, and makes it possible to use a subtle appearance (like curly underlines) for in-buffer errors while keeping Kakoune errors bold and jarring as they should be.
2021-09-07Add support for curly underline and separate underline colorMaxime Coste
Add support for a third color in face definition that controls the underline and a 'c' attribute for curly underline (that takes precedence over 'u' if both are specified) Allow empty colors to mean default, so that `,,red+u` means the same as `default,default,red+u` Fixes #4138
2021-09-05Fix strikethrough support in face to string conversionMaxime Coste
2021-07-12src: Support strikethrough facesJason Felice
2020-08-30Fix face attributes to string conversion with F shorthandMaxime Coste
Previously a `F` attribute would end up being converted to Ffga which is confusing as F *means* fga.
2019-12-03Document that fg face is optionalMaxime Coste
2019-11-04Use a specific WrapMarker face for wrap highlighter wrapped line markerMaxime Coste
2019-04-28Fix parsing of faces with a base but no attributesMaxime Coste
2019-04-23Change faces alias to be a base that can be modifiedMaxime Coste
Using <fg>,<bg>+<attr>@<base> will apply the given fg color, bg color and attributes on top of base dynamically. Simply giving <base> is a shorthand for default,default@<base>. Inspired by the discussion in #2862
2018-09-24Misc fixesOlivier Perret
2018-09-23Replace the `Exclusive` face attribute with `Final`Maxime Coste
Final is more granular, it consists of FinalFg (f), FinalBg (g) and FinalAttr (a) which control if a face's fg, bg, or attributes fully overwrite the previous face (instead of merging) and if following faces apply on top of this face or not. Fixes #2388 if the Whitespace face has the FinalFg flag.
2018-07-26Cleanup some trailing whitespaces and double semicolonMaxime Coste
2018-07-20src: Allow face names to contain an underscoreFrank LENORMAND
Closes #2229
2018-04-10FaceRegistry: Support referencing a named face from a parent scopeMaxime Coste
2018-04-07Make FaceRegistry scopedMaxime Coste
set-face now takes a scope argument, and faces can be overridden on a buffer or window basis. colorscheme apply on global scope, which should be good enough for now. Fixes #1411
2018-04-06Make error messages more consistentDelapouite
2018-03-13ranges: Add transform overload taking directly a pointer to memberMaxime Coste
This overload will forward to the general transform implementation using std::mem_fn to generate a callable.
2018-02-24Highlight cursors differently when they lie on an end of lineMaxime Coste
When on an end of line, certain behaviours can be surprising, for example delete will join the following line (which makes sense, and is consistent, but hard to predict if we do not know the cursor is on and end of line). As Kakoune is moving more and more towards treating end of lines as any other character, making it clear when the cursor lies on them seems like a good way to reduce surprise.
2018-02-09FaceRegistry: pass face names as StringViews instead of const String&Maxime Coste
2018-01-18Use the _str and _sv string literals more oftenMaxime Coste
2017-10-10Move all non-core string code to string_utils.{hh,cc}Maxime Coste
2017-09-12Rename some string conversion function to the common 'to_string'Maxime Coste
2017-09-11Add debug facesDelapouite
2017-09-01Slight tweak of FaceRegistry::FaceOrAlias definitionMaxime Coste
2017-08-29Rename containers.hh to ranges.hh (and Container to Range)Maxime Coste
2017-05-30fix: remove duplicate include to containers.hh in face_registry.ccDelapouite
2017-05-07Introduce a LineNumberWrapped faceMaxime Coste
2017-03-07Replace uses of UnorderedMap with HashMapMaxime Coste
2016-10-10Convert some uses of lambda to more concise std::mem_fnMaxime Coste
2016-04-30fix whitespace labelpierroelmito
The author of this work hereby waives all claim of copyright (economic and moral) in this work and immediately places it in the public domain; it may be used, distorted or destroyed in any manner whatsoever without further attribution or notice to the creator
2016-04-30add face to change whitespace colorspierroelmito
2016-04-11Merge remote-tracking branch 'lenormf/buffer-padding'Maxime Coste
2016-03-08Rework container helpers, use pipe syntax and cleanup implementationMaxime Coste
use 'container | filter(func) | reverse() | transform(func)' instead of 'transform(reverse(filter(container), func), func)' to express container transformations.
2016-02-17Cleanup/fix some codeFrank LENORMAND
2016-02-17Allow users to chose how the buffers are paddedFrank LENORMAND
2016-02-12Fix face completion, avoid a spurious temporaryMaxime Coste
2016-02-10Fix use of dead temporary strings in completionsMaxime Coste
2015-12-12Avoid instanciation of a `String` object everytime the `parse_color`Frank LENORMAND
function is called.
2015-12-11Ensure that at least one character follows a ',' or a '+' sign in a faceFrank LENORMAND
description (respectively a background color and attributes).
2015-11-24Add StatusLine{Mode,Info,Value} built in facesMaxime Coste
Fixes #491
2015-11-09Merge search hihglighter and regex option highlighter in dynregexMaxime Coste
2015-10-23Add an exclusive attribute that overrides existing faceMaxime Coste
2015-10-05Allow parsing empty strings as default color in face descsMaxime Coste