Commit graph

15257 commits

Author SHA1 Message Date
Andreas Kling
bc5635422b LibGUI: Give a default min-width to a bunch of widgets 2020-12-30 02:57:45 +01:00
Andreas Kling
10b5b9ee66 CrashReporter: Don't keep the coredump file open longer than necessary
Let's be nice and close the file after we've extracted what we need.
2020-12-30 02:56:31 +01:00
Andreas Kling
8df1f6951e DisplaySettings: Convert the GUI to GML :^) 2020-12-30 02:45:20 +01:00
Andreas Kling
01ccbdb017 LibGUI: Register GUI::ComboBox :^) 2020-12-30 02:45:20 +01:00
Andreas Kling
e07a66d011 LibGUI: Remove unused Widget backcolor/forecolor properties
These were some leftovers from the VisualBuilder times.
2020-12-30 02:45:20 +01:00
William Marlow
96cd04f2ba Shell: Implement a very basic exec builtin
Other shells also support a number of other options with exec and
some have special behaviour when calling exec with no arguments except
redirections.

This PR only supports the basic case of replacing the Shell process
(or LibShell host process) with the provided command.
2020-12-30 02:13:53 +01:00
asynts
50d24e4f98 AK: Make binary_search signature more generic. 2020-12-30 02:13:30 +01:00
Gal Horowitz
35c4338625 HexEditor: Ignore control keys in text mode
The HexEditor now ignores control key events in text mode.
Previously null bytes were written.
2020-12-30 02:12:04 +01:00
Gal Horowitz
fea498e9ac LibKeyboard: get_char now handles e0 prefix for control keys
Control keys which have numpad counter-parts have the same scancode
except for an e0 prefix. We now return a 0 code_point for those keys.
2020-12-30 02:12:04 +01:00
Tom
c2332780ee Kernel: Fix HPET::update_time to set ticks within the valid range
ticks_this_second must be less than the ticks per second (frequency).
2020-12-30 02:11:06 +01:00
Andreas Kling
675bfb934b LibGUI: Unbreak GUI::ScrollBar default size
Oops, got my width/height mixed up here. :^)
2020-12-30 01:55:25 +01:00
Andreas Kling
1cca2405fc LibGUI: Give some widgets a reasonable default fixed height
Instead of hard-coding 22 in random places, just make the following
widgets have a fixed height of 22 by default: Button, CheckBox,
ColorInput, ComboBox, RadioButton, SpinBox, TextBox.

In the future we can make this relative to the current font size,
but for now at least this centralizes the setting a bit better.
2020-12-30 01:54:53 +01:00
Andreas Kling
0f3b0b65ae LibGUI+LibCore: Remove the GUI::SizePolicy enum 2020-12-30 01:38:29 +01:00
Andreas Kling
7dc5a3ead8 LibGUI: Rewrite layout system in terms of min and max sizes
This patch removes size policies and preferred sizes, and replaces them
with min-size and max-size for each widget.

Box layout now works in 3 passes:

    1) Set all items (widgets/spacers) to their min-size
    2) Distribute remaining space evenly, respecting max-size
    3) Place widgets one after the other, adding spacing in between

I've also added convenience helpers for setting a fixed size (which is
the same as setting min-size and max-size to the same value.)

This significantly reduces the verbosity of widget layout and makes GML
a bit more pleasant to write, too. :^)
2020-12-30 01:36:41 +01:00
Andreas Kling
b2bba5ce5c LibGUI: Make Layout::margins() return a const reference 2020-12-30 01:28:28 +01:00
Andreas Kling
881379e324 SystemMonitor: Use new-style widget size constraints
This is a lot more expressive in C++ as well, not just in GML. :^)
2020-12-30 01:28:28 +01:00
Andreas Kling
ee85713e52 LibGUI: Add fixed_size/fixed_width/fixed_height helpers to Widget
Fixed sizes are really just shorthands for setting min and max size to
the same value.

This makes it much nicer to express fixed sizes in GML:

Before:

    @GUI::Widget {
        horizontal_size_policy: "Fixed"
        preferred_width: 20
    }

After:

    @GUI::Widget {
        fixed_width: 20
    }
2020-12-30 01:28:28 +01:00
Andreas Kling
c9331a96d6 Taskbar: Set min/max size for taskbar buttons
This makes them shrink when the taskbar fills with too many buttons.
It doesn't scale to infinity open windows, but it's better than them
escaping off screen after 6 open windows. :^)
2020-12-30 01:28:28 +01:00
Andreas Kling
60e3f685db LibGUI: Add min/max sizes to GUI::Widget
This patch adds min_size and max_size properties to GUI::Widget. These
can also be accessed as min_width/min_height and max_width/max_height.

Layouts will respect these constraints and size widgets accordingly.
2020-12-30 01:28:28 +01:00
William Marlow
91b65ec328 Build: Expose symbols SECTION_start and SECTION_size for embedded resources.
Resources embedded by the embed_resource() function will now also expose
a SECTION_start and SECTION_size symbol so the embedded resource can be found
by an application without having to parse its own ELF image which is not
something applications can currently do from userspace.
2020-12-29 23:38:48 +01:00
Luke
18d99919be LibWeb: Expose three more attribute methods on Element
Exposes removeAttribute, hasAttribute and hasAttributes.
2020-12-29 23:38:14 +01:00
Idan Horowitz
b05f048c05 LibGUI: offset value by minimum to ensure proper rendering of sliders
This subtracts the minimum from the value when rendering so that the
knob doesnt go off screen for a non-zero minimum.
2020-12-29 23:37:38 +01:00
Linus Groh
356f11bc76 CrashReporter: Tweak width of spacer widget by 1px
This prevents the shadow of the close button on its right side being cut
off.

Fixes #4635.
2020-12-29 18:59:57 +01:00
meme
23b23cee5a Build: Support non-i686 toolchains
* Add SERENITY_ARCH option to CMake for selecting the target toolchain
* Port all build scripts but continue to use i686
* Update GitHub Actions cache to include BuildIt.sh
2020-12-29 17:42:04 +01:00
AnotherTest
8ca0e8325a LibJS: Don't save rule start positions along with the parser state
This fixes #4617.
Also fixes the small problem where some save states would be leaked.
2020-12-29 17:39:42 +01:00
Luke
6ffcd53479 LibWeb: Fix character references losing characters in certain situations
This fixes 4 issues:
- RECONSUME_IN_RETURN_STATE was functionally equivalent to
  SWITCH_TO_RETURN_STATE, which caused us to lose characters.
  For example, &test= would lose the =

- & characters by themselves would be lost. For example, 1 & 2
  would become 1 2. This is because we forgot to flush
  characters in the the ANYTHING_ELSE path in CharacterReference

- Named character references didn't work at all in attributes.
  This is because there was a path that was checking the entity
  code points instead of the entity itself. Plus, the path that
  was checking the entity itself wasn't quite spec compliant.

- If we fail to match a named character reference, the first
  character is lost. For example &test would become &est.
  However, this relies on a little hack since I can't wrap my
  head around on how to change the code to do as the spec says.
  The hack is to reconsume in AmbigiousAmpersand instead of
  just switching to it.

Fixes #3957
2020-12-29 17:39:08 +01:00
AnotherTest
bca7be2aef Userland: Make `test' accept single-digit negative numbers 2020-12-29 16:55:43 +01:00
AnotherTest
66b26fc1c2 Shell: Fix wrong step value for brace ranges
This fixes numeric ranges like {1..10}.
2020-12-29 16:55:43 +01:00
AnotherTest
5e5eb615ec Shell: Add runtime errors and implement break/continue
Such errors are raised when SyntaxError nodes are executed, and are also
used for internal control flow.
The 'break' and 'continue' commands are currently only allowed inside
for loops, and outside function bodies.

This also adds a 'loop' keyword for infinite loops.
2020-12-29 16:55:43 +01:00
AnotherTest
9bd81f34a5 Shell: Make for/match/functions put their variables only in the new scope
Otherwise, a function would, for example, overwrite its parent scope:
```sh
foo(x) { }
x=1
foo 2 # would make x=2 otherwise
```
2020-12-29 16:55:43 +01:00
AnotherTest
97c5a78d27 Shell: Add a 'glob' builtin
This builtin takes a bunch of strings, resolves them as globs (in the
current directory) and prints out the matching entries.
Its main use is to allow dynamic glob resolution:
```sh
glob "$whatever/*"
```
2020-12-29 16:55:43 +01:00
Andreas Kling
af28a8ad11 Kernel: Hold InodeVMObject reference while inspecting it in sys$mmap() 2020-12-29 15:43:35 +01:00
Andreas Kling
b8db585a83 Kernel: Remove unnecessary non-const Inode::shared_vmobject() 2020-12-29 15:43:35 +01:00
Linus Groh
b13b27b4d2 Applications: Add CrashReporter :^)
This is a simple application that can read a coredump file and display
information regarding the crash, like the application's name and icon
and a backtrace. It will be launched by CrashDaemon whenever a new
coredump is available.
Also, it's mostly written in GML! :^)

Closes #400, but note that, unlike mentioned in that issue, this
implementation doesn't ignore applications that "have been started in
the terminal". That's just overcomplicating things, IMO. When my js(1)
REPL segfaults, I want to see a backtrace!
2020-12-29 15:42:30 +01:00
Linus Groh
2939ad0110 LibCoreDump+CrashDaemon: Add and use CoreDump::Backtrace
Creating a backtrace from a crashdump already existed as a few
standalone functions in CrashDaemon. This patch refactors the code
required for this to make it generally usable and moves it to
CoreDump::Backtrace, which provides both raw data as well as
stringification.
2020-12-29 15:42:30 +01:00
Linus Groh
e2e2b2c08e LibELF: Add MemoryRegionInfo::object_name()
We had multiple implementations of this function, and it's a small
helper related to MemoryRegionInfo's region_name, so let's move it
there.
2020-12-29 15:42:30 +01:00
Linus Groh
c39323401c LibGUI: Consider comment tokens in GMLParser
It was just ignoring them, so any GML containing a comment would fail
to parse with "Expected child, property, or }"!
2020-12-29 15:42:30 +01:00
Linus Groh
d161007e9e LibGUI: Register Label "text_alignment" property 2020-12-29 15:42:30 +01:00
Linus Groh
750a608441 LibGUI: Register TextEditor "mode" property
This makes it possible to construct a read-only (or display-only)
TextEditor in GML:

    @GUI::TextEditor {
        mode: "ReadOnly"
        text: "Well hello friends! :^)"
    }
2020-12-29 15:42:30 +01:00
Linus Groh
1e70986d19 LibCore: Add REGISTER_TEXT_ALIGNMENT_PROPERTY macro 2020-12-29 15:42:30 +01:00
Linus Groh
6c0fa6ad93 LibCore: Add REGISTER_ENUM_PROPERTY macro
This can be used to register a property that maps enum values to certain
strings, e.g.

    REGISTER_ENUM_PROPERTY(
        property_name, getter, setter, Enum,
        { Enum::Foo, "Foo" },
        { Enum::Bar, "Bar" });

Also use it for REGISTER_SIZE_POLICY_PROPERTY :^)
2020-12-29 15:42:30 +01:00
Linus Groh
c4991d969c LibGUI: Register the ImageWidget and LinkLabel widgets 2020-12-29 15:42:30 +01:00
Linus Groh
b8eb1baac8 LibGUI: Move REGISTER_WIDGET(GUI, TabWidget) to Widget.cpp
All the other (GUI) registrations happen here, so it's confusing to have
just one elsewhere ("wait... is TabWidget not registered?!").
2020-12-29 15:42:30 +01:00
Linus Groh
a514f2cbfd LibGUI: Set default value of LinkLabel text argument to a null string
The regular Label also does this, being able to call the constructor
with no arguments is required for REGISTER_WIDGET(GUI, LinkLabel).
2020-12-29 15:42:30 +01:00
Linus Groh
21bc8cfe8f LibCoreDump: Make for_each_thread_info() callback arg a reference
It's never nullptr, so it should be a reference.
2020-12-29 15:42:30 +01:00
Linus Groh
87f1f69dd2 LibCoreDump: Make for_each_memory_region_info() callback arg a reference
It's never nullptr, so it should be a reference.
2020-12-29 15:42:30 +01:00
Linus Groh
8ec1da2fca LibCoreDump: CoreDumpReader => CoreDump::Reader
As mentioned in 2d39da5 the usual pattern is that LibFoo provides a Foo
namespace - LibCoreDump doesn't, so this renames CoreDumpReader to
Reader and puts it in the CoreDump namespace. :^)
2020-12-29 15:42:30 +01:00
Linus Groh
1ed72cc580 AK: Add HashMap(std::initializer_list<Entry>) constructor
This allows us to construct a HashMap from an initializer list like so:

    HashMap<K, V> hash_map = { { K, V }, { K, V } { K, V } };
2020-12-29 15:22:15 +01:00
Egor Ananyin
1dbd264239 LibJS: Uncomment the tests that pass now 2020-12-29 13:43:16 +01:00
Egor Ananyin
92c6ae57fc LibM: Reimplement some functions using FPU 2020-12-29 13:43:16 +01:00