Commit graph

88 commits

Author SHA1 Message Date
Robin Burchell
8aecebe8f3 GTextEditor: Introduce triple click to select all 2019-05-16 01:24:34 +02:00
Robin Burchell
966c5d10b1 GTextEditor: Minor cleanup
Remove an unnecessary layer of nesting
2019-05-16 01:24:34 +02:00
Andreas Kling
ad731cc08f LibGUI: Support cycling through focusable widgets with Tab and Shift-Tab. 2019-05-15 02:39:58 +02:00
Andreas Kling
6b40b081b2 GTextEditor: Add a readonly mode. 2019-05-08 05:00:28 +02:00
Andreas Kling
26110f7753 GTextEditor: set_cursor() should gracefully handle old cursor being invalid.
Since set_cursor() may be called after arbitrary document changes, it can't
rely on the old cursor being valid. To make things simple, if the old cursor
is on a line no longer in the document, just repaint the whole editor.
2019-05-06 22:04:53 +02:00
Andreas Kling
71770e000b GTextEditor: Add very basic automatic indentation.
This is off by default, but enabled by TextEditor. It simply inserts the
same number of leading spaces as the previous line when hitting Enter. :^)
2019-04-25 22:56:09 +02:00
Andreas Kling
e2e2c78332 GTextEditor: Double-clicking on a word should select that word. 2019-04-25 22:29:25 +02:00
Andreas Kling
737315c228 GTextEditor: Improve cursor positioning accuracy when using a mouse.
Put the cursor on the left or right side of a glyph when clicking it based
on distance to middle of glyphs. This is such an obvious change that makes
a small but noticeable difference in feel. :^)
2019-04-25 02:15:45 +02:00
Andreas Kling
7a5525edf4 GTextEditor: Go a little past the cursor for Home/End scroll-into-view.
When jumping to the start of a line, or to the end of a line, scrolling two
pixels past the end yields a pleasant effect.
2019-04-25 01:33:59 +02:00
Andreas Kling
2c51bc92af GTextEditor: Always call did_change() before set_cursor().
This is not very obvious and I need to come up with a better design, but for
now just make sure to call did_change() before calling set_cursor().
This is needed because set_cursor() will try to scroll the cursor into view,
and for right-aligned text, did_change() may change the content rect which
needs to be reflected by the time we call scroll_cursor_into_view().
2019-04-25 01:28:17 +02:00
Andreas Kling
4e715dbc71 GTextEditor: Account for the GFrame border in the painting code.
We were forgetting to translate the painter by the frame_thickness().
With this fixed, we can also do proper vertical centering of lines for
single-line editors, and things suddenly look nicer than ever! :^)
2019-04-25 01:11:35 +02:00
Andreas Kling
0c88ce9ee3 GTextEditor: Expand the content "to-fill" for right aligned text.
When using a right-side text alignment, hook the resize event to make sure
that the content width is at least frame_inner_rect().width() wide.

This allows us to use content_width() as the anchor point for right aligned
text, rather than using the frame inner rect, which was clearly wrong in
the overflow case.
2019-04-24 23:42:49 +02:00
Andreas Kling
f1eba2295d GTextEditor: Make the line_widget_rect() span the widget horizontally. 2019-04-24 23:15:15 +02:00
Andreas Kling
4bea3a4aa6 GTextEditor: Turn off the ruler by default.
You're usually not gonna want the ruler. TextEditor can enable it manually.
2019-04-24 23:06:44 +02:00
Andreas Kling
5c240af3f7 GTextEditor: Fix line_content_rect() behavior with custom alignments. 2019-04-24 22:46:27 +02:00
Andreas Kling
62f0aae4ca GTextEditor: Add support for different text alignments.
Currently only CenterLeft and CenterRight are supported, but it would be
very straightforward to add other alignments as well.
2019-04-24 22:24:16 +02:00
Andreas Kling
5c5ce4f885 LibGUI: Allow GActions to be scoped either globally or widget-locally.
This makes it possible for e.g GTextEditor to create a bunch of actions
with popular shortcuts like Ctrl+C, etc, without polluting the global
shortcut namespace. Widget-local actions will only activate while their
corresponding widget has focus. :^)
2019-04-20 21:56:56 +02:00
Andreas Kling
ae3ec3fc37 LibGUI: Give GTextEditor a context menu.
Now GTextEditor manages its own editing actions (cut/copy/paste/etc) and
will show a context menu containing them when requested.

Apps that want to put a GTextEditor's actions in its menu can get to the
actions via public getters. :^)
2019-04-18 12:28:29 +02:00
Andreas Kling
32e5c8c689 GTextEditor: Add on_selection_changed callback.
This is probably a bit eager and won't coalesce all updates or even
ignore no-op changes to the selection.
2019-04-12 02:52:34 +02:00
Andreas Kling
b8062f69d8 LibCore: Add CEvent and make LibGUI/GEvent inherit from it. 2019-04-10 16:56:55 +02:00
Andreas Kling
4ab0cd5d4c LibGUI: Move frame painting from GFrame to StylePainter.
This way it can be used by others who might not have a GFrame object.
2019-04-10 03:43:46 +02:00
Andreas Kling
313ac51832 LibGUI: Turn GTextBox into a wrapper around a single-line GTextEditor. 2019-04-10 03:08:29 +02:00
Andreas Kling
151b7149e6 GTextEditor: Add GTextEditor::on_change callback for when content changes. 2019-04-09 16:20:36 +02:00
Andreas Kling
bcc00857a4 AK: Revert Eternal<T> for now since it doesn't work as intended. 2019-04-05 05:14:20 +02:00
Andreas Kling
c02c9880b6 AK: Add Eternal<T> and use it in various places.
This is useful for static locals that never need to be destroyed:

Thing& Thing::the()
{
    static Eternal<Thing> the;
    return the;
}

The object will be allocated in data segment memory and will never have
its destructor invoked.
2019-04-03 16:52:25 +02:00
Andreas Kling
dcf6726487 WindowServer: Add support for per-window override cursors.
Use this to implement automatic switching to an I-beam cursor when hovering
over a GTextEditor. :^)
2019-03-31 23:52:02 +02:00
Andreas Kling
f249c40aaa Rename Painter::set_clip_rect() to add_clip_rect().
It was confusing to see multiple calls to set_foo() in a row. Since this is
an intersecting operation, let's call it add_clip_rect() instead.
2019-03-29 15:01:54 +01:00
Andreas Kling
9d7a513681 GTextEditor: Keep tweaking the single-line look. 2019-03-29 01:57:29 +01:00
Andreas Kling
5d72cf5a3f LibGUI: Improve GFrame's look for Container shapes.
This is now starting to look like a proper container. Very nice :^)
2019-03-28 20:15:13 +01:00
Andreas Kling
9fa21fa585 LibGUI: Add a GPainter class that inherits from Painter.
This gets rid of the last little piece of LibGUI knowledge in Painter.
2019-03-28 17:19:56 +01:00
Andreas Kling
3dc4255eb4 LibGUI: Use GFrame to draw the frames around GItemView and GTableView. 2019-03-28 16:58:29 +01:00
Andreas Kling
1fc03a7644 LibGUI: Make GScrollableWidget a GFrame and fix up GTextEditor for it. 2019-03-28 16:14:26 +01:00
Andreas Kling
cb296ffede LibGUI: Add a GFrame class that can be inherited by framey widgets.
This will gather the code for painting sunken/raised frames etc in a single
place and make it easier add a bit of pleasant shading to UI's. :^)
2019-03-28 15:30:29 +01:00
Andreas Kling
670e376e27 Tweak the look of various UI surfaces and buttons. 2019-03-27 20:48:23 +01:00
Andreas Kling
0058da734e Kernel: Add Inode::truncate(size).
- Use this to implement the O_TRUNC open flag.
- Fix creat() to pass O_CREAT | O_TRUNC | O_WRONLY.
- Make sure we truncate wherever appropriate.
2019-03-27 16:42:30 +01:00
Andreas Kling
a3390b6f1c GTextEditor: Draw a simple border around single-line editors. 2019-03-25 14:13:21 +01:00
Andreas Kling
838a06096a GTextEditor: Shift+Delete should delete the current line. 2019-03-25 13:14:02 +01:00
Andreas Kling
b4da451c9a WindowServer+LibGUI: Implement automatic cursor tracking.
When a mouse button is pressed inside a window, put that window into an
automatic mouse tracking state where all mouse events are sent to that
window until all mouse buttons are released.

This might feel even better if it only cared about the mouse buttons you
actually pressed while *inside* the windows to get released, I don't know.
I'll have to use it for a while and see how it's like.
2019-03-24 15:01:56 +01:00
Andreas Kling
ed2303e2d8 TextEditor: The delete key should work even when there's no selection. 2019-03-20 23:11:00 +01:00
Andreas Kling
daa1dcb5e8 FileManager: Use a GTextEditor for the location bar + tweak icons. 2019-03-20 18:12:56 +01:00
Andreas Kling
46577a6948 GTextEditor: Fix invalidation glitches in single-line mode. 2019-03-19 02:45:49 +01:00
Andreas Kling
a6538feed1 LibGUI: Add GInputBox for getting a string from a modal dialog.
Use this to implement some of the toolbar actions in IRCClient. :^)
2019-03-19 01:41:00 +01:00
Andreas Kling
ec8bffb06d LibGUI: Let GTextEditor deal with its horizontal padding internally.
I originally wanted to have the padding concept in GScrollableWidget
but it's really finicky with the ruler and everything.
2019-03-16 23:16:37 +01:00
Andreas Kling
3854e752cb LibGUI: Make GTextEditor inherit from GScrollableWidget.
This is quite nice, now we can share a ton of logic. :^)
2019-03-16 16:54:51 +01:00
Andreas Kling
7e3673f710 GTextEditor: Disable the ruler in single-line mode.
Also make it possible to hide the ruler in multi-line mode, if you should
want to do that. :^)
2019-03-15 17:54:05 +01:00
Andreas Kling
1fc283ed7d IRCClient+LibGUI: Add an input box so we can send messages to channels.
Implement this using a GTextEditor with a special single-line mode.
This new mode needs some polishing, but it's already very useful.
2019-03-15 17:37:13 +01:00
Andreas Kling
10dcd3a47f GTextEditor: Make sure the scroll corner helper widget is filled in. 2019-03-11 12:52:07 +01:00
Andreas Kling
5d69bf06d2 LibGUI: Don't fill widgets with background color by defualt. 2019-03-10 13:16:36 +01:00
Andreas Kling
8017c1e17c GTextEditor: Let the Tab key insert up to 4 spaces. 2019-03-10 11:08:36 +01:00
Andreas Kling
b4a099d212 GTextEditor: Allow jumping lines by hitting Left/Right at start/end of line. 2019-03-09 22:02:35 +01:00