Commit graph

82 commits

Author SHA1 Message Date
Arda Cinar
25f1e81d62 LibVT: Handle utf-8 search strings in find
Instead of iterating through the needle being searched one byte at a
time (like an ascii string), we calculate its unicode code points first
and then iterate through those.
2023-02-05 13:50:38 +01:00
Tim Schumacher
82a152b696 LibGfx: Remove try_ prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit
it.
2023-01-26 20:24:37 +00:00
Andrew Kaster
ddf348daeb Everywhere: Use ElapsedTimer::elapsed_time() for comparisons
Simplify a lot of uses of ElapsedTimer by converting the callers to
elapsed_time from elapsed, as the AK::Time returned is better for unit
conversions and comparisons against constants.
2023-01-07 14:51:04 +01:00
Andreas Kling
c3018f8beb LibVT: Simplify TerminalWidget::widget_size_for_font()
Reuse the base size calculation from compute_base_size() instead of
duplicating it.
2023-01-06 12:02:20 +01:00
Andreas Kling
ddc0c13007 LibVT: Use font pixel height (pixel_size) when calculating line heights 2023-01-06 12:02:20 +01:00
Andreas Kling
2e1b8b90f4 LibVT: Compute the font metrics once and cache them
The height of a line or column doesn't change unless the font changes,
and we were already caching the line height. This patch extends it so
we also cache the column width.
2023-01-06 12:02:20 +01:00
Andreas Kling
b4946eac6e LibVT: Fix bug where terminal size got lost on font size change
When changing the font size, we now resize the terminal widget *before*
setting the font. This ensures that we keep the same logical terminal
size after the font change.
2023-01-06 12:02:20 +01:00
Andreas Kling
555d7a6fce LibGfx: Make Font::glyph_width*() APIs return float 2023-01-03 15:25:02 +01:00
Ben Wiederhake
6b7ce19161 Everywhere: Remove unused includes of LibC/stdlib.h
These instances were detected by searching for files that include
stdlib.h, but don't match the regex:

\\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_
uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex
it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs|
ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble
n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o
penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo
c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete
nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou
l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use anything from the stdlib.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00
implicitfield
800c292be8 Terminal+LibVT: Get the color scheme from the system theme 2022-12-31 04:20:59 -07:00
implicitfield
4aec8491d6 Everywhere: Move Base/res/terminal-colors to Base/res/color-schemes 2022-12-31 04:20:59 -07:00
MacDue
27fae78335 Meta+Userland: Pass Gfx::IntSize by value
Just two ints like Gfx::IntPoint.
2022-12-07 11:48:27 +01:00
MacDue
7be0b27dd3 Meta+Userland: Pass Gfx::IntPoint by value
This is just two ints or 8 bytes or the size of the reference on
x86_64 or AArch64.
2022-12-07 11:48:27 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Zaggy1024
52a5da51bf LibVT: Make shortcuts propagate completely before terminal input
This allows shorcuts to be used in the Terminal app rather than
processing the terminal input first and ignoring shortcuts after.
2022-11-14 16:08:11 +00:00
networkException
4230dbbb21 AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and
create_with_file_protocol() already. This patch removes these function
and updates all call sites to use the functions named according to the
specification.

See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-29 09:39:04 +01:00
Timothy Flynn
31b2d93038 LibGUI+LibVT: Notify widgets of emoji selection with a callback
Currently, LibGUI modifies the Ctrl+Alt+Space key event to instead
represent the emoji that was selected through EmojiInputDialog. This is
limited to a single code point.

For multiple code point emoji support, individual widgets now set a hook
to be notified of the emoji selection with a UTF-8 encoded string. This
replaces the previous set_accepts_emoji_input() method.
2022-09-11 20:33:57 +01:00
networkException
b29fbe96dd LibVT: Handle non file urls in on hover tooltips
Previously we would simply compute the basename of the hovered url's
path and display it as the resource that will be opened. This patch adds
a fallback for non file urls to simply show the full url, making http
urls show up properly.
2022-09-05 09:23:20 +01:00
Karol Kosek
1d9ec8bd56 LibVT: Accept supported drag enter events 2022-08-31 17:29:44 +01:00
Wuzado
d3cffcfee5 LibVT: Show application display name when hovered over, if available
Fixes #14416.
2022-07-14 13:11:48 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Michał Lach
e2b0f6795f LibVT+Kernel: Separate the caret shapes and its steadiness
Currently CursorStyle enum handles both the styles and the steadiness or
blinking of the terminal caret, which doubles the amount of its entries.
This commit changes CursorStyle to CursorShape and moves the blinking
option to a seperate boolean value.
2022-06-22 12:12:00 +01:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Ben Wiederhake
d13283f952 LibVT: Fix tooltip condition, properly reset when tooltip not available 2022-03-25 02:33:23 +01:00
Brian Gianforcaro
913374163c LibVT/Kernel: Make VT::Attribute::Flags enum class, use AK EnumBits
Noticed the TODO in `Attribute.h` and realized we have as solution
to this problem already. :^)
2022-03-18 11:29:43 +01:00
Lenny Maiorani
8b334248e4 Libraries: Use default constructors/destructors in LibVT
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
2022-03-13 22:34:38 +01:00
MacDue
8fbe96af45 LibVT: Use coarse scrolling animation in TerminalWidget
The smooth scrolling looks slightly off in the terminal as the
scrollbar animation lasts longer than the actual scroll.

This behaviour is also consistent with other terminal emulators.
2022-03-13 11:45:07 +01:00
networkException
3052c0578c LibVT: Properly populate context menu with open actions
We would previously overwrite m_hovered_href with tooltip texts instead
of leaving it as an url as was expected by the context menu event
handler.
2022-02-17 11:56:38 +01:00
Sam Atkins
8260135d4d LibCore+Everywhere: Return ErrorOr from ConfigFile factory methods
I've attempted to handle the errors gracefully where it was clear how to
do so, and simple, but a lot of this was just adding
`release_value_but_fixme_should_propagate_errors()` in places.
2022-02-16 19:49:41 -05:00
brapru
93496af02b LibVT: Fix triple click behavior
When triple clicking a line in the terminal the selection will span the
whole line. However, after dragging down to lines above/below the
selection will stop at the cursor.

Instead, the expected functionality of triple clicking and dragging is
to select the whole line and any whole lines dragged to after the triple
click.

Previously, the triple line counter would get reset as soon as the whole
line was selected. This patch resets the m_triple_click_timer in the
mouse up event, so that the triple click selecting functionality is
maintained during the entire click event and terminated when the event
is over.
2022-02-13 23:05:39 +01:00
Dmitry Petrov
1662213737 Userland: Add horizontal mouse scroll support 2022-01-20 10:37:52 +01:00
Matt Jacobson
87630c5fd5 LibVT: Don't clip TerminalWidget's drawing to avoid scroller
The scroller might be hidden or (in theory) non-opaque.
2022-01-15 19:47:53 -08:00
Brian Gianforcaro
0e26ba59f7 LibVT: Enable caller to control the visibility of the scrollbar widget
In preparation for another feature, expose an API so that any users of
this widget can control the scrollbar visibility.
2022-01-15 11:03:23 +01:00
Elyse
086615535f Everywhere: Use 'decrease_slider_by()' method from AbstractSlider
The same idea as 'increase_slider_by()', it helps us to avoid repeating
the pattern 'set_value(value() - delta)'.
2021-12-30 14:31:50 +01:00
Elyse
d53e1fa1fa Everywhere: Use 'increase_slider_by()' method from AbstractSlider
This method help us to avoid repeating the pattern
'set_value(value() + delta)'.
2021-12-30 14:31:50 +01:00
Andreas Kling
7d7950b322 LibVT: Don't leave 50ms auto-scroll timer running at all times
This timer was causing wake-ups every 50ms in all terminals, just to
right back to sleep unless we were in the middle of an auto-scroll.
2021-12-25 14:20:13 +01:00
ryanb-dev
3a6f550b24 Terminal: Fix broken selection after dbl/trp click
This commit resets the terminal triple click timer when appropriate.
2021-12-16 18:49:46 +01:00
Ben Wiederhake
f22c0ffe0c LibGUI+Everywhere: Make sync requests to Clipboard server more obvious 2021-11-21 11:49:06 +00:00
Ben Wiederhake
ff17f6877a LibVT: Make paste access to Clipboard atomic
This avoids data race issues and saves a synchronous request to
ClipboardServer.
2021-11-21 11:49:06 +00:00
David Lindbom
3c98a9430b LibVT: Show action of double click in tooltip
When hovering an item in Terminal we now show what application will
handle it, e.g "Open app-catdog.png in ImageViewer".

If the file is its own handler, i.e an executable, it will show
"Execute myscript.sh"
2021-11-13 23:33:46 +01:00
Andreas Kling
80d4e830a0 Everywhere: Pass AK::ReadonlyBytes by value 2021-11-11 01:27:46 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Filiph Sandström
d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03:00
brapru
b5f812d11d LibVT: Add movemouse support for triple click
When moving the mouse after a triple click, the selected buffer does not
maintain the whole line selection. This patch will allow triple click
highlighting to hold the whole line selection.
2021-09-19 20:28:09 +04:30
brapru
7a673f5aa3 LibVT: Keep track of the buffer postiion on mousedown events 2021-09-19 20:28:09 +04:30
Musab Kılıç
7f46022e66 LibVT: Execute DragOperation after resetting active hyperlink 2021-09-02 22:48:10 +02:00
Andreas Kling
82d8cd2b87 Terminal+LibVT: Use LibConfig instead of Core::ConfigFile 2021-08-26 00:54:27 +02:00