Commit graph

15269 commits

Author SHA1 Message Date
Andrew Kaster
0c51778510 AK: Move String::number entirely to header file
Use SFINAE to enforce the fact that it's supposed to only be called for
Arithmetic types, rather than counting on the linker to tell us that an
instantiation of String::number(my_arg) was not found. This also adds
String::number for floating point types as a side-effect.
2020-12-30 11:32:20 +01:00
Andrew Kaster
b4eb734204 AK: Add tests for type traits and IndexSequence
Use TypeLists to add test for IsIntegral, IsFloatingPoint, IsVoid,
IsNullPointer, IsArithmetic, IsFundamental, and AddConst type traits.

More can "easily" be added once the TypeList and macro magic is squinted
at for long enough :).
2020-12-30 11:32:20 +01:00
Andrew Kaster
3bf77f01a7 AK: Add a TypeList class for expanded compile-time tools
Also add IndexSequence and associated helpers. The TypeList class can be
queried for what type is at a certain index, and there are two helper
functions: for_each_type, and for_each_type_zipped.

for_each_type will invoke a lambda with a TypeWrapper object for
each type in the type list. The original type can be obtained by
extracting the ::Type from the type of your generic lambda's one
argument.

for_each_type_zipped will walk two TypeLists in lockstep and pass a
TypeWrapper object for the current index in each list to a generic
lambda. The original type from the TypeList can again be extracted via
the ::Type of the generic lambda's two parameters.
2020-12-30 11:32:20 +01:00
Andrew Kaster
fe4b44b489 AK: Add IsArithmetic and IsFundamental type traits
Also, make sure to using AK::IsNullPointer
2020-12-30 11:32:20 +01:00
Andrew Kaster
874df07ffd AK: Correct name in TestMain for TestTrie
Copy paste error :)
2020-12-30 11:32:20 +01:00
Andrew Kaster
06b6f838d6 AK: Use MacOS pthread_get_stacksize_np to get stack size for StackInfo
Seems Rust and OpenJDK both had issues with getting accurate stack size
for the main thread with MacOS Maverick and above. Apply a variant of
their workarounds. We could probably assume 8MB in all cases just to
be safe, as the only user of AK::StackInfo right now is lib JS's heap
for determining possible pointer candidates. But, this approach should
work if userspace apps start trying to add custom guard pages, as well.
2020-12-30 11:28:50 +01:00
Andreas Kling
bc0658ce27 FileManager: Use GUI::SeparatorWidget in the properties dialog
This looks a lot better than putting a GUI::Frame in there.
2020-12-30 03:53:37 +01:00
Andreas Kling
5b1a6d7c66 LibGUI: Move GUI::SeparatorWidget from ToolBar.cpp to its own file
This makes this nice line separator widget usable outside toolbars.
Also support both horizontal and vertical orientation. :^)
2020-12-30 03:52:27 +01:00
Andreas Kling
2dc09d1cd7 TextEditor: Show "Untitled" when there's no current document path 2020-12-30 03:44:38 +01:00
Andreas Kling
7c0e43eb3d CrashDaemon: Move from Applications to Services 2020-12-30 03:20:06 +01:00
Andreas Kling
a331a39a99 DisplaySettings: Push the bottom buttons to the bottom the window 2020-12-30 03:18:45 +01:00
Andreas Kling
972fedf3cf Terminal: Tweak settings window slightly 2020-12-30 03:15:00 +01:00
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