Commit graph

883 commits

Author SHA1 Message Date
Andreas Kling
fdfda6dec2 AK: Make string-to-number conversion helpers return Optional
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-12 21:28:55 +02:00
Andreas Kling
2ce2c4810a LibIPC+WindowServer+LibGUI: Detect and highlight unresponsive GUI apps
IPC::ClientConnection now tracks the time since the last time we got
a message from the client and calls a virtual function on itself after
3 seconds: may_have_become_unresponsive().

Subclasses of ClientConnection can then react to this if they like.

We use this mechanism in WindowServer to send out a friendly Ping
message to the client. If he doesn't Pong within 1 second, we mark
the client as "unresponsive" and recompose all of his windows with
a darkened appearance and amended title until he Pongs us.

This is a little on the aggressive side and we should figure out a way
to wake up less often. Perhaps this could only be done to windows the
user is currently interacting with, for example.

Anyways, this is pretty cool! :^)
2020-06-11 22:46:49 +02:00
Andreas Kling
116cf92156 LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize
This fits nicer with FloatRect,FloatPoint,FloatSize and gives a much
better visual clue about what type of metric is being used.
2020-06-10 10:59:04 +02:00
Andreas Kling
b81b2a85c4 LibGUI: Don't scroll cursor into view while reflows are deferred
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-07 21:05:05 +02:00
Linus Groh
0ff9d7e189 LibJS: Add BigInt 2020-06-07 19:29:40 +02:00
Matthew Olsson
61ac1d3ffa LibJS: Lex and parse regex literals, add RegExp objects
This adds regex parsing/lexing, as well as a relatively empty
RegExpObject. The purpose of this patch is to allow the engine to not
get hung up on parsing regexes. This will aid in finding new syntax
errors (say, from google or twitter) without having to replace all of
their regexes first!
2020-06-07 19:06:55 +02:00
Andreas Kling
984a6ff97b LibGUI: Fix broken clip rect when scrolling a TextEditor 2020-06-07 18:02:43 +02:00
Andreas Kling
5c485d4a1e LibGUI: Fix TextEditor painting glitch after add_clip_rect() change 2020-06-06 19:37:03 +02:00
Andreas Kling
5be613c9c8 LibGUI: Fix bad KeyEvent::m_key initializer to unbreak SDL2 port 2020-06-04 16:02:40 +02:00
Hüseyin ASLITÜRK
c6f1962919 LibGUI: Add scancode value to KeyEvent 2020-06-03 21:52:40 +02:00
Hüseyin ASLITÜRK
eead3878a1 LibGUI: Add save action to CommonActions list 2020-06-03 21:52:40 +02:00
Andreas Kling
517cf65c99 LibGUI: Tweak AboutDialog a bit, remove big Buggie from system variant
One Buggie is enough, it looks a lot less confused without the big one.
Also make the dialog a bit shorter since there was a lot of dead space.
2020-06-01 18:50:28 +02:00
Andreas Kling
1d6ec51bee WindowServer+LibGUI: Add per-window progress
Each window now has an associated progress integer that can be updated
via the SetWindowProgress IPC call.

This can be used by clients to indicate the progress of ongoing tasks.
Any number in the range 0 through 100 indicate a progress percentage.
Any other number means "no progress"
2020-05-30 23:00:35 +02:00
FalseHonesty
12fe546be9 LibGUI+HackStudio: Fix cursor appearance and crash while debugging
HackStudio uses a TreeView to display the list of current variables
while debugging, and when the program completes, it sets that view's
model to a null model. This would trip an assertion if the TreeView
had something selected at the time, so this patch lessens the
assertion into a simple null check.

Additionally, the cursor would look laggy when moving about the
editor because the code was waiting for a window repaint to update
the cursor's look when it makes more sense to update the cursor
when it actually moves. This change also requires the base
GUI::TextEditor to expose a getter to tell if its currently in a drag
selection.

Finally, requesting a context menu in the line ruler on the side of
the editor would also place/remove breakpoints, which was counter
intuitive, so this requires a left click to modify breakpoint placement.
2020-05-30 10:18:14 +02:00
FalseHonesty
061938206a LibGUI: Fix cursor being out of view after typing
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-29 22:14:45 +02:00
FalseHonesty
b0b03c52af LibGUI: Fix TextEditor crashing when selecting a blank line
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-29 20:17:53 +02:00
Emanuele Torre
937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Andreas Kling
49f3323fa8 LibGUI: Don't show big Buggie in app about dialogs
It was getting to crowded between two Buggies and the app icon.
2020-05-28 11:45:01 +02:00
FalseHonesty
139dbfd5b5 LibGUI: Add up & down arrow hooks and input history to TextBox
This patch adds the ability to enable "input history" on a textbox,
allowing to navigate between the history with the arrow keys.

Also removes a custom TextBox subclass from HackStudio that added
the exact same hooks, and moves it to use the now standard ones.
2020-05-27 20:04:52 +02:00
Andreas Kling
a8f0e4d56e LibGUI: Defer line reflow during text insertion
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-27 19:52:18 +02:00
Andreas Kling
30edd198ec LibGUI: Make TextEditor::select_all() move the cursor to document head
This feels a lot nicer than moving the cursor to the document end.
2020-05-27 19:52:18 +02:00
Nick Vella
e53fa97cfb LibGUI, About: Implement system-wide W2k-esque About dialog
The new About dialog reads version information from /res/version.ini,
which is generated at build time.
2020-05-27 11:44:19 +02:00
Sergey Bugaev
fce49b3e32 LibGUI: Change GUI::KeyEvent::key() type to KeyCode
...instead of a plain int. Yay for some type safety.
2020-05-27 11:19:38 +02:00
Sergey Bugaev
602c3fdb3a AK: Rename FileSystemPath -> LexicalPath
And move canonicalized_path() to a static method on LexicalPath.

This is to make it clear that FileSystemPath/canonicalized_path() only
perform *lexical* canonicalization.
2020-05-26 14:35:10 +02:00
FalseHonesty
4ad891a078 LibGUI: Add flag to TextDocument's word break locator methods
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-25 11:33:39 +02:00
FalseHonesty
5e45d68442 LibGUI: Use word breaks to intelligently navigate a TextEditor
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-24 02:15:21 +02:00
FalseHonesty
a3bf8c72f3 LibGUI: Add word break locator methods to TextDocument
TextDocument now has utilities to locate a word break both before
and after any TextPosition.
2020-05-24 02:15:21 +02:00
FalseHonesty
e0312ec2ce LibGUI: Improve double click selection on documents without spans
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-23 01:30:20 +02:00
FalseHonesty
28f74df2e6 LibGUI: Add hook when a context menu is requested on a button 2020-05-22 18:23:02 +02:00
FalseHonesty
bf2e6325a4 LibGUI: Add hook when a context menu is requested on a tab 2020-05-21 21:53:17 +02:00
Andreas Kling
ff98f55b85 LibGUI: Fix view column auto-sizing of icon-only columns
For icon columns, just use the item height as the auto width for now.
This gives us 16x16 icons, which is always what we want anyway.
2020-05-21 20:54:21 +02:00
Andreas Kling
248f2d5cf5 LibGUI: Remove Model::row_name() since nothing used it 2020-05-21 20:19:43 +02:00
Andreas Kling
278b307713 LibGUI: Make all views use CenterLeft as the default text alignment
If a model doesn't specify a text alignment for a given field, we now
fall back to CenterLeft. This will look better than Center in the vast
majority of cases.
2020-05-21 19:55:44 +02:00
Andreas Kling
2adb0a07e5 LibGUI: Get rid of Model::ColumnMetadata and always use auto-sizing
Auto-sizing of view columns is now enabled by default. This removes the
last remaining need for ColumnMetadata, so this patch gets rid of it.
2020-05-21 19:55:44 +02:00
Andreas Kling
c666c251c8 LibGUI: Replace ColumnMetadata::sortable => Model::is_column_sortable()
Now there's only one thing left in ColumnMetadata: the initial width.
2020-05-21 19:55:44 +02:00
Andreas Kling
2e03bded43 LibGUI: Add Model::Role::TextAlignment and remove from ColumnMetadata 2020-05-21 19:55:44 +02:00
Andreas Kling
04187576ff LibGUI: Models should always specify font via Model::Role::Font
This gets rid of one field in ColumnData. The goal is to get rid of all
fields and lose ColumnData entirely.
2020-05-21 19:55:44 +02:00
Andreas Kling
4cdbdf0a84 LibGUI: Always paint the cursor visible when focusing a TextEditor
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-21 17:38:01 +02:00
Andreas Kling
4806cd122d LibGUI: Focus the first focusable widget added to a window
It feels really awkward if nothing is focused when opening a window.
2020-05-21 17:26:09 +02:00
Andreas Kling
80f43ffc27 LibGUI: Move AbstractTableView::keydown_event() down to TableView
We can't really share this stuff with TreeView anyway, since tables
and trees have very different spatial relationships between indexes.
2020-05-21 13:40:52 +02:00
Andreas Kling
9d9a31384e LibGUI: Allow expand/collapse subtrees in TreeView with Alt+Left/Right
This makes TreeView a lot more keyboard friendly.
2020-05-21 13:36:08 +02:00
Hüseyin ASLITÜRK
9300a8cfe5 LibGUI: FileSystemModel, markdown file icon for .md files. 2020-05-21 01:19:13 +02:00
Hüseyin ASLITÜRK
25227ee284 LibGUI: Add MessageBox question icon 2020-05-20 13:54:10 +02:00
Hüseyin ASLITÜRK
d18f6e82eb LibGUI: Replace up and down arrows with emoji 2020-05-20 13:40:24 +02:00
Hüseyin ASLITÜRK
80699a0824 LibGUI: Update copyright character in about dialog 2020-05-20 13:40:24 +02:00
Andreas Kling
6d078a9ec3 LibGUI: Use dbg() instead of dbgprintf() in GUI::Dialog 2020-05-19 17:46:28 +02:00
Andreas Kling
ff8d250cbc LibGUI: Remove some ancient unused debug logging in AbstractButton 2020-05-19 17:46:28 +02:00
Linus Groh
4ab4de7810 LibGUI: Add ability to hide GUI::TabWidget's tab bar 2020-05-19 17:42:48 +02:00
Andreas Kling
bdfd1f1545 LibGUI: Make text selection feel better in single-line editors
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-18 17:55:21 +02:00
Andreas Kling
62b7418376 LibGUI: Add 1px of horizontal content padding to TextEditor
This adds a little bit of needed air around the text.
2020-05-18 17:47:01 +02:00