Commit graph

7944 commits

Author SHA1 Message Date
AnotherTest
8f08ec5038 LibLine: Restore previous state only if initialized
This makes the library safe to construct/destruct without actually using
it.
2020-04-02 08:49:11 +02:00
Andreas Kling
cd1d369cdd LibJS: Add argument(i) and argument_count() to Interpreter
Add some convenience accessors for retrieving arguments from the
current call frame.
2020-04-01 22:38:59 +02:00
Andreas Kling
1549c5c48b LibJS: Make Value::as_object() return Object&
Let's move towards using references over pointers in LibJS as well.
I had originally steered away from it because that's how I've seen
things done in other engines. But this is not the other engines. :^)
2020-04-01 22:18:47 +02:00
Emanuel Sprung
b995a499d3 AK: Add equals method to JsonValue to semantically compare two values.
This patchsets adds the semantic check of two values. One first approach
was to compare the (generated) json strings of the two values. This works
out in the most cases, but not with numbers, where "1.0" and "1" in JSON
format are semantically the same. Therefore, this patch adds deep (recursive)
check of two JsonValues.
2020-04-01 22:12:19 +02:00
Dov Alperin
c27e8a258a Userland/JS: Extend the global object when using a REPL
When we enter a repl we call initialize_global_object on our custom
ReplObject in order to expose REPL specific features. Specifically:
help(), exit(code), and load("file1.js", "file2.js", "fileEtc.js").
2020-04-01 22:11:33 +02:00
Linus Groh
a0da97cb5a LibJS: Add NaN to global object 2020-04-01 22:09:37 +02:00
Emanuel Sprung
2577712a1c AK: Add String::replace() functionality
This adds a replace functionality that replaces a string that contains
occurences of a "needle" by a "replacement" value. With "all_occurences"
enabled, all occurences are being replaced, otherwise only the first
occurence is being replaced.
2020-04-01 21:47:23 +02:00
Andreas Kling
9d5d0261e1 LibJS: Add Interpreter::create<GlobalObjectType>()
Force Interpreter construction to go via a create() helper that takes
the global object type as a template parameter.
2020-04-01 21:05:35 +02:00
Andreas Kling
aee4c1f583 LibJS: Add GlobalObject to the forwarding header 2020-04-01 21:05:35 +02:00
Andreas Kling
806d3d8e79 AK: Add adopt_own() to create a NonnullOwnPtr<T> from a T& 2020-04-01 21:05:35 +02:00
Linus Groh
ee6472fef2 LibJS: Implement Error function/constructor 2020-04-01 20:47:37 +02:00
Linus Groh
849e2c77e4 LibJS: Implement constructor/non-constructor function calls
This adds Function::construct() for constructor function calls via `new`
keyword. NativeFunction doesn't have constructor behaviour by default,
ScriptFunction simply calls call() in construct()
2020-04-01 20:18:36 +02:00
Andreas Kling
a27884e4be LibWeb: Remove debug spam in WindowObject 2020-04-01 19:09:37 +02:00
Andreas Kling
d062d7baa7 LibWeb+LibJS: Move DOM Window object to dedicated classes
LibWeb now creates a WindowObject which inherits from GlobalObject.
Allocation of the global object is moved out of the Interpreter ctor
to allow for specialized construction.

The existing Window interfaces are moved to WindowObject with their
implementation code in the new Window class.
2020-04-01 18:57:00 +02:00
Andreas Kling
cd9379dca9 LibJS: Reorganize computing of |this| for CallExpressions
This avoids executing the LHS of the object expression twice when doing
a call on the result of an object expression.
2020-04-01 18:57:00 +02:00
Linus Groh
021d78f8f7 Browser: Add error page
Add a simple HTML error page that gets loaded into the HtmlView when
loading the page fails.

Closes #1210 and #1516
2020-04-01 18:49:48 +02:00
Liav A
b1365d94f4 Kernel: Align read operation in HPET registers' block 2020-04-01 18:35:57 +02:00
Brendan Coles
175ec99814 IRCClient: Add Channel application menu and LIST and KICK commands
The new Channel application menu allow offers various commands
related to the currently visible channel, including changing
the topic, kicking a user, and leaving the channel.
2020-04-01 13:11:46 +02:00
Tibor Nagy
9e855376dd HackStudio: Move the "Find in files" button in line with the search box 2020-04-01 11:35:21 +02:00
Andreas Kling
296f87fa7f LibLine: Fix Shell crashing (due to write() EFAULT) on <tab><tab>
Use a StringBuilder instead of blindly passing a bunch of potentially
empty/null strings to the kernel. StringBuilder is more lenient and
generally more pleasant to use anyway.
2020-04-01 11:25:53 +02:00
AnotherTest
9ba9bba529 Clock menu applet: launch the new Calendar on click 2020-04-01 10:42:33 +02:00
Linus Groh
632231cc0c js: Implement print function for Date objects 2020-03-31 21:19:21 +02:00
Andreas Kling
839beb52f3 Base: Tweak the canvas demo page to stop using fractional RGB values
This is a hack to workaround missing support for fractional values in
"rgb(r,g,b)" color parsing.
2020-03-31 19:10:08 +02:00
Andreas Kling
a8dc6501de LibJS: Use "%d" to stringify numeric values that are whole integers
This unbreaks a bunch of the JS tests since they were now printing all
the numbers as "1.000000" instead of "1".
2020-03-31 19:06:10 +02:00
Andreas Kling
b71e504bba js: Don't construct a Line::Editor unless we're going into the REPL
Otherwise the Line::Editor will try to reset termios on exit, which can
have unpleasant effects.
2020-03-31 19:00:20 +02:00
Andreas Kling
28edafbfa6 LibLine: Fix build in Linux environment
My host compiler was complaining about "%b" in format strings and about
ignoring the return value from a bunch of write() calls.
2020-03-31 18:59:15 +02:00
Andreas Kling
6529b78d08 Lagom: Build LibLine since "js" depends on it 2020-03-31 18:58:59 +02:00
Brendan Coles
2de2f49abc IRCClient: Add support for /HOP and /TOPIC commands 2020-03-31 18:06:30 +02:00
Andreas Kling
c56c8c8953 WindowServer: Remove applets from AppletManager on client disconnection
Disconnecting from WindowServer without explicit calls to DestroyWindow
would leave nulled-out WeakPtr's in the AppletManager applet list.

This led to a null dereference when adding a new applet, since we were
assuming the list contained no nulled-out applets.

This patch fixes the issue by always unregistering applet windows from
the AppletManager in ~ClientConnection(). We also do an extra pass of
pruning any nulled-out WeakPtrs from the applet list when adding to it.

Fixes #1551.
2020-03-31 13:55:28 +02:00
Emanuel Sprung
c54855682c AK: A few JSON improvements
* Add double number to object serializer

* Handle negative double numbers correctly

* Handle \r and \n in quoted strings independently
  This improves the situation when keys contain \r or \n that currently
  has the effect that "a\rkey" and "a\nkey" in an JSON object are the
  same key value.
2020-03-31 13:42:39 +02:00
Emanuel Sprung
c925aaceb2 AK: Print double numbers with printf
This patchset allows double numbers to be printed with the printf function.
The fraction will always be printed as 6 digit number. This can be improved :^)
2020-03-31 13:42:39 +02:00
Andreas Kling
c7257ed827 LibLine: Rename on_char_input() => register_character_input_callback()
The "on_foo" format is our convention for public callback members.
2020-03-31 13:37:01 +02:00
Andreas Kling
8ab576308f LibLine: Rename LineEditor.{cpp,h} => Editor.{cpp,h} 2020-03-31 13:34:57 +02:00
Andreas Kling
6595469de1 LibLine: Rename LineEditor to Line::Editor 2020-03-31 13:34:06 +02:00
Andreas Kling
a30a3277a3 LibLine: Rename from LibLineEdit 2020-03-31 13:32:11 +02:00
Andreas Kling
9c7451a21d js: Don't exit the REPL when pressing enter on an empty line 2020-03-31 13:30:00 +02:00
AnotherTest
06d35d036d Userland/js: Use the new line editor in repl
We now get cursor movements for free!
and we're rid of that icky `free` call, yay.
2020-03-31 13:21:46 +02:00
AnotherTest
6f407fff32 LibLineEdit + Shell: Handle Termios internally and give a copy if asked
This moves the Termios logic inside LibLineEdit and allows users to
simply forget about the existence of termios if they so choose to :^)
2020-03-31 13:21:46 +02:00
AnotherTest
5062a7d4cd LibLinEdit + Shell: handle signals
This allows the LineEditor to get notified about signals, since we
cannot set signal handlers in a clean way within the LineEditor
instance.
2020-03-31 13:21:46 +02:00
AnotherTest
21c4c67119 Shell: Move LineEdit out and add it as a dependency
This builds up on the 'new' LibLineEdit and overrides some of its hooks
For instance, on_tab_complete_first_token
2020-03-31 13:21:46 +02:00
AnotherTest
305b1a6248 LibLineEdit: Add a new Line Editor library
This library is moved over from Shell/LineEdit and has all its
Shell-specific functionalities stripped off.
Currently it exposes some internal things, for instance
cut_mismatching_chars() and insert(); This behaviour is not the most
acceptable, however, let's just roll with it for now :^)
2020-03-31 13:21:46 +02:00
Andreas Kling
297e6625f3 Browser: Refuse to run as root 2020-03-31 13:02:05 +02:00
Andreas Kling
b2b5da8a17 IRCClient: Refuse to run as root
There's no good reason to allow this, and some pretty great reasons
to disallow it. :^)
2020-03-31 13:02:05 +02:00
Brendan Coles
e8b17c42bb Base: Change root user home directory from / to /root 2020-03-31 11:43:46 +02:00
Brendan Coles
d64589101c Userland: Add optional human readable output to /bin/df
/bin/df now allows the operator to view human readable
output using `-h` or `--human-readable` optional flags.
2020-03-31 09:08:30 +02:00
Sergey Bugaev
7bd077a3ae LibGUI: Fix index invalidation
When the model gets updated, we have to let go of the old indexes,
because they're invalid from that moment on.

Fixes https://github.com/SerenityOS/serenity/issues/1541
2020-03-30 23:05:14 +02:00
Linus Groh
3fcea71538 LibJS: Implement Date.prototype.to{Date,Time}String() 2020-03-30 21:43:35 +02:00
Linus Groh
dc9b1226ac LibJS: Implement Date.prototype.toString() 2020-03-30 20:36:18 +02:00
Andreas Kling
b4fde72013 LibGUI: Brighten icons when hovering items in item views
View classes now track their hovered item and paint them in a slightly
brighter shade to liven up the user interface. :^)
2020-03-30 19:57:44 +02:00
Andreas Kling
add93bf593 LibGUI: Brighten buttons when hovering over them :^) 2020-03-30 19:40:44 +02:00