Commit graph

877 commits

Author SHA1 Message Date
Linus Groh
7b21335caa Playground: Add "Format GML" menu action
This can be invoked via the Edit menu or with Ctrl+Alt+F. If the current
text in the editor can be parsed as valid GML, it will be formatted and
updated, otherwise an alert is shown (no specific error message as those
are only printed to the debug console in the parser for now).
If the source contains comments, which would be lost after formatting,
the user will be notified and has to confirm the action.
2021-01-03 22:12:08 +01:00
AnotherTest
6dbdbec835 Playground: Improve the autocompleted suggestions
- Now sorted
- Add a "layout" property to GUI::Widget and GUI::Frame
- Only complete Layouts for the values of "layout"
- Don't suggest anything if the only suggestion is what the user has
  already typed
2021-01-03 10:47:29 +01:00
Linus Groh
306aff80d0 LibGUI: Remove Widget's unused m_{foreground,background}_color
...as well as the few remaining references to set_foreground_color().

These properties are not being used for rendering anymore, presumably
because they completely mess up theming - assigning random white and
gray backgrounds just doesn't work with dark themes.
I've chosen to not replace most of the few remaining uses of this
broken functionality with custom palette colors (the closest
replacement is background_role) for now (except for Minesweeper where
squares with mines are painted red again now), as no one has actually
complained about them being broken, so it must look somewhat decent
(some just look right anyway). :^)

Examples of this are the taskbar buttons, which apparently had a
DarkGray foreground color for minimized windows once - this has since
been replaced with bold/regular font. Another one is the Profiler's
ProfileTimelineWidget, which is supposed to have a white background -
which it didn't have for quite some time, it's grey now (with the
default theme, that is). Doesn't look bad either.
2021-01-02 23:31:22 +01:00
Andreas Kling
05f5d0dda3 LibGfx: Add Gfx::TextAttributes (and use it in GUI::TextDocumentSpan) 2021-01-02 20:57:43 +01:00
AnotherTest
7785d9715d Playground: Enable automatic autocomplete in the editor
This makes it a bit more useful, as the user doesn't have to explicitly
ask for completion, it just provides completions, and tries really hard
to avoid suggesting things where they're not expected, for instance:
(cursor positions denoted as pipes)
```
@G | {|
    foo: bar |
    foo |
}
```

The user does not expect any suggestions in any of those cursor positions,
so provide no suggestions for such cases. This prevents the automatic autocomplete
getting in the way of the user, esp. when they try to press return fully
expecting to go to a new line.
2021-01-02 11:37:01 +01:00
Linus Groh
7d72168b14 Playground: Use pledge() 2021-01-02 01:49:48 +01:00
Linus Groh
fb7cc4ec46 Playground: Add "Help" menu with "About" action
An application with menubar that's missing an about dialog feels
incomplete! :^)
2021-01-02 01:49:48 +01:00
Andreas Kling
93e82e8459 HackStudio: Use is<T> instead of strcmp on a widget class_name() :^) 2021-01-01 23:02:31 +01:00
Andrew Kaster
744322c247 HackStudio: Call Thread::join instead of pthread_join
It's really awkward that HackStudioWidget was calling the pthread API on
its LibThread::Thread. Change to calling the new Thread::join call,
which returns the information it wants to log.
2021-01-01 23:01:48 +01:00
Andreas Kling
febc8a5ac7 UserspaceEmulator: Remove hand-rolled is_foo() helpers in favor of RTTI 2021-01-01 19:37:36 +01:00
Andreas Kling
865f524d5b AK+LibGUI+LibWeb: Remove AK::TypeTraits in favor of RTTI-based helpers
Now that we have RTTI in userspace, we can do away with all this manual
hackery and use dynamic_cast.

We keep the is<T> and downcast<T> helpers since they still provide good
readability improvements. Note that unlike dynamic_cast<T>, downcast<T>
does not fail in a recoverable way, but will assert if the object being
casted is not a T.
2021-01-01 15:33:30 +01:00
Andrew Kaster
2b3993b008 LibThread: Hide Thread's constructor, as it is a Core::Object
Just constructing one of these guys on the stack willy nilly will leak
the first reference to them. There might be other C_OBJECTs that have
public constructors, seems like a good place for some static analysis
checks :).

Force users to call the construct() method for it.
2020-12-31 21:59:20 +01:00
Andreas Kling
e27d281bf1 UserspaceEmulator: Support sys$mremap()
This makes UE able to run dynamically linked executables once again.
2020-12-31 14:22:56 +01:00
Luke
0f66589007 Everywhere: Fix more typos 2020-12-31 01:47:41 +01:00
Luke
28bad49ed4 DevTools: Add open, save as and quit actions to GML playground 2020-12-31 01:08:58 +01:00
Stephan Unverwerth
b4d1390714 LibGFX: Move default_xxx_font() methods from Font to FontDatabase
When we have an abstract font class it makes no sense to keep
these methods in the Font class.
2020-12-30 20:40:30 +01:00
asynts
7e62ffbc6e AK+Format: Remove TypeErasedFormatParams& from format function. 2020-12-30 20:33:53 +01:00
AnotherTest
7d30692ac2 Playground: Add autocomplete 2020-12-30 12:53:39 +01:00
AnotherTest
20b74e4ede LibGUI+HackStudio: Add an opt-in autocompletion interface to TextEditor
...and use that to implement autocomplete in HackStudio.

Now everyone can have autocomplete :^)
2020-12-30 12:53:39 +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
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
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
f1b596e75e Inspector: unveil("/bin", "r") so it can show app icons 2020-12-29 13:42:21 +01:00
Linus Groh
fe6a312714 Base+Playground: Add app-playground.png 16x16 and 32x32 icons 2020-12-27 18:36:43 +01:00
Linus Groh
dc55fbeb79 Playground: Pre-populate the text editor with some GML
The text editor is now populated with some very basic GML after startup:

    @GUI::Widget {
        layout: @GUI::VerticalBoxLayout {
        }

        // Now add some widgets!
    }

Less typing, less intimidating! :^)
2020-12-27 18:36:43 +01:00
Linus Groh
e955c024b2 LibCore: Add Object::remove_all_children() 2020-12-27 18:36:43 +01:00
Andreas Kling
0e2b7f9c9a Kernel: Remove the per-process icon_id and sys$set_process_icon()
This was a goofy kernel API where you could assign an icon_id (int) to
a process which referred to a global shbuf with a 16x16 icon bitmap
inside it.

Instead of this, programs that want to display a process icon now
retrieve it from the process executable instead.
2020-12-27 01:16:56 +01:00
Andreas Kling
2588b14d38 DevTools: Add a simple GML Playground application :^)
This app allows you to edit GML and see the results live. Pretty cool!
2020-12-26 19:04:46 +01:00
Andreas Kling
788594c0c2 Profiler: Show the name & PID of process being profiled
Also tweak the GUI a little bit to look nicer.
2020-12-26 12:58:50 +01:00
Andreas Kling
bd47957c3a Profiler: Show a GUI message box with the error when profiling fails
This came up in @jonathandturner's video walking through the system
and playing with things: https://www.youtube.com/watch?v=TtV86uL5oD4

At one point, he tried profiling his Terminal app, and since the
Terminal was completely idle while profiling, no samples were captured
and there was no profile to show.

Make sure we propagate any error when loading the profile, and show it
in a GUI message box instead of stderr. :^)
2020-12-26 10:27:57 +01:00
Lenny Maiorani
b2316701a8 Everywhere: void arguments to C functions
Problem:
- C functions with no arguments require a single `void` in the argument list.

Solution:
- Put the `void` in the argument list of functions in C header files.
2020-12-26 10:10:27 +01:00
Andreas Kling
d55fb7b5e2 UserspaceEmulator: Use ring 3 segment selectors
We were using ring 0 selectors everywhere (the bottom 3 bits of a
selector determines the ring.) This doesn't really make any practical
difference since UE doesn't run code in other rings anyway, but let's
have correct-looking segment selectors. :^)
2020-12-25 15:39:26 +01:00
Andreas Kling
40e9edd798 LibELF: Move AuxiliaryValue into the ELF namespace 2020-12-25 14:48:30 +01:00
Andreas Kling
6c9a6bea1e Kernel+LibELF: Abort ELF executable load sooner when something fails
Make it possible to bail out of ELF::Image::for_each_program_header()
and then do exactly that if something goes wrong during executable
loading in the kernel.

Also make the errors we return slightly more nuanced than just ENOEXEC.
2020-12-25 14:42:42 +01:00
Andreas Kling
1e4c010643 LibELF: Remove ELF::Loader and move everyone to ELF::Image
This commit gets rid of ELF::Loader entirely since its very ambiguous
purpose was actually to load executables for the kernel, and that is
now handled by the kernel itself.

This patch includes some drive-by cleanup in LibDebug and CrashDaemon
enabled by the fact that we no longer need to keep the ref-counted
ELF::Loader around.
2020-12-25 02:14:56 +01:00
Andreas Kling
ab549cf942 LibGUI+TextEditor+HackStudio: Add GML syntax highlighter :^) 2020-12-21 18:26:18 +01:00
Brendan Coles
9ca34c3047 UserspaceEmulator: Implement profiling, disown, purge syscalls 2020-12-21 09:57:51 +01:00
William Marlow
39364bdda4 Build: Embed application icons directly in the executables.
New serenity_app() targets can be defined which allows application
icons to be emedded directly into the executable. The embedded
icons will then be used when creating an icon for that file in
LibGUI.
2020-12-21 00:12:59 +01:00
Lenny Maiorani
765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling
71d92cef17 UserspaceEmulator: Add lazy caching of debug info for shared libraries
Keep the debug symbols for shared libraries in memory after we opened
them the first time. This dramatically speeds up symbolication of
backtraces when running dynamically linked programs in UE.
2020-12-20 15:45:39 +01:00
Andreas Kling
0e4ecca336 LibIPC: Remove use of ByteBuffer::wrap()
ByteBuffer::wrap() was useful before we had Span. Let's see if we can't
get rid of some more ByteBuffer wrapping.
2020-12-19 11:30:02 +01:00
Sahan Fernando
354a1a7891 HackStudio: Remove duplicate auto-indentation in HackStudio Language Server 2020-12-18 16:25:42 +01:00
Brendan Coles
c8fb00fe4d UserspaceEmulator: Implement geteuid, getegid, ptsname syscalls 2020-12-17 00:02:03 +01:00
Brendan Coles
a46e48089d UserspaceEmulator: Implement beep syscall 2020-12-16 17:27:20 +01:00
Andreas Kling
d410449d87 HackStudio: Don't take LexicalPath as argument
Also make use of LexicalPath::has_extension() in one place.
2020-12-15 11:58:47 +01:00
Itamar
72ca45e300 UserspaceEmulator: Support dynamically loaded programs
When loading dynamic objects, the emulator loads the interpreter,
generates an auxiliary vector and starts executing the loader.

Additionally, this commits also makes the MallocTracer and backtrace
symbolication work for dynamically loaded programs.
2020-12-14 23:05:53 +01:00
Itamar
28cda567c1 UserspaceEmulator: Support the name argument in mmap for file backed mappings 2020-12-14 23:05:53 +01:00
Itamar
d2262b8f6d UserspaceEmulator: Update memory protection of underlying pages
If a MmapRegion is file backed, we need to call mprotect on its
underlying pages.
2020-12-14 23:05:53 +01:00
Itamar
d89858f42a Profiler: Symbolicate samples using coredump file 2020-12-14 23:05:53 +01:00
Andreas Kling
dd3e6451ac HackStudio: Rethink the "project" concept to be about a directory
Instead of having .hsp files that determine which files are members
of a project, a project is now an entire directory tree instead.

This feels a lot less cumbersome to work with, and removes a fair
amount of busywork that would otherwise be expected from the user.

This patch refactors large parts of HackStudio to implement the new
way of thinking. I've probably missed some details here and there,
but generally I think it's pretty OK.
2020-12-10 20:42:11 +01:00