summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/TextEditor.cpp
AgeCommit message (Collapse)Author
2020-09-21Base: Add the PlaceholderText attribute to themesPeter Elliott
2020-09-21LibGUI: Add optional placeholder to TextEditorPeter Elliott
This lets you show some disabled text when no text is entered, and the editor is not focused.
2020-09-11LibGUI: Use widget override cursors in GUI::TextEditorAndreas Kling
2020-09-11LibGUI+WindowServer: Rename window "override cursor" to just "cursor"Andreas Kling
Let's just say each window has a cursor, there's not really overriding going on.
2020-09-10LibGfx: Move StandardCursor enum to LibGfxAndreas Kling
This enum existed both in LibGUI and WindowServer which was silly and error-prone.
2020-09-05LibGUI: Make the Clipboard API deal in raw byte buffers a bit moreAndreas Kling
To open up for putting not just text/plain content on the clipboard, let's make the GUI::Clipboard API a bit more raw-data-friendly. :^)
2020-09-01LibGUI: Disable whitespace visualization in single-line text editorsAndreas Kling
You can enable it manually if you really want it, of course. :^)
2020-09-01LibGUI: Implement trailing whitespace visualization in TextEditorAndreas Kling
This patch adds an optional mode where TextEditor highlights trailing whitespace characters on each line with a nice reddish dither pattern. We should probably make this themable and I'm sure it could be nicer somehow, but this is just a first cut and I do kinda like it. :^)
2020-08-22TextEditor: Increase padding in ruler widthItamar
2020-08-16LibGUI: Use matching family fonts for TextEditor rulerthankyouverycool
Fixes incorrect glyph sizes when drawing bold line counts.
2020-08-16LibGUI: Resize TextEditor ruler based on needed spacethankyouverycool
Ruler width is now calculated according to the number of digits in the line count.
2020-08-15LibGUI: When focusing a TextEditor via keyboard, select all contentsAndreas Kling
This feels very natural and allows you to start typing immediately knowing it will replace whatever was in the text box before.
2020-08-15LibGUI: Make focus events more aware of why focus is changingAndreas Kling
This patch adds GUI::FocusEvent which has a GUI::FocusSource. The focus source is one of three things: - Programmatic - Mouse - Keyboard This allows receivers of focus events to implement different behaviors depending on how they receive/lose focus.
2020-08-12LibGUI: Mark compilation-unit-only functions as staticBen Wiederhake
This enables a nice warning in case a function becomes dead code.
2020-08-05Unicode: Try s/codepoint/code_point/g againNico Weber
This time, without trailing 's'. Ran: git grep -l 'codepoint' | xargs sed -ie 's/codepoint/code_point/g
2020-08-05Revert "Unicode: s/codepoint/code_point/g"Nico Weber
This reverts commit ea9ac3155d1774f13ac4e9a96605c0e85a8f299e. It replaced "codepoint" with "code_points", not "code_point".
2020-08-05LibGUI: Use set_cursor() in TextEditor::set_document()Linus Groh
Instead of setting m_cursor directly to reset the cursor position, TextEditor::set_document() now uses set_cursor() which will call cursor change callback functions, if any. This fixes a bug in HackStudio where the cursor information text would not update immediately after changing the active TextDocument, even though the cursor is always visibly being reset to 0, 0.
2020-08-03Unicode: s/codepoint/code_point/gAndreas Kling
Unicode calls them "code points" so let's follow their style.
2020-08-01LibGUI: Add focus hooks to TextEditorAnotherTest
2020-07-23TextEditor: Jump to word break when deleting and holding Ctrl modifierSasan Hezarkhani
2020-07-16LibGUI: Add InputBox::show with required parent window argumentTom
Similar to MessageBox::show, this encourages passing in a window.
2020-07-16LibGUI: Disallow typing in DisplayOnly TextEditorsthankyouverycool
2020-07-15LibGUI: Add hover highlighting and keyboard controls to ComboBoxthankyouverycool
Adds a new highlighting effect to the actively selected row in ComboBox ListView. ComboBoxEditor can now be controlled with page up, page down, and the up and down arrow keys. ESC and loss of focus now cause comboboxes to close. Now activates on mouseup as well as return.
2020-07-15LibGUI: Use enum for TextEditor modes & add new DisplayOnly modethankyouverycool
Adds a new, more restrictive read-only state to TextEditor which forbids copying, selecting, editor cursors, and context menus. Provides a unique appearance on focus which accomodates ComboBox widgets. All TextEditor modes are now accessed by enum and set_mode() which sets the editor to Editable, ReadOnly or DisplayOnly. Updates applications still using set_readonly().
2020-07-04Userspace: Remove a bunch of unnecessary Kernel/API/KeyCode.h includesAndreas Kling
2020-07-04Kernel: Move headers intended for userspace use into Kernel/API/Andreas Kling
2020-07-03LibGUI: Add GUI::CommonActions::make_select_all_action() :^)Andreas Kling
2020-06-29LibGUI: Add TextEditor::set_icon()Andreas Kling
You can now set a 16x16 icon on a single-line TextEditor. If present, the icon will be painted to the left of the text content.
2020-06-16LibGUI: Replace text attribute on KeyEvent with code_point attributeHüseyin ASLITÜRK
2020-06-15LibGUI: Don't update cursor, if visual data out-of-dateKevin Meyer
This fixes https://github.com/SerenityOS/serenity/issues/2498 A nullptr dereference was caused by the visual data beeing out of sync with the line data, due to a deferred recompute.
2020-06-12AK: Make string-to-number conversion helpers return OptionalAndreas Kling
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
2020-06-10LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSizeAndreas Kling
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much better visual clue about what type of metric is being used.
2020-06-07LibGUI: Don't scroll cursor into view while reflows are deferredAndreas Kling
We don't have up-to-date visual line rects until after reflow, and we already do a "scroll cursor into view" when deferral ends anyway. Fixes #2524.
2020-06-07LibGUI: Fix broken clip rect when scrolling a TextEditorAndreas Kling
2020-06-06LibGUI: Fix TextEditor painting glitch after add_clip_rect() changeAndreas Kling
2020-05-29LibGUI: Fix cursor being out of view after typingFalseHonesty
Previously, if the cursor moved out of the visible area while text was being inserted, the text editor would never scroll the cursor back into view until the arrow keys were pressed to move the cursor. This was caused by the TextEditor's reflow deferral system stopping visual line recomputation until the end of text insertion, so now when reflow deferral is completed, the TextEditor will make sure the cursor is visible.
2020-05-29LibGUI: Fix TextEditor crashing when selecting a blank lineFalseHonesty
Previously, the TextEditor would crash when selecting a line with no codepoints due to a null dereference, so this patch makes sure there is actually any text to render before giving it to the painter.
2020-05-27LibGUI: Defer line reflow during text insertionAndreas Kling
Add a deferral counter and defer reflowing the visual lines until the counter is at zero. Use this to defer reflow when inserting text. This fixes glacial slowdown while paste large amounts of text.
2020-05-27LibGUI: Make TextEditor::select_all() move the cursor to document headAndreas Kling
This feels a lot nicer than moving the cursor to the document end.
2020-05-25LibGUI: Add flag to TextDocument's word break locator methodsFalseHonesty
TextDocument::first_word_break_before was refactored out to be able to be used in multiple places throughout the project. It turns out that its behaviour needs to be slightly different depending on where its called, so it now has a start_at_column_before flag to decide which letter it "thinks" was clicked.
2020-05-24LibGUI: Use word breaks to intelligently navigate a TextEditorFalseHonesty
Previously, holding Control while using the left/right arrow keys to navigate through a TextEditor would only be helpful if the document had spans. Now, if there are no spans, it will navigate to the next "word break", defined to be the threshold where text changes from alphanumeric to non-alphanumeric, or vice versa.
2020-05-23LibGUI: Improve double click selection on documents without spansFalseHonesty
Previously, double clicking would select the range around your click up until it found a space, and in the browser's location bar this behavior didn't suffice. Now, it will select the range around your click until there is a "word break". A word break is considered to be when your selection changes from being alphanumeric to being non alphanumeric, or vice versa.
2020-05-21LibGUI: Always paint the cursor visible when focusing a TextEditorAndreas Kling
If the cursor happened to be blinking in the invisible state, it would take 500ms before we actually see the cursor in a newly focused editor widget. This patch makes it show up right away.
2020-05-18LibGUI: Make text selection feel better in single-line editorsAndreas Kling
We should always stay on the only line when selecting in a single-line editor, instead of requiring the user to keep the cursor inside the text when selecting. This broke with the variable-width font changes.
2020-05-18LibGUI: Grow the "line content rect" slightly in single line text boxesAndreas Kling
Previously we would sometimes leave some pixels from an old selection rect on screen after clearing the selection. It was because the line content rect was smaller than the visual selection rect, and we were using the line content rect for invalidations.
2020-05-18LibGUI: Use a variable-width font by default in single-line TextEditorsAndreas Kling
This makes things like the Browser location bar look way nicer. :^)
2020-05-18LibGUI: Support variable-width fonts in TextEditorAndreas Kling
This patch reworks metric and coordinate computation to iterate over text content instead of making assumptions about fixed glyph widths.
2020-05-18LibGUI: Remove outdated FIXME in TextEditorAndreas Kling
2020-05-17LibGUI: TextEditor now opts in to emoji input by default :^)Andreas Kling
2020-05-17LibGUI: Make the TextEditor widget store UTF-32 codepointsAndreas Kling
A TextDocumentLine is now backed by a non-null-terminated sequence of Unicode codepoints encoded as UTF-32 (one u32 per codepoint.) This makes it possible to view and edit arbitrary Unicode text without strange cursor and selection behavior. You can freely copy and paste emojis between TextEditor and Terminal now. :^) Storing UTF-32 is quite space-inefficient, but we should be able to use the same optimization techniques as LibVT does to reduce it in the typical case where most text is ASCII. There are a lot of things that can be cleaned up around this code, but this works well enough that I'm pretty happy with it.