Commit graph

1751 commits

Author SHA1 Message Date
Andreas Kling
94b95a4924 LibJS: Remove Interpreter::call()
Just use VM::call() directly everywhere.
2020-10-04 23:08:49 +02:00
asynts
59e7ffa86d AK: Make the return type of dbgputstr consistent. 2020-10-04 19:18:32 +02:00
Andreas Kling
4cf3a1eb41 Browser: Remove dbgln() statement that was crashing on startup
Don't have time to dig into this right now, but let's unbreak Browser.
2020-10-04 17:12:11 +02:00
Andreas Kling
6f5322409d Browser: Fix build after dbgf() -> dbgln() rename 2020-10-04 17:09:01 +02:00
asynts
d5ffb51a83 AK: Don't add newline for outf/dbgf/warnf.
In the future all (normal) output should be written by any of the
following functions:

    out    (currently called new_out)
    outln
    dbg    (currently called new_dbg)
    dbgln
    warn   (currently called new_warn)
    warnln

However, there are still a ton of uses of the old out/warn/dbg in the
code base so the new functions are called new_out/new_warn/new_dbg. I am
going to rename them as soon as all the other usages are gone (this
might take a while.)

I also added raw_out/raw_dbg/raw_warn which don't do any escaping,
this should be useful if no formatting is required and if the input
contains tons of curly braces. (I am not entirely sure if this function
will stay, but I am adding it for now.)
2020-10-04 17:04:55 +02:00
asynts
616af36d91 Browser: Use format functions instead of printf. 2020-10-04 14:23:25 +02:00
Linus Groh
bcfc6f0c57 Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
Andreas Kling
44f9637e20 Browser: Add a special context menu for images
Now, right-clicking on an image allows you to open that image in this
tab or a new tab. You can also copy the image URL, and even copy the
image itself to the clipboard! :^)

Copying to the clipboard will not work in a multi-process context yet,
since we need to send the image bitmap across the IPC boundary and this
patch does not do that.
2020-10-02 19:03:10 +02:00
Andreas Kling
d00bfd0eaa Browser: Move the opening of a download window to its own function
This should probably grow into a proper download manager at some point,
but for now let's at least move it out of the context menu callback.
2020-10-02 19:00:45 +02:00
AnotherTest
c1fc27cab2 HackStudio+TextEditor: Add the Shell syntax highlighter 2020-09-30 20:05:24 +02:00
Andreas Kling
e4bda2e1e7 LibJS: Move Console from Interpreter to GlobalObject
Each JS global object has its own "console", so it makes more sense to
store it in GlobalObject.

We'll need some smartness later to bundle up console messages from all
the different frames that make up a page later, but this works for now.
2020-09-29 21:15:06 +02:00
AnotherTest
f159d161fa Spreadsheet: Let the cells know their own position in the sheet 2020-09-28 17:41:48 +02:00
Andreas Kling
2946a684ef ProtocolServer+LibWeb: Support more detailed HTTP requests
This patch adds the ability for ProtocolServer clients to specify which
HTTP method to use, and also to include an optional HTTP request body.
2020-09-28 11:55:26 +02:00
Benoît Lormeau
f0f6b09acb AK: Remove the ctype adapters and use the actual ctype functions instead
This finally takes care of the kind-of excessive boilerplate code that were the
ctype adapters. On the other hand, I had to link `LibC/ctype.cpp` to the Kernel
(for `AK/JsonParser.cpp` and `AK/Format.cpp`). The previous commit actually makes
sense now: the `string.h` includes in `ctype.{h,cpp}` would require to link more LibC
stuff to the Kernel when it only needs the `_ctype_` array of `ctype.cpp`, and there
wasn't any string stuff used in ctype.
Instead of all this I could have put static derivatives of `is_any_of()` in the
concerned AK files, however that would have meant more boilerplate and workarounds;
so I went for the Kernel approach.
2020-09-27 21:15:25 +02:00
Benoit Lormeau
f158cb27ea LibC: Remove an unneeded string.h include in ctype.h/cpp
And include string.h in the files that actually needed it
2020-09-27 21:15:25 +02:00
Andreas Kling
591b7b7031 LibJS: Remove js_string(Interpreter&, ...) 2020-09-27 20:26:58 +02:00
Andreas Kling
340a115dfe LibJS: Make native function/property callbacks take VM, not Interpreter
More work on decoupling the general runtime from Interpreter. The goal
is becoming clearer. Interpreter should be one possible way to execute
code inside a VM. In the future we might have other ways :^)
2020-09-27 20:26:58 +02:00
Andreas Kling
6861c619c6 LibJS: Move most of Interpreter into VM
This patch moves the exception state, call stack and scope stack from
Interpreter to VM. I'm doing this to help myself discover what the
split between Interpreter and VM should be, by shuffling things around
and seeing what falls where.

With these changes, we no longer have a persistent lexical environment
for the current global object on the Interpreter's call stack. Instead,
we push/pop that environment on Interpreter::run() enter/exit.
Since it should only be used to find the global "this", and not for
variable storage (that goes directly into the global object instead!),
I had to insert some short-circuiting when walking the environment
parent chain during variable lookup.

Note that this is a "stepping stone" commit, not a final design.
2020-09-27 20:26:58 +02:00
Andreas Kling
b245121f13 Spreadsheet: clang-format 2020-09-26 00:10:57 +02:00
Tibor Nagy
59a0e5ba1e Applications: Paint transparency grids through StylePainter 2020-09-26 00:00:08 +02:00
AnotherTest
43b2928688 Spreadsheet: Add the 'Date' cell type
Since `JS::Date::value_of()' returns the timestamp in ms, this new type
assumes that the value given is also in ms.
2020-09-25 23:55:33 +02:00
AnotherTest
a2efff9287 Spreadsheet: Treat an empty format string as "default" 2020-09-25 23:55:33 +02:00
AnotherTest
4748248fef Spreadsheet: Save and load cell types and formatting options 2020-09-25 23:55:33 +02:00
AnotherTest
395df7b27d Spreadsheet: Add conditional formatting
Currently only supports setting the foregound and the background colours.
This patch also unifies `foreground_color' and `background_color' used
throughout to a `Format' struct, in hopes of getting more formatting
options one day :P
2020-09-25 23:55:33 +02:00
Ben Wiederhake
9ef1461ec9 Meta+Applications: Make clang-format-10 clean 2020-09-25 21:18:17 +02:00
Andreas Kling
7d30cf7122 FileManager: Teach DirectoryView subviews to create editing delegates
This enables inline editing of filenames for table views, where this is
already supported. More work in LibGUI will be required to support the
feature in icon and columns views.
2020-09-24 11:36:02 +02:00
asynts
1cb8be9906 Applications+IRCClient: Use new format functions. 2020-09-23 21:45:28 +02:00
Andreas Kling
4a8bfcdd1c LibJS: Move the current exception from Interpreter to VM
This will allow us to throw exceptions even when there is no active
interpreter in the VM.
2020-09-22 20:10:20 +02:00
Tibor Nagy
3bd6142918 SystemMonitor: Wrap file descriptor and unveiled paths model into a SortingProxyModel 2020-09-22 19:05:50 +02:00
Tibor Nagy
f910cdcdb7 SystemMonitor: Fix assert when sorting by the "Page map" column 2020-09-22 19:05:50 +02:00
Tibor Nagy
e596b1da88 SystemMonitor: Wrap adapters and sockets model into a SortingProxyModel 2020-09-22 19:05:50 +02:00
Tibor Nagy
2c1b244889 SystemMonitor: Add sorting key to the devices model 2020-09-22 19:05:50 +02:00
Peter Elliott
7907df7617 Applications: Use placeholders in TextBoxes where applicable 2020-09-21 20:15:10 +02:00
Andreas Kling
df3ff76815 LibJS: Rename InterpreterScope => InterpreterExecutionScope
To make it a little clearer what this is for. (This is an RAII helper
class for adding and removing an Interpreter to a VM's list of the
currently active (executing code) Interpreters.)
2020-09-21 14:35:12 +02:00
AnotherTest
e7f5090808 Spreadsheet: Always keep the workbook interpreter in VM scope
Fixes #3570.
2020-09-21 00:10:19 +02:00
Tibor Nagy
cba5a69f07 FontEditor: Draw the baseline in the glyph editor widget 2020-09-20 23:23:56 +02:00
Andreas Kling
1c43442be4 LibJS+Clients: Add JS::VM object, separate Heap from Interpreter
Taking a big step towards a world of multiple global object, this patch
adds a new JS::VM object that houses the JS::Heap.

This means that the Heap moves out of Interpreter, and the same Heap
can now be used by multiple Interpreters, and can also outlive them.

The VM keeps a stack of Interpreter pointers. We push/pop on this
stack when entering/exiting execution with a given Interpreter.
This allows us to make this change without disturbing too much of
the existing code.

There is still a 1-to-1 relationship between Interpreter and the
global object. This will change in the future.

Ultimately, the goal here is to make Interpreter a transient object
that only needs to exist while you execute some code. Getting there
will take a lot more work though. :^)

Note that in LibWeb, the global JS::VM is called main_thread_vm(),
to distinguish it from future worker VM's.
2020-09-20 19:24:44 +02:00
Andreas Kling
95eeb321f9 LibGfx+FontEditor+Base: Add "baseline" value to all fonts
This does nothing at the moment but will soon allow us to improve the
vertical positioning of text.
2020-09-19 19:16:22 +02:00
Andreas Kling
e1965a5a8e FileManager: Prevent feedback loop between treeview and directory view
When opening something in the left-side treeview, it also opens in the
right-side directory view. That triggers the "path changed" hook in the
directory view, which causes us to fully reveal the opened directory
in the left-side treeview.

This feedback loop made the UI feel weird since it caused directories
to expand just by selecting them in the left-side treeview. So let's
break that loop.
2020-09-19 14:09:59 +02:00
Andreas Kling
eb24603da0 FileManager: Properly reveal newly opened directories in the treeview
Use the new TreeView::expand_all_parent_of() API to ensure that newly
opened directories are revealed and scrolled-into-view in the left-side
treeview. :^)
2020-09-18 21:29:01 +02:00
Andreas Kling
56328409d9 FileManager: Update GUI when "entering" an inaccessible directory
When we enter an inaccessible directory, we still allow that directory
to become selected in the left-side treeview, so we need to update the
location box and window title to reflect the new current path.

This is not perfectly factored and there's a bit of duplication between
the model's on_error and on_complete hook callbacks in DirectoryView.
Needs more work. :^)
2020-09-18 21:29:01 +02:00
Andreas Kling
8075db683b FileManager: Show an inline error message for inaccessible directories
Instead of popping up a message box whenever we can't read an opened
directory, show the error message inside the DirectoryView (as a label)
instead.

This fixes a visual inconsistency where an inaccessible directory would
be selected in the left-side treeview while the previous directory's
contents were still showing on the right.

This also makes keyboard navigation a bit more pleasant since you're
not suddenly interrupted by a message box.
2020-09-18 21:29:01 +02:00
Andreas Kling
65b246aaf4 FileManager: Remove an unused enum in DirectoryView 2020-09-18 21:29:01 +02:00
Andreas Kling
07d4b41bac FileManager: Move DirectoryView into the FileManager namespace 2020-09-17 17:23:37 +02:00
Andreas Kling
8055f7a1f5 FileManager: Move the DesktopWidget to its own compilation unit 2020-09-17 14:34:47 +02:00
Andreas Kling
4e8c50d92d FileManager: Handle drop events in DirectoryView
This makes it possible to drag & drop files to/from the desktop! :^)
2020-09-17 14:30:00 +02:00
Andreas Kling
e1e58d5bc9 FileManager: Use GUI::FileIconProvider for the location box icon 2020-09-16 21:08:55 +02:00
Andreas Kling
17ae1c37bb FileManager: Show the root (/) directory in the treeview on the left
This gives you something to click on if you actually want to open
the root directory. Previously, if you wanted to get to /, you had to
use the "to parent directory" repeatedly. Silly. :^)
2020-09-16 21:08:55 +02:00
Andreas Kling
95b6c98435 LibGUI: Fix TreeView scrolling to top when clicking sub-items
This code was confusing two different versions of scroll_into_view that
were getting mixed up due to member function shadowing.

Adding an "override" to the subclass declaration exposed the problem.

With this fixed, we no longer lose our scroll position wildly when
using the mouse to select TreeView items.
2020-09-16 16:37:28 +02:00
Andreas Kling
d67b421628 Browser: Move the basic Tab UI skeleton to JSON GUI 2020-09-14 19:55:17 +02:00
Andreas Kling
1307f7292c Browser: Set tab text alignment from JSON GUI 2020-09-14 19:55:17 +02:00
Andreas Kling
856f683dc9 Browser: Generate the main browser window UI from JSON :^) 2020-09-14 19:55:17 +02:00
Andreas Kling
f67c876df0 Build+TextEditor: Add a compile_json_gui() CMake helper
This makes it easier to include JSON GUI declarations in any app. :^)
2020-09-14 16:16:36 +02:00
Andreas Kling
119a0c5dee TextEditor: Move the find/replace buttons to JSON GUI 2020-09-14 16:16:36 +02:00
Andreas Kling
89822c5ae7 TextEditor: Set initial widget visibilities from JSON 2020-09-14 16:16:36 +02:00
Andreas Kling
8a7935a29f TextEditor: Move the "find" and "replace" widget containers to JSON GUI 2020-09-14 16:16:36 +02:00
Andreas Kling
2e547ce7a3 TextEditor: Move the main window UI to JSON
This is our first client of the new JSON GUI declaration thingy.
The skeleton of the TextEditor app GUI is now declared separately from
the C++ logic, and we use the Core::Object::name() of widgets to locate
them once they have been instantiated by the GUI builder.
2020-09-14 16:16:36 +02:00
Andreas Kling
67dca51f47 FileManager: Use the correct delete action in the treeview context menu 2020-09-13 21:48:16 +02:00
Andreas Kling
ef50e5aaee FileManager: Move delete and force-delete actions to DirectoryView
This is a little bit messy since the left-side treeview also has a
delete action. Because of that, we have to put a focus-dependent action
that delegates to the relevant view-specific action in the tool bar
and menu bar.

I'm not sure yet what a good abstraction would be for this. We'll see
what we can think of.
2020-09-13 21:41:45 +02:00
Andreas Kling
174527b580 KeyboardMapper: Avoid using [&] captures for persistent lambdas
These are not bugfixes, just improving the hygiene.
2020-09-13 21:41:45 +02:00
Andreas Kling
825fcb8292 FileManager: Move "Open Terminal here" action to DirectoryView 2020-09-13 21:41:45 +02:00
AnotherTest
d103686261 Spreadsheet: Implement a specialised version of printf for formatting
Now all format values will format a single double, cast to the
appropriate types.
2020-09-12 15:01:19 +02:00
AnotherTest
c2228b669d Spreadsheet: Allow customising the cell foreground and background colors 2020-09-12 15:01:19 +02:00
AnotherTest
8fa385f774 Spreadsheet: Allow cells to optionally have static fg/bg colors 2020-09-12 15:01:19 +02:00
Ben Wiederhake
83b85e5578 IRCClient: Remove unused dump() logic
A 'FIXME' asked for this to be removed, so I did.
2020-09-12 13:46:15 +02:00
Ben Wiederhake
9c3a33762b LibGfx: Saner memory usage of indexed bitmaps
Indexed bitmaps used to allocate four times the required amount of memory.

Also, we should acknowledge that the underlying data is not always RGBA32,
and instead cast it only when the true type is known.
2020-09-12 00:13:29 +02:00
Andreas Kling
8f5b92865d HexEditor: Use widget override cursors 2020-09-11 14:37:30 +02:00
Andreas Kling
b4f307f982 LibGUI+WindowServer: Rename window "override cursor" to just "cursor"
Let's just say each window has a cursor, there's not really overriding
going on.
2020-09-11 14:26:37 +02:00
Andreas Kling
0f9be82826 LibGfx: Move StandardCursor enum to LibGfx
This enum existed both in LibGUI and WindowServer which was silly and
error-prone.
2020-09-10 19:25:13 +02:00
Andreas Kling
4e0df06f86 IRCClient: Use NonnullRefPtr<IRCClient> throughout
To protect against mishaps during app exit teardown, make sure everyone
who needs to be is a co-owner of the IRCClient object.

Fixes #3451.
2020-09-10 18:45:00 +02:00
Andreas Kling
b4bfc3ed54 Spreadsheet: Add "final" to JS objects and tweak declarations 2020-09-08 14:11:43 +02:00
asynts
9c83d6ff46 Refactor: Replace usages of FixedArray with Array. 2020-09-08 14:01:21 +02:00
Andreas Kling
c460f4a3cb IRCClient: Add the "/me" command to send CTCP ACTION emotes :^)
You can now express your feelings and actions with our IRC client by
using the /me command.
2020-09-07 20:49:35 +02:00
Andreas Kling
3c49a82ae9 Terminal: Use utmpupdate to update /var/run/utmp
We now put entries for interactive terminal sessions in the utmp file.
They are removed when you exit the terminal.
2020-09-06 16:15:51 +02:00
Andreas Kling
f405cd3830 PixelPaint: Update "paste" action enabled state based on clipboard
This action should only be enabled when there's a pastable bitmap
on the system clipboard. :^)
2020-09-05 16:57:03 +02:00
Andreas Kling
6aa7f59608 PixelPaint: Allow pasting a copied bitmap as a new layer :^) 2020-09-05 16:53:51 +02:00
Andreas Kling
00bdb74c84 QuickShow: Allow copying the current bitmap to the clipboard :^) 2020-09-05 16:53:30 +02:00
Andreas Kling
51146e3075 LibGUI: Make the Clipboard API deal in raw byte buffers a bit more
To open up for putting not just text/plain content on the clipboard,
let's make the GUI::Clipboard API a bit more raw-data-friendly. :^)
2020-09-05 16:16:01 +02:00
Avery
1da38eeb3c DisplaySettings: Remove unnecessary file open for non-paths
Currently, every time the wallpaper picker changes, an additional
attempted file load happens on top of the file load to create the
bitmap. The only values that the wallpaper picker can take on are
filenames that can never be valid when loaded without the /res/wallpaper
prefix. To reduce the amount of log spam and speed up wallpaper picking,
this patch only attempts to load wallpapers with slash-prefixed names,
assumed to be the absolute path to that wallpaper. Additional wallpapers
outside of /res/wallpapers/ should still be accessible with this patch,
and the experience is improved for the more common case of selecting a
built-in wallpaper.
2020-09-03 11:03:16 +02:00
thankyouverycool
60872a7c5a DevTools+Apps: Set correct icons for ThemeEditor and VisualBuilder
VB appears deprecated in favor of HackStudio, but until it's
officially gone-no app left behind!
2020-08-31 09:14:18 +02:00
Ben Wiederhake
c587db387c TextEditor: Don't try to move(lambda)
The move constructor of a lambda just copies it anyway.

Even if the first move() left an 'empty' closure behind, then
'm_editor->on_cursor_change' would only be able to see an empty
closure, which is certainly not what was intended.
2020-08-30 10:31:04 +02:00
Ben Wiederhake
70a2adaace Calendar: Avoid unnecessary lambda
Especially when a constant is passed as a boolean that contradicts the default value.
2020-08-30 10:31:04 +02:00
Ben Wiederhake
c9bafa9467 FontEditor: Cannot take reference to local lambda
Under the hood, a lambda is just a struct full of pointers/references/copies and whatever else
the compiler deems necessary. In the case of 'update_demo', the struct lives on the stack
frame of FontEditorWidget::FontEditorWidget(). Hence it is still alive when it's called
during the constructor.

However, when 'fixed_width_checkbox.on_checked' fires, that stack frame is no longer alive,
and thus the *reference* to the (struct of) the lambda is invalid\! This meant that
'update_demo' silently read invalid data, tried to call '.update()' on some innocent arbitrary
memory address, and it crashed somewhere unrelated.

Passing 'update_demo' by value (like with all the other event handlers) fixes this issue.
Note that this solution only works because 'update_demo' itself has no state; otherwise
the various copies of 'update_demo' might notice that they are, in fact, independent copies
of the original lambda. But that doesn't matter here.
2020-08-30 10:31:04 +02:00
Ben Wiederhake
61521315ed FontEditor: Enforce boundaries of GlyphEditorWidget
Drawing out of bounds no longer affects any neighboring glyphs.
2020-08-30 10:31:04 +02:00
Ben Wiederhake
b2de1ba779 Browser: Mark default action in context menu of hyperlinks 2020-08-30 09:47:49 +02:00
Ben Wiederhake
a5f7b7e3e7 Browser: Mark default action in context menu of bookmarks 2020-08-30 09:47:49 +02:00
Ben Wiederhake
bc1dc2b688 IRCClient: Unbreak building with extra debug macros 2020-08-30 09:43:49 +02:00
AnotherTest
054638c355 Spreadsheet: Add (limited) support for custom cell formatting 2020-08-29 17:42:03 +02:00
AnotherTest
e75247a75b DisplaySettings+LibGUI: Move ItemListModel into LibGUI
Without this model, comboboxes are abysmal to work with, so let's not
redefine it every time.
2020-08-29 17:42:03 +02:00
Andreas Kling
87f36b0852 Spreadsheet: Make cells right-aligned by default
Until we have better control over cell content alignment, let's make
them all right-aligned by default since that makes numbers look nice,
and numbers are the bread & butter of spreadsheets. :^)
2020-08-29 00:49:15 +02:00
Andreas Kling
64e448eef0 Spreadsheet: Treat Return as a cursor key in the cell editing delegate
This allows you to enter many rows of cells like so:

    1<return>2<return>3<return>...

Very cool! :^)
2020-08-28 21:29:59 +02:00
Andreas Kling
c3b2495320 Spreadsheet: Have cursor movement keys commit and stop cell editing
Customize the cell editing delegate to stop editing when one of the
various cursor movement keys is hit. This allows you to type into a
cell and then move to an adjacent cell by simply pressing an arrow.

This may not be the best factoring for this feature, but it's pretty
dang cool and we'll see how it evolves over time. :^)
2020-08-28 21:26:16 +02:00
Andreas Kling
057d04d98f Spreadsheet: Enable "tab key navigation" in the spreadsheet tables
Moving left/right with the tab key is a classic spreadsheet behavior.
2020-08-28 21:10:12 +02:00
Andreas Kling
cd930e0f3d Spreadsheet: Make Return move the cursor one step down
This seems to be a common behavior in spreadsheet applications,
so let's replicate it here by hooking the activation signal.
2020-08-28 21:03:09 +02:00
Andreas Kling
c43f0f012d Spreadsheet: Enable the "any key pressed" edit trigger in spreadsheets 2020-08-28 20:49:51 +02:00
Andreas Kling
ccea1b2376 Spreadsheet: Let GUI::TableView paint the grid and cursor :^) 2020-08-28 17:09:30 +02:00
AnotherTest
6614ee703b Spreadsheet: Setup and prepare for cell types
This commit adds a generic interface for cell types and hooks it up.
There is no way to set these from the UI, and so they're not saved
anywhere yet.
Also implicitly converts numeric values (strictly integers) to numeric
javascript values, as numbery-looking + numbery-looking === string is
not very interesting. :^)
2020-08-28 17:08:09 +02:00
AnotherTest
5715ed3dd6 Spreadsheet: Reorganise the sources a bit
This commit just moves some code around:
- Give Cell its own file
- Pull all forward-declared classes/structs into Forward.h
- Clean up the order of member functions a bit
2020-08-28 17:08:09 +02:00
Andreas Kling
6cf064e4c6 Spreadsheet: Open help pages immediately when selecting them 2020-08-28 13:56:26 +02:00
Andreas Kling
60cf97726f Spreadsheet: Don't store help window's widgets in raw pointers
We can just use RefPtr for these and lighten the cognitive burden.
2020-08-28 13:56:19 +02:00