Commit graph

9726 commits

Author SHA1 Message Date
Shannon Booth
1048283186 WindowServer: Remove uneeded const_casts for getting a submenu 2020-05-18 14:34:57 +02:00
Shannon Booth
41471eb3ae WindowServer: Add const version of Menu::find_menu_by_id(int menu_id)
It's a little sad having two diferent versions of this function, but I
don't know of any better way to do it. This also gets rid of some const
casts down the line.
2020-05-18 14:34:57 +02:00
Shannon Booth
08064ed219 WindowServer: Add const qualified version of MenuItem::submenu() 2020-05-18 14:34:57 +02:00
Linus Groh
f06c12173c LibJS: Return early from parseFloat() if argument is a number
This saves us both a bit of time and accuracy, as Serenity's strtod()
still is a little bit off sometimes - and stringifying the result and
parsing it again just increases that offset.
2020-05-18 14:33:53 +02:00
Andreas Kling
088841202d LibGUI: Remove outdated FIXME in TextEditor 2020-05-18 14:25:57 +02:00
Andreas Kling
4402207b98 Kernel: WaitBlocker should always unblock immediately on WNOHANG
This fixes a problem where we'd block if a process with no children
would call sys$waitid() with WNOHANG. This unbreaks bash :^)
2020-05-18 13:07:20 +02:00
Linus Groh
eb72ba2466 LibJS: Remove is_nan() check in as_size_t() and fix to_size_t()
We need to call as_double() on the freshly converted number, not the
value itself.
2020-05-18 11:39:11 +02:00
AnotherTest
3bc3f36cfe LibLine: Handle unicode correctly
This commit also fixes a problem with us throwing out data that was
inserted while a command was running.
2020-05-18 11:31:43 +02:00
AnotherTest
a4e0b585fe AK: Add a way to get the number of valid bytes in a Utf8View 2020-05-18 11:31:43 +02:00
Linus Groh
07c765e258 Ports: Make bash link again
No idea why this was suddenly broken, but removing these duplicated
declarations make it build to completion again.
2020-05-18 11:29:08 +02:00
Nicholas Hollett
181eacd3ba LibVT: Pass the handler name to Launcher::open_url to control what gets launched
Now we can pick which application gets opened in the context menu for
URLs in the Terminal \o/
2020-05-18 11:27:27 +02:00
Nicholas Hollett
02cc3ac21f Base: Add file type & protocol definitions for known handlers.
This matches the existing user configuration in /home/anon/LaunchServer.ini
2020-05-18 11:27:27 +02:00
Nicholas Hollett
3c5f75ed53 LaunchServer: Discover handlers from *.af files, allow launching based on a known handler
Adds metadata about apps for what file types and protocols they can
handle, then consumes that in the LaunchServer. The LaunchServer can
then use that to offer multiple options for what apps can open a given
URL. Callers can then pass back the handler name to the LaunchServer to
use an alternate app :)
2020-05-18 11:27:27 +02:00
Linus Groh
36996bd720 LibJS: Rename to_{i32,size_t}() to as_{i32,size_t}() for clarity
As these parameter-less overloads don't change the value's type and
just assume Type::Number, naming them as_i32() and as_size_t() is more
appropriate.
2020-05-18 10:21:51 +02:00
Andreas Kling
014cb1a55b LibGUI: Tweak EmojiInputDialog layout :^) 2020-05-18 09:55:19 +02:00
Andreas Kling
5aba8cc750 Base: Add thinking face emoji (U+1F914) 🤔 2020-05-18 09:52:48 +02:00
Linus Groh
56502b0e84 LibJS: Check for exception after converting object to string primitive 2020-05-18 09:39:55 +02:00
Linus Groh
4569e88bea LibJS: Throw TypeError when coercing symbol to number 2020-05-18 09:39:55 +02:00
Linus Groh
476094922b LibJS: Pass Interpreter& to Value::to_number() et al.
This patch is unfortunately rather large and might make some things feel
bloated, but it is necessary to fix a few flaws in LibJS, primarily
blindly coercing values to numbers without exception checks - i.e.

interpreter.argument(0).to_i32();  // can fail!!!

Some examples where the interpreter would actually crash:

var o = { toString: () => { throw Error() } };
+o;
o - 1;
"foo".charAt(o);
"bar".repeat(o);

To fix this, we now have the following...

to_double(Interpreter&)
to_i32()
to_i32(Interpreter&)
to_size_t()
to_size_t(Interpreter&)

...and a whole lot of exception checking.

There's intentionally no to_double(), use as_double() directly instead.

This way we still can use these convenient utility functions but don't
need to check for exceptions if we are sure the value already is a
number.

Fixes #2267.
2020-05-18 09:39:55 +02:00
Linus Groh
1a1394f7a2 LibJS: Change Value::to_object(Heap& -> Interpreter&)
Passing a Heap& to it only to then call interpreter() on that is weird.
Let's just give it the Interpreter& directly, like some of the other
to_something() functions.
2020-05-18 09:39:55 +02:00
Linus Groh
b8b7f84547 LibJS: Remove no-op SymbolPrototype::description_setter()
We can just give put_native_property() a nullptr for the setter.
2020-05-18 09:36:14 +02:00
jarhill0
50c116e57b Base: Add smiling face with horns emoji (U+1F608) 😈 2020-05-18 09:36:00 +02:00
jarhill0
50336dc6ff Base: Add splashing sweat emoji (U+1F4A6) 💦 2020-05-18 09:36:00 +02:00
jarhill0
ec8edee19e Base: Add cherries emoji (U+1F352) 🍒 2020-05-18 09:36:00 +02:00
jarhill0
5fa40080cd Base: Add peach emoji (U+1F351) 🍑 2020-05-18 09:36:00 +02:00
jarhill0
aabad11dbf Base: Add eggplant emoji (U+1F346) 🍆 2020-05-18 09:36:00 +02:00
jarhill0
054385ae0e Base: Add Cancer emoji (U+264B) 2020-05-18 09:36:00 +02:00
Devashish
e4f7080bbd Meta: Update CLion and WSL configuration documentations
This commit updates CLionConfiguration.md and NotesOnWSL.md so that
they comply with new build system. In addition to that, the WSL doc
is updated to include instructions to run qemu (and serenity) natively
on Windows, without needing an X-window server.
2020-05-17 23:07:35 +02:00
Andreas Kling
6060c7444b LibGUI: Fix crash in TextDocument::remove(TextRange)
Oops, we can't be appending substrings of a string we just deleted!

Fix this by building up the new line instead of trying to clear and
append in place. This works out nicely as we now do fewer document view
updates when removing a range. :^)
2020-05-17 22:35:25 +02:00
Andreas Kling
30a3b8333a LibVT: TerminalWidget now opts into emoji input by default :^) 2020-05-17 22:35:25 +02:00
Andreas Kling
604fb278c1 LibGUI: TextEditor now opts in to emoji input by default :^) 2020-05-17 22:35:25 +02:00
Andreas Kling
4173905198 LibGUI: Add a simple emoji input dialog activated by Ctrl+Alt+Space :^)
Widgets can now opt in to emoji input via set_accepts_emoji_input().
If the focused widget accepts emoji input, we'll pop up a simple dialog
with all the available emojis as clickable buttons.

You can press escape if you change your mind and don't want an emoji.

This UI layout definitely will not scale as we add more emojis, but it
works for the moment, and we can adapt it as we go. Pretty cool! :^)
2020-05-17 22:35:25 +02:00
Andreas Kling
1b78d9fa1f LibVT: Handle keydown events with multi-byte text correctly
TerminalWidget can now handle keydown events that contain multi-byte
UTF-8 sequences. :^)
2020-05-17 22:35:25 +02:00
Andreas Kling
1bef057ec3 LibGUI: Make the TextEditor widget store UTF-32 codepoints
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.
2020-05-17 22:35:25 +02:00
Andreas Kling
0272bbb4fb LibGfx: Add UTF-32 version of the text painting code paths
There's a large amount of code duplication here right now, which will
need to be reduced.
2020-05-17 22:35:25 +02:00
Andreas Kling
0d78ee95f9 LibVT: Make TerminalWidget::selected_text() produce UTF-8 strings :^) 2020-05-17 22:35:25 +02:00
Andreas Kling
86242f9c18 AK: Add StringBuilder::append(Utf32View)
This encodes the incoming UTF-32 sequence as UTF-8.
2020-05-17 22:35:25 +02:00
Andreas Kling
bc6f469544 LibGfx: Let's make it Font::width(Utf32View) 2020-05-17 22:35:25 +02:00
Andreas Kling
00b5614ce2 AK: Add a very basic Utf32View class
This allows you to wrap a { const u32* codepoints, size_t length } in a
simple object.
2020-05-17 22:35:25 +02:00
Andreas Kling
b3f6b43d3c LibC: Don't let ctype isfoo() helpers access array out of bounds 2020-05-17 22:35:25 +02:00
Andreas Kling
35875b68f5 LibGfx: Add Font::width(u32* codepoints, size_t)
This allows you to measure the width of a UTF-32 sequence.
2020-05-17 22:35:25 +02:00
mattco98
4ced126704 LibJS: Add symbol objects
This commit adds the following classes: SymbolObject, SymbolConstructor,
SymbolPrototype, and Symbol. This commit does not introduce any
new functionality to the Object class, so they cannot be used as
property keys in objects.
2020-05-17 18:05:15 +02:00
Conrad Pankoff
b5b08fba92 AK: Make sure URL retains trailing slash if present in complete_url 2020-05-17 16:35:42 +02:00
AnotherTest
013cb76d77 LibGemini: Implement rendering text/gemini documents to HTML
This also sets Content-Type to whatever 'meta' contains on success, to
allow the browser to pick up what the document contains.
2020-05-17 16:35:42 +02:00
Andreas Kling
a4902e0eec ProtocolServer: Put everything in the ProtocolServer namespace 2020-05-17 16:33:09 +02:00
Andreas Kling
2949c3e5e1 Meta: Add Linus, Ali and Shannon to the "Contributors" list
I've been adding people here after they cross over the 100 commit line.
Make that criteria explicit in the text.
2020-05-17 16:27:51 +02:00
Linus Groh
71ec72bddf LibJS: Simplify various StringPrototype functions 2020-05-17 16:23:48 +02:00
Linus Groh
73eef31f49 LibJS: Add Number.parseFloat() 2020-05-17 16:21:38 +02:00
Linus Groh
6f6b089aa0 LibJS: Add parseFloat() 2020-05-17 16:21:33 +02:00
Andreas Kling
cc42d75209 ls: Make column alignment Unicode-aware :^)
You can now have emojis in file names and they will line up correctly
in "ls" output.
2020-05-17 13:05:39 +02:00