Commit Graph

39 Commits

Author SHA1 Message Date
Andreas Kling
21db2b7b90 Everywhere: Remove NonnullOwnPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Sam Atkins
3d25b4eb34 LibGUI: Add folding regions to TextDocument
A `TextDocumentFoldingRegion` represents a region of the document which
the user can collapse/expand to make code easier to navigate.
2023-02-28 13:23:55 +01:00
Fausto Tommasi
f7458b3e17 LibGUI: Update TextEditor to delete emoji based on gbp cluster
Updated TextDocument and TextEditor to use calls to
`find_grapheme_segmentation_boundary` in order to make "correct-feeling"
deletions on backspace and delete keys being pressed
2023-02-17 07:50:09 -05:00
Sam Atkins
a5ff6769f5 LibGUI: Make undo work for TextDocument ReplaceAllTextCommand
The undo code here was just replacing the new text with the new text.
Now we actually save the old text and use that instead. :^)
2023-01-13 13:37:19 +01:00
Snow
2f8c7b1b30 LibGUI: Add shortcut for inserting new line
This adds shortcut for inserting a new empty indented line
above/below current cursor position.

- <Ctrl-Return> for inserting line below.
- <Ctrl-Shift-Return> for inserting line above.
2022-12-11 19:47:42 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Kyle Lanmon
ad250dd484 TextEditor: Add UndoCommands for commenting and uncommenting lines 2022-11-27 18:28:43 -07:00
Kyle Lanmon
9aa00a6d70 TextEditor: Add utility to keep a range of text within a line 2022-11-27 18:28:43 -07:00
Lucas CHOLLET
d391f1fb2a LibGUI: Add TextDocument::take_line(size_t line_index)
This method is similar in all respects to remove_line except that it
returns the removed line.
2022-07-19 10:49:38 +01:00
Lucas CHOLLET
a85223e13b LibGUI: Add a default virtual destructor to virtual classes
Affected classes are children of TextDocumentUndoCommand:
 - InsertTextCommand
 - RemoveTextCommand
 - ReplaceAllTextCommand
2022-07-19 10:49:38 +01:00
huttongrabiel
9369610bf4 LibGUI: Unindent selected text on shift+tab press
Selected text is unindented when Shift+Tab is pressed. Select text,
indent it with Tab, then unindent with Shift+Tab.
2022-07-08 11:47:56 +01:00
huttongrabiel
2fbaa7996c LibGUI: Indent selected text on tab press
If selected text is less than a whole line, usual delete/replace takes
place. Otherwise, if the selected text is a whole line or spans
multiple lines, the selection will be indented.
2022-07-08 11:47:56 +01:00
ForLoveOfCats
2adc5efe2b LibGUI: Don't merge TextDocumentUndoCommand if too much time has elapsed 2022-04-26 19:13:22 +02:00
SimonFJ20
399202f1d3 LibGUI: Make class final and seperate from GML Playground 2022-04-13 21:24:48 +02:00
SimonFJ20
661e7d691e LibGUI+GMLPlayground: Replace text using ReplaceAllTextCommand 2022-04-13 21:24:48 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Itamar
a12385dc4b LibGUI: Add match_case parameter to TextDocument::find_all() 2022-03-29 17:45:36 +02: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
fe3b846ac8 Libraries: Use default constructors/destructors in LibGUI
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-12 14:44:43 -08:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
thankyouverycool
92fffc3abc LibGUI: Rename CallOnChange => AllowCallback and implement elsewhere
This is a helpful option to prevent unwanted side effects, distinguish
between user and programmatic input, etc. Sliders and SpinBoxes were
implementing it idiosyncratically, so let's generalize the API and
give Buttons and TextEditors the same ability.
2021-09-22 21:35:42 +02:00
Ariel Don
808e5e813f LibGUI: Add Ctrl-W to insert mode
In Vim's insert mode, Ctrl-W deletes the word before the cursor, like
Ctrl-Backspace. Unlike Ctrl-Backspace, if only whitespace exists between
the end of the word and the cursor, the word will be deleted with the
whitespace.

To do so, this commit introduces two methods: delete_previous_word() for
TextEditor and first_word_before() for TextDocument, where the former
depends on the latter. delete_previous_word() is then called in
VimEditingEngine.
2021-07-20 03:22:28 +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
Andreas Kling
194a90884c LibGUI: Remove now-unused undo coalescing timer from GUI::TextEditor
This is no longer used since commands handle merging themselves.
2021-05-08 22:17:51 +02:00
Andreas Kling
ce90d87eb6 LibGUI: Show command name in GUI::TextEditor undo/redo action text
We can now show things like "Undo Insert Text" and "Redo Remove Text"
instead of just "Undo" and "Redo" in menu items. Pretty neat! :^)
2021-05-08 22:17:51 +02:00
Andreas Kling
81bc861085 LibGUI: Implement merging of TextDocument's RemoveTextCommand
When deleting text by pressing backspace, the commands will be merged
into a single RemoveTextCommand.
2021-05-08 22:17:51 +02:00
Andreas Kling
ff6bac4854 LibGUI: Implement merging of TextDocument's InsertTextCommand
When performing multiple text insertions in a row, they will now
be merged into a single InsertTextCommand.
2021-05-08 22:17:51 +02:00
Andreas Kling
ee19f7c0aa LibGUI: Use UndoStack::on_state_change inside TextDocument/TextEditor
Have TextDocument listen for state changes on the internal undo stack,
and forward those to all clients via a new virtual function.

This simplifies updating the can_undo / can_redo states of TextEditor.
2021-05-08 13:49:34 +02:00
Carlos César Neves Enumo
928f16d360 LibGUI: Remember modified state on undo/redo actions 2021-05-06 08:40:26 +02:00
Carlos César Neves Enumo
97d0028098 LibGUI: Debounce TextDocument undo stack
This replaces the repeating 2-sec timer with a debounced single-shot
timer on user input.
2021-05-03 08:43:10 +02:00
Andreas Kling
68a0e4f8d5 LibGUI+HackStudio: Remove editing specific hacks from GUI::Command
Use is<T> to check for specific types of command in HackStudio instead
of cluttering up GUI::Command with specialized getters.
2021-05-02 14:49:46 +02:00
Andreas Kling
5b68a76c77 LibGUI: Track modified state in GUI::TextDocument
Until now, this has been hackishly tracked by the TextEditor app's
main widget. Let's do it in GUI::TextDocument instead, so that anyone
who uses this class can know whether it's modified or not.
2021-05-01 19:42:29 +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
Rafał
c41c41cc0f
LibGUI: Prevent selecting empty line in TextEditor on double click (#6537) 2021-04-21 23:48:26 +02:00
Itamar
3cc7b00e24 LibGUI: Allow TextDocument::set_text to fail 2021-03-21 09:46:21 +01:00
thankyouverycool
3e987eba2b TextEditor+LibGUI: Add case matching and wrap around optionality
Adds simple ASCII case matching and wrap around toggles to
TextEditor's find/replace widget and reorganizes its layout
2021-02-22 09:21:30 +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
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00