Commit Graph

12863 Commits

Author SHA1 Message Date
Andreas Kling
5444cabd39 Kernel: Rename FileDescription::fstat() => stat() 2020-09-06 18:17:07 +02:00
Andreas Kling
c14de7da99 Kernel: Remove bogus FIXME in TTY::write()
Failure to send SIGTTOU to the current process is not something that
should cause write() to fail with -ESRCH.
2020-09-06 18:13:04 +02:00
Andreas Kling
8e489b451a Userland: Add a simple 'w' program that shows current terminal sessions
This fetches information from /var/run/utmp and shows the interactive
sessions in a little list. More things can be added here to make it
more interesting. :^)
2020-09-06 16:16:10 +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
171bfcff36 utmpupdate: Use pledge() and unveil() 2020-09-06 16:14:27 +02:00
Andreas Kling
dcd47655d0 utmpupdate: Add a program for updating /var/run/utmp
To keep track of ongoing terminal sessions, we now have a sort-of
traditional /var/run/utmp file, like other Unix systems.
Unlike other Unix systems however, ours is of course JSON. :^)

The /bin/utmpupdate program is used to update the file, which is
not writable by regular user accounts. This helper program is
set-GID "utmp".
2020-09-06 16:10:27 +02:00
Andreas Kling
35b844ba4c LibCore: Add Core::IODevice::truncate()
This is just a wrapper around ftruncate(). Today I also learned that
ftruncate() does not reset the file descriptor offset. :^)
2020-09-06 16:09:26 +02:00
Andreas Kling
9dafbc82ff AK: Add JsonObject::remove() 2020-09-06 16:09:09 +02:00
Andreas Kling
8a6a9a8fb6 LibWeb: Move DOM event dispatch to its own class
For now, the new DOM::EventDispatcher is very simple, it just iterates
over the set of listeners on an EventTarget and invokes the callbacks
as it goes.

This simplifies EventTarget subclasses since they no longer have to
implement the callback mechanism themselves.
2020-09-06 14:48:14 +02:00
AnotherTest
521475dc01 LibLine: Do not reset suggestion state immediately when encountering esc
Some multikey binding might depend on the suggestion state, and this is
indeed the case for 'reverse tab', which is just '^[[Z'.
Fixes #3407.
2020-09-06 13:00:02 +02:00
asynts
4c317a94c7 LibCompress: Simplify logic in deflate implementation. 2020-09-06 12:54:45 +02:00
asynts
6de63782c7 Streams: Consistent behaviour when reading from stream with error.
The streaming operator doesn't short-circuit, consider the following
snippet:

    void foo(InputStream& stream) {
        int a, b;
        stream >> a >> b;
    }

If the first read fails, the second is called regardless. It should be
well defined what happens in this case: nothing.
2020-09-06 12:54:45 +02:00
asynts
5d85be7ed4 LibCompress: Add another unit test.
I suspected an error in CircularDuplexStream::read(Bytes, size_t). This
does not appear to be the case, this test case is useful regardless.

The following script was used to generate the test:

    import gzip

    uncompressed = []
    for _ in range(0x100):
        uncompressed.append(1)
    for _ in range(0x7e00):
        uncompressed.append(0)
    for _ in range(0x100):
        uncompressed.append(1)

    compressed = gzip.compress(bytes(uncompressed))
    compressed = ", ".join(f"0x{byte:02x}" for byte in compressed)

    print(f"""\
    TEST_CASE(gzip_decompress_repeat_around_buffer)
    {{
        const u8 compressed[] = {{
            {compressed}
        }};

        u8 uncompressed[0x8011];
        Bytes{{ uncompressed, sizeof(uncompressed) }}.fill(0);
        uncompressed[0x8000] = 1;

        const auto decompressed = Compress::GzipDecompressor::decompress_all({{ compressed, sizeof(compressed) }});

        EXPECT(compare({{ uncompressed, sizeof(uncompressed) }}, decompressed.bytes()));
    }}
    """, end="")
2020-09-06 12:54:45 +02:00
asynts
e2e2e782d4 Deflate: Fix deadly typo. 2020-09-06 12:54:45 +02:00
asynts
b9a6c07bb7 LibCore: FileStream.h: Fix infinite loop when trying to read past end-of-file. 2020-09-06 12:54:45 +02:00
asynts
612c1bc84d Userland: Use Buffered<T> in gunzip. 2020-09-06 12:54:45 +02:00
asynts
359fcf348f AK: Add Buffered<T> which wraps a stream, adding input buffering. 2020-09-06 12:54:45 +02:00
asynts
b011f87d34 AK: Add log stream operator overload for Span. 2020-09-06 12:54:45 +02:00
asynts
f9ba037674 LibCompress: Replace ASSERT_NOT_REACHED with set_fatal_error.
We shouldn't assert that the input file is valid.
2020-09-06 12:54:45 +02:00
Andreas Kling
40e6a3dcc3 ClipboardHistory: Copy metadata when reusing a historical clipping 2020-09-05 17:06:34 +02:00
Andreas Kling
2e446b662b ClipboardHistory: Show bitmap width/height/bpp for bitmap clippings 2020-09-05 17:05:22 +02:00
Andreas Kling
0b051a5e15 ClipboardHistory: Show the size (in bytes) of each remembered clipping 2020-09-05 17:02:25 +02:00
Andreas Kling
b8d73e259c ClipboardHistory: Cap the history at 20 entries for now
Now that we can copy bitmaps, we need some kind of cap here or memory
usage quickly skyrockets.

This could probably be improved or made adaptive somehow, this is just
a simple hard cap for now.
2020-09-05 17:00:18 +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
158f3b9362 LibGUI: Add a Clipboard API for retrieving a copied Gfx::Bitmap
The returned bitmap is always going to be a 32-bit RGBA bitmap for now.
In the future we may want to support copy-pasting other formats.
2020-09-05 16:52:35 +02:00
Andreas Kling
2e6d59b7b2 Clipboard: Add a key-value map alongside the clipboard storage
A clipping now consists of three things:

- The raw clip data
- A MIME type
- A key-value map (String, String) for anything you like
2020-09-05 16:52:24 +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
Andreas Kling
802f541184 Kernel/USB: Disable autodetection of UHCI controllers for now
Until this thing becomes stable, let's not bother everyone with it.
2020-09-05 15:42:54 +02:00
Andreas Kling
3f36903201 Kernel/USB: Start the UHCI controller after resetting it 2020-09-05 15:42:54 +02:00
Ben Wiederhake
c8668e9b7c Meta: Fix wonky copyright headers in Tests 2020-09-05 14:19:38 +02:00
Muhammad Zahalqa
fad0c8e712
AK: Make all DoublyLinkedList search methods use Traits<T>::equals (#3404) 2020-09-05 14:17:14 +02:00
Andreas Kling
02b3cb8123 Kernel: Add a missing "#pragma once" 2020-09-04 23:51:50 +02:00
Andreas Kling
eb74f62201 Kernel/USB: Add a simple UHCIController::stop()
This stops the controller and waits for it to complete.
2020-09-04 21:21:46 +02:00
Andreas Kling
1254447bd7 Kernel/USB: Add some constants for the USBCMD and USBSTS bits 2020-09-04 21:21:46 +02:00
Andreas Kling
e834c24eea Kernel/USB: Start fleshing out a basic UHCI controller driver :^)
Let's see if we can talk to some USB devices. We will now detect
a UHCI controller if present on the PCI bus.
2020-09-04 21:21:41 +02:00
Andreas Kling
2e01f1f9b9 Kernel: Add PCI::get_programming_interface(PCI::Address)
This returns the programming interface at a given PCI address.
This is sometimes referred to as "prog-if" on other systems.
2020-09-03 21:02:47 +02:00
Luke
9b9c752dbe Documentation: Add Windows section in build instructions
It seems that new people go to the build instructions from the main
README, don't see Windows and are then stuck.

We do have instructions for Windows, but they aren't noted in the build
instructions, so new people get stuck thinking there's no way to build
on Windows.
2020-09-03 11:03:34 +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
Avery
6fe37cb471 Userland/tt: Use a default value for the test to run
Addresses #3394 which was caused by dereferencing null `test_name`
when no arguments were given to /bin/tt. Additionally, arguments
other than the defined tests now print usage and exit to avoid
running the default test.
2020-09-03 10:08:15 +02:00
Andreas Kling
27687b1c6e LibGUI: Handle cursor keydown events in AbstractView
Move the basic movement keys (up/down/left/right/home/end/pgup/pgdn)
up to AbstractView::keydown_event() and have it call the virtual
move_cursor() which is then implemented by subclasses.
2020-09-02 21:29:31 +02:00
Andreas Kling
4ba12e9c23 LibGUI: Simplify ListView hover highlighting
Instead of tracking the last valid hovered index, just hook the
mousemove event and make the cursor follow the hover when it changes.
2020-09-02 21:29:31 +02:00
Andreas Kling
274a09246b LibGUI: Move ListView to using AbstractView::move_cursor() 2020-09-02 21:29:31 +02:00
Jordan Dalcq
c840c47c13
Keymaps: Add Belgian (be) keyboard (#3387) 2020-09-02 20:11:35 +02:00
Tom
bf268a0185 Kernel: Handle committing pages in regions more gracefully
Sometimes a physical underlying page may be there, but we may be
unable to allocate a page table that may be needed to map it. Bubble
up such mapping errors so that they can be handled more appropriately.
2020-09-02 00:35:56 +02:00
Tom
1ece93c805 Kernel: Use removed memory as backup if backup hasn't been allocated
It may be impossible to allocate more backup memory after expanding
the heap if memory is running low. In that case we wouldn't allocate
backup memory until trying to expand the heap again. But we also
wouldn't take advantage of using removed memory as backup, which means
that no backup memory would be available when the heap needs to grow
again, causing subsequent expansion to fail because there is no
backup memory.
2020-09-02 00:35:56 +02:00
Tom
ee51b28edd Kernel: Prevent recursive expansion or removing memory while expanding it
The process of expanding memory requires allocations and deallocations
on the heap itself. So, while we're trying to expand the heap, don't
remove memory just because we might briefly not need it. Also prevent
recursive expansion attempts.
2020-09-02 00:35:56 +02:00
Andreas Kling
dec3998b3c LibGUI: Disable whitespace visualization in single-line text editors
You can enable it manually if you really want it, of course. :^)
2020-09-01 23:57:30 +02:00
Andreas Kling
aa70d8c217 LibGUI: Implement trailing whitespace visualization in TextEditor
This patch adds an optional mode where TextEditor highlights trailing
whitespace characters on each line with a nice reddish dither pattern.

We should probably make this themable and I'm sure it could be nicer
somehow, but this is just a first cut and I do kinda like it. :^)
2020-09-01 23:55:35 +02:00