Commit graph

14042 commits

Author SHA1 Message Date
Linus Groh a10d09faba LibJS: Tweak generated source in 'new Function()' to match ES 2015 spec
ES 5(.1) described parsing of the function body string as:

https://www.ecma-international.org/ecma-262/5.1/#sec-15.3.2.1

7. If P is not parsable as a FormalParameterList[opt] then throw a SyntaxError exception.
8. If body is not parsable as FunctionBody then throw a SyntaxError exception.

We implemented it as building the source string of a complete function
and feeding that to the parser, with the same outcome. ES 2015+ does
exactly that, but with newlines at certain positions:

https://tc39.es/ecma262/#sec-createdynamicfunction

16. Let bodyString be the string-concatenation of 0x000A (LINE FEED), ? ToString(bodyArg), and 0x000A (LINE FEED).
17. Let prefix be the prefix associated with kind in Table 49.
18. Let sourceString be the string-concatenation of prefix, " anonymous(", P, 0x000A (LINE FEED), ") {", bodyString, and "}".

This patch updates the generated source string to match these
requirements. This will make certain edge cases work, e.g.
'new Function("-->")', where the user supplied input must be placed on
its own line to be valid syntax.
2020-10-29 22:27:55 +01:00
AnotherTest bed270ca47 Userland: Do not put a trailing space after the resulting pids in pidof 2020-10-29 22:27:24 +01:00
Tom 180cc85d79 Kernel: Report more accurate ticks per second for APIC timer 2020-10-29 22:26:08 +01:00
Tom d076b00248 Kernel: Fix APIC timer frequency
The APIC current count register decrements on each clock tick.
Fixes the APIC timer firing much less frequently than it should be.
2020-10-29 22:10:20 +01:00
AnotherTest 3fa0b887ed Shell: Document the new 'pattern as (list of names)' match syntax 2020-10-29 11:53:01 +01:00
AnotherTest 1a4ac3531f Shell: Allow parts of globs to be named in match expressions
This patchset allows a match expression to have a list of names for its
glob parts, which are assigned to the matched values in the body of the
match.
For example,
```sh
stuff=foobarblahblah/target_{1..30}
for $stuff {
    match $it {
        */* as (dir sub) {
            echo "doing things with $sub in $dir"
            make -C $dir $sub # or whatever...
        }
    }
}
```

With this, match expressions are now significantly more powerful!
2020-10-29 11:53:01 +01:00
AnotherTest 0801b1fada AK: Make String::matches() capable of reporting match positions too
Also, rewrite StringUtils::match(), because the old implementation was
fairly broken, e.g. "acdcxb" would *not* match "a*?b".
2020-10-29 11:53:01 +01:00
AnotherTest 2d6d1ca67f Shell: Add some basic tests for backgrounding 2020-10-29 11:53:01 +01:00
AnotherTest 6e2a383f25 Shell: Wait for the rest of the members of a pipeline when one exits
Assuming we were blocking on one to begin with.
2020-10-29 11:53:01 +01:00
AnotherTest c92865bd05 Shell: Use kill_job() to kill jobs 2020-10-29 11:53:01 +01:00
AnotherTest 384e872ff9 Shell: Add redirections to the formatted command string 2020-10-29 11:53:01 +01:00
AnotherTest a46318d414 Shell: Do not bail early when printing jobs if waitpid() fails
This fixes running `jobs` in a child process.
Also makes sure that stdout is flushed when writing jobs out.
2020-10-29 11:53:01 +01:00
AnotherTest a935a31ecf Userland: Add an implementation of 'expr'
This implements all expressions except 'match', which errors out when executed.
Closes #1124?
2020-10-29 11:53:01 +01:00
AnotherTest f0e59f2dac AK: Add a `is_one_of()' to StringView
This copies the similar API from String.
2020-10-29 11:53:01 +01:00
AnotherTest f4b7a688b1 Shell: Rename {source,dest}_fd to {old,new}_fd
This makes `Rewiring' much more understandable, and un-confuses the uses
of `dup2()'.
Also fixes `dup2()' bugs.
2020-10-29 11:53:01 +01:00
AnotherTest 0bc758d34a Shell: Run builtins that cannot be run in the main process in a new child
e.g. `$(jobs | wc -l)` would blow up horribly otherwise.
(it still does)
2020-10-29 11:53:01 +01:00
AnotherTest a8c18f9fd2 Shell: Drop all the jobs after killing them in stop_all_jobs() 2020-10-29 11:53:01 +01:00
AnotherTest 2610477836 Shell: Only prompt the user for a second 'exit' when in interactive mode 2020-10-29 11:53:01 +01:00
AnotherTest 71bb62d03c Shell: Add the `wait' builtin
This builtin...waits...for the jobs it's given (or all the existing
jobs).
2020-10-29 11:53:01 +01:00
asynts 607931268e CMake: Use CONFIGURE_DEPENDS in existing globs. 2020-10-29 11:52:47 +01:00
Linus Groh 3dbf4c62b0 LibJS: Use GenericLexer for Token::string_value()
This is, and I can't stress this enough, a lot better than all the
manual bounds checking and indexing that was going on before.

Also fixes a small bug where "\u{}" wouldn't get rejected as invalid
unicode escape sequence.
2020-10-29 11:52:31 +01:00
Linus Groh 1daa5158eb AK: Add GenericLexer::retreat()
This allows going back one character at a time, and then re-consume
previously consumed chars.
The code I need this for looks something like this:

    ASSERT(lexer.consume_specific('\\'));
    if (lexer.next_is("foo"))
        ...
    lexer.retreat();
    lexer.consume_escaped_character();  // This expects lexer.peek() == '\\'
2020-10-29 11:52:31 +01:00
Andreas Kling ffd1e4831e Userland: Make killall accept signal names as well
Use getsignalbyname() to support killall -HUP foo, and such things.
2020-10-29 11:49:47 +01:00
Andreas Kling ad0295d033 LibC: Move getsignalbyname() helper from Userland/kill into LibC 2020-10-29 11:49:24 +01:00
Andreas Kling a6b2598fba Userland: Teach "kill" to understand signal names (not just numbers)
You can now do things like "kill -STOP pid" :^)

The getsignalbyname() helper function should probably move to LibC
or somewhere where it can be used by other signal related programs.
2020-10-29 11:45:53 +01:00
Andreas Kling d27a8e505f LibGUI: IconView was hard-coding column 0 instead of model_column()
Some of the indexes generated during cursor movement were using column
instead of model_column(), which caused inconsistent display of items
under the cursor.
2020-10-28 21:41:51 +01:00
Andreas Kling de3dc15a6e LibGUI: Default-initialize cursor when focusing an AbstractView
If an AbstractView receives focus without a valid cursor index, we now
ask it to move its cursor to the home position. This way, the user can
actually start moving the cursor after tabbing to a view.
2020-10-28 21:40:31 +01:00
Andreas Kling 1f789a07b1 LibGUI: Don't start AbstractView type-ahead search with tab key
This was preventing views from relinquishing focus via the keyboard.

Fixes #3862.
2020-10-28 21:26:27 +01:00
Andreas Kling 80e12999c4 LibGUI: Model-less views should not swallow key events
At least pass them up to GUI::Widget so they can be handled there.
2020-10-28 21:26:27 +01:00
Linus Groh b5bd05b717 LibJS: Don't parse numeric literal containing 8 or 9 as octal
If the value has a leading zero (allowed in non-strict mode) but
contains the digits 8 or 9 it can't be an octal number.
2020-10-28 21:11:32 +01:00
Linus Groh b4e51249e9 LibJS: Always insert semicolon after do-while statement if missing
https://tc39.es/ecma262/#sec-additions-and-changes-that-introduce-incompatibilities-with-prior-editions

11.9.1: In ECMAScript 2015, Automatic Semicolon Insertion adds a
semicolon at the end of a do-while statement if the semicolon is
missing. This change aligns the specification with the actual behaviour
of most existing implementations.
2020-10-28 21:11:32 +01:00
Linus Groh d278f61f4c LibJS: Restrict toEval() failures to SyntaxError
We only use expect(...).toEval() / not.toEval() for checking syntax
errors, where we obviously can't put the code in a regular function. For
runtime errors we do exactly that, so toEval() should not fail - this
allows us to use undefined identifiers in syntax tests.
2020-10-28 21:11:32 +01:00
Andreas Kling 3ec19ae4b6 LibGUI+LibGfx+WindowServer: Auto-generate disabled action icons :^)
This patch adds a simple filter that makes button and menu item icons
have that "'90s disabled" look when disabled. It's pretty awesome.
2020-10-27 21:25:40 +01:00
Andreas Kling ea14c67e29 LibGUI: Make TreeView use the view cursor properly
TreeView was still partly sticking to the pre-cursor way of using the
first index in the selection as the implied cursor. This patch fixes
all of the TreeView code to operate on the cursor instead.

This makes trees behave much more intuitively when alternating between
mouse and keyboard interaction.
2020-10-27 21:00:12 +01:00
Andreas Kling ce4ee1df1b WindowServer: Improve look of drag&drop items somewhat
This just adds a bit of padding around items. There's lots of room for
improvement here.
2020-10-27 20:45:38 +01:00
Andreas Kling 0391806eec LibGUI: Shrink the default selection rect of TreeView items
Instead of filling the whole row with selection color, only fill behind
the text. This gives a snugger, more focused appearance.

For embedders that want the entire row to get filled with the selection
color when selected, they can opt in to the old behavior by calling
TreeView::set_should_fill_selected_rows(). This is used by Profiler.
2020-10-27 20:33:30 +01:00
Andreas Kling df98c9ebbe LibGUI: Run clang-format on TableView.cpp 2020-10-27 20:21:51 +01:00
Andreas Kling f7d8174bee LibGUI: Paint a focus rect around the cursor index in ColumnsView 2020-10-27 16:20:20 +01:00
Andreas Kling c0076681ad LibGUI: Paint a focus rect around the cursor index in TableView 2020-10-27 16:18:55 +01:00
Andreas Kling 5030f1ed4b LibGUI: Paint a focus rect around the cursor index in IconView
This makes the cursor actually visible to the user, and looks rather
neat if I may say so. :^)
2020-10-27 16:12:54 +01:00
Andreas Kling 272af7685b LibGUI: Improve and simplify IconView item name wrapping
Move the wrapping logic to get_item_rects(). This makes mouse events
able to hit the wrapped labels, and various other little things stop
glitching out as well.

Also, instead of having a per-line width when wrapping icon names,
make the text rect wide enough to fit every line.
2020-10-27 16:10:30 +01:00
Linus Groh 7112031bfb LibJS: Use message from invalid token in syntax error 2020-10-26 21:38:34 +01:00
Linus Groh 6a3389cec6 LibJS: Emit token message for invalid numeric literals 2020-10-26 21:38:34 +01:00
Linus Groh 19edcbd79c LibJS: Emit TokenType::Invalid for unterminated multi-line comments 2020-10-26 21:38:34 +01:00
Linus Groh 03c1d43f6e LibJS: Add message string to Token
This allows us to communicate details about invalid tokens to the parser
without having to invent a bunch of specific invalid tokens like
TokenType::InvalidNumericLiteral.
2020-10-26 21:38:34 +01:00
Till Mayer 2ac734b7a8 Solitaire: Play animation when starting a new game 2020-10-26 21:36:40 +01:00
Till Mayer ef458f7b66 Solitaire: Refactor CardStack layout code 2020-10-26 21:36:40 +01:00
Andreas Kling 4bc8768737 LibGUI: Tint selected icons in {Icon,Table,Columns}View
Add a gentle tint to selected icons based on the selection color. :^)
2020-10-26 21:32:27 +01:00
Andreas Kling d172783d33 LibGUI: Fix bogus focus rect in buttons with icon but no text 2020-10-26 21:08:01 +01:00
Andreas Kling 06b5d292d7 LibGUI: Allow activating a focused button by pressing the space key :^)
This applies to normal push buttons, checkboxes, and radio buttons.
It feels very natural. Even moreso than activating with return..
2020-10-26 21:01:45 +01:00