Commit Graph

12453 Commits

Author SHA1 Message Date
RasmusNylander
9678ff15a8 KeyboardMapper: Propagate errors using ErrorOr and TRY
KeyboardMapperWidget's load_map_from_file, load_map_from_system, save,
and save_to_file now all return ErrorOr<void> and no longer handles
alerting the user to potential errors.

main is now responsible for handling errors originating from its calls
to these four functions; it will simply alert the user using the new
method KeyboardMapperWidget::show_error_to_user(Error), which simply
creates a MassageBox displaying the error's string_literal.

This makes the whole program slight more clean feeling :^).
2022-01-06 17:54:03 +01:00
RasmusNylander
4e65c4dae4 LibKeyboard: Change some Optional<T> returns to ErrorOr<T>
Makes CharacterMapFile::load_from_file and CharacterMap::load_from_file
return ErrorOr instead of Optional. This makes them a little nicer to
use and a little easier to read, as they seem to have been approximating
this.
2022-01-06 17:54:03 +01:00
RasmusNylander
017135b44e KeyboardMapper: Port to LibMain 2022-01-06 17:54:03 +01:00
RasmusNylander
64684cbd5d KeyboardMapper: Fix discrepancy between cursor and button clickability
KeyButton now only responds to clicks on the key-cap's face. This
corresponds to when the cursor switches from the default arrow to a
hand.
2022-01-06 17:54:03 +01:00
RasmusNylander
35afd32a51 KeyboardMapper: Fix displaying null characters
Fixes a bug where KeyButtons would display null characters. A single
null character should be handled as an empty string.
2022-01-06 17:54:03 +01:00
RasmusNylander
41b0795f99 KeyboardMapper: Name formerly inlined variables
Renames some variables in KeyButton.cpp to increase clarity and grants
some slightly opaque inline variables names.
2022-01-06 17:54:03 +01:00
RasmusNylander
c4b2efd95e KeyboardMapper: Show multiple pressed keys at once
When depressing a key, KeyboardMapperWidget::keydown_event() will now
update only the pressed state of the button associated with the specific
key, instead of also setting the pressed state of the all the buttons to
false.

This makes it possible to highlight multiple pressed keys at once and
makes the code more consistent; the implementation of keyup_event
implied that this was a feature of the program.
2022-01-06 17:54:03 +01:00
RasmusNylander
a1531dba91 KeyboardMapper: Extract method map_from_name
Extract the mapping of a name to a character map into its own method.
This only slightly reduces the number of lines, going from 24 to 17
lines, but makes the code somewhat more readable and reduces repetition.
2022-01-06 17:54:03 +01:00
RasmusNylander
b2a6c9e5ea KeyboardMapper: Extract creation of map-selection buttons
Extract the creation of map-selection radio buttons from create_frame
into the new private method add_map_radio_button(map_name, button_text)
turning 24 lines into 4 + 6 lines. This makes create_frame a little
easier to read. :^)
2022-01-06 17:54:03 +01:00
martinfalisse
8eb8949d9c LibGUI: Calculate row position for scroll into view
When a user is navigating a table view with arrow keys and a row is
outside of the current view, then scroll_into_view is called, and the
position of the rectangle passed to this should take into account the
column headers.

This can be seen making more pleasant the navigation in the System
Monitor in the Processes view, for example.
2022-01-06 17:48:04 +01:00
martinfalisse
938380e88b LibGUI: Table View navigating with arrow keys continuity after update
When a user is navigating a table view with arrow keys and a row is
outside of the current view, then scroll_into_view is called, and the
position of the rectangle passed to this should take into account the
column headers.

This can be seen making more pleasant the navigation in the System
Monitor in the Processes view, for example.
2022-01-06 17:48:04 +01:00
Tobias Christiansen
923979ca93 PixelPaint: Unveil FileIconProvider.ini
This is used by the Filter Gallery and previously complained in the
debug log that it was not unveiled.
2022-01-06 15:13:05 +01:00
Jun Zhang
0ac7931545 Utilities/ln: Port to LibMain
This patch simply ports the utility ln to LibMain :^)
2022-01-06 13:32:22 +01:00
Linus Groh
81492b3cee LibJS: Remove the now unused custom VM unwind mechanism
Goodbye VM::m_unwind_until, you served us well :^)
2022-01-06 12:36:23 +01:00
Linus Groh
9d0d3affd4 LibJS: Replace the custom unwind mechanism with completions :^)
This includes:

- Parsing proper LabelledStatements with try_parse_labelled_statement()
- Removing LabelableStatement
- Implementing the LoopEvaluation semantics via loop_evaluation() in
  each IterationStatement subclass; and IterationStatement evaluation
  via {For,ForIn,ForOf,ForAwaitOf,While,DoWhile}Statement::execute()
- Updating ReturnStatement, BreakStatement and ContinueStatement to
  return the appropriate completion types
- Basically reimplementing TryStatement and SwitchStatement according to
  the spec, using completions
- Honoring result completion types in AsyncBlockStart and
  OrdinaryCallEvaluateBody
- Removing any uses of the VM unwind mechanism - most importantly,
  VM::throw_exception() now exclusively sets an exception and no longer
  triggers any unwinding mechanism.
  However, we already did a good job updating all of LibWeb and userland
  applications to not use it, and the few remaining uses elsewhere don't
  rely on unwinding AFAICT.
2022-01-06 12:36:23 +01:00
Linus Groh
eed764e1dd LibJS: Implement the LoopContinues AO 2022-01-06 12:36:23 +01:00
Linus Groh
fc474966bc LibJS: Implement LabelledStatement & LabelledEvaluation semantics
Instead of slapping 0..N labels on a statement like the current
LabelableStatement does, we need the spec's LabelledStatement for a
proper implementation of control flow using only completions - it always
has one label and one labelled statement - what appears to be 'multiple
labels' on the same statement is actually nested LabelledStatements.

Note that this is unused yet and will fully replace LabelableStatement
in the next commit.
2022-01-06 12:36:23 +01:00
Jelle Raaijmakers
558fd5b166 LibCore: Make EventLoop::pump() return event count
Sometimes, pumping the event loop will cause new events to be
generated. For example, an IPC message could be delivered which then
dispatches a new event to be handled by the GUI. To the invoker of
`EventLoop::pump()`, it is not obvious if any events were processed at
all.

Libraries like SDL2 might not have the opportunity to run the event
loop often enough that events can be processed swiftly, since it might
spend time doing other things. This can result in stuttering GUI
interactions.

This changes `EventLoop::pump()` to return the number of processed
events. This functionality will be used by our SDL2 port in another PR.
2022-01-06 11:30:04 +01:00
Sam Atkins
93ef8c8080 LibMarkdown: Output alignment when rendering HTML tables
Previously, only terminal output aligned table column contents
correctly. Now, we apply a `text-align` to each cell. This does not
actually *work* however, since LibWeb's table layout code is not yet
fully functional.
2022-01-06 08:22:46 +03:30
Lucas CHOLLET
75d1840cfc FileManager: Show Dotfiles when passing a Dotfile as an argument
Before this patch, FileManager was failing to open the directory and
open `/` instead.
2022-01-05 15:20:54 -08:00
Lucas CHOLLET
693ae73606 FileManager: Use String const& instead of String
Change ErrorOr<int> run_in_windowed_mode(String, String)
to ErrorOr<int> run_in_windowed_mode(String const&, String const&)
2022-01-05 15:20:54 -08:00
Luke Wilde
3e0c19d6ea LibJS: Add tests for all the unscopable Array prototype properties
When I was writing for tests for groupBy and groupByToMap, I noticed
there were no tests for these.
2022-01-05 20:31:25 +01:00
Timothy Flynn
260d2099da LibJS: Implement Date.UTC according to the spec
This fixes all failing Date.UTC test262 tests, which failed due to not
handling invalid input and evaluating inputs out of order. But this also
avoids using timegm(), which doesn't work on macOS for years before 1900
(they simply return -1 for those years).

Partially addresses #4651. Date.parse.js still fails.
2022-01-05 20:05:12 +01:00
Timothy Flynn
7a0830bb24 LibJS: Use AK::Time to implement the MakeDay AO
We currently use Core::DateTime create, which internally uses mktime().
This has the issues pointed out by the (now removed) FIXME, but also has
an issue on macOS where years before 1900 are not supported.
2022-01-05 20:05:12 +01:00
Timothy Flynn
e8f860048e LibJS: Set the length of Date.UTC to 7
This is a bit unusual because there is only 1 required argument, but the
spec dictates that the length is 7.
2022-01-05 20:05:12 +01:00
Andreas Kling
2375e1bcda LibGUI: Rename ModelSelection::remove_matching => remove_all_matching
Let's be consistent with how Vector, HashTable and HashMap names these.
2022-01-05 18:57:14 +01:00
Andreas Kling
c6bcd0dfe4 LibGUI: Use HashTable::remove_all_matching() in GUI::ModelSelection 2022-01-05 18:57:14 +01:00
Andreas Kling
c7ac0c2c80 LibJS: Use HashMap::remove_all_matching() in WeakMap 2022-01-05 18:57:14 +01:00
Andreas Kling
e08d325124 LibJS: Use HashTable::remove_all_matching() in WeakSet :^) 2022-01-05 18:57:14 +01:00
Timothy Flynn
ec7d5351ed LibJS+LibUnicode: Handle flexible day periods that roll over midnight
When searching for the locale-specific flexible day period for a given
hour, we were neglecting to handle cases where the period crosses 00:00.
For example, the en locale defines a day period range of [21:00, 06:00).
When given the hour of 05:00, we were checking if (21 <= 5 && 5 < 6),
thus not recognizing that the hour falls in that period.
2022-01-05 16:22:55 +01:00
Mathieu PATUREL
c8addf1a5e LibGUI: Consume initial spaces when going to next/prev word break
This impacts text editors' ctrl+left, ctrl+shift+right, ctrl+backspace,
etc..

For example, consider the text "Hello world   |", pressing
ctrl+backspace each time.

Before: "hello world   |"
        "hello world|"
        "hello |"
        "hello|"
        "|"
 After: "hello world   |"
        "hello|"
        "|"

Note that this breaks a nice symmetry. Doing ctrl+left and then
ctrl+right doesn't necessarily get you to the same place like it use to.

Before: " hello |"
        " hello| "
        " hello |" // same as initial
 After: " hello |"
        "|hello "
        " hello| " // different from initial
2022-01-05 14:18:44 +01:00
Brian Gianforcaro
538986c991 Kernel+LibVT: Use MUST + try_prepend / try_append
In preparation for making Vector::append + Vector::prepend
unavailable during compilation of the Kernel.

This specific file is compiled into the Kernel as well as LibVT.
2022-01-05 14:04:18 +01:00
Jesse Buhagiar
48c9350036 LibELF: Add LD_LIBRARY_PATH envvar support :^)
The dynamic linker now supports having custom library paths
as specified by the user.
2022-01-05 15:01:14 +02:00
thankyouverycool
d375904978 Base+LibGUI: Add unique "Save As" icon
Icon by: Mustafa Quraish <mustafaq9@gmail.com>
2022-01-05 13:58:18 +01:00
Mustafa Quraish
7c69830169 PixelPaint: Add new icon for New Image from Clipboard
This is just a slight variation of `/res/icons/16x16/paste.png`, I've
removed the lines on the paper to make it look consistent with the
"New Image" icon, which is an empty piece of paper.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
e2c73a114d PixelPaint: Use 'save' action in toolbar instead of 'save as'
I think this is likely the more common operation and makes more sense
in the toolbar. It calls the 'save as' action internally anyway if there
is no associated file.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
c03f271bbf PixelPaint: Ask about unsaved changes for all tabs on close
Now, when trying to close the application, there is a separate prompt
for each open tab with unsaved changes. Each tab is closed after it is
handled appropriately (assuming the user didn't Cancel), this makes it
so that the message box is always asking about the currently active tab,
allowing the user to see that the image contains.

If at any point the user presses "Cancel", all remaining tabs are kept
open.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
915211252d PixelPaint: Mark editor as unmodified when creating a default image
This is similar to opening an empty text file in TextEditor, the user
is only asked to saved changes if they have made any changes to it.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
fc5c327751 PixelPaint: Mark editor as unmodified when opening an image
Previously a newly opened (and unedited) project was considered
modified, even though there was no need to actually re-save the
contents.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
8c4579bced PixelPaint: Only prompt for unsaved changes if there any
Previously MainWidget::request_close() would always put up the
message box asking to save unsaved changes, even if there aren't any.
This patch makes it so that the message box is only shown if the
undo stack is in a modified state.
2022-01-05 12:08:20 +01:00
Mustafa Quraish
2440d2c2fe PixelPaint: Move title and path from Image to ImageEditor
As noted in the latest hacking video, it doesn't seem to make much
sense to store the title and path in the image itself. These fields
have now been moved to the actual ImageEditor itself.

This allows some nice simplicfications, including getting rid of the
`image_did_change_title` hook of ImageClient (which was just a way to
report back to the editor that the title had changed).
2022-01-05 12:08:20 +01:00
Luke Wilde
0b9ea712be LibJS: Implement Array.prototype.groupByToMap 2022-01-05 11:21:38 +01:00
Luke Wilde
48cc1c97d5 LibJS: Implement Array.prototype.groupBy 2022-01-05 11:21:38 +01:00
Luke Wilde
4a14455dff LibJS: Make MarkedValueList copyable and move assignable
This is required to store a MarkedValueList as the value of a HashMap.
2022-01-05 11:21:38 +01:00
Luke Wilde
c97244d3a5 LibJS: Add Handle specialisation for Value
This allows you to keep an arbitrary JS::Value alive without having to
hook visit_edges somewhere, e.g. by being a NativeFunction that
overrides visit_edges.

For example, this allows you to store JS::Handle<JS::Value> as the key
of a HashMap. This will be used to keep arbitrary Values alive in
the key of a temporary HashMap in Array.prototype.groupByToMap.

Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
2022-01-05 11:21:38 +01:00
mjz19910
1f1383fe1e unzip: Remove useless .characters() calls 2022-01-04 23:53:46 -08:00
mjz19910
2351bb2db9 Utilities/CMakeList: Remove duplicate target_link_libraries(...) 2022-01-04 19:14:57 -08:00
mjz19910
87b719a494 Utilities/CMakeList: Sort target_link_libraries(...) 2022-01-04 19:14:57 -08:00
Linus Groh
bfa42cbe4f LibJS: Remove the now retired TRY_OR_DISCARD() macro :^) 2022-01-04 23:37:26 +00:00
Linus Groh
9e50bd91a6 js: Remove uses of TRY_OR_DISCARD()
Slightly more verbose, but that's the last user of TRY_OR_DISCARD gone!
2022-01-04 23:37:26 +00:00