Commit graph

746 commits

Author SHA1 Message Date
Andreas Kling
43a6c70c2a LibCore: Make CTCPServer's local address/port getters return Optionals 2019-11-04 13:07:41 +01:00
Andreas Kling
50d937152a LibCore: Constify CTCPServer's local_address() and local_port() 2019-11-04 12:49:48 +01:00
Conrad Pankoff
fbe8569412 LibCore: Add local_{address,port} functions to CTCPServer 2019-11-04 12:49:15 +01:00
Andreas Kling
f5c2ae1192 GTextEditor: Move the cursor to column 0 after deleting a whole line 2019-11-04 12:36:10 +01:00
Jesse Buhagiar
70fb92fa0e LibC: Implemented atof()
`atof()` has now been implemented as part of the standard C library.
It supports scientific notation such as `1.2e-3` etc, ala the version
found as part of `glibc`.

It's a bit chunky, so there's probably room for optimisations here
and there, however, for now it works as intended (and allows Quake
to run).
2019-11-04 12:34:46 +01:00
Andreas Kling
ea4e02ed86 LibCore: Flush outgoing IPC messages before trying to send a new one
This ensures that messages are sent in order.
2019-11-04 10:52:01 +01:00
rhin123
9e608885d1 TextEditor: Added undo functionality
Created a stack where a vector of undo actions are stored.
2019-11-03 20:21:14 +01:00
Andreas Kling
53cfed7c8b LibCore: Put a limit on how many unsent messages an IPC server queues
This patch adds a limit of 200 unsent messages per client. If a client
does not handle its incoming messages and we manage to queue up 200
messages for it, we'll now disconnect that client. :^)
2019-11-03 12:40:57 +01:00
Andreas Kling
31c1b8ec3e LibCore: Have IPC server connections queue up unsendable messages
If an IPC client is giving us EAGAIN when trying to send him a message,
we now queue up the messages inside the CoreIPCServer::Connection and
will retry flushing them on next post/receive.

This prevents WindowServer from freezing up when one of its clients is
not taking care of its incoming messages.
2019-11-03 12:36:35 +01:00
Andreas Kling
4565b2d2d9 LibM: Add back ampsin() since it was still used by tan() 2019-11-03 09:59:44 +01:00
Andreas Kling
1282b778e7 LibGUI: Move GTextPosition and GTextRange LogStream<< to their headers 2019-11-03 09:57:14 +01:00
Jesse
bcf3a4457f LibM: Fixed sin() precision (#726)
The old implementation of sin() had a very unacceptable amount of
error that was causing a lot of texture perspective issues in Quake.
This has been remedied through the use of the hardware `fsin`
x87 instruction. As has been noted in #246, this instruction is both
very slow, and can become wildly inaccurate for more precise values,
however the current implementation made an incorrect assumption about
applications "will end up writing their own implemtnation anyways",
which is not the case for Quake in Software mode, which relies heavily
on a correct `sin()` and `cos()` function for `R_ScanEdges()`.

Realistically, we should be using something like the CORDIC algorithm
(https://en.wikipedia.org/wiki/CORDIC) or `Taylor Expansion`, however
for now these provides a somewhat accurate result that allows Quake to
run without any texture or geometry issues.
2019-11-03 09:56:39 +01:00
George Pickering
704f48d7f3 POSIX compliance: (most) shell scripts converted to generic shell
Ports/.port_include.sh, Toolchain/BuildIt.sh, Toolchain/UseIt.sh
have been left largely untouched due to use of Bash-exclusive
functions and variables such as $BASH_SOURCE, pushd and popd.
2019-11-03 09:26:22 +01:00
Andreas Kling
cc68654a44 Kernel+LibC: Implement clock_gettime() and clock_nanosleep()
Only the CLOCK_MONOTONIC clock is supported at the moment, and it only
has millisecond precision. :^)
2019-11-02 19:34:06 +01:00
Andreas Kling
b8bf998b61 LibGUI: Move text search functions from GTextEditor to GTextDocument
Also add a find_all() that retuns a Vector<GTextRange> and simply does
a find_next() loop, returning all the matching ranges.
2019-11-01 21:31:06 +01:00
Andreas Kling
f37cf5ea4a LibCore: Only wait 10ms between IPC connection retries instead of 1 sec
This makes startup feel way faster in case the WindowServer is not yet
available when we try connecting to it from Taskbar, Terminal, etc.
2019-10-31 16:28:30 +01:00
Andreas Kling
a4709502d1 GTextEditor: Make text_position_at() protected 2019-10-30 20:28:44 +01:00
Andreas Kling
bddba567b3 LibGUI: Add GTextDocument::text_in_range(GTextRange)
This function returns a String containing the text in a given range.
GTextEditor::selected_text() is now just a wrapper around this.
2019-10-30 20:28:44 +01:00
Andreas Kling
c1efa4f336 LibMarkdown: Include a <head> element when rendering MD to HTML
This should really be handled by LibHTML, but just include a <head>
element for now, so generated man pages always have a <head>.
2019-10-30 20:28:44 +01:00
Andreas Kling
014f8ca8c4 AK: Allow JsonValue to store 64-bit integers internally
Add dedicated internal types for Int64 and UnsignedInt64. This makes it
a bit more straightforward to work with 64-bit numbers (instead of just
implicitly storing them as doubles.)
2019-10-29 16:36:50 +01:00
Andreas Kling
98ff8ef0cf LibHTML: Add Document::force_layout()
..for when you really need a layout to happen right now.
Also, automatically repaint the layout root after layout.
2019-10-28 20:51:45 +01:00
Andreas Kling
f0da3ab9b2 LibGUI: Make GTextBox non-final
There's nothing wrong with subclassing GTextBox.
2019-10-28 19:08:48 +01:00
Andreas Kling
9b13a3905b LibGUI: Support multiple GTextEditors editing the same GTextDocument
With this patch, you can now assign the same GTextDocument to multiple
GTextEditor widgets via GTextEditor::set_document().

The editors have independent cursors and selection, but all changes
are shared, and immediately propagate to all editors.

This is very unoptimized and will do lots of unnecessary invalidation,
especially line re-wrapping and repainting over and over again.
2019-10-27 19:36:59 +01:00
Andreas Kling
f96c683543 LibGUI: Move visual line metadata from GTextDocument to GTextEditor
This patch decouples GTextDocument and GTextDocumentLine from the line
wrapping functionality of GTextEditor.

This should basically make it possible to have multiple GTextEditors
editing the same GTextDocument. Of course, that will require a bit more
work since there's no paint invalidation yet.
2019-10-27 18:00:07 +01:00
Andreas Kling
f1c6193d6d LibGUI: Move GTextDocument out of GTextEditor
The idea here is to decouple the document from the editor widget so you
could have multiple editors being views onto the same document.

This doesn't work yet, since the document and editor are coupled in
various ways still (including a per-line back-pointer to the editor.)
2019-10-27 16:44:16 +01:00
Andreas Kling
de2b25e2c1 LibGUI: Move GTextRange and GTextPosition to their own header files 2019-10-27 11:23:53 +01:00
Andreas Kling
db5178fb8f GTextEditor: Double-clicking on a span should select the span
This makes double-clicking on a C++ token in HackStudio select the
whole token, which is pretty nice. It's not perfect in all cases,
but a lot nicer than just expanding until we hit whitespace. :^)
2019-10-27 11:18:19 +01:00
Andreas Kling
8fa466e496 GTextEditor: Backspace over soft tabs
This makes the backspace erase backwards until the next soft tab stop.
We currently always use 4 as the soft tab width, but I suppose we could
make it configurable at some point. :^)
2019-10-27 10:42:48 +01:00
Andreas Kling
4089690cf1 GFilePicker: Allow overriding the window title for get_open_filepath() 2019-10-26 21:42:34 +02:00
Andreas Kling
b513a787fb GTextEditor: set_text() should clear any existing spans 2019-10-26 20:21:12 +02:00
Andreas Kling
cdac60e876 LibHTML: Make <header> and <footer> be "display: block" by default
This makes http://www.motherfuckingwebsite.com/ readable :^)
2019-10-26 15:40:51 +02:00
Andreas Kling
bc2026d26d LibGUI: Make GTextEditor::Span have a range instead of two positions
A GTextRange is really just two GTextPositions (start and end) anyway.
This way we can say nice things like "if (range.contains(position))"
2019-10-26 15:33:19 +02:00
Andreas Kling
4fa8acf6ea GTextEditor: The Home key should jump to the first non-space character
Press Home twice to get to column 0. This feels way more natural.
2019-10-26 14:02:39 +02:00
Andreas Kling
532001f4c1 GTextEditor: Arrow keys should only modify selection when Shift is held 2019-10-26 14:01:53 +02:00
Andreas Kling
98a6149b4f LibGUI: Make GWindow drive relayout and do it recursively
Instead of only doing a relayout in the widget you're invalidating,
we now do a recursive top-down relayout so everything gets updated.

This fixes invalid results after updating a preferred size in some
situations with nested layouts.
2019-10-26 12:28:54 +02:00
Andreas Kling
59107a7cfe GTextEditor: Allow setting a custom font for each span 2019-10-26 00:13:07 +02:00
Andreas Kling
0d53d74d5f GTextEditor: Add a "span" mechanism for having custom-style text ranges
It's now possible to give GTextEditor a vector of Span objects.
Spans currently tell the editor which color to use for each character
in the span. This can be used to implement syntax highlighting :^)
2019-10-25 21:07:02 +02:00
Brandon Scott
51e655f903 LibGUI: Added window creation callback to GApplication/GWindow
Added a window creation callback to GApplication that gets called
by GWindow which will reset any pending exit request in the
CEventLoop.

This is to prevent a bug which prevents your application from
starting up if you had a message box or other dialog before
showing your main application form. The bug was triggered by
there being no more visible windows which was triggering a
premature quit().
2019-10-25 15:29:19 +02:00
Brandon Scott
5311f8fae1 LibCore: Added unquit() method to CEventLoop.
Added an unquit() method to CEventLoop allowing you to cancel a
pending exit request.
2019-10-25 15:29:19 +02:00
Vincent Sanders
1be4c6e9cf LibC: Stop stdio from adding null terminators out of bounds (#685)
When using the bounded string operations (e.g. snprintf), the null
terminator was always being written even if there was no space for
it (or indeed any valid buffer at all)

This overwriting caused segmentation faults and memory corruption
2019-10-24 14:12:37 +02:00
Brandon Scott
a1c89c2734 LibGUI: Add very limited multi-label support to GStatusBar
Created a constructor argument and getter/setter methods to allow
you to have a multi-label status bar.
2019-10-24 09:57:27 +02:00
Andreas Kling
41289e652f GWidget: On second thought, don't assert on negative sizes in rects
Just neutralize incoming negative-size rects in set_relative_rect().
2019-10-23 20:50:01 +02:00
Andreas Kling
b916e34fed LibGUI: GTabWidget should not set children to have negative size
This could happen if a child was added to a GTabWidget before the
GTabWidget had its first layout.

Also add an assertion to catch this in GWidget::set_relative_rect()
since it was not immediately obvious what was happening.
2019-10-23 19:51:09 +02:00
Andrew Kaster
98c86e5109 Kernel: Move E2BIG calculation from Thread to Process
Thread::make_userspace_stack_for_main_thread is only ever called from
Process::do_exec, after all the fun ELF loading and TSS setup has
occured.

The calculations in there that check if the combined argv + envp
size will exceed the default stack size are not used in the rest of
the stack setup. So, it should be safe to move this to the beginning
of do_exec and bail early with -E2BIG, just like the man pages say.

Additionally, advertise this limit in limits.h to be a good POSIX.1
citizen. :)
2019-10-23 07:45:41 +02:00
Andreas Kling
5a83e053b3 LibVT: Make inject_string() a public API so clients can use it
This API allows you to add arbitrary input at the current cursor
position. You can even do escape sequences! :^)
2019-10-22 22:14:36 +02:00
Andreas Kling
cd1eee6604 LibVT+Terminal: Give TerminalWidget a hook for EOF on the pty
Instead of quitting the application immediately when the pty gives an
EOF, fire an on_command_exit hook so the TerminalWidget client can
decide for himself what to do.
2019-10-22 21:57:53 +02:00
Andreas Kling
31b5047894 LibGUI: Allow override the font on a per-index basis in GListView
This should be ported to all of the GAbstractView subclasses.
2019-10-22 21:38:04 +02:00
Andreas Kling
b89f64cb55 LibGUI: Make it possible to wrap a Font in a GVariant 2019-10-22 21:37:11 +02:00
Andreas Kling
e9f6e1e287 LibVT+Terminal: Don't set window title directly from TerminalWidget
Instead, have TerminalWidget provide an on_title_change hook.
This allows embedders to decide for themselves what to do if we receive
a "set terminal title" escape sequence.
2019-10-21 22:07:59 +02:00
Andreas Kling
da0958a882 LibVT: Make TerminalWidget's automatic size policy updates optional
When embedding a TerminalWidget, you might not want it to automatically
update its own size policy based on the exact terminal buffer size.

This behavior is now passed as a flag to the TerminalWidget constructor
which makes it behave nicely both inside HackStudio and in Terminal.
2019-10-21 20:28:30 +02:00