When pushing a new command on an undo stack, we will now attempt to
merge it into the stack's current command.
Merging is implemented by overriding the "merge_with(Command const&)"
virtual on GUI::Command. :^)
Renamed the virtual from "on_edit_action" to "will_execute" so it
doesn't clash with our convention for Function hook names.
Also tighten the parameter type to GUI::TextDocumentUndoCommand
since that's the only kind of command it will receive.
This was quite unreliable before. Changes to the undo stack's modified
state are now reflected in the document's modified state, and the
GUI::TextEditor widget has its undo/redo actions updated automatically.
UndoStack is still a bit hard to understand due to the lazy coalescing
of commands, and that's something we should improve upon (e.g with more
explicit, incremental command merging.) But for now, this is a nice
improvement and undo/redo finally behaves in a way that feels natural.
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.
The undo stack was very difficult to understand as it grew by adding
new undo commands to the front of the internal vector. This meant we
had to keep updating indices as the stack grew and shrank.
This patch makes the internal vector grow by appending instead.
Since the `redo` action never goes back to `index: 0`,
we have to mark the clean index as being the current
non-empty index for the undo/redo navigation to work properly.
The problem is that if we never `undo`, the stack index stays at zero,
which is the empty container waiting for commands. In that situation,
if we save the document, it registers the clean index as being 1
(the non-empty index) but because the stack index has never left zero,
the document was being reported as modified, being out of sync with
the window modified state.
Since we keep a stack of command combos, let's call entries on the
stack "Combo" instead of "UndoCommandsContainer".
And since it has a vector of commands, let's call it "commands"
instead of "m_undo_vector".
This patch removes an incorrect way for TextDocument::text_in_range
to return early when the first line of the selection was empty. This
fixes an issue in TextEditor where the status bar showed that 0
characters are selected when the selection started on an empty line.
This also moves Widget::load_from_json into Core::Object as a virtual
function in order to allow loading non-widget objects in GML (e.g.
BoxLayout).
Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
This widget provides a scrollable view onto another (child) widget.
If the child is larger than the parent, scrollbars are provided for
panning around the child.
Recent changes in the button painting code made this unnecessary. For
the case of value() == max(), the scrubber button would overlap the
increment button.
Fixes#6838.
Most of the IPC that happens between clients and WindowServer when
creating and configuring windows can be asynchronous. This further
reduces the amount of ping-ponging played during application startup.
Creating a menu/menubar needs to be synchronous because we need the
ID from the response, but adding stuff *to* menus (and adding menus
to menubars, and menubars to windows) can all be asynchronous.
This dramatically reduces the amount of IPC ping-pong played by
each GUI application during startup.
I measured how long it takes TextEditor to enter the main event loop
and it's over 10% faster here. (Down from ~86ms to ~74ms)
This changes client methods so that they return the IPC response's
return value directly - instead of the response struct - for IPC
methods which only have a single return value.
This patches fixes a crash of the Userland/TextEditor where it would
crash when deleting a range spanning two lines. This was because the
TextEditor would delete the range and modify the cursor position
before clearing the selection. This would trigger a status bar update
with the invalid selection.
This allows the painter to be scaled separately in both directions, and
not just in integer intervals. This is crucial for proper SVG viewBox
support.
Most bitmap-related things verify the scale to be one as of now.
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
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.
This state lives in WindowServer and has no local copy in the client
process for now. This may turn out to be a performance issue, and if
it does we can easily cache it.
When a Button has a menu, the AbstractButton behaviour will now not
be used in the mousemove_event. This was already the case for
mousedown_event.
Why only sometimes?
Normally the presence of the menu prevents mousemove_events from being
delivered to the button. But the menu doesn't spawn immediately. So
sometimes mousemove events got through to the AbstractButton after the
menu was told to spawn but before it appeared. This caused the
m_being_pressed field of AbstractButton to be set to true. But there
was never a mouseup_event because the menu got those instead.
We had some inconsistencies before:
- Sometimes "The", sometimes "the"
- Sometimes trailing ".", sometimes no trailing "."
I picked the most common one (lowecase "the", trailing ".") and applied
it to all copyright headers.
By using the exact same string everywhere we can ensure nothing gets
missed during a global search (and replace), and that these
inconsistencies are not spread any further (as copyright headers are
commonly copied to new files).
This patch fixes the visual selection of endline characters in the
VimEditingEngine. When the visual mode is disabled and the cursor
is located on the endline character, it is shifted back to the last
character of the line.
This patch adds handling of the arrow, Home/End, and PageUp/PageDown
keys to the Vim emulation mode. Home acts as 0, End acts as $, arrow
keys act as their HJKL variants, and PageUp/Down behaves as you would
expect.
This patch also moves the default handling of the aforementioned keys
to insert mode, since regular EditingEngine semantics are more
appropriate there.
This patch moves selection updates outside movement functions in
EditingEngine. Previously, movement functions would automatically
update the selection based on whether the Shift key was pressed down
during movement. However, not all EditingEngine subclasses want that;
VimEditingEngine being a good example (because all selection is handled
in visual mode).
Therefore, this patch moves all selection updating to
EditingEngine::on_key(). Subclasses wishing to provide custom movement
and selection semantics should override it (and VimEditingEngine already
does).
This patch implements Vim motions. The VimMotion class will accept
keycodes from the editing engine to build up a motion, and will
signal when a motion is complete via VimMotion::is_complete(). The
editing engine can then call VimMotion::get_range() to obtain a
TextRange object which can be used to perform operations on the text,
or VimMotion::get_position() to obtain a TextPosition which is the
new position of the cursor after the motion.
Currently, the following motions are supported:
- h/j/k/l, regular Vim line and character movements
- 0/^/$, start/end of line and start of non-blank
- w/e/b/ge, word-related movements
- W/E/B/gE, WORD (anything non-blank) versions of the above motions
- gg/G, document related movements
- t/f, to/find character
All motions except gg/G accept a number prefix to repeat the motion that
many times.
This patch updates insert, normal and visual modes to use this motion
system for movement.
Previously a Painter's m_clip_origin field was initialized to a
widget's window_relative_rect, which is not ensured to be within
the target rect.
m_clip_origin is normally not used for clipping, but after calling
clear_clip_rect the clip rect that IS used for clipping gets reset
to m_clip_origin (so an invalid state is entered).
Now the window_relative_rect will be clipped by the target rect
first, and will only then be used to initialize both the active
clip_rect and m_clip_origin.
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 *
Modifying the selection while holding the shift button and selecting
with the mouse or the arrow keys no longer results in broken selections.
Fixes#6279.
Changing the statusbar appearance when overriding text makes it less
confusing as it's supposed to be something temporary, e.g. only when
hovering over a toolbar or menu item.
This behavior is present on old Windows systems, although things work
slightly differently there (where only the overridden text is displayed
rather than all the segments).
This commit adds an event called WM_SuperKeyPressed which is sent to all
windows via WindowManagerServerConnection.
The event is fired from WindowManager when the super key is pressed,
which is the windows key on most keyboards :)
Each statusbar segment now has an optional "override text" which can
be set, and if non-null will be displayed instead of the regular text.
This allows programs to display contextual information in the statusbar
temporarily without losing whatever text was already on there.
Actions can now have a longer text description, in addition to its
regular UI string. The longer text will soon be used to display
a more detailed description of hovered actions in statusbars.
We now send out MenuItemEntered and MenuItemLeft messages to the client
when the user hovers/unhovers menu items.
On the client side, these become GUI::ActionEvent, with one of two
types: ActionEnter or ActionLeave. They are sent to the Application.
This will allow GUI applications to react to these events.
With this patch the window manager related functionality is split out
onto a new endpoint pair named WindowManagerServer/Client. This allows
window manager functionality to be potentially privilege separated in
the future. To this end, a new client named WMConnectionClient
is used to maintain a window manager connection. When a process
connects to the endpoint and greets the WindowServer as a window manager
(via Window::make_window_manager(int)), they're subscribed to the events
they requested via the WM event mask.
This patch also removes the hardcoding of the Taskbar WindowType to
receive WM events automatically. However, being a window manager still
requires having an active window, at the moment.
This commit adds a SpinBox to the FontPicker dialog to allow users to
set arbitrary font sizes (1 to 255 inclusive) for TTF fonts.
The SpinBox is only visible when the user is selecting a TTF font.
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:
- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar
This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
This enables the user to view and navigate classes with a TreeView that
is updated by the LanguageServer as it parses the code.
It offers a new neat way to view the project's structure :^)
This now means that when trying to open a folder, one can click on
the folder and press open instead of having to actually step into
the desired folder. Of course, it also means it won't let you open
non-directories anymore.
This commit makes the user-facing StdLibExtras templates and utilities
arguably more nice-looking by removing the need to reach into the
wrapper structs generated by them to get the value/type needed.
The C++ standard library had to invent `_v` and `_t` variants (likely
because of backwards compat), but we don't need to cater to any codebase
except our own, so might as well have good things for free. :^)
Instead of mixing directories and files, sorting a FileSystemModel by
the Name column will now give you all the directories first, followed
by all the files.
If you double-click on a symlink to a directory while browsing with
a FilePicker, you most likely want to open the directory the symlink
points to, not open the symlink itself. So let's do that. :^)
Previously, this was updating the suggestions before processing the keys
and whatever changes they caused, making the suggestions stale until the
periodic auto-autocomplete timer fired (if enabled).
We now use the checked state of these buttons to indicate that you are
in that specific folder. The checked state is updated automagically
no matter how you navigate the file system. :^)
This patch adds a handy set of buttons on the left hand side that can
take you to common locations such as:
- Your home directory
- Your desktop directory
- The root directory
When a button has a menu, it opens the menu on mousedown and the
menu gains input focus immediately. While the menu is open, the
button is painted in a pressed state.
Having to rely on GUI::Desktop's on_rect_change is quite limiting and a
bit awkward (continuing to use it would mean having to setup the
callback in every application using a webview) - we need a better way of
letting widgets know of a screen rect change automatically.
The specific use case will be IPWV/OOPWV which need to keep track of the
screen rect and notify the WebContent service of any change (which on
its own deliberately can't interact with WindowServer at all).
It'll also be useful for notification windows and the taskbar, which
currently both rely on the GUI::Desktop callback but will now be able to
listen and react to the event themselves.
While space distribution along the primary axis of a BoxLayout is
pretty sophisticated, the secondary axis is very simple: we simply
center the widget.
However, this doesn't always look very nice if we don't take margins
into account, so make sure we subtract them from the rect we do all
the centering within.
Since applet windows live in the applet area window, the AppletManager
has to keep track of which applet is hovered and send the appropriate
enter/leave events to the applet windows.
This makes applet tooltips work again. :^)
WindowServer now collects applet windows into an "applet area" which is
really just a window that a WM (window management) client can position
via IPC.
This is rather hackish, and I think we should come up with a better
architecture eventually, but this brings back the missing applets since
the global menu where they used to live is gone.
Previously, when jumping to the next word on the last column of a line,
or when jumping to the previous word on the first column, it would
crash. This checks if that is the case, and if so, will do nothing.
And overhaul resize and paint events to fix layout edge cases in
which Calendar wasn't filling its parent widget completely. Ensures
month views always display prior month days for click navigation.
Converts Calendar app layout to GML.
This is particularly useful when wanting to open files in ~/.config
from the Text Editor. The option is currently not persistent, but could
be hooked into File Manager's configuration.
While iterating the items contained by the rubberband we need to skip
the correct number of items either vertically or horizontally, depending
on which direction the items flow.
Fixes#5993
This leaves menu applets running but invisible, and that's a regression
we need to take care of obviously. But not today, because it's getting
too late.