Commit graph

13919 commits

Author SHA1 Message Date
AnotherTest
a461526b07 LibHTTP+ProtocolServer+LibGemini: Remove Request::schedule()
This API is only used for HttpRequest, but replicated in GeminiRequest
without an actual user, so remove it and construct the job like the rest
of the protocols.
2020-10-30 23:42:03 +01:00
Andreas Kling
b11b4b29e9 LibGUI: Add Widget::has_focus_within()
This returns true if the widget has focus, or if one of its descendant
widgets does. Use this in StackWidget and TabWidget.

This also fixes HackStudio crashing on startup in StackWidget, due to
running before the window has a focused widget.
2020-10-30 23:40:23 +01:00
Andreas Kling
dee639f19b LibGUI: Improve TabWidget+StackWidget focus behavior further
When setting a new active widget, transfer focus if it's anywhere in
the old active widget's tree, not just at the immediate child.
2020-10-30 19:17:09 +01:00
Andreas Kling
b0cdb6b074 LibGUI: Deduplicate widgets with proxied focus in focus chain
When computing the chain of focusable widgets in a window, only include
each widget once (to avoid loops) and resolve focus proxies immediately
instead of lazily. This prevents the focus from getting stuck when
cycling backwards and hitting a proxy that points forward.
2020-10-30 19:17:09 +01:00
Uma Sankar Yedida
9ccae7a908 WindowServer+LibGfx: Added Crosshair cursor 2020-10-30 19:10:15 +01:00
Andreas Kling
ddad7575a9 LibGUI: Improve automatic focus guessing somewhat
When opening a new window, we'll now try to find a suitable widget for
initial focus by picking the first available mouse-focusable one.

Whenever you press the tab key in a window with no focused widget,
we'll attempt to find a keyboard-focusable widget and give it focus.

This should make all applications keyboard-interactive immediately
without having to manually place focus with the mouse.
2020-10-30 17:03:29 +01:00
Andreas Kling
28df2ede06 LibGUI: Use ToolBarButton helper class inside ToolBar 2020-10-30 17:03:29 +01:00
Andreas Kling
9baa649389 LibGUI: Fix null parent deref in AbstractButton::set_checked()
If a button is orphaned, there are no siblings anyway, so there's no
need to try to update them.
2020-10-30 17:03:29 +01:00
Andreas Kling
3f4df354cb LibGUI: Make TabWidget unfocusable when tab-less
If there are no tab buttons or tab children, don't participate in the
focus chain.
2020-10-30 17:03:29 +01:00
Andreas Kling
0b798a50dc LibGUI: Make StackWidget/TabWidget preserve focus in inactive windows
This one is a bit sketchy. While a window is inactive, none of its
widgets are considered focused (Widget::is_focused() will return false)
but this caused programmatic changes of the active widget in a tab
or stack widget to fail focus propagation from old child to new child.

Work around this by checking against Window::focused_widget() directly
instead of asking Widget::is_focused().
2020-10-30 17:03:29 +01:00
Andreas Kling
cf93c66e6e LibGUI: Make StackWidget set the active widget as its focus proxy
This transparently transfers focus to the active widget whenever the
stack widget is focused.
2020-10-30 17:03:29 +01:00
Andreas Kling
698490c565 LibGUI: Make TabWidget focusable and allow left/right arrow tab switch
You can now focus a TabWidget by tabbing (with the keyboard!) to it.
Once focused, you can switch the active tab by pressing the left/right
keyboard keys.
2020-10-30 17:03:28 +01:00
Andreas Kling
73ea191a05 LibGUI: TabWidget should not steal focus on programmatic tab switch
This matches the behavior of GUI::StackWidget.
2020-10-30 17:03:28 +01:00
Andreas Kling
aef56159a8 LibGUI: Add Widget focus policies
Every widget now has a GUI::FocusPolicy that determines how it can
receive focus:

- NoFocus: The widget is not focusable (default)
- TabFocus: The widget can be focused using the tab key.
- ClickFocus: The widget can be focused by clicking on it.
- StrongFocus: Both of the above.

For widgets that have a focus proxy, getting/setting the focus policy
will affect the proxy instead.
2020-10-30 17:03:28 +01:00
Andreas Kling
34014fa838 LibC: Use dbgln() in setlocale() 2020-10-30 17:03:28 +01:00
Andreas Kling
27a7ebe548 LibVT: Use dbgln() in TerminalWidget 2020-10-30 17:03:28 +01:00
Brendan Coles
d4c34d50c9 LibChess: Forbid King moving into check by a pawn on the home rank
A player can no longer move the King piece into any position on
their home rank if the move would place the King in check.

A player can also no longer ignore a check position when in check
by a pawn on their home rank. The player must now resolve the check
during their move.
2020-10-30 16:51:41 +01:00
Andreas Kling
6365b44773 HackStudio: Use GUI::TextDocument::span_at() 2020-10-29 23:52:31 +01:00
Andreas Kling
23c4f10027 LibGUI: Add TextDocument::span_at(TextPosition) 2020-10-29 23:52:07 +01:00
Andreas Kling
4e0ab1dd22 HackStudio: Remove ProcessStateWidget
This was a little banner that would pop up when running something in
the "Build" tab. It didn't look very good and it was mostly distracting
how it would pop in and out of the window.
2020-10-29 23:40:20 +01:00
Andreas Kling
18739ba87e LanguageServers/Cpp: Find the right token under the cursor
When the cursor is immediately to the right of a token, the cursor's
column will be token.end.column + 1, so take this into account when
choosing which token to autocomplete.
2020-10-29 23:32:18 +01:00
Andreas Kling
d28127c807 LanguageServers/Cpp: Make token_in_position() return a StringView
This avoids a whole bunch of string allocation churn.
2020-10-29 23:32:18 +01:00
Andreas Kling
aaf4ec62cf LanguageServers/Cpp: Avoid some unnecessary vector copies 2020-10-29 23:32:18 +01:00
Andreas Kling
c3a79e1483 HackStudio: Don't track ctrl key state manually
Since we only need it in the mouse and key event handlers, we can get
the ctrl key state from the event. :^)
2020-10-29 23:32:18 +01:00
Andreas Kling
77e9eadd9d Userland+LibC: Add "kill -l" to show all known signal names/numbers 2020-10-29 23:32:18 +01:00
Andreas Kling
662959b173 LibC: Use NSIG instead of hard-coding 32 as the signal count 2020-10-29 23:32:18 +01:00
Linus Groh
69845ae460 LibJS: "-->" preceded by token on same line isn't start of HTML-like comment
B.1.3 HTML-like Comments

The syntax and semantics of 11.4 is extended as follows except that this
extension is not allowed when parsing source code using the goal symbol
Module:

Syntax (only relevant part included)

    SingleLineHTMLCloseComment ::
        LineTerminatorSequence HTMLCloseComment

    HTMLCloseComment ::
        WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt]

Fixes #3810.
2020-10-29 22:28:15 +01:00
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