Commit Graph

17 Commits

Author SHA1 Message Date
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Itamar
ab0b4f46f7 LibGUI: Support multiple layers of TextDocument spans
TextDocument::set_spans() now also takes a "span collection index"
argument.

TextDocument keeps a map between a span collection index and its spans.
It merges the spans from all collections into a single set of spans
whenever set_spans() is called.

This allows us to style a document with multiple layers of spans, where
as previously we only supported a single layer of spans that was set
from the SyntaxHighlighter.
2022-03-29 17:45:36 +02:00
Lenny Maiorani
7cc6ba16be Libraries: Use default constructors/destructors in LibSyntax
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
thankyouverycool
94b74937d8 LibGUI+LibSyntax: Stringify Highlighter::Language
This patch adds a Highlighter::Language -> string helper and a
callback for Highlighter changes.
2022-02-24 19:09:41 +01:00
Itamar
4646bf4b92 LibCpp: Add SemanticSyntaxHighlighter
The SemanticSyntaxHighlighter uses TokenInfo results from the
language server to provide 'semantic' syntax highlighting, which
provides more fin-grained text spans results.

For example, the SemanticSyntaxHighlighter can color function calls,
member fields references and user-defined types in different colors.

With the simple lexer-only syntax highlighter, all of these tokens were
given the same text highlighting span type.

Since we have to provide immediate highlighting feedback to the user
after each edit and before we get the result for the language server,
we use a heuristic which computes the diff between the current tokens
and the last known tokens with compete semantic information
(We use LibDiff for this).

This heuristic is not very performant, and starts feeling sluggish with
bigger (~200 LOC) files.
A possible future improvement would be only computing the diff for
tokens in text ranges that have changes since the last commit.
2022-02-09 00:51:31 +01:00
Brian Gianforcaro
d32736582e LibSyntax: Add a language enum entry for git commit messages 2022-01-18 09:01:16 +01:00
Sam Atkins
38f6140159 LibWeb: Implement first draft of CSS syntax highlighting :^)
This works at the Token level, which is quick and easy but has
drawbacks: We don't know when something is a property name or a value,
or if something is part of a selector. But, this works for now.
2021-10-23 19:07:44 +02:00
Ben Wiederhake
e6ea13af61 LibSyntax: Add missing headers to HighlighterClient.h 2021-10-06 23:52:40 +01:00
Mustafa Quraish
4961fa4715 LibSyntax: Fix bug in matching cursor highlighting
Fixes #9760.
2021-09-03 11:45:50 +02:00
Ali Mohammad Pur
71b4433b0d LibWeb+LibSyntax: Implement nested syntax highlighters
And use them to highlight javascript in HTML source.
This commit also changes how TextDocumentSpan::data is interpreted,
as it used to be an opaque pointer, but everyone stuffed an enum value
inside it, which made the values not unique to each highlighter;
that field is now a u64 serial id.
The syntax highlighters don't need to change their ways of stuffing
token types into that field, but a highlighter that calls another
nested highlighter needs to register the nested types for use with
token pairs.
2021-06-07 14:45:49 +04:30
Ali Mohammad Pur
97a230e4ef LibWeb: Add a super basic HTML syntax highlighter
This can currently highlight tag names and attribute names/values.
2021-05-20 22:06:45 +02:00
Dylan Katz
984b6e08cf LibSQL: Add a syntax highlighter 2021-05-09 09:39:05 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
a50ba0a491 LibSyntax: Make rehighlight() take Gfx::Palette as by const-reference 2021-02-11 23:52:39 +01:00
Andreas Kling
ddbf20ecf6 LibSyntax+LibGUI+LibJS: Move JS syntax highlighter to LibJS
This is a little bit messy but the basic idea is:

Syntax::Highlighter now has a Syntax::HighlighterClient to talk to the
outside world. It mostly communicates in LibGUI primitives that are
available in headers, so inlineable.

GUI::TextEditor inherits from Syntax::HighlighterClient.

This let us to move GUI::JSSyntaxHighlighter to JS::SyntaxHighlighter
and remove LibGUI's dependency on LibJS.
2021-02-07 16:56:02 +01:00
Andreas Kling
43c7d7d285 LibSyntax: Move GUI::Highlighter to Syntax::Highlighter in LibSyntax
This is a move towards dropping more LibGUI dependencies.
2021-02-07 15:15:10 +01:00