Commit graph

13293 commits

Author SHA1 Message Date
pkotzbach
82696078b0 LibGUI: Fix to ComboBox fields activation 2020-09-15 20:37:13 +02:00
AnotherTest
3a8109d1e0 Shell: Add some sections on the manpage about `match' 2020-09-15 20:36:59 +02:00
AnotherTest
4f223793c0 Shell: Add some tests for 'match' 2020-09-15 20:36:59 +02:00
AnotherTest
4c6f7846b4 Shell: Add 'match' expressions
This commit adds an equivalent to the sh 'case' construct, except it's
much more pleasing to look at and write:
```sh
match "$something" {
    p1 { echo "p1!" }
    p2 { echo "p2!" }
    *  { echo "string catch-all!" }
}
```
is the equivalent of:
```sh
case $something in
    p1)
        echo "p1!"
        ;;
    p2)
        echo "p2!"
        ;;
    *)
        echo "catch-all!"
        ;;
esac
```

Since our shell does not treat lists as strings, matching lists is also
possible:

```sh
match (1foo 2foo foo3) {
    (?foo 2* *) { echo wowzers! }
    (* * *) { echo 3-element list catch-all }
}
```
2020-09-15 20:36:59 +02:00
AnotherTest
53b85bcdd0 Shell: Make Parser::expect() revert the offset when matching fails 2020-09-15 20:36:59 +02:00
AnotherTest
afe0ae586c Shell: Make Node::resolve_as_list(nullptr) resolve to a 'pure' repr
'pure' as in "not requiring a shell", similar to
JS::Value::to_string_without_side_effects().
2020-09-15 20:36:59 +02:00
asynts
206dcd84a6 FileSystem: Use OutputMemoryStream instead of BufferStream. 2020-09-15 20:36:45 +02:00
asynts
c8ed882b8e AK: Add OutputMemoryStream::fill_to_end. 2020-09-15 20:36:45 +02:00
asynts
83d0803861 AK: Re-add OutputMemoryStream for static buffers only. 2020-09-15 20:36:45 +02:00
asynts
f18e927827 AK: Remove OutputMemoryStream for DuplexMemoryStream.
OutputMemoryStream was originally a proxy for DuplexMemoryStream that
did not expose any reading API.

Now I need to add another class that is like OutputMemoryStream but only
for static buffers. My first idea was to make OutputMemoryStream do that
too, but I think it's much better to have a distinct class for that.

I originally wanted to call that class FixedOutputMemoryStream but that
name is really cumbersome and it's a bit unintuitive because
InputMemoryStream is already reading from a fixed buffer.

So let's just use DuplexMemoryStream instead of OutputMemoryStream for
any dynamic stuff and create a new OutputMemoryStream for static
buffers.
2020-09-15 20:36:45 +02:00
Nico Weber
c9a3a5b488 Kernel: Use Userspace<> for sys$writev 2020-09-15 20:20:38 +02:00
Nico Weber
e1c54b8a0f LibLine: Implement ctrl-del: It does the same thing as alt-d, delete-word 2020-09-15 09:45:13 +02:00
Nico Weber
5198eb7c1c LibVT: Use xterm modifier scheme for tilde keys too 2020-09-15 09:45:13 +02:00
Nico Weber
d7539cf497 LibLine: Support Alt + Arrow left/right
It does the same thing as Ctrl + Arrow left/right: Wordwise movement.
2020-09-15 09:45:13 +02:00
Nico Weber
83c07be794 LibVT+LibLine: Use 1;mods CSI parameters for ctrl/alt/shift-arrow keys
xterms send a bitmask (+ 1) in the 2nd CSI parameter if "special"
keys (arrow keys, pgup/down, etc) are sent with modifiers held down.

Serenity's Terminal used to send ^[[O, which is a nonexistent
escape sequence and a misread of VT100's ^[O (ie the '[' is
replaced by 'O'). Since the xterm scheme also supports shift
and alt modifiers, switch to that.

More flexible, and makes ctrl-left/right and alt-left/right work
in SerenityOS's bash port.

Also do this for page up/down.

No behavior change for SerenityOS's Shell.
2020-09-15 09:45:13 +02:00
Nico Weber
2fe127d96f LibLine: Parse CSI parameters and immediates
No behavior change, but it makes it easy to handle
page up and page down if we wanted to make them do something
in libline.
2020-09-15 09:45:13 +02:00
Tom
365fa05a82 Kernel: Handle safe_memcpy/safe_memset/safe_strnlen faults in irq handlers
Fix gracefully failing these calls if used within IRQ handlers. If we're
handling IRQs, we need to handle these failures first, because we can't
really resolve page faults in a meaningful way. But if we know that it
was one of these functions that failed, then we can gracefully handle
the situation.

This solves a crash where the Scheduler attempts to produce backtraces
in the timer irq, some of which cause faults.

Fixes #3492
2020-09-14 21:18:59 +02:00
Andreas Kling
95964e7cbe Meta: Add Paul Scharnofske to the contributors list :^) 2020-09-14 21:17:47 +02:00
asynts
96edcbc27c AK: Lower the requirements for InputStream::eof and rename it.
Consider the following snippet:

    void foo(InputStream& stream) {
        if(!stream.eof()) {
            u8 byte;
            stream >> byte;
        }
    }

There is a very subtle bug in this snippet, for some input streams eof()
might return false even if no more data can be read. In this case an
error flag would be set on the stream.

Until now I've always ensured that this is not the case, but this made
the implementation of eof() unnecessarily complicated.
InputFileStream::eof had to keep a ByteBuffer around just to make this
possible. That meant a ton of unnecessary copies just to get a reliable
eof().

In most cases it isn't actually necessary to have a reliable eof()
implementation.

In most other cases a reliable eof() is avaliable anyways because in
some cases like InputMemoryStream it is very easy to implement.
2020-09-14 20:58:12 +02:00
pkotzbach
8a21c528ad
LibGUI: Minor consistency cleanup in AbstractView::set_cursor() (#3478) 2020-09-14 20:55:07 +02:00
Andreas Kling
2b17d980cf Meta: Include .json files in the Qt Creator refresh script 2020-09-14 19:55:18 +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
e78cf6c590 LibGfx+LibGUI: Allow setting tab text alignment with set_property() 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
3355a3e179 LibGUI: Add TabWidget::set_property() and handle some properties 2020-09-14 19:55:17 +02:00
AnotherTest
cd0ddf27f3 Shell: Allow builtins and functions as conditions for 'if' 2020-09-14 17:40:18 +02:00
AnotherTest
2b867ff555 Shell: Complete named function parameters inside the function body 2020-09-14 17:40:18 +02:00
AnotherTest
b4da45ab76 Shell: Add documentation for functions 2020-09-14 17:40:18 +02:00
AnotherTest
b7661dee46 Shell: Add some tests for functions 2020-09-14 17:40:18 +02:00
AnotherTest
d1550ea64f Shell: Add support for functions
This implementation does not have support for 'return' yet.
2020-09-14 17:40:18 +02:00
AnotherTest
519aa2048a Shell: Use a subshell instead of explicitly calling a shell binary in a test
This commit fixes a FIXME in a test, as we have subshells now.
2020-09-14 17:40:18 +02:00
AnotherTest
0b57cdff82 Shell: Add support for $0,$1,... 2020-09-14 17:40:18 +02:00
Andreas Kling
2f97590409 Meta: Make the text-to-cpp-string thingy pass shellcheck 2020-09-14 16:33:53 +02:00
Andreas Kling
22b03dd11b LibGUI: Add registration for GUI::TabWidget 2020-09-14 16:23:39 +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
093de0e323 LibGUI: Use Core::Object::set_property() to handle JSON GUI properties
Piggyback on the existing mechanism to set individual properties.
This doesn't cover layouts or child widgets, but the per-widget own
properties can be set this way.

Any property can now be set in JSON GUI, all you need to do is handle
it in the relevant Core::Object::set_property() override. :^)
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
6fc8dedd28 LibGUI: Allow setting widget visibility from JSON GUI spec 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
6590eb8eb7 LibGUI: Complain about malformed "layout" values in JSON GUI 2020-09-14 16:16:36 +02:00
Andreas Kling
aa3c28957a LibCore: Include object names in Object::dump_tree() output 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
40892ac72e Meta: Add helper for generating a C++ string from a text file 2020-09-14 16:16:36 +02:00
Andreas Kling
ea17b0cbb6 LibGUI: Start building a way to instantiate GUI from JSON
My original idea for GUI building tools was to have the "VisualBuilder"
app generate C++ code which in turn programmatically instantiated UI.
That never really materialized in any useful way beyond static UIs.

This is a fresh, new approach: using JSON to declare the UI and parsing
and constructing this UI at runtime. This will allow for way more
dynamic and flexible approaches to GUI development (I think.)

The basic idea is that you pass a JSON string to Widget::load_from_json
and it takes care of the rest.

This first version supports basic box layouts and instantiation of
arbitrary widgets, as long as those widgets have been registered.

This code has some pretty rough edges right now as it's evolving and
we need to figure out a lot of things about how it should work.
Nevertheless, it feels pretty cool. :^)
2020-09-14 16:16:36 +02:00
Andreas Kling
c7133bf081 LibWeb: Register the InProcessWebView widget 2020-09-14 16:16:36 +02:00
Andreas Kling
3c580233d1 LibGUI: Improve widget registration mechanism a bit
Allow registering widgets from namespaces other than GUI. :^)
Also add a few widgets.
2020-09-14 16:16:36 +02:00
Ben Wiederhake
3ab706cac3 Travis: Strip every executable
This cuts down the size of a Toolchain cache entry by another quarter.
(About 250 MiB to about 190 MiB).
2020-09-14 11:40:48 +02:00
Ben Wiederhake
f067fb0aef Travis: Switch to Ubuntu Focal 2020-09-14 11:40:48 +02:00