Commit graph

8913 commits

Author SHA1 Message Date
Sergey Bugaev
f1a8fb1e88 LibMarkdown: Add support for images :^) 2020-04-30 11:30:27 +02:00
Sergey Bugaev
b8aab5fdc3 LibMarkdown: Handle broken link markup better
Let's output *something* instead of crashing on a failed assertion.
2020-04-30 11:30:27 +02:00
Sergey Bugaev
279cf9294a AK: Always inline trivial StringView constructors 2020-04-30 11:30:27 +02:00
Sergey Bugaev
135d29b498 AK: Assert that we don't create StringViews of negative length
Due to us using size_t for the length, the actual value will always be positive.
If, for example, we calculate the length as "0 - 1", we'll get SIZE_T_MAX. What
we can do is check that adding the characters pointer and the length together
doesn't overflow.
2020-04-30 11:30:27 +02:00
Sergey Bugaev
361a1b54d7 AK: Add Checked::addition_would_overflow()
And switch the two-argument version of Checked::multiplication_would_overflow()
to use __builtin_mul_overflow_p(). This helps GCC optimize the code better.
2020-04-30 11:30:27 +02:00
Sergey Bugaev
1b36ddce1d LibC: Hint the compiler that assertions rarely fail
Also, rewrite the macro to expand to an if statement instead of
a weird ternary operator with a (void)0 banch.
2020-04-30 11:30:27 +02:00
Sergey Bugaev
b319aca81a LibCore: Do not assert that NonnullRefPtr is non-null
Clang complains about this; with the change the next commit is going
to make to ASSERT() internals, GCC is going to start to complain as well.
2020-04-30 11:30:27 +02:00
AnotherTest
0fb4a808ef Shell: Provide the correct invariant length to the line editor 2020-04-30 10:47:22 +02:00
mattco98
683a0696f3 LibJS: Add Object.{keys,values,entries}() 2020-04-30 09:53:16 +02:00
Andreas Kling
36a5e0be4b LibCore: Don't continue in forked child if exec() fails
Fixes #1854.
2020-04-30 09:52:07 +02:00
Andreas Kling
8fc6ff94fe LibGUI: Scale TabWidget tabs according to available space
In TabWidgets with the "uniform tabs" mode on, we will now scale tabs
between a minimum and maximum size, distributing the available space.

Partially addresses #1971.
2020-04-30 09:28:36 +02:00
AnotherTest
a80ddf584f Shell+LibLine: Handle escaped characters correctly
This patchset fixes incorrect handling of escaped tokens (`a\ b`) in
Shell autocompletion and LibLine.
The users of LibLine can now choose between two token splitting modes,
either taking into account escapes, or ignoring them.
2020-04-30 09:07:38 +02:00
Andreas Kling
f2cdef5c47 LibGUI: Cycle through TabWidget tabs with Ctrl+Tab / Ctrl+Shift+Tab
Fixes #2022.
2020-04-30 09:04:39 +02:00
Andreas Kling
a9f6f862e2 WindowServer: Fix typo (backgound_color => background_color) 2020-04-30 09:04:39 +02:00
Dylan Katz
47f413c47f Browser: Add missing tooltip to bookmark button
The tip will say "Add Bookmark" if not a bookmark and "Remove
Bookmark" if it is.
2020-04-30 08:52:21 +02:00
AnotherTest
fb63b84c78 Shell: Correctly parse quoted filenames in redirection
This commit fixes the (incorrect) behaviour of treating quotes as part
of the redirection filename.

Fixes #1857 :^)
2020-04-30 08:51:54 +02:00
Linus Groh
fc34123a54 LibJS: Fix ConditionalExpression::dump()
Let's not print m_test three times :^)
2020-04-30 08:43:38 +02:00
Linus Groh
8614fb4092 LibJS: Enforce that ++/-- operand is an identifier or member expression 2020-04-30 08:41:31 +02:00
Linus Groh
624eaa32af LibJS: Add Parser::syntax_error() helper
Instead of having fprintf()s all over the place we can now use
syntax_error("message") or syntax_error("message", line, column).

This takes care of a consistent format, appending a newline and getting
the line number and column of the current token if the last two params
are omitted.
2020-04-30 08:41:31 +02:00
Andreas Kling
85fd0d2187 FileManager: Fix crash when file properties has unnamed UID or GID
It's perfectly valid for a file to be owned by a UID or GID with no
corresponding entry in /etc/passwd or /etc/group respectively.

Fixes #1988.
2020-04-29 19:35:20 +02:00
Andreas Kling
9f32d71782 LibGUI: Use "OK, Cancel" button order in InputBox 2020-04-29 19:31:15 +02:00
Andreas Kling
77916f030f LibGUI: Use "OK, Cancel" button order in ColorPicker 2020-04-29 19:29:09 +02:00
Andreas Kling
51ab0e967e LibGUI: Use a sunken GUI::Frame for the ColorPicker color spectrum
This looks a lot nicer than just a plain widget. :^)
2020-04-29 19:28:19 +02:00
Andreas Kling
d7d5788469 LibGUI: ColorPicker should pick custom color from bitmap, not window
It's not always safe to access pixel data of a window's backing store
since the kernel may decide to purge it at his leisure. Fix this by
instead picking colors from the color spectrum bitmap directly instead.

Also fix up mouse event logic while we're here so it only cares about
the left mouse button

Fixes #1657.
2020-04-29 19:17:40 +02:00
Andreas Kling
6a01827046 LibGUI: Exit ColorPicker (successfully) when double-clicking a color
It feels natural that if I double click a color button, the dialog
closes successfully and "returns" that color.
2020-04-29 19:17:40 +02:00
Andreas Kling
57fe4d19ac LibGUI: Remove unnecessary is_enabled() checks in mouse event handlers
We never deliver mouse events to disabled widgets, so there's no need
to check is_enabled() in these event handlers.
2020-04-29 19:17:40 +02:00
Andreas Kling
cdbc252190 LibGUI: Require a full click on ColorInput's color rect to open picker
Let's not open the ColorPicker on mousedown, that was too jarring.
2020-04-29 19:17:40 +02:00
Linus Groh
8159f45f6e LibJS: Make String.prototype.slice() generic 2020-04-29 19:14:36 +02:00
Linus Groh
cfdb7b8806 LibJS: Make (most) String.prototype functions generic
I.e. they don't require the |this| value to be a string object and
"can be transferred to other kinds of objects for use as a method" as
the spec describes it.
2020-04-29 18:53:21 +02:00
Linus Groh
4bdb6daac5 LibJS: Handle non-string primitive values in Object::to_string() 2020-04-29 18:53:21 +02:00
Linus Groh
2c6e7dbd07 LibJS: Throw error in Object::to_string() if string conversion fails 2020-04-29 18:53:21 +02:00
mattco98
95abcc3722 LibJS: Implement correct object property ordering
This commit introduces a way to get an object's own properties in the
correct order. The "correct order" for JS object properties is first all
array-like index properties (numeric keys) sorted by insertion order,
followed by all string properties sorted by insertion order.

Objects also now print correctly in the repl! Before this commit:

courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ bar: 2, foo: 1, baz: 3 }

After:

courage ~/js-tests $ js
> ({ foo: 1, bar: 2, baz: 3 })
{ foo: 1, bar: 2, baz: 3 }
2020-04-29 18:47:03 +02:00
Kesse Jones
58f6f50de4 LibJS: Add String.prototype.slice 2020-04-29 18:35:18 +02:00
Andreas Kling
bf727eb44c DisplaySettings: Arrange buttons in "OK, Cancel, Apply" order 2020-04-29 16:25:02 +02:00
Andreas Kling
e8a044390e DisplaySettings: Don't allow desktop background color with alpha 2020-04-29 16:22:29 +02:00
Andreas Kling
f8069418e1 LibGUI: Transfer "color has alpha channel" state 2020-04-29 16:22:09 +02:00
Andreas Kling
51df4bdbfc DisplaySettings: Rename from DisplayProperties 2020-04-29 15:53:51 +02:00
Andreas Kling
c7107385ee LibGUI: Allow disabling the alpha channel in ColorInput widgets 2020-04-29 15:33:36 +02:00
Andreas Kling
17e76b4760 LibGfx: Add Color::to_string_without_alpha()
This simply returns an "#rrggbb" string and ignores the alpha value.
2020-04-29 15:31:45 +02:00
Andreas Kling
bc305a16ae LibGUI: Allow editing ColorInput widgets as text
You can now enter a specific color as #rrggbb instead of clicking your
way through the color picker.

If you still want the color picker, just click the little color rect in
the widget and we'll bring up a ColorPicker. For a visual cue that this
rect is interactive, we use a hover hand cursor when hovering the rect.
2020-04-29 15:30:01 +02:00
Andreas Kling
033a4aee50 LibGUI: Remove copy-pasted auto-repeat logic from ColorInput
This was copy-pasted from button classes and not useful here.
2020-04-29 14:38:19 +02:00
Andreas Kling
40fe076e10 Base: Tweak default desktop background color slightly 2020-04-29 14:37:10 +02:00
Andreas Kling
aaf35112a4 LibJS: Pass JS::Function around by reference more 2020-04-29 13:43:57 +02:00
Andreas Kling
97382677bd LibWeb: Make EventListener::function() return a reference 2020-04-29 12:46:20 +02:00
Andreas Kling
a38658dc88 LibJS: Don't use Optional<Value> for bound |this| values
Just use a plain Value since it already has an empty state.
2020-04-29 12:41:58 +02:00
Andreas Kling
698652a548 LibJS: Make Value::as_string() return a PrimitiveString reference 2020-04-29 12:35:39 +02:00
Andreas Kling
75f246dde8 LibJS: Make StringObject::primitive_string() return a reference 2020-04-29 12:33:28 +02:00
Andreas Kling
7dadb75e28 WindowServer: Pop up the window menu at bottom left of window icon
When clicking the window icon, we now pop up the window menu at the
bottom left of the icon, no matter where you clicked it.

Right-clicking the title bar still pops up at the event position.
2020-04-29 12:07:40 +02:00
Andreas Kling
f0cde70c18 LibGUI: Simplify submenu construction
The API for adding a submenu to a menu is now:

auto& submenu = menu.add_submenu("Name");
submenu.add_action(my_action);
2020-04-29 11:48:11 +02:00
Andreas Kling
13dcd9a037 WindowServer: Fix build after FBResolution changes 2020-04-29 11:41:34 +02:00