Commit Graph

375 Commits

Author SHA1 Message Date
Timothy Flynn
7cab86ad28 Userland: Unveil /proc/all in applications which require it
These were missed in 7af5eef. It is needed for any application using
e.g. FileSystemAccessServer.
2022-10-03 17:09:21 +01:00
Timothy Flynn
25e0ab3ee4 Userland: Tighten promises by removing 'proc' where it isn't used
This is a partial revert of commit 7af5eef. After 97d15e9, the 'proc'
promise is not needed for operations using getsid().

This also fixes launching several applications in which 7af5eef added
the 'proc' promise only in the second call to pledge().
2022-10-03 17:09:21 +01:00
Peter Elliott
7af5eef0dd SystemServer+LoginServer+Userland: Switch to sid-based sockets
This commit does three things atomically:
- switch over Core::Account+SystemServer+LoginServer to sid based socket
  names.
- change socket names with %uid to %sid.
- add/update necessary pledges and unveils.

Userland: Switch over servers to sid based sockets

Userland: Properly pledge and unveil for sid based sockets
2022-10-03 11:11:29 +02:00
Sam Atkins
a58d72656d Userland: Replace empty GUI::Widgets in GML with GUI::Layout::Spacer
This fixes the "Cancel" button on HackStudio's "New Project" dialog
being too small. It's also clearer what these actually are.
2022-09-29 08:31:15 -04:00
networkException
4230dbbb21 AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and
create_with_file_protocol() already. This patch removes these function
and updates all call sites to use the functions named according to the
specification.

See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-29 09:39:04 +01:00
Marco Santos
5f76ab9836 Spreadsheet: Add toolbar actions to change the cell style 2022-09-27 13:38:11 +03:30
thankyouverycool
b70e4e9909 Spreadsheet+LibGUI: Set EmojiInputDialog as a CaptureInput modal
This has two advantages: First the picker no longer changes the active
window state of its parent. Visually this is an additional hint that the
dialog is "fragile" and will close on loss of focus. Second, because
it contains a search box, its own input won't be preempted by global
application shortcuts when typing (pending #15129). This is a problem
in apps like PixelPaint which use shortcuts without modifiers.
2022-09-09 11:27:38 -04:00
electrikmilk
fff79379d4 Spreadsheet: Add Insert Emoji action
This adds the Insert Emoji action to Spreadsheet.
2022-09-08 23:08:54 +01:00
Timothy Flynn
fc8bf7ac3e LibUnicode+Userland: Migrate generated CLDR data to LibLocaleData
Currently, LibUnicodeData contains the generated UCD and CLDR data. Move
the UCD data to the main LibUnicode library, and rename LibUnicodeData
to LibLocaleData. This is another prepatory change to migrate to
LibLocale.
2022-09-05 14:37:16 -04:00
thankyouverycool
cce9172cd4 Applications+DevTools: Remove fixed sizes from Splitters
And adjust some GML properties. Since a808cfa, splitters grow
opportunistically. Setting them to fixed sizes now quite literally
fixes them in place. Fixes immovable splitters missed in the
aforementioned commit.
2022-08-30 16:28:44 +01:00
Linus Groh
cfa5885855 LibJS: Turn initialize_global_object() into a regular initialize()
There's nothing special about global object initialization anymore, this
can just work the same way as for any other object now.
2022-08-28 16:36:56 +01:00
Linus Groh
50428ea8d2 LibJS: Move intrinsics to the realm
Intrinsics, i.e. mostly constructor and prototype objects, but also
things like empty and new object shape now live on a new heap-allocated
JS::Intrinsics object, thus completing the long journey of taking all
the magic away from the global object.
This represents the Realm's [[Intrinsics]] slot in the spec and matches
its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of
architecture.

In the majority of cases it should now be possibly to fully allocate a
regular object without the global object existing, and in fact that's
what we do now - the realm is allocated before the global object, and
the intrinsics between both :^)
2022-08-27 11:29:10 +01:00
thankyouverycool
3dd522a109 SpreadSheet: Pass parent window when constructing About action
Fixes About dialog not blocking the app's main window.
2022-08-26 12:48:05 +02:00
thankyouverycool
d5de9bcc51 Applications: Use modeless windows in some apps
Browser, Spreadsheet and Charactermap now open child windows
modelessly.
2022-08-25 13:28:50 +02:00
thankyouverycool
4c7f95e2f8 LibGUI+WindowServer+Apps: Replace Accessory Windows
with the CaptureInput WindowMode. This mode will serve the same
function as accessories: redirecting input while allowing parent
windows to remain active.
2022-08-25 13:28:50 +02:00
Linus Groh
275dea9d98 LibJS: Remove {Bytecode::,}Interpreter::global_object()
The basic idea is that a global object cannot just come out of nowhere,
it must be associated to a realm - so get it from there, if needed.

This is to enforce the changes from all the previous commits by not
handing out global objects unless you actually have an initialized
realm (either stored somewhere, or the VM's current realm).
2022-08-23 13:58:30 +01:00
Linus Groh
b345a0acca LibJS+LibWeb: Reduce use of GlobalObject as an intermediary
- Prefer VM::current_realm() over GlobalObject::associated_realm()
- Prefer VM::heap() over GlobalObject::heap()
- Prefer Cell::vm() over Cell::global_object()
- Prefer Wrapper::vm() over Wrapper::global_object()
- Inline Realm::global_object() calls used to access intrinsics as they
  will later perform a direct lookup without going through the global
  object
2022-08-23 13:58:30 +01:00
Linus Groh
e3895e6c80 LibJS: Pass Realm to define_native_{accessor,function}()
This is needed so that the allocated NativeFunction receives the correct
realm, usually forwarded from the Object's initialize() function, rather
than using the current realm.
2022-08-23 13:58:30 +01:00
Linus Groh
7c468b5a77 LibJS: Pass Realm to GlobalObject::initialize_global_object()
Global object initialization is tightly coupled to realm creation, so
simply pass it to the function instead of relying on the non-standard
'associated realm' concept, which I'd like to remove later.

This works essentially the same way as regular Object::initialize() now.

Additionally this allows us to forward the realm to GlobalObject's
add_constructor() / initialize_constructor() helpers, so they set the
correct realm on the allocated constructor function object.
2022-08-23 13:58:30 +01:00
Linus Groh
b465f46e00 LibJS: Remove GlobalObject parameter from native functions 2022-08-23 13:58:30 +01:00
Linus Groh
25849f8a6d LibJS: Replace GlobalObject with VM in common AOs [Part 18/19] 2022-08-23 13:58:30 +01:00
Linus Groh
a022e548b8 LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]
This is where the fun begins. :^)
2022-08-23 13:58:30 +01:00
Linus Groh
999da617c5 LibJS: Remove GlobalObject from VM::this_value()
This is a continuation of the previous six commits.

The global object is only needed to return it if the execution context
stack is empty, but that doesn't seem like a useful thing to allow in
the first place - if you're not currently executing JS, and the
execution context stack is empty, there is no this value to retrieve.
2022-08-23 13:58:30 +01:00
Linus Groh
f3117d46dc LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits.

A first big step into the direction of no longer having to pass a realm
(or currently, a global object) trough layers upon layers of AOs!
Unlike the create() APIs we can safely assume that this is only ever
called when a running execution context and therefore current realm
exists. If not, you can always manually allocate the Error and put it in
a Completion :^)

In the spec, throw exceptions implicitly use the current realm's
intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23 13:58:30 +01:00
Linus Groh
e992a9f469 LibJS+LibWeb: Replace GlobalObject with Realm in Heap::allocate<T>()
This is a continuation of the previous three commits.

Now that create() receives the allocating realm, we can simply forward
that to allocate(), which accounts for the majority of these changes.
Additionally, we can get rid of the realm_from_global_object() in one
place, with one more remaining in VM::throw_completion().
2022-08-23 13:58:30 +01:00
Linus Groh
b99cc7d050 LibJS+LibWeb: Replace GlobalObject with Realm in create() functions
This is a continuation of the previous two commits.

As allocating a JS cell already primarily involves a realm instead of a
global object, and we'll need to pass one to the allocate() function
itself eventually (it's bridged via the global object right now), the
create() functions need to receive a realm as well.
The plan is for this to be the highest-level function that actually
receives a realm and passes it around, AOs on an even higher level will
use the "current realm" concept via VM::current_realm() as that's what
the spec assumes; passing around realms (or global objects, for that
matter) on higher AO levels is pointless and unlike for allocating
individual objects, which may happen outside of regular JS execution, we
don't need control over the specific realm that is being used there.
2022-08-23 13:58:30 +01:00
Linus Groh
5dd5896588 LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functions
This is a continuation of the previous commit.

Calling initialize() is the first thing that's done after allocating a
cell on the JS heap - and in the common case of allocating an object,
that's where properties are assigned and intrinsics occasionally
accessed.
Since those are supposed to live on the realm eventually, this is
another step into that direction.
2022-08-23 13:58:30 +01:00
Linus Groh
ecd163bdf1 LibJS+LibWeb: Replace GlobalObject with Realm in object constructors
No functional changes - we can still very easily get to the global
object via `Realm::global_object()`. This is in preparation of moving
the intrinsics to the realm and no longer having to pass a global
object when allocating any object.
In a few (now, and many more in subsequent commits) places we get a
realm using `GlobalObject::associated_realm()`, this is intended to be
temporary. For example, create() functions will later receive the same
treatment and are passed a realm instead of a global object.
2022-08-23 13:58:30 +01:00
davidot
e746360b9a LibJS: Use NaN boxing to decrease the memory size of Values
Using the fact that there are 2^52-2 NaN representations we can
"NaN-box" all the Values possible. This means that Value no longer has
an explicit "Type" but that information is now stored in the bits of a
double. This is done by "tagging" the top two bytes of the double.
For a full explanation see the large comment with asserts at the top of
Value.

We can also use the exact representation of the tags to make checking
properties like nullish, or is_cell quicker. But the largest gains are
in the fact that the size of a Value is now halved.

The SunSpider and other benchmarks have been ran to confirm that there
are no regressions in performance compared to the previous
implementation. The tests never performed worse and in some cases
performed better. But the biggest differences can be seen in memory
usage when large arrays are allocated. A simple test which allocates a
1000 arrays of size 100000 has roughly half the memory usage.

There is also space in the representations for future expansions such as
tuples and records.

To ensure that Values on the stack and registers are not lost during
garbage collection we also have to add a check to the Heap to check for
any of the cell tags and extracting the canonical form of the pointer
if it matches.
2022-08-15 17:11:25 +02:00
Lucas CHOLLET
ac7b0e69e5 Base: Launch WebContent at session start-up 2022-08-14 21:52:35 +01:00
Andreas Kling
50d951aea2 LibJS: Let Shape store a Realm instead of a GlobalObject
This is a cautious first step towards being able to create JS objects
before a global object has been instantiated.
2022-08-05 12:42:46 +02:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
c70f45ff44 Everywhere: Explicitly specify the size in StringView constructors
This commit moves the length calculations out to be directly on the
StringView users. This is an important step towards the goal of removing
StringView(char const*), as it moves the responsibility of calculating
the size of the string to the user of the StringView (which will prevent
naive uses causing OOB access).
2022-07-12 23:11:35 +02:00
FrHun
307d113594 Spreadsheet: Make conditional-formatting condition-list scrollable 2022-06-30 11:53:50 +02:00
FrHun
93112458b8 Spreadsheet: Use new layout system 2022-06-30 11:51:25 +02:00
Ali Mohammad Pur
db4a5aafc8 Spreadsheet: Display a detailed view of a cell error on hover
With this, Spreadsheet can now show an almost full stack trace for the
error (which is infintely better than just the error message).
2022-06-26 22:21:17 +01:00
Ali Mohammad Pur
64ef808aeb Spreadsheet: Allow importing sheets into an existing workbook 2022-06-26 22:21:17 +01:00
Ali Mohammad Pur
135683795b Spreadsheet: Throw if lookup value doesn't exist and no default is given
And explicitly state which value wasn't found and where in the error.
2022-06-26 22:21:17 +01:00
Ali Mohammad Pur
746b8ec8de Spreadsheet: Make it possible to refer to ranges in other sheets
Now the range A0:C4 in a sheet named "foo" can be represented as:

    R`sheet("foo"):A0:C4`

This makes it possible to do cross-sheet lookups and more.
2022-06-26 22:21:17 +01:00
Ali Mohammad Pur
0e2f4c50d3 Spreadsheet: Prevent OOB access to text editor buffer
For some reason LibGUI sends two events for each edit, and one of them
contains an OOB cursor if a character was deleted.
This works around that for now.
2022-06-26 22:21:17 +01:00
FrHun
8081a8a5de LibGUI: Add layout spacer support to GML
This is a bit of a hack, but it is an easy way to finally get spacers
into GML.
This will translate well if spacers are later to become child objects of
the continer widget.
2022-06-10 21:26:06 +01:00
Linus Groh
173dcfb7cb Everywhere: Fix a bunch of typos 2022-05-29 15:22:00 +02:00
Karol Kosek
3667d7e93c Userland: Depend some applications on WebContent if it's being used
Deduced this mostly by looking at unveil()s.
2022-05-26 21:54:58 +01:00
Karol Kosek
6a4b125fe5 Spreadsheet: Make save functions take a Core::File instead of a filename
This allows us to use FileSystemAccessClient functions.
2022-05-24 03:36:04 +04:30
Karol Kosek
04443eb847 Spreadsheet: Open files using FileSystemAccessClient::try_open_file() 2022-05-24 03:36:04 +04:30
Karol Kosek
d877c2fcd6 Spreadsheet: Remove unused Workbook::load() function 2022-05-24 03:36:04 +04:30
Karol Kosek
01824fd19a Spreadsheet: Use TRY() on file load and save 2022-05-24 03:36:04 +04:30
Karol Kosek
169498f9db Spreadsheet: Recognize sheets files by mime type, not by file extension
These conditions weren't executed since 933a717f3b and always showed
a file import/export wizard.
2022-05-22 03:08:53 +04:30
DexesTTP
dcbbbf5b4a LibWebView: Move OutOfProcessWebView to a new LibWebView library
Also moves WebContentClient and the references to the generated IPC
descriptions, since they are all components of OutOfProcessWebView.

This patch has no functional changes.
2022-05-15 12:17:36 +02:00
Sam Atkins
cdffe556c8 LibGUI+Userland: Make Dialog::ExecResult an enum class 2022-05-13 16:27:43 +02:00
Eli Youngs
04763c4a12 Spreadsheet: Sort functions by name in the help window 2022-04-18 17:36:34 +02:00
Sam Atkins
73552c1856 Userland: Always construct Application with try_create() 2022-04-18 12:57:34 +02:00
martinfalisse
356eca7e33 Spreadsheet: Implement undo functionality where missing
Implement undo/redo functionality in the Spreadsheet application
for the "extend" function, the drag-and-drop function, and when
copying and pasting.
2022-04-13 09:26:44 +04:30
martinfalisse
22575c9370 Spreadsheet: Make undo operation handle multiple cells at a time
Instead of having the undo operation only be able to undo one cell
for a given undo, make it able to handle multiple cells at a time.
 Please enter the commit message for your changes. Lines starting
2022-04-13 09:26:44 +04:30
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Karol Kosek
35934acbd3 Spreadsheet: Change paste action's enabled state on clipboard change
Previously, the paste action was always enabled and always assumed that
anything was selected, which led to a crash by clicking the paste action
right after the application startup.

This patch will automatically enable/disable the paste action depending
on whether a selection exists (it usually does, except on the app launch
and after adding a new tab) and if the clipboard mime type is a text/
group.

So no, you can't paste an image into the app anymore, even though this
mostly froze the app before...
2022-04-06 18:32:49 +02:00
Brian Gianforcaro
9cfd520bb8 Applications: Use default execpromises parameter to pledge(..) 2022-04-03 17:13:51 -07:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Karol Kosek
d665492e35 Spreadsheet: Don't remove on_change tab function after loading a file
Forgot to remove that in c0c9825f67, as
this function was no longer declared and used... Until the previous
commit.

This meant that pressing the F2 key after opening a file no longer
matched the current tab.
2022-03-28 22:28:40 +04:30
Karol Kosek
07b369b7d9 Spreadsheet: Create rename action using the GUI::CommonActions helper
Besides from reusing more parts from the code, this allows us to call
the action using the F2 key. That is also the reason why we have
to reassign `m_tab_context_menu_sheet_view` on tab change.
2022-03-28 22:28:40 +04:30
Karol Kosek
3b352e46d6 Spreadsheet: Reuse save and rename actions
These parts of code were identical to their action counterparts.
2022-03-28 22:28:40 +04:30
circl
eeeaf410fb WindowServer+LibGUI: Expose raw scroll wheel values to applications
This is useful, for instance, in games in which you can switch held
items using the scroll wheel. In order to implement this, they
previously would have to either add a hard-coded division by 4, or look
up your mouse settings to adjust correctly.

This commit adds an MouseEvent.wheel_raw_delta_x() and
MouseEvent.wheel_raw_delta_y().
2022-03-27 01:11:27 +01:00
Simon Danner
1888e60015 Spreadsheet: Update Undo / Redo button state 2022-03-26 18:29:21 +00:00
Ali Mohammad Pur
5dc0855489 Spreadsheet: Use the correct top-center alignment when set to Top+Center 2022-03-20 13:20:33 +00:00
Ali Mohammad Pur
292e459901 Spreadsheet: Allow the user to format Identity cells via JS expressions
Also add some hints as to what the format field expects as it would be
very confusing otherwise.
2022-03-20 13:20:33 +00:00
Ali Mohammad Pur
8919e4b2b6 Spreadsheet: Only update the selection on primary mousedown
Otherwise we'd end up clearing the selected rect before doing anything
with it if the user right-clicks on it.
2022-03-20 13:20:33 +00:00
Ali Mohammad Pur
0d302516d5 Spreadsheet: Skip over "invalid" saved cell values
These can be generated by saving something that's not serialisable (e.g.
functions), skip over them and let the load logic reevaluate them when
needed.
2022-03-20 13:20:33 +00:00
martinfalisse
11dffbd96f Spreadsheet+LibGUI: Calculate cell position given scroll position
Take into account the current scroll position when calculating the
position of cells. This way when the user scrolls either horizontally
or vertically, the calculations done to find the cell position
will be correct.
2022-03-19 09:31:29 +03:30
martinfalisse
5759b25ca8 Spreadsheet: Handle case when drag-and-drop location is out of bounds
When the drop location of a drag-and-drop operation is not valid, then
don't continue with the drop_event. For example, if the ending location
is the header row or header column, or is outside of the table, then
should not continue.
2022-03-19 09:31:29 +03:30
martinfalisse
9e54815799 Spreadsheet: Implement extend functionality
Implements ability to extend a cell's contents by clicking the bottom
right of the cell and dragging in a linear direction. For now, the
content that is extended is simply a copy of the target cell's
values.
2022-03-19 09:31:29 +03:30
martinfalisse
f6ad98b1a1 Spreadsheet: Take into account cell order when copying and cutting
Since copying and cutting uses the cell values in the origin to decide
which values to paste in the destination, it is necessary to do it
in an ordered manner when the origin and destination ranges overlap.
Otherwise you may overwrite values in the origin unintentionally
before having successfully transferred them to the destination.
2022-03-19 09:31:29 +03:30
martinfalisse
2f2a705a8e Spreadsheet: Cut instead of copy when dragging a cell's items
Use cut instead of copy when dragging one or many cells' contents.
This is more intuitive as most other spreadsheet applications
handle the drag in this manner instead of as a copy operation.
2022-03-19 09:31:29 +03:30
martinfalisse
8a7d2c3336 Spreadsheet: Rename variables to better describe their function
Rename some variables relating to the drag-and-cut operations as
well as the select operation so that they are more clear.
2022-03-19 09:31:29 +03:30
martinfalisse
e98d0dafa0 Spreadsheet: On cut end select same cells in target location
When finished dragging and cutting, select the cells in the
destination. E.g. if you select 5 cells and drag and paste
them in a new location, select the 5 pasted cells in the
destination.
2022-03-19 09:31:29 +03:30
martinfalisse
10bbb01ed8 Spreadsheet: Set cursor manually so that correct cells are outlined
Due to the fact that in the AbstractView, when multiple cells are
selected, and then another cell is selected within this selection,
the cursor is not updated as the user may be beginning to drag, have
to override this functionality for the Spreadsheet application.

This is because in spreadsheets when multiple cells are selected,
and then you click on one of the cells within the selection,
the selection should be cleared and the targetted cell highlighted.
2022-03-19 09:31:29 +03:30
martinfalisse
1287238430 Spreadsheet: Select the correct cell on click
Due to the margin that is given to be able to select cells for
cutting or extending, have to override the mouse click function
so that the targetted cell is chosen and not the one that may be
beneath the cursor.
2022-03-19 09:31:29 +03:30
martinfalisse
4f0a123b2f Spreadsheet: Display different cursors depending on action
Depending on the cursor location with respect to a selected cell,
display different icons pertaining to the distinct possible actions,
for example dragging and cutting, extending the cell's contents, or
doing a simple selection.
2022-03-19 09:31:29 +03:30
martinfalisse
a378e3ccbf Spreadsheet: Add states for cursor hovering
Add states for the cutting and extending icons that are to be shown
depending on where the user's cursor is with respect to the target
cell.
2022-03-19 09:31:29 +03:30
Linus Groh
9422ae9bb2 LibJS: Add infallible variant of VM::push_execution_context()
It makes no sense to require passing a global object and doing a stack
space check in some cases where running out of stack is highly unlikely,
we can't recover from errors, and currently ignore the result anyway.

This is most commonly in constructors and when setting things up, rather
than regular function calls.
2022-03-18 01:12:12 +01:00
Karol Kosek
62668ebd81 Spreadsheet: Move tab widget actions to the main widget constructor
There's no need to reassign these functions when we add a new tab.
Nothing changes inside them and they don't depend on anything in the
function.
2022-03-15 12:01:27 +03:30
Karol Kosek
c0c9825f67 Spreadsheet: Get the active sheet via TabWidget::active_widget()
We don't have to track the active widget ourselves anymore -- less
possible boogs!
2022-03-15 12:01:27 +03:30
Karol Kosek
dcd3d7fe22 Spreadsheet: Set tab functions for every tab on setup
Previously, we were setting tab actions only for the active tab on a tab
change, and the same actions for the previous tab were removed.

Unfortunately, this also happened when making a new tab, which meant
that you could trick the cell editor to jump to the new sheet and start
writing there.

To fix this, every view will always have on_selection_changed
and on_selection_dropped assigned.  I haven't seen much difference in
the memory usage, so I guess it'll be fine :)
2022-03-15 12:01:27 +03:30
u9g
c8803afe3e Spreadsheet: Add CommonRange#unique() 2022-03-09 10:22:20 +03:30
u9g
b9d44eb022 Spreadsheet: Add SplitRange class and CommonRange#filter 2022-03-09 10:22:20 +03:30
javabird25
67d10a50ee Spreadsheet: Fix overridden max length related crash
NumericCell::display() attempted to take a substring of cell contents
according to the "Override max length" parameter,
but it did not account for the actual string length.
2022-03-09 01:05:12 +03:30
Vrins
3b22fd9a9f LibGfx: Add support for TextAlignment::TopCenter / BottomCenter
Now supports TextAlignment::TopCenter and TextAlignment::BottomCenter
for the Painter::draw_text.

Also patched this in Spreadsheet/CellTypeDialog.cpp
2022-03-08 22:09:52 +01:00
u9g
4147b56e79 Spreadsheet: Allow integer() to throw in weird cases
Also makes numericResolve use parseInt to avoid using our own integer()
2022-03-05 05:46:35 +03:30
u9g
75a02300ba Spreadsheet: Add find, findIndex, indexOf, & has to CommonRange 2022-03-05 05:46:35 +03:30
u9g
87c818c571 Spreadsheet: Put common Range(s) functionality into CommonRange class 2022-03-05 05:46:35 +03:30
Karol Kosek
5c978266e3 Spreadsheet: Ask about unsaved changes on "Open..." action activation 2022-03-04 11:56:52 -05:00
u9g
12ef20b869 Spreadsheet: Improve R function to support all of the examples 2022-03-04 04:29:20 +03:30
u9g
93115ee044 Spreadsheet: Add Range(s).toArray() 2022-03-04 04:29:20 +03:30
Karol Kosek
20dbbdf90c Spreadsheet: Simplify enabling actions on selection
Since the function will *always* be called with some selection, we can
straight up enable actions.
2022-03-03 22:19:50 +03:30
Karol Kosek
f384aff510 Spreadsheet: Move deselection instructions to on_selection_dropped
The previous code never executed, as SpreadsheetView splits selection
events into `on_selection_changed` and `on_selection_dropped` depending
on whether there is any selection.
2022-03-03 22:19:50 +03:30
Karol Kosek
dc65543fa9 Spreadsheet: Show the opened filename in the window title
Prior to this commit, there was a set_filename() function that could set
the window title, but actually it never did that.  It was called only
in one place -- by the 'Save as...' action, but it always failed to
change anything, because there was a check that tried to reassign
the same filename. :/

This patch:
1. removes that check, and therefore
2. renames the function to simply `update_window_title()`,
3. starts calling the function from more places (at startup and after
   loading a file),
4. changes the window title order
   (`{app_name} - {filename}` -> `{filename} - {app_name}`) to match
   the other applications style on the system. :^)
2022-03-03 22:17:54 +03:30
u9g
4eb2c70a03 Spreadsheet: Make Range(s).forEach() return Position objects 2022-03-02 21:49:17 +03:30
u9g
d047f26a74 Spreadsheet: Add Range(s).at(ix) 2022-03-02 21:49:17 +03:30
roughjericho
8dd08a1103 Spreadsheet: Make function examples easier to read
Up until now, the Spreadsheet function examples appeared below their
descriptions. Let's swap them to make it clearer which JS example
goes to which description.
2022-02-28 20:27:50 -08:00
u9g
d2adf54e73 Spreadsheet: Add sumProduct(If) functions 2022-02-27 02:48:32 +03:30
u9g
99425c5adc Spreadsheet: Add max(If)/min(If) function for ranges 2022-02-27 02:48:32 +03:30
u9g
6c35419236 Spreadsheet: Add Range(s).first() functions 2022-02-27 02:48:32 +03:30
Filiph Sandström
3c01ef1c23 Spreadsheet: Disable cut/copy if no cell is selected
This resolves #12766 which occurred when the user tried to
use either the cut or copy action before selecting a cell.
2022-02-26 10:36:27 +01:00
Ali Mohammad Pur
bed129a69f LibTest+Spreadsheet: Add some basic spreadsheet runtime behaviour tests
As there's a somewhat active development going on, let's keep the
expected behaviour under tests to make sure nothing blows up :^)
2022-02-23 03:17:12 +03:30
Zack Penn
e41dfa6599 Spreadsheet: Add undo/redo implementation
The Spreadsheet application currently does not support undo/redo,
and with this update, we are starting the process of adding this feature
:-)

Additionally, the save dialog has been updated to use
GUI::MessageBox::ask_about_unsaved_changes() for system cohesity.

Spreadsheet: Add basic undo functinoality

The spreadsheet application now has basic support for undo. Testing of
this feature is limited, and may not work as intended yet.

Spreadsheet: Add callback when a cell's value is changed

In addition to the callback being added, this commit also exposes the
SheetModel class via a getter in SpreadSheetView.

Spreadsheet: Remove debug statements and use cell change callback

This commit uses the on_cell_data_change callback from within the
SheetModel class. This allows for us to push/pop changes to the undo
stack.

With this, we have basic Undo/Redo functionality :-)

Spreadsheet: Actually add window::set_modified

Spreadsheet: Const-correctness :-)

Spreadsheet: Reorder the edit menu actions
2022-02-21 16:04:48 +03:30
u9g
0d50ac1657 Spreadsheet: Remove Debug Statement 2022-02-20 20:05:31 +00:00
Karol Kosek
410254dbe2 Spreadsheet: Use the system-wide unsaved changes dialog 2022-02-20 08:40:26 -05:00
electrikmilk
8fea7d9752 Spreadsheet: Improve 'Functions Help' button
Add icon and tooltip to 'Functions Help' button.
2022-02-15 12:16:23 +01:00
electrikmilk
ffa140c613 Spreadsheet: Insert missing icons
Add icons where they are missing.
2022-02-15 12:16:23 +01:00
Lenny Maiorani
160bda7228 Applications: Use default constructors/destructors
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-02-14 22:06:55 +00:00
Idan Horowitz
c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
Lenny Maiorani
2e87a5b7eb Applications: Port Spreadsheet to LibMain 2022-02-10 10:24:18 +00:00
davidot
4ef1e8f226 Spreadsheet: No longer use vm.exception() to signal exception state
Instead, use the completions which are returned directly. This means we
no longer have to worry about the global VM state when running code.
2022-02-08 09:12:42 +00:00
kleines Filmröllchen
6ee597369d Meta+Userland: Run the GML formatter on CI and pre-commit
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
2022-02-07 18:39:50 +01:00
Sam Atkins
45cf40653a Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOr
Apologies for the enormous commit, but I don't see a way to split this
up nicely. In the vast majority of cases it's a simple change. A few
extra places can use TRY instead of manual error checking though. :^)
2022-01-24 22:36:09 +01:00
mjz19910
1ef633472b Everywhere: Convert VM::call() to JS::call() 2022-01-23 15:24:45 +00:00
davidot
2d4b345bb1 Spreadsheet: Enable dynamic import of javascript modules
This has some risks as it can (attempt to) load arbitrary files on the
filesystem but for now it can only load local files which do go through
normal file operations. But let's enable it for now to see what we can
do with it.
2022-01-22 01:21:18 +00:00
Luke Wilde
631bbcd00a LibJS: Refactor interpreter to use Script and Source Text Modules
This also refactors interpreter creation to follow
InitializeHostDefinedRealm, but I couldn't fit it in the title :^)

This allows us to follow the spec much more closely rather than being
completely ad-hoc with just the parse node instead of having all the
surrounding data such as the realm of the parse node.

The interpreter creation refactor creates the global execution context
once and doesn't take it off the stack. This allows LibWeb to take the
global execution context and manually handle it, following the HTML
spec. The HTML spec calls this the "realm execution context" of the
environment settings object.

It also allows us to specify the globalThis type, as it can be
different from the global object type. For example, on the web, Window
global objects use a WindowProxy global this value to enforce the same
origin policy on operations like [[GetOwnProperty]].

Finally, it allows us to directly call Program::execute in perform_eval
and perform_shadow_realm_eval as this moves
global_declaration_instantiation into Interpreter::run
(ScriptEvaluation) as per the spec.

Note that this doesn't evalulate Source Text Modules yet or refactor
the bytecode interpreter, that's work for future us :^)

This patch was originally build by Luke for the environment settings
object change but was also needed for modules. So I (davidot) have
modified it with the new completion changes and setup for that.

Co-authored-by: davidot <davidot@serenityos.org>
2022-01-22 01:21:18 +00:00
Mustafa Quraish
bba32de857 SpreadSheet: Use FileSystemAccessClient::try_* APIs 2022-01-20 10:39:12 +01:00
creator1creeper1
19d9d5bfe1 Everywhere: Mark Vector of mutable references as mutable
The point of a reference type is to behave just like the referred-to
type. So, a Foo& should behave just like a Foo.

In these cases, we had a const Vector. If it was a const Vector of Foo,
iterating over the Vector would only permit taking const references to
the individual Foos.

However, we had a const Vector of Foo&. The behavior should not
change. We should still only be permitted to take const references to
the individual Foos. Otherwise, we would be allowed to mutate the
individual Foos, which would mutate the elements of the const Vector.
This wouldn't modify the stored pointers, but it would modify the
objects that the references refer to. Since references should be
transparent, this should not be legal.

So it should be impossible to get mutable references into a const
Vector. Since we need mutable references in these cases to call the
mutating member functions, we need to mark the Vector as mutable as
well.
2022-01-16 00:38:21 +03:30
Glenford Williams
c55dfabdd5 Spreadsheet: Use FileSystemAccessClient for the reading of files 2022-01-15 22:20:15 +03:30
Glenford Williams
f5ff011c1b Spreadsheet: Properly pass parent window to Workbook
Change the parent of the WizardDialog to that of the Spreadsheet window.
Previously the WizardDialog was using the open file dialog as the
parent resulting in the csv import dialog
2022-01-09 20:38:55 +01:00
Linus Groh
eb60d16549 LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and
then receiving the relevant result via VM::last_value(), we can
consolidate all of this by using completions.

This allows us to remove more uses of VM::exception(), and all uses of
VM::last_value().
2022-01-08 23:43:03 +01:00
mjz19910
10ec98dd38 Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
Linus Groh
85f0fc2b83 LibJS: Return Optional<T> from Completion::{value,target}(), not T
In the end this is a nicer API than having separate has_{value,target}()
and having to check those first, and then making another Optional from
the unwrapped value:

    completion.has_value() ? completion.value() : Optional<Value> {}
    //                       ^^^^^^^^^^^^^^^^^^
    //         Implicit creation of non-empty Optional<Value>

This way we need to unwrap the optional ourselves, but can easily pass
it to something else as well.

This is in anticipation of the AST using completions :^)
2022-01-03 21:50:50 +01:00
martinfalisse
b39aede8fe Spreadsheet: Background fill color after reaching vertical end
When selecting a cell in the spreadsheet that was added
automatically as per the InfinitelyScrollableTableView
implementation, the background color is now filled correctly.

Previously, when navigating horizontally in a spreadsheet, after
a certain point the cells would not have the same background fill
color as the user would have experienced in the previous column
ranges (A-Z).
2022-01-03 22:30:04 +03:30
Timothy Flynn
565a880ce5 Userland: Link directly against LibUnicodeData where needed
This is partially a revert of commits:
    10a8b6d411
    561b67a1ad

Rather than adding the prot_exec pledge requried to use dlopen(), we can
link directly against LibUnicodeData in applications that we know need
that library.

This might make the dlopen() dance a bit unnecessary. The same purpose
might now be fulfilled with weak symbols. That can be revisted next, but
for now, this at least removes the potential security risk of apps like
the Browser having prot_exec privileges.
2021-12-30 14:18:12 +01:00
Timothy Flynn
10a8b6d411 Userland: Add unveil/pledge requisites for dynamic Unicode data loading
Loading libunicodedata.so will require dlopen(), which in turn requires
mmap(). The 'prot_exec' pledge is needed for this.

Further, the .so itself must be unveiled for reading. The "real" path is
unveiled (libunicodedata.so.serenity) as the symlink (libunicodedata.so)
itself cannot be unveiled.
2021-12-21 13:09:49 -08:00
Ali Mohammad Pur
f0709c7a24 LibC+AK: Implement all sorts of wprintf variants 2021-12-21 21:24:36 +03:30
RasmusNylander
fa99125571 Spreadsheet: Handle emptying of cell containing only an '='
Cell::set_data(String new_data) now checks whether the cell is a
formula-cell and the new_data is an empty string. If this is case, it
will no longer simply return and will now instead actually set the
cell's contents to an empty string.

This fixes an error whereupon committing the string "=" to a cell, it
would not be possible to directly delete the cell's contents. Instead,
it first had to be overwritten with another string, which then could be
deleted.

This could probably be done more elegantly. Right now, I believe,
writing the string "=" to a (formula-)cell already containing an
identical string will result in the cell being marked as dirty, even
though nothing actually changed.
2021-12-16 02:44:37 +03:30
Ali Mohammad Pur
5f1a34bba3 Spreadsheet: Avoid using Value.to_string_without_side_effects()
We should use .to_string() and handle the possible exceptions.
This makes the displayed cell contents so much more informative than
'[object Object]' :^)
2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
235eb0b1ad Spreadsheet: Replace hacky JS VM configuration with a more correct one
Now we give each sheet its own interpreter and realm, and only make them
share the VM.
This is to prepare for the next commit, which will be refactoring a
bunch of things to propagate exceptions via ThrowCompletionOr<T>.
2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
82dde46a30 Spreadsheet: Replace the help button's text with something we can render 2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
91444de2cf Spreadsheet: Reimplement ranges as lazy objects instead of arrays
Doing so makes it possible to talk about theoretically infinite ranges
like "all of column A".
2021-12-12 14:49:49 +03:30
Ali Mohammad Pur
892e585e9a Spreadsheet: Don't recreate the global environment on every evaluation
The worksheet's realm does not change, and is not shared, so we can
safely leave the global environment be.
This fixes lexical scoping in the spreadsheet's runtime file.
2021-12-12 14:49:49 +03:30
Ben Wiederhake
13cba5f8b4 Spreadsheet: Avoid implicitly copying ByteBuffer 2021-12-08 09:46:13 -08:00
Erik Biederstadt
e052d647b7 Spreadsheet: Allow sheet renaming after double clicking on the tabwidget 2021-12-01 00:44:26 +03:30
Ben Wiederhake
f22c0ffe0c LibGUI+Everywhere: Make sync requests to Clipboard server more obvious 2021-11-21 11:49:06 +00:00
Andreas Kling
587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
Andreas Kling
4a2b718ba2 LibCore: Use ErrorOr<T> for Core::File::copy_file() 2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
FrHun
54605794f9 Applications: Remove border from GroupBox margins 2021-11-03 16:13:19 +01:00
Timothy Flynn
1939c72ecc Spreadsheet: Convert JSIntegration to ThrowCompletionOr 2021-10-31 15:48:36 +01:00
Marco Cutecchia
5f04fb0ece Spreadsheet: Make the 'Help' window accessory 2021-10-31 00:58:05 +03:30
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
Andreas Kling
398c181c79 LibJS: Rename PropertyName to PropertyKey
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Idan Horowitz
40eb3a39d4 LibJS: Rename define_native_function => define_old_native_function
This method will eventually be removed once all native functions are
converted to ThrowCompletionOr
2021-10-20 12:27:19 +01:00
Idan Horowitz
20163c0584 LibJS: Add ThrowCompletionOr versions of the JS native function macros
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and
JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all
native functions were converted to the new format.
2021-10-20 12:27:19 +01:00