Commit Graph

3735 Commits

Author SHA1 Message Date
Andreas Kling
687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Ariel Don
a4fdb7f029 VimEditingEngine: Prevent crash upon 'x' or 'v' on blank lines
Previously, pressing 'x' for deletion on an otherwise empty line
insinuated a crash in TextEditor because a nonexistent code point was
accessed -- likewise for visual mode.
2021-07-21 21:13:57 +02:00
Andreas Kling
cdc1315dc8 LibJS: Use IntrusiveList for keeping track of WeakContainers 2021-07-21 20:17:55 +02:00
Andreas Kling
3fe1be20b7 LibJS: Use IntrusiveList for keeping track of MarkedValueLists 2021-07-21 19:51:19 +02:00
Andreas Kling
746b310061 LibJS: Use IntrusiveList for keeping track of HandleImpls
This allows us to remove a HashTable from heap and cuts down on
some of the malloc traffic when creating handles.
2021-07-21 19:45:21 +02:00
Andreas Kling
3d0c5814d2 LibGfx: Sprinkle [[nodiscard]] on Gfx::Bitmap 2021-07-21 18:09:05 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Andreas Kling
f0409081f5 LibC: Simplify assertion failure dbgln() a bit
There's no need to say USERSPACE(PID) since dbgln() will prefix lines
with that information anyway.
2021-07-21 17:45:24 +02:00
Jamie Mansfield
137d716495 LibLine: Correct spelling mistake in variable name
This corrects the spelling of 'matching' from 'macthing'.
2021-07-21 14:15:24 +02:00
Tom
7e8a5d7323 LibIPC: Fix losing messages when connection is closed
This fixes not processing any messages read up until a connection
close is detected. We were returning from the function despite having
read some messages.
2021-07-21 01:13:45 +02:00
Tom
1ecb725357 LibGfx: Add an algorithm to disperse overlapping rectangles 2021-07-21 00:06:58 +02:00
davidot
295192bf15 LibJS: Add tests for strict mode and strict mode propagation 2021-07-20 23:45:28 +02:00
davidot
f8a869f2fc LibJS: Fix that non-existent references are unresolvable in strict mode 2021-07-20 23:45:28 +02:00
davidot
a49b47bfe6 LibJS: Fix tests that expected wrong this values 2021-07-20 23:45:28 +02:00
Timothy Flynn
c6e9c6d6ab LibJS: Follow the spec more closely when determining the this value
Co-authored-by: davidot <david.tuin@gmail.com>
2021-07-20 23:45:28 +02:00
davidot
a394aa5830 LibJS: Fix that vm.in_strict_mode was propagated to eval and functions
For eval it depends on the CallerMode and for a created function it
depends on the function itself.
2021-07-20 23:45:28 +02:00
davidot
a6263150be LibJS: Disallow unqualified deletes in strict mode 2021-07-20 23:45:28 +02:00
davidot
697882a7ad LibJS: Disallow multiple __proto__ keys in object expression 2021-07-20 23:45:28 +02:00
davidot
93b57e6d8c LibJS: Disallow static methods named prototype in classes 2021-07-20 23:45:28 +02:00
davidot
40b8689f9b LibJS: Disallow duplicated variable declarations 2021-07-20 23:45:28 +02:00
davidot
5cc518f07a LibJS: Handle strict mode for functions more correctly
If a function is strict (has 'use strict' directive) it cannot have
bindings, cannot have duplicated parameter names and cannot have some
reserved keywords and identifiers as parameter names.
The logic partly applies depending on whether we are already in strict
mode or the function contains 'use strict';
2021-07-20 23:45:28 +02:00
davidot
4485df1405 LibJS: Be more strict about reserved and special identifiers 2021-07-20 23:45:28 +02:00
davidot
2a61b90fef LibJS: Be less strict about 'use strict'
It is allowed to have (bogus) directives e.g.
'does nothing'; 'same'; 'use strict';
Should still trigger strict mode.
2021-07-20 23:45:28 +02:00
Andreas Kling
3652ab8b2a LibGUI: Tweak GUI::GroupBox title text position 2021-07-20 21:50:06 +02:00
Linus Groh
feea534dae LibJS/Tests: Fix typo in Temporal.Instant.compare test description 2021-07-20 17:57:50 +01:00
Linus Groh
99662975ed LibJS: Partially revert e3fa32b
This was causing some syntactically wrong inputs to crash and
subsequently broke CI (test262 parser tests).
2021-07-20 17:53:48 +01:00
Andreas Kling
e7136399a1 LibX86: Add INT1 instruction (needed for disassembly) 2021-07-20 18:05:05 +02:00
Alexander
d528c9c2ee LibWeb: Don't print JavaScript syntax error hints
This uses the new flag in print_errors to not print hints. This
decreases the load time of JavaScript heavy webpages with many errors
significantly.
2021-07-20 16:20:59 +02:00
Alexander
e3fa32b2ad LibJS: Optimize source_location_hint and add flag in print_errors
This optimizes the algorithm used in source_location_hint and adds a
flag to not print hints in print_errors.
2021-07-20 16:20:59 +02:00
Peter Elliott
2ce8cca7b5 LibC: Implement flock(2) using fcntl's F_SETLK
While flock is not a posix interface, it exists on linux and all BSDs as
far as I am aware.
2021-07-20 17:44:30 +04:30
Peter Elliott
3fa2816642 Kernel+LibC: Implement fcntl(2) advisory locks
Advisory locks don't actually prevent other processes from writing to
the file, but they do prevent other processes looking to acquire and
advisory lock on the file.

This implementation currently only adds non-blocking locks, which are
all I need for now.
2021-07-20 17:44:30 +04:30
Gunnar Beutner
60b52cfb02 Userland: Hardcode the x86_64 kernel base address for now 2021-07-20 15:12:19 +02:00
Ali Mohammad Pur
3184086679 LibLine: Avoid excessive write() syscalls when refreshing the display
Previously, we were generating the display update one character at a
time, and writing them one at a time to stderr, which is not buffered,
doing so caused one syscall per character printed which is s l o w (TM)
This commit makes LibLine write the update contents into a buffer, and
flush it after all the update is generated :^)
2021-07-20 11:55:42 +04:30
Ali Mohammad Pur
0f6654fef2 LibLine: Reset the suggestion page offset when finding the max length
Otherwise, something like shift+tab->tab->tab will mess up the page
contents (assuming that the max lengths in the pages are different).
2021-07-20 11:55:42 +04:30
Ariel Don
54bf6a7884 LibGUI: Add Ctrl-U to insert mode
While under insert mode, Ctrl-U deletes all characters between the first
non-blank character of the line and the cursor.

Implement delete_from_line_start_to_cursor() in TextEditor. Then, call
the method in VimEditingEngine via its pointer to an instance of
TextEditor.
2021-07-20 03:22:28 +02:00
Ariel Don
8230bf8944 LibGUI: Add Ctrl-H to insert mode
In Vim, Ctrl-H is effectively equivalent to backspace in insert mode, as
it deletes the previous character.

This commit implements method delete_previous_char() to TextEditor.
delete_char() already exists in EditingEngine, but it deletes the
next character rather than the previous. delete_previous_char() is then
called from within VimEditingEngine.
2021-07-20 03:22:28 +02:00
Ariel Don
808e5e813f LibGUI: Add Ctrl-W to insert mode
In Vim's insert mode, Ctrl-W deletes the word before the cursor, like
Ctrl-Backspace. Unlike Ctrl-Backspace, if only whitespace exists between
the end of the word and the cursor, the word will be deleted with the
whitespace.

To do so, this commit introduces two methods: delete_previous_word() for
TextEditor and first_word_before() for TextDocument, where the former
depends on the latter. delete_previous_word() is then called in
VimEditingEngine.
2021-07-20 03:22:28 +02:00
Andreas Kling
f5e914fb9f LibTTF+LibGfx: Make Gfx::Font::bold_variant() work for TTF fonts
There's no need for this to be a virtual, it's just a font database
lookup and can be done in the Font base class.
2021-07-20 02:48:29 +02:00
Andreas Kling
9f601fcbcf LibTTF+LibGfx: Improve vertical alignment of glyphs
Before this patch, some glyphs had a weird off-by-1 vertical position
which looked really jarring at small font sizes.

This was caused by glyph bitmaps having different heights from each
other. (Each glyph bitmap was minimally sized to fit only the glyph
itself, and then vertically positioned during the paint phase.
Since this vertical positioning was integer based, subpixel precision
was lost and things ended up looking wonky.)

Fix this by making all glyph bitmaps be the same height so we can blit
them at the same integer y position. We use the typographic ascent from
the OS/2 table to transform the glyph coordinates.

The end result is a huge improvement visually. :^)
2021-07-20 02:48:29 +02:00
Andreas Kling
e984200206 LibTTF: Parse OS/2 tables
The OS/2 table contains nice typographic ascent/descent information.
2021-07-20 02:48:29 +02:00
Andreas Kling
3b1e05f714 LibTTF: Don't choke on fonts with CompositeGlyfFlags::UseMyMetrics
This was preventing us from loading JetBrains Mono Regular with LibTTF.
2021-07-20 02:48:29 +02:00
Andreas Kling
808f1f63ff LibTTF: Minor const correctness fix in TTF rasterizer 2021-07-20 02:48:29 +02:00
Andreas Kling
d8f435fa50 LibTTF: Propagate glyph bitmap allocation failure in rasterizer 2021-07-20 02:48:28 +02:00
Andreas Kling
7b3a4f8281 LibTTF: Rename "raster" => "rasterize" 2021-07-20 02:48:28 +02:00
Andreas Kling
8070bbd442 LibTTF: Convert code to east-const style 2021-07-20 02:48:28 +02:00
Linus Groh
4983a972b0 LibDesktop: Add a RunInTerminal boolean field to app files
This is common enough to warrant its own setting by now - but it's also
partially a workaround. Since app files currently only support a single
executable path with no arguments, we resort to generating wrapper
scripts for port launchers with arguments - and then the executable is
that shell script. We also moved from manually specifying icon files to
embedding them in executables. As shell scripts can't have icons
embedded in them, a different solution is needed - this one solves the
common case of running a CLI program in a terminal, and still allows
embedding of icons in the executable itself as no shell script is
needed, meaning it will be shown in the taskbar and system menu.

The second use case of actually passing arguments to the executable
itself (and not just "Terminal -e ...") is not covered by this and still
requires an external script (meaning no icon for now), but I think that
can easily be solved by adding something like an "Arguments" field to
app files. :^)
2021-07-20 00:58:26 +01:00
Peter Elliott
b8f3441300 LibGUI: Add callback for screen rect change to Desktop.h
callbacks for screen rect changes can be added with
on_receive_screen_rects()
2021-07-19 18:21:40 +02:00
ls
fe7bacc2df File Manager: Differentiate between navigation and rename errors
Adds a new on_rename_error handler and renames the old on_error handler
to on_directory_change_error in FileSystemModel. The on_rename_error
handler creates a MessageDialog with the error message.
2021-07-19 18:20:34 +02:00
Itamar
941087ee25 LibGUI: Call did_update() from AutocompleteSuggestionModel::update()
This fixes an issue where the column widths of the AutocompleteBox did
not properly update after update_suggestions() was called.
2021-07-19 17:48:05 +02:00
Itamar
4a7be3f81c LibGUI: Remove column width limitation in AutocompleteProvider 2021-07-19 17:48:05 +02:00