Commit Graph

4765 Commits

Author SHA1 Message Date
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
3fa16dfae2 HackStudio: "Go to line" was mixed up about 0/1-based line numbers 2019-10-21 20:33:47 +02:00
Andreas Kling
d1916700ea HackStudio: Restrict the "Go to line" shortcut to the text editor
We don't want Ctrl+L presses to be snatched while we're in the embedded
terminal, for example. :^)
2019-10-21 20:31:32 +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
Andreas Kling
43ccb28852 HackStudio: Embed a Terminal widget below the text editor
This will be very useful for running (and interacting with) programs
after we build them. :^)
2019-10-21 20:17:32 +02:00
Andreas Kling
5b30aa8b02 LibVT: Make TerminalWidget logically focusable when not a main widget
TerminalWidget was relying on the "window became active/inactive"
events from WindowServer to update its own internal focus state.

Unfortunately those events are only sent to the window's main widget,
so this was not working when the TerminalWidget was embedded deeper in
a widget tree.

This patch hooks the focusin and focusout events and uses those to
set the focus state when received. This makes TerminalWidget behave
nicely in both configurations. This design is kind of a workaround for
this awkward focus architecture and we should figure out something
better in the long term.
2019-10-21 20:14:51 +02:00
Andreas Kling
8b4903e733 LibVT: Move TerminalWidget from the Terminal app to here
It would be nice to be able to reuse this widget in other apps. :^)
2019-10-21 19:50:07 +02:00
Andreas Kling
c1f72e0bbf HackStudio: Show line numbers in the text editor by default 2019-10-21 19:03:09 +02:00
Andreas Kling
0a0dfeee8b LibGUI: Make GTextEditor::set_cursor() public
Also clamp the cursor value to the possible range instead of asserting
when trying to set a cursor past the end of the document.
2019-10-21 19:01:27 +02:00
Andreas Kling
7eed2e968c HackStudio: Show cursor line and column in the statusbar 2019-10-21 18:50:24 +02:00
Andreas Kling
0311e8d50a HackStudio: Start working on an IDE for SerenityOS
This will be fun. :^)
2019-10-21 18:46:55 +02:00
Andreas Kling
74bba649c3 LibCore: Make CFile::open() assert that the filename is non-null 2019-10-21 18:45:27 +02:00
Andreas Kling
835496375f URL: https:// URLs should default to port 443 2019-10-21 17:19:17 +02:00
Andreas Kling
9c434d8c6a JsonObject: Add JsonObject::has(key) 2019-10-21 14:47:18 +02:00
Andreas Kling
b74a433809 URL: Unbreak the serialization test
http:// URLs no longer include ":80" when serialized, since port 80 is
implied by the protocol. Non-standard ports are still serialized.
2019-10-21 14:46:36 +02:00
Andreas Kling
04b94a7695 LibHTML: <a href="#foo"> should prefer any element type with id=foo
It turns out that other engines also prefer <h1 id=x> over <a name=x>.
So we can just use get_element_by_id() directly without worrying about
the type of element we find.
2019-10-21 12:14:00 +02:00
Andreas Kling
8e710b16de LibHTML: Clicking on a fragment link should prefer <a id> over <a name>
It turns out that other engines prefer <a id> over <a name> when
deciding which anchor element to jump to.

This patch aligns LibHTML's behavior with WebKit and Gecko.

Thanks to "/cam 2" for bringing this up. :^)
2019-10-21 12:04:17 +02:00
Andreas Kling
4d9740ecef LibHTML: Add Document::get_element_by_id() and get_elements_by_name()
These will be useful for implementing various things. They don't do any
caching at the moment, but that might become valuable in the future.

To facilitate this change, I also made it possible to abort a tree walk
with for_each_in_subtree() by returning IterationDecision::Break from
the callback.
2019-10-21 12:01:30 +02:00
Brandon Scott
465a33443c HexEditor: Fix half byte offset bug
If you had made a change to the first 4 bits of a byte and then changed
your offset via keyboard or menu option it would change the last 4 bits
of the new offset the next time you made a change and would not show that
the byte had been changed at the new offset.
2019-10-21 09:45:21 +02:00
Brandon Scott
a76b02f741 HexEditor: Added navigate to a hex offset
Added the ability to navigate to a specified hex offset.
2019-10-21 09:45:21 +02:00
Brandon Scott
443eda986a HexEditor: Fixed off-by-one copying bug
When copying as hex or text we missed the last byte.
2019-10-21 09:45:21 +02:00
Brandon Scott
5cc722cec4 HexEditor: Reverse selections
Added the ability to select text and hex in reverse.
2019-10-21 09:45:21 +02:00
Andreas Kling
3bd29ad98c LibHTML: Remove trailing whitespace in line boxes
After the splitting-into-lines pass, remove any trailing whitespace
from all of a block's line boxes.

This improves the appearance of text-align: justify/right :^)
2019-10-20 17:20:20 +02:00
Andreas Kling
570c6c8458 LibM: Make roundf() and ceilf() slightly less terrible
These implementations still don't handle all of the corner cases that
are possible, but at least they are somewhat usable now.
2019-10-20 17:20:20 +02:00
Andrew Kaster
138abb9098 ELF: Fail layout when program header hooks return nullptr (#673)
ELFLoader::layout() had a "failed" variable that was never set. This
patch checks the return value of each hook (alloc/map section and tls)
and fails the load if they return null.

I also needed to patch Process so that the alloc_section_hook and 
map_section_hook actually return nullptr when allocating a region fails.

Fixes #664 :)
2019-10-20 16:24:42 +02:00
Andreas Kling
eb77e680ed LibHTML: Implement "text-align: justify"
In order for this to work nicely, I made the line box classes use float
instead of int for its geometry information.

Justification works by distributing all of the whitespace on the line
(including the trailing whitespace before the line break) evenly across
the spaces in-between words.

We should probably use floating point (or maybe fixed point?) for all
the layout metrics stuff. But one thing at a time. :^)
2019-10-20 12:55:55 +02:00
Andreas Kling
ea5da0f9b5 LibHTML: The CSS parser should tolerate whitespace-only stylesheets 2019-10-20 12:55:55 +02:00
Andreas Kling
9eaaaeec6e LibM: Add dummy implementations of roundf() and ceilf()
I though I could just use __builtin_roundf() and __builtin_ceilf() but
it seems like I can't, as they just become calls to roundf and ceilf.
2019-10-20 12:55:55 +02:00
Andreas Kling
14c8446ea4 LibDraw: Add FloatPoint, FloatSize and FloatRect
These are floating point varians of Point, Size and Rect.
2019-10-20 12:55:55 +02:00
Andreas Kling
457e49f528 LibHTML: Rename HTMLImageElement::m_image_loader => m_image_decoder
This matches the new class name, ImageDecoder.
2019-10-20 12:55:55 +02:00
Drew Stratford
58f67c1ccb Shell: Update termios settings to match line discipline.
Shell.cpp uses its own line discipline which handles
echoing and line editing. Because of this we disable
ICANON and ECHO so that we don't get duplicate characters
or weird line editing errors.

We also revert these settings just before running a command.
This is so that commands may run with proper line editing
and echoing.
2019-10-20 10:51:12 +02:00
Drew Stratford
4c35c8d7fd TTY: Implement Canonical mode and basic echoing.
The TTY driver now respects the ICANON flag, enabling basic line
editing like VKILL, VERASE, VEOF and VWERASE. Additionally,
ICANON is now set by default.

Basic echoing has can now be enabled via the ECHO flag, though
more complicated echoing like ECHOCTL or ECHONL has not been
implemented.
2019-10-20 10:51:12 +02:00
Drew Stratford
67041f3a8c AK: Add CircularDeque.
This class inherits from CircularQueue and adds the ability dequeue
from the end of the queue using dequeue_end().

Note that I had to make some of CircularQueue's fields protected to
properly implement dequeue_end.
2019-10-20 10:51:12 +02:00
Andreas Kling
f11c85f4a7 LibHTML: HtmlView only needs to store the main Frame, not the Document
Remove the Document pointer from HtmlView and always get to it through
the main Frame instead.

The idea here is to move towards HtmlView being higher-level than the
DOM stuff (as much as possible and practical.)
2019-10-20 10:36:14 +02:00
Andreas Kling
64ce453050 LibHTML: Only actually-linked <a> elements should be blue+underlined
Turns out this just needed a little push in the selector engine. :^)
2019-10-20 10:07:26 +02:00
Andreas Kling
c41bae3d54 LibHTML+Browser: Support scrolling to anchor with <a href="#foo">
This patch implements basic support for <a href="#foo"> fragment links.

To figure out where we actually want to scroll to, we have to do
something different based on the layout node's box type. So if it's a
regular LayoutBox we can just use the LayoutBox::position().

However, if it's an inline layout node, we use the position of the
first line box fragment in the containing block contributed by this
layout node or one of its descendants.
2019-10-20 10:07:26 +02:00
Andreas Kling
202dfbd6cd LibHTML: Add Element::name() convenience attribute getter 2019-10-20 10:07:26 +02:00
Tidux
d09a28856f Kernel: Move Boot/ into Arch/i386/Boot (#667) 2019-10-20 08:15:39 +02:00
Andreas Kling
8b07025145 LibHTML: Don't insert unnecessary line breaks at start of text lines
Basically the same exact fix as I did for replaced elements. There's no
point in inserting a line break at the start of a line if all you're
trying to achieve is make more horizontal space for something.
2019-10-19 21:34:15 +02:00
Andreas Kling
884ae80699 LibHTML+Browser: Show target URL of hovered links in Browser statusbar
HtmlView will now invoke the on_link_hover hook when the cursor enters
or leaves a DOM node that has an enclosing link element.

This patch also updates the meaning of Node::enclosing_link_element()
to find the nearest HTMLAnchorElementAncestor *with an href attribute*.
2019-10-19 21:25:49 +02:00
Andreas Kling
73af2f8d02 LibHTML: DOM fixup should handle a completely empty document
We were forgetting to check if there was even a first child of the
root Document node.
2019-10-19 21:20:42 +02:00
Andreas Kling
7b0f3b19df ls: Fix alignment of device files in long mode (ls -l) 2019-10-19 20:54:47 +02:00
Andreas Kling
8a3fabffb3 ls: Add -t and -r flags
-t: Sort by modification time (default is to sort by name)
-r: Reverse sort order

Note that these only apply when used together with -l (long mode.)
2019-10-19 20:54:47 +02:00
Andreas Kling
96f9e6a64f String: Define operator>(String) 2019-10-19 20:54:47 +02:00
Andreas Kling
fbdd0def47 Terminal: Make Shift+PgUp/PgDown scroll the terminal up/down one page
I keep doing this out of habit, expecting it to scroll, and now it
actually will scroll. :^)
2019-10-19 20:54:47 +02:00
Andreas Kling
b472229781 LibHTML: Do DOM tree fixup before firing insertion callbacks
There's no reason to run the callbacks before fixing up the tree.
2019-10-19 20:54:47 +02:00
Andreas Kling
f970578cd4 LibDraw: Rename ImageLoader => ImageDecoder
ImageLoader was not the right name for this, as there is no loading
happening, only decoding. :^)
2019-10-19 20:54:47 +02:00
Till Mayer
02e787f8a4 aplay: Fixed incomplete playback of files
aplay used to quit as soon as the last enqueue of new buffer data
was sucessful. Because the connection closes as soon as the
application quits, samples were still in the buffer of the
ASBufferQueue as playback was halted.
2019-10-19 20:05:13 +02:00
Till Mayer
406aabff23 AudioServer: Added ability to get count of samples in the buffer queue
Now the AClientConnection can get the count of samples still in the
buffer queue.
2019-10-19 20:05:13 +02:00
Till Mayer
8bb919d1cc ASMixer: Removed unused variable in ASBufferQueue
The variable m_playing_queued_buffer_id was defined but not used.
2019-10-19 20:05:13 +02:00