When growing the buffer, realloc was passed the element count instead of
the byte count, shrinking the buffer while capacity was set to the larger
value. Lines with more than 4096 codepoints (e.g. many combining chars)
would then write past the end of the allocation.
Fix dangling text pointer in buffered key events and test CSI param overflow
Key events buffered while waiting for an overlay to become ready stored
the text pointer from the GLFWkeyevent, which is only valid for the
duration of the key callback. Make the buffered events own a copy of
the text and free it in a single place.
Also add a test for the out of bounds write of is_sub_param when a
separator follows the last allowed CSI parameter.
A full screen reverse scroll (ESC M at the top, CSI T) moves every image
ref down a row. scroll_filter_func() only removed refs that left through
the top, so a cell image on the bottom line ended up at row `lines`, off
screen, while its line was discarded. The next forward scroll brought it
back onto the bottom row, where the line has no placeholders.
screen_render_line_graphics() returns early for such lines, so nothing
removed the ref and a slice of the old image was drawn over the new text.
tmux and pagers send ESC M when scrolling down, so this shows up in
practice. Fix it by dropping cell image refs that move below the bottom
margin, the same way the margins scroll path drops refs that leave the
region.
This replaces PR #10623, which was not merged for these reasons:
- It does not find the cause. It removes cell image refs at render time
for every line without placeholders, so the stale ref still exists and
is still seen by anything that reads refs before the next render, such
as graphics query and delete commands and the paused rendering path,
which returns before the new code.
- It costs time on every frame. Whenever any image is loaded, even with
no placeholders at all, each clean visible line and each visible
history line triggers a walk over all images and refs. Before, such
lines cost nothing. This fix adds one comparison to a loop that only
runs when the screen scrolls.
Close#10623
The scale between scaled and unscaled offsets was only calculated for
positive deltas, so when scrolling up or left it stayed at zero (or stale from
a previous scroll), causing momentum events to have zero offsets.
Closes#10610
Turn glfw touch events into mouse and scroll events. A tap is a left
click where the finger landed, a finger that moves scrolls through the
glfw momentum scroller so it coasts like touchpad scrolling, and a
finger held still before it moves drags the left button, selecting
text. Only the first finger of a sequence is used. Touch events are
printed by --debug-input.
The compensatory padding at the left and right of a window extends alongside
its title bar, but the padding shader only drew it alongside the rows of the
terminal screen, leaving the strips beside the title bar unpainted. Draw them
when rendering the title bar, colored to match the neighboring title bar cell.
Draw the compensatory padding (the pixels left over after fitting whole
cells) inside the window border instead of outside it, so the border is
always exactly one margin inside the area allocated to the window. Windows
that share an allocation edge now share a frame edge and all gaps are the
sum of the neighboring margins. Cell counts and content positions are
unchanged. Mouse hit testing includes the compensatory padding.
Move the compensatory padding away from the window title bar so the title
bar is always flush with the border, computing blank rects from the final
window geometries at the end of a layout pass.
Add the collapse_window_margins option to have the margins of neighboring
windows collapse into each other.
Fix the Grid layout not recording compensatory padding and ignoring
vertical placement_strategy values.
Based on #10508 without needing a constraint solver.
Allow creating docked windows with percentage or fixed sizes at any edge of a
window or tab. Fixes#2391
Also close#10506 and close#10508
The approach in #10506 was not used for several reasons.
1) Performance: this PR costs nothing when docs are unused vs several
milliseconds for the cassowary based approach
2) Way less code (700 lines total): No complicated solver (2K lines of code) needed
3) No risk behaviour changes for without docks
Follow up to the merge of PR #10560 which skips input_delay when less
than 1 KiB of program output is pending.
Fix a data race: the I/O thread called
vt_parser_pending_input_is_interactive() which read read.pos under the
parser lock, but the main thread modifies read.pos without the lock
while parsing, so taking the lock on one side only did not protect it.
Instead, vt_parser_commit_write() now returns whether the pending input
is small, computed from read.sz and write.pending, which are only
modified with the lock held. This may overestimate while a parse is in
progress or when an incomplete escape code is retained, in which case
we simply fall back to the normal input_delay behavior. It also saves a
lock/unlock cycle per read in the I/O thread.
Bound the number of early main loop wakeups: since render() bypasses
repaint_delay whenever input was read, input_delay was the effective
cap on parse/render frequency for streaming output. Waking the main
loop on every small read removed that cap entirely for programs that
emit a continuous stream of small writes, costing CPU and increasing
the chance of drawing partial screen updates. Now an early wakeup is
only allowed if the previous wakeup was not itself early, so typed
character echo is still delivered immediately while streams of small
writes get at most two wakeups per input_delay.
Replace the magic 1024 with SMALL_PENDING_INPUT_THRESHOLD, rename
pending_input_is_interactive() to pending_input_is_small() since the
check has nothing to do with interactivity, clarify the input_delay
option documentation and add a changelog entry.
find_matches_in_lines was passing the exclusive end offset of a match to
find_pos, so a match ending at the end of the joined screen lines mapped
to no line and was dropped. It was not highlighted, not counted and n/N
skipped it. Since screen lines are not padded, this hit any match on the
last character of a line, for example searching for foo in "x := foo".
Look up the line holding the last matched byte instead.