Commit graph

44064 commits

Author SHA1 Message Date
Ali Mohammad Pur
08fc42002c AK: Format the contents of NNRP<T> if T is formattable 2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
ff038f306a AK: Ignore "alternative" formatting of StringView instead of crashing
Jakt implements this in a different way, but it's a noop for
StringViews anyway.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
1cc8cdcd23 AK: Add a Error::__jakt_from_string_literal(StringView) factory function
Note that Jakt only allows StringView creation from string literals, so
none of the invariants in the class are broken by this (if used only
from within Jakt).
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
537924a8d0 AK: Let ErrorOr<T, E> expose its result/error types
`ErrorOr<T, E>::ResultType` can now refer to `T`.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
c3b4b0e88b AK: Add support for modulo to Checked<T>
This is used by the Jakt runtime.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
cc0b970d81 AK: Allow Optional<T> to be constructed by OptionalNone()
This is needed by the Jakt runtime too.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
12e4cd3b77 AK: Allow the user to access the variant index
The average user has no need for this, but the Jakt compiler uses this
to avoid going through the expensive ::visit() and ::get<>() APIs.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
543890c5c9 AK: Add a fallible StringBuilder::create() factory function
This is nice, and is also used by the Jakt runtime.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
21c2d8bd98 AK: Add a Optional::value_or_lazy_evaluated(constructor_function) API
This allows the user to avoid constructing the default value if the
optional already contains a value.
This is used by the Jakt runtime.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
cc948d06a6 AK: Add a functional-style Optional::map(mapper_function) API
This allows the user to transform the contents of the optional (if any
exists), without manually unwrapping and then rewrapping it.
This is needed by the Jakt runtime.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
5809b4aafa AK: Let HashMap also take a ValueTraits
We were previously using Traits<V>, take that frrom the template
parameters instead.
This is needed by the Jakt runtime.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
58252a7684 AK: Elaborate the Error constructors a bit
The old constraints were making clang mad, so express them in a less
complex way.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
099a6bc45f AK: Give DeprecatedString::replace() a default mode
This is used in Jakt, and providing that value from Jakt's side is more
trouble than doing this.
Considering this class is bound to go away, a little
backwards-compatible API change is just fine.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
7a17fd6d71 AK: Add a DeprecatedString::byte_at() getter
`operator[]` returns a char, this is used in Jakt.
2022-12-11 20:44:54 +03:30
Ali Mohammad Pur
c547b55a00 AK: Add a Checked::unchecked_value() function
This is used in Jakt.
2022-12-11 20:44:54 +03:30
kleines Filmröllchen
b65258c093 Help+man+LibManual: Move argument handling to LibManual
This deduplicates argument handling logic from Help and man and makes it
more modular for future use cases. The argument handling works as
before: two arguments specify section and page (in this order), one
argument specifies either a page (the first section that it's found in
is used) or a path to a manpage markdown file.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
64ca546a06 man: Refactor with LibManual and Core::Stream 2022-12-11 16:05:23 +00:00
kleines Filmröllchen
146bce53dd Help: Fix search query parsing
This was failing probably because AK::URL was being too strict; and the
query emptyness check was flipped.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
a438c4d568 Help+LibManual: Move all manpage path handling to LibManual
This way, we'll have an easier time changing these paths.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
16ca41ec10 AK: Add LexicalPath::is_child_of
This API checks whether this path is a child of (or the same as) another
path.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
4625f7aab5 LibManual: Refactor SectionNode in preparation for subsections
- Calculate the full name on demand
- Make section and name protected
- Reorder some members logically
- Change the name getter to be fallible, as some implementors need to
  allocate
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
f502e24bd7 AK: Change the moved-from String state to the empty short string
The previous moved-from state was the null string. This violates both
our invariant that String is never null, and also the C++ contract that
the moved-from state must be valid but unspecified. The empty short
string state is of course valid, so it satisfies both invariants. It
also allows us to remove any extra checks for the null state.

The reason this change is made is primarily because swap() requires
moved-from objects to be reassignable (C++ allows this). Because the
move assignment of String would not check the null state, it crashed
trying to increment the data reference count (nullptr signals a
non-short string). This meant that e.g. quick_sort'ing String would
crash immediately.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
ca80353efe AK: Add comparison operator
s p a c e s h i p  o p e r a t o r

Comparing UTF-8 can be done by simple byte lexicographic comparison per
definition, so we just piggy-back on StringView's high-performance
comparator.
2022-12-11 16:05:23 +00:00
kleines Filmröllchen
ad6a55e1f0 Help+LibManual: Move non-UI-specific manual handling to LibManual
This is a first step in deduplicating code within and across Help and
man.

Because LibManual also doesn't contain any DeprecatedString, some
adjustments to Help's string handling is included, just to interoperate
with LibManual better. Further work in this area mostly requires String
APIs in LibGUI.
2022-12-11 16:05:23 +00:00
Timothy Flynn
78353ec184 sql: Support running the sql REPL on Lagom 2022-12-11 10:08:17 -05:00
Timothy Flynn
4e5f56f737 LibSQL: Support launching a singleton SQLServer instance for Lagom hosts
On Serenity, SQLServer is started by SystemServer. But on Lagom, it is
manually started by e.g. Ladybird when the application is started, and
killed when the application exits. This means every Ladybird process
starts its own SQLServer, which defeats the purpose of SQLServer acting
as the single process interacting with the database files.

This patch will allow SQLClient to start up a single SQLServer instance,
first checking if one already exists. If it does exist, SQLClient will
simply connect to SQLServer's socket. If it does not exist, SQLClient
will launch SQLServer much like SystemServer would (with a local socket
file, etc.).

The child SQLServer process is double-forked; the grandchild process
becomes the SQLServer process, which the middle child process simply
exits to "detach" the grandchild process from the SQLClient process.
2022-12-11 10:08:17 -05:00
Timothy Flynn
12152a4556 SQLServer: Re-use already opened SQL::Database objects
Currently, we create a new SQL::Database object for each database we are
requested to open. When multiple clients connect to the same database,
the same underlying database file is opened and cached each time. This
results in updates from one client not being propagated to others.

To prevent this, when a database is requested to be open, check if it is
already open. We can then re-use that SQL::Database object for the new
connection.
2022-12-11 10:08:17 -05:00
Timothy Flynn
6b64485b40 LibIPC: Add a hook to MultiServer to inform owners of new clients
This will allow the owner of the server to mutate the client after it
has been accepted.
2022-12-11 10:08:17 -05:00
Timothy Flynn
c46c3555a1 LibCore: Add a standard path for runtime communication files
This corresponds to XDG_RUNTIME_DIR, which is the path applications may
place runtime communication files, like local sockets.
2022-12-11 10:08:17 -05:00
kleines Filmröllchen
7a5ceebb50 Base: Add a quote to the fortunes database 2022-12-11 11:32:29 +00:00
Tim Schumacher
20f0858f67 Meta: Return 0 from the fuzzing function in most cases
LibFuzzer documentation [1] states that all return values except for 0
and -1 are currently reserved for future use. -1 is a special return
value that causes LibFuzzer to not add a testing input to the testing
corpus, regardless of the code coverage that it causes.

[1] https://llvm.org/docs/LibFuzzer.html
2022-12-10 16:21:12 -07:00
Luke Wilde
eabb0be7ea LibWeb: Check HTML parser position is equal to or after insertion point
This used to be the other way around. If we just inserted input with
document.write, this would always be true and not allow document.write
to immediately parse its input (given that there's no pending parsing
blocking script)
2022-12-10 21:37:18 +00:00
Lucas CHOLLET
fa29214d9a CI: Fix commit linting for multi-line commit messages
Third time's the charm
2022-12-10 17:52:26 +00:00
Lucas CHOLLET
b3478b3613 CI: Correct regex to retrieve git merge commit
In 839c1a57, I wrongly assumed that a matched pattern will raise an
error, it's the opposite. This patch "negates" the regex to solve the
issue.
2022-12-10 16:23:09 +00:00
Thomas Queiroz
54c12b76ed AK: Remove HashMap::ensure_capacity
This is not perfect, since the constuctor can still fail.
2022-12-10 14:29:46 +01:00
Thomas Queiroz
0380ff30aa Kernel: Use HashMap::try_ensure_capacity 2022-12-10 14:29:46 +01:00
Thomas Queiroz
7c82713ecb test-test262: Use HashMap::try_ensure_capacity 2022-12-10 14:29:46 +01:00
Thomas Queiroz
eacfcac932 LibWeb: Use HashMap::try_ensure_capacity in StyleComputer 2022-12-10 14:29:46 +01:00
Thomas Queiroz
6debd967ba Lagom/CodeGenerators: Use HashMap::try_ensure_capacity 2022-12-10 14:29:46 +01:00
Andreas Kling
a3a5d2b27d SpaceAnalyzer: Consolidate the node context menus
Instead of having two separate context menus and popping up either the
"file" or "directory" one depending on the selected node, we now have a
single context menu and update it (before popping it up) to show the
context-appropriate actions.

This is achieved by simply updating the visibility of the actions.

This takes care of one TODO! :^)
2022-12-10 14:28:38 +01:00
Andreas Kling
49f5767789 LibGUI+WindowServer: Add "visible" state to GUI actions
This patch adds a visibility state to GUI::Action. All actions default
to being visible. When invisible, they do not show up in toolbars on
menus (and importantly, they don't occupy any space).

This can be used to hide/show context-sensitive actions dynamically
without rebuilding menus and toolbars.

Thanks to Tim Slater for assuming that action visibility was a thing,
which gave me a reason to implement it! :^)
2022-12-10 14:28:38 +01:00
Snow
df7c0eacd4 TextEditor: Fix commenting shortcut <Ctrl-/>
When you select a text area in "bottom-up" way (e.g. from line 10
to line 5), then type the shortcut, the text editor will not
comment those text for you.

Normalize the text range can easily fix this minor bug.
2022-12-10 14:04:51 +01:00
Tim Schumacher
b0af53749d Meta: Switch to the Lagom directory before building fuzzers
This confused quite a number of people in the past, and it is still
slightly annoying to always switch the directory when testing both the
OS and the fuzzer build. Instead, let's just switch to the correct
directory automatically.
2022-12-10 14:03:46 +01:00
DragonAlex98
b8706729ba LibGUI: Disable corresponding Scrollbar button when reaching min or max 2022-12-10 14:03:27 +01:00
Andreas Oppebøen
4b12def5d8 LibWeb: Use start-of-line in hit test of position directly to the left
This fixes a bug where selecting from the left within a line would
begin the selection from the right, as pointed out by @AtkinsSJ in
https://github.com/SerenityOS/serenity/pull/16245#pullrequestreview-1197595820
2022-12-10 13:19:49 +01:00
Andreas Oppebøen
9cab5059f8 LibWeb: Use correct end-of-fragment node index for HitTestResult
The indexes are into the _node_, not in the fragment, so when a node is
split into multiple fragments, simply taking the length of the fragment
is incorrect. This patch corrects this mistake.
2022-12-10 13:19:49 +01:00
thankyouverycool
31f4ec66c5 Magnifier: Add a manual to Help menu and propagate construction errors 2022-12-10 13:15:35 +01:00
thankyouverycool
5e96ad0345 Magnifier: Standardize File menu
File->Quit should appear as the final item in its menu
2022-12-10 13:15:35 +01:00
thankyouverycool
0c2f36966c WindowServer: Update checked state of m_window_menu_always_on_top_item
when setting it programmatically.
2022-12-10 13:15:35 +01:00
thankyouverycool
f8e0bcbedf Magnifier: Remove always_on_top_action
This action was originally added so that Magnifier's window would
always be on top by default, but it's a redundant menu item and wasn't
actually setting itself at start-up. Instead, rely on the same menu
item provided to all Modeless windows by default for a more consistent
UX, and set the option after show() so it takes effect.
2022-12-10 13:15:35 +01:00