822 Commits

Author SHA1 Message Date
Jonathan Marler
e1996ad1e5 os: remove UB, tmpDir is returning stack memory on Windows
On Windows, the tmpDir function is currently using a buffer on the stack
to convert the WTF16-encoded environment variable value "TMP" to utf8
and then returns it as a slice...but that stack buffer is no longer valid
when the function returns.  This was causing the "image load...temporary
file" test to fail on Windows.

I've updated the function to take an allocator but it only uses
the allocator on Windows.  No allocation is needed on other platforms
because they return environment variables that are already utf8 (ascii)
encoded, and the OS pre-allocates all environment variables in the process.
To keep the conditional that determines when allocation is required, I
added the `freeTmpDir` function.
2024-02-10 21:09:05 -07:00
Mitchell Hashimoto
004405ccf9 terminal: only apply VS15/16 to emoji
Fixes #1482
2024-02-10 17:26:45 -08:00
Mitchell Hashimoto
f7c945c4a7 Merge pull request #1494 from mitchellh/grapheme-break
Optimized grapheme break detection (6x speedup)
2024-02-10 07:54:06 -08:00
Mitchell Hashimoto
6f8b4204b9 terminal: use new grapheme break algo 2024-02-09 20:31:20 -08:00
Gregory Anders
21412847c7 Reset status display after a full reset 2024-02-09 15:50:50 -06:00
Mitchell Hashimoto
fc459ad827 Merge pull request #1486 from mitchellh/unilut
Use precomputed lookup tables for even faster codepoint width computations
2024-02-08 21:51:33 -08:00
Mitchell Hashimoto
8d891fb05c terminal: fast-path ASCII on char width 2024-02-08 21:28:14 -08:00
Mitchell Hashimoto
c838bfc1c1 terminal: swap to table implementatino 2024-02-08 21:17:30 -08:00
Qwerasd
777ecffe6b fix(terminal/stream): fix OOB read and integer overflow 2024-02-08 22:34:21 -05:00
Qwerasd
68c0813397 terminal/stream: Added ESC parsing fast tracks 2024-02-08 21:49:58 -05:00
Qwerasd
f8c544c119 terminal: stream/parser changes 2024-02-07 19:08:34 -05:00
Mitchell Hashimoto
ae50f2ec97 Merge pull request #1481 from mitchellh/codewidth
SIMD Codepoint Width Implementation
2024-02-07 15:35:20 -08:00
Mitchell Hashimoto
17dc64053e terminal: swap codepointwidth implementations 2024-02-07 09:38:17 -08:00
Qwerasd
343cb9a334 fix(terminal): send SI to execute instead of print 2024-02-07 00:14:54 -05:00
Mitchell Hashimoto
fdc67a08f4 terminal: add tests for incomplete utf-8, fix one bug 2024-02-06 08:45:41 -08:00
Qwerasd
689a521256 terminal: remove unused properties 2024-02-06 03:04:00 -05:00
Qwerasd
5769bb16dd fix(terminal): Fix boundary utf-8 decoding crash
Get rid of completePartialUtf8 and simply use the scalar parse (`.next`) to resolve boundary conditions instead.
2024-02-06 02:51:04 -05:00
Mitchell Hashimoto
dc6c52fac1 terminal: do not have the UTF8Decoder overhead if SIMD 2024-02-05 21:26:40 -08:00
Mitchell Hashimoto
12885a445a simd: remove old attempts 2024-02-05 21:22:27 -08:00
Mitchell Hashimoto
449d3b49a4 terminal: split input to fit output chunks 2024-02-05 21:22:27 -08:00
Mitchell Hashimoto
351d9eb402 terminal: use new VT simd to process slices 2024-02-05 21:22:27 -08:00
Mitchell Hashimoto
c751619b7e terminal: use highway-based indexOf to support all targets 2024-02-05 21:22:26 -08:00
Mitchell Hashimoto
36b0db2a72 pkg/highway 2024-02-05 21:22:26 -08:00
Mitchell Hashimoto
fc605c7865 terminal: fix import issue 2024-02-05 21:22:26 -08:00
Mitchell Hashimoto
62ce93dcff terminal: use SIMD w/ Neon to find ESC in VT streams 2024-02-05 21:22:25 -08:00
Mitchell Hashimoto
c042b052b2 simd: convert indexOf, mess around with simdvt 2024-02-05 21:22:04 -08:00
Mitchell Hashimoto
0c2a87e5fb terminal: small stylistic tweaks 2024-02-05 21:20:20 -08:00
Qwerasd
cd570890f6 remove commented out test 2024-02-05 23:32:47 -05:00
Qwerasd
846b3421e6 terminal: replace utf8 decoding with custom decoder in stream.zig
(Completely removed utf8 handling from Parser.zig)
2024-02-05 23:20:47 -05:00
Qwerasd
f165d36dd2 Add fast DFA utf-8 decoder implementation 2024-02-05 22:15:58 -05:00
Mitchell Hashimoto
986fa34d3e terminal: remove unused const 2024-02-02 13:28:19 -08:00
Mitchell Hashimoto
7aeb7c1a58 terminal: rename theme to color_scheme for dsr 2024-02-02 13:20:59 -08:00
Mitchell Hashimoto
6fe8376073 terminal: support mode 2031 2024-02-02 13:08:10 -08:00
Mitchell Hashimoto
ae8f5f3ceb core: colorSchemeCallback on surface, can report 2024-02-02 12:51:20 -08:00
Mitchell Hashimoto
3c26828a3f terminal: distinguish between DSRs with "?" and not 2024-02-02 12:42:22 -08:00
Mitchell Hashimoto
eb653907d6 config: grapheme-width-method sets mode 2027
Fixes #1403

This changes the behavior of `grapheme-width-method = unicode` to change
the default state of mode 2027 to true. Prior to this, setting this
config would force grapheme clustering regardless of mode 2027. Now,
this only sets the default and running TUI programs can disable it if
they want.
2024-02-02 12:13:13 -08:00
Mitchell Hashimoto
e5400bad06 config: add window-theme = auto for automatic choosing based on bg color 2024-02-01 20:49:28 -08:00
Jeffrey C. Ollie
67e347070d fix typo in CSI n handling 2024-02-01 10:50:49 -06:00
Mitchell Hashimoto
cd642eb100 Merge pull request #1405 from mitchellh/term-crash
terminal: avoid reading reset memory for preserving prompt
2024-01-28 09:04:04 -08:00
Mitchell Hashimoto
4b607a07fe terminal: avoid reading reset memory for preserving prompt
Fixes #1400
2024-01-28 08:58:43 -08:00
Mitchell Hashimoto
c871140419 terminal: handle SCOSC/SCORC
Fixes #1401

SCOSC is ambiguous with regards to DECSLRM. This commit copies the logic
of xterm: if left/right mode is enabled, then CSI S is always DECSLRM.
But if left/right mode is disabled then CSI S empty always uses SCOSC.

SCORC always works.
2024-01-28 08:04:14 -08:00
Mitchell Hashimoto
2d612ab168 terminal: preserve multi-point grapheme clusters on scrollback deletion
This codepath was not previously tested (an accident). Upon testing
this codepath its clear to see the logic was incorrect. When we have to
remove rows from our scrollback to fit new rows in the circular buffer,
we have to delete graphemes, but we were deleting them from the wrong
row offset.

For the row offset, we previously used the _active_ screen but the
proper offset is the _full_ screen. Tests verify.
2024-01-25 09:35:56 -08:00
Mitchell Hashimoto
238361698b kitty graphics: use internal ID for placements with ID 0
Fixes #1356 correctly.

This was previously fixed by #1360 which just assigned a random
placement ID. I asked the Kitty maintainer about this and this is not
the correct logic and the spec has been updated.

When a placement ID of zero is sent, we allow multiple placements but
use an internal, non-addressable placement ID. The issue with my
previous approach was someone with knowledge of internals (or luck)
could technically address the placement. This isn't allowed.
2024-01-24 22:17:13 -08:00
Mitchell Hashimoto
f445ee269f terminal: ignore change window title requests with invalid UTF-8 2024-01-23 11:52:56 -08:00
Mitchell Hashimoto
46dd6e6caf kitty graphics: assign automatic placement ID if p==0
Fixes #1356

As stated in the code, the specification itself doesn't explicitly
specify this behavior (as far as I can tell), but testing in Kitty
results in this working and I believe this is how they do it.
2024-01-22 15:51:51 -08:00
Mitchell Hashimoto
7c8b156960 kitty images: support pngs with greyscale/alpha (bpp=2)
Fixes #1355
2024-01-22 14:32:27 -08:00
Chris Marchesi
1b8b59538c Selection: don't alter x position when rectangle select is off viewport
This ensures that the start or end x values do not get adjusted when
they are off the viewport in rectangle select.

This also includes some tests for the toViewport method.

Fixes #1339.
2024-01-21 19:38:25 -08:00
Mitchell Hashimoto
628b54fbb5 Merge pull request #1344 from rockorager/reflow
reflow: respect wraparound mode when reflowing text
2024-01-21 09:12:18 -08:00
Mitchell Hashimoto
8b23d5c9ab terminal: handle wide character print at edge with wraparound disabled
Fixes #1343

If a wide character is found at the right edge of a terminal screen and
can't be printed without wrapping, the wide character is ignored. This
matches xterm behavior.

The one funky behavior is with grapheme clustering enabled and VS16
emoji. For VS16, we act as if VS16 was never received. This is not
specified in any way and no other terminal handles this correctly at the
time of authoring this so we're just making this up because it seems
most sensible.
2024-01-21 09:02:15 -08:00
Tim Culverhouse
6dcec75e32 reflow: add unit tests for wraparound mode
Add unit tests for resizing with wraparound on and off.
2024-01-21 07:02:06 -06:00