<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/terminal.h, branch 1.15.1</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.15.1</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.15.1'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2023-07-18T03:48:01Z</updated>
<entry>
<title>terminal: break out scaling factor updating, and reduce number of calls to render_resize()</title>
<updated>2023-07-18T03:48:01Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-07-17T14:21:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=21d99f8dced335826964ca96b8ba7ccac059e598'/>
<id>urn:sha1:21d99f8dced335826964ca96b8ba7ccac059e598</id>
<content type='text'>
Break out the logic that updates the terminal’s scaling factor value,
from render_resize(), to a new function, term_update_scale(). This
allows us to update the scaling factor without a full grid resize.

We also change how we pick the scaling factor (when fractional scaling
is not in use). Before, we’d use the highest scaling factor from all
monitors we were mapped on. Now, we use the scaling factor from the
monitor we were *last* mapped on.

Then, add a boolean parameter to term_set_fonts(), and when
false, *don’t* call render_resize_force().

Also change term_font_dpi_changed() to only return true if the font
was changed in any way.

Finally, rewrite update_term_for_output_change() to:

* Call term_update_scale() before doing anything else
* Call render_resize{,_force} *last*, and *only* if either the scale
  or the fonts were updated.

This fixes several things:

* A bug where we failed to update the fonts when fractional scaling
  was in use, and we guessed the initial scale/DPI wrong. The bug
  happened because updated the internal "preferred" scale value, and a
  later call to render_resize() updated the terminal’s scale value,
  but since that code path didn’t call term_font_dpi_changed() (and it
  shouldn’t), the fonts weren’t resized properly.

* It ensures we only resize the grid *once* when the scaling factor,
  or DPI is changed. Before this, we’d resize it twice. And this
  happened when e.g. dragging the window between monitors.
</content>
</entry>
<entry>
<title>term: font_dpi_changed: scale (and old_scale) are floating point</title>
<updated>2023-07-18T03:48:01Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-07-16T06:28:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=829353a5dad410ce9b6b1ca78f9d86beedc3a90e'/>
<id>urn:sha1:829353a5dad410ce9b6b1ca78f9d86beedc3a90e</id>
<content type='text'>
This should fix an issue where the font size wasn’t updated when
moving the window between outputs whose scaling factors match when
truncated.
</content>
</entry>
<entry>
<title>refactor: track current xcursor using an enum, instead of a char pointer</title>
<updated>2023-07-03T12:36:32Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-27T14:57:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ee794a121e4603d01fb662ad6d1f3b18b6937d2c'/>
<id>urn:sha1:ee794a121e4603d01fb662ad6d1f3b18b6937d2c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: re-scale images when the cell dimensions change</title>
<updated>2023-06-30T06:29:35Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-29T12:49:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=49fb0cf359bb2486bbdf58df62c66c890d7e31cd'/>
<id>urn:sha1:49fb0cf359bb2486bbdf58df62c66c890d7e31cd</id>
<content type='text'>
Before this patch, when the cell dimensions changed (i.e. when the
font size changes), sixel images were either removed (the new cell
dimensions are smaller than the old), or simply kept at their original
size (new cell dimensions are larger).

With this patch, sixels are instead resized. This means a
sixel *always* occupies the same number of rows and columns,
regardless of how much the font size is changed.

This is done by maintaining two sets of image data and pixman images,
as well as their dimensions. These two sets are the new ‘original’ and
‘scaled’ members of the sixel struct.

The "top-level" pixman image pointer, and the ‘width’ and ‘height’
members either point to the "original", or the "scaled" version.

They are invalidated as soon as the cell dimensions change. They, and
the ‘scaled’ image is updated on-demand (when we need to render a
sixel).

Note that the ‘scaled’ image is always NULL when the current cell
dimensions matches the ones used when emitting the sixel (to save
run-time memory).

Closes #1383
</content>
</entry>
<entry>
<title>sixel: special case parsing of images with an aspect ratio of 1:1</title>
<updated>2023-06-29T13:40:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-27T12:25:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3555e81fee4a069bf4886007082f676b8777f6f9'/>
<id>urn:sha1:3555e81fee4a069bf4886007082f676b8777f6f9</id>
<content type='text'>
Images with an aspect ratio of 1:1 are by far the most common (though
not the default).

It makes a lot of sense, performance wise, to special case
them.

Specifically, the sixel_add() function benefits greatly from this, as
it is the inner most, most heavily executed function when parsing a
sixel image.

sixel_add_many() also benefits, since allows us to drop a
multiplication. Since sixel_add_many() always called first (no other
call sites call sixel_add() directly), this has a noticeable effect on
performance.

Another thing that helps (though not as much), and not specifically
with AR 1:1 images, is special casing DECGRI a bit.

Up until now, it simply updated the current sixel parameter value. The
problem is that the default parameter value is 0. But, a value of 0
should be treated as 1. By adding a special ‘repeat_count’ variable to
the sixel struct, we can initialize it to ‘1’ when we see DECGRI, and
then simply overwrite it as the parameter value gets updated. This
allows us to drop an if..else when emitting the sixel.
</content>
</entry>
<entry>
<title>term: convert ‘scale’ to a float</title>
<updated>2023-06-29T13:38:22Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-22T12:21:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c1f374cc8dab121388669cee6df3e2d1c483d77f'/>
<id>urn:sha1:c1f374cc8dab121388669cee6df3e2d1c483d77f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: stop cropping images to the last non-transparent row</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-19T17:09:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=774570ec41a3c585f40b03467eaada786a2e97d3'/>
<id>urn:sha1:774570ec41a3c585f40b03467eaada786a2e97d3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>sixel: respect sixel aspect ratio</title>
<updated>2023-06-24T05:31:08Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-19T17:06:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d6d143e2a6916178d1ea74551617cf8a5cddc39e'/>
<id>urn:sha1:d6d143e2a6916178d1ea74551617cf8a5cddc39e</id>
<content type='text'>
That is, parse P1 when initializing a new sixel, and don’t ignore
pad/pad in the raster attributes command.

The default aspect ratio is 2:1, but most sixels will override it in
the raster attributes command (to 1:1).
</content>
</entry>
<entry>
<title>term: add term_cursor_col()</title>
<updated>2023-06-20T12:55:32Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-16T14:33:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=24f12c7b5e753a5152eac44da9024954d43250e9'/>
<id>urn:sha1:24f12c7b5e753a5152eac44da9024954d43250e9</id>
<content type='text'>
Set cursor column, absolute.

term_cursor_to() needs to reload the current row pointer, and is thus
not very effective when we only need to modify the column.
</content>
</entry>
<entry>
<title>vt: split up action_param() to three separate functions</title>
<updated>2023-06-16T14:26:13Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-06-16T14:26:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d88bea5e22330c36c241ae0d441279799ac5897f'/>
<id>urn:sha1:d88bea5e22330c36c241ae0d441279799ac5897f</id>
<content type='text'>
We’re already switching on the next VT input byte in the state
machine; no need to if...else if in action_param() too.

That is, split up action_param() into three:

* action_param_new()
* action_param_new_subparam()
* action_param()

This makes the code cleaner, and hopefully slightly faster.

Next, to improve performance further, only check for (sub)parameter
overflow in action_param_new() and action_param_subparam().

Add pointers to the VT struct that points to the currently active
parameter and sub-parameter.

When the number of parameters (or sub-parameters) overflow, warn, and
then point the parameter pointer to a "dummy" value in the VT struct.

This way, we don’t have to check anything in action_param().
</content>
</entry>
<entry>
<title>term: protect against integer overflow when accumulating scroll damage</title>
<updated>2023-03-30T14:13:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-03-28T16:37:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=981e4b77cb96ab277ea3b7a1e8aebf0e4589c032'/>
<id>urn:sha1:981e4b77cb96ab277ea3b7a1e8aebf0e4589c032</id>
<content type='text'>
When accumulating scroll damage, we check if the last scroll damage’s
scrolling region, and type, matches the new/current scroll damage. If
so, the number of lines in the last scroll damage is increased,
instead of adding a new scroll damage instance to the list.

If the scroll damage list isn’t consumed, this build up of scroll
damage would eventually overflow.

And, even if it didn’t overflow, it could become large enough, that
when later used to calculate e.g. the affected surface area, while
rendering a frame, would cause an overflow there instead.

This patch fixes both issues by:

a) do an overflow check before increasing the line count
b) limit the line count to UINT16_MAX
</content>
</entry>
<entry>
<title>render: fix glitchy selection while resizing the ‘normal’ screen</title>
<updated>2023-03-27T14:53:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-03-27T14:53:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=296e75f4f54f56be7d36fcccb032dca9e5be959b'/>
<id>urn:sha1:296e75f4f54f56be7d36fcccb032dca9e5be959b</id>
<content type='text'>
The selection coordinates are in absolute row numbers. As such,
selection breaks when interactively resizing the normal grid, since we
then instantiate a temporary grid mapping directly to the current
viewport (for performance reason, to avoid reflowing the entire grid
over and over again).

Fix by stashing the actual selection coordinates, and ajusting the
"active" ones to the temporary grid.
</content>
</entry>
<entry>
<title>interactive resize: improve user experience</title>
<updated>2022-10-17T16:49:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-17T16:49:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0ac0d0647ae996bcef119d885cbd2d22a9940d8d'/>
<id>urn:sha1:0ac0d0647ae996bcef119d885cbd2d22a9940d8d</id>
<content type='text'>
Re-initialize the temporary ‘normal’ grid instance each time we
receive a configure event while doing an interactive resize.

This way, window content will not be "erased" when the window is first
made smaller, then larger again.

And, if the viewport is up in the scrollback history, increasing the
window size will reveal more of the scrollback, instead of just being
black.

The last issue is the cursor; it’s currently not "stuck" where it
should be. Instead, it follows the window around. This is due to two
things:

1) the temporary grid we create is large enough to contain the current
   viewport, but not more than that. That means we can’t "scroll up", to
   hide the cursor.

2) grid_resize_without_reflow() doesn’t know anything about
   "interactive resizing". As such, it will ensure the cursor is bound
   to the new grid dimensions.

I don’t yet have a solution for this. This patch implements a
workaround to at least reduce the impact, by simply hiding the cursor
while we’re doing an interactive resize.
</content>
</entry>
<entry>
<title>render: rename term-&gt;render.resizing -&gt; term-&gt;interactive_resizing</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-09T14:17:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=298f210ed93a83a531a44f772172da7f64510217'/>
<id>urn:sha1:298f210ed93a83a531a44f772172da7f64510217</id>
<content type='text'>
But also, more importantly, logical fixes:

* Stash the number of new scrollback lines the stashed ‘normal’ grid
  should be resized *to*.

There’s also a couple of performance changes here:

* When doing a delayed reflow (tiocswinsz timer), call
  sixel_reflow_grid(term, &amp;term-&gt;normal) - there’s no need to reflow
  sixels in the ‘alt’ screen.

* When doing a delayed reflow, free all scroll damage. It’s not
  needed, since we’re damaging the entire window anyway.

* Use minimum size for the temporary ‘normal’ grid (that contains the
  current viewport). We just need it to be large enough to fit the
  current viewport, and be a valid grid row count (power of 2). This
  just so happens to be the current ‘alt’ grid’s row count...
</content>
</entry>
<entry>
<title>term_ptmx_{pause,resume}: return success/fail</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-09T14:16:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c5c97c2fd4a674d0fcce16d40e0e56994195e9b0'/>
<id>urn:sha1:c5c97c2fd4a674d0fcce16d40e0e56994195e9b0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: resize: ignore ptmx read events during interactive resize</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-06T15:23:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f4f1989b6ef341557cc90a6805d745fef2a7a815'/>
<id>urn:sha1:f4f1989b6ef341557cc90a6805d745fef2a7a815</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: delay reflow for ‘resize-delay-ms’ milliseconds</title>
<updated>2022-10-10T15:19:17Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-05T15:05:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8179d73daa95dc3b3bdd76eaecc78e456bb4686a'/>
<id>urn:sha1:8179d73daa95dc3b3bdd76eaecc78e456bb4686a</id>
<content type='text'>
Reflowing a large scrollback is *slow*. During an interactive resize,
it can easily take long enough that the compositor fills the Wayland
socket with configure events. Eventually, the socket becomes full and
the compositor terminates the connection, causing foot to exit.

This patch is work-in-progress, and the first step towards alleviating
this.

It delays the reflow by:

* Snapshotting (copying) the original grid when an interactive resize
  is started.
* While resizing, we apply a simple truncation resize of the
  grid (like we handle the alt screen).
* When the resize is done, or paused for ‘resize-delay-ms’, the grid
  is reflowed.

TODO: we *must* not allow any changes to the temporary (truncated)
grid during the resize. Any changes to the grid would be lost when the
final reflow is applied. That is, we must completely pause the ptmx
pipe while a resize is in progress.

Future improvements:

The initial copy can be slow. We should be able to avoid it by
rewriting the reflow algorithm to not free anything. This is
complicated by the fact that some resources (e.g. sixel images) are
currently *moved* to the new grid. They’d instead have to be copied.
</content>
</entry>
<entry>
<title>render: apply a dimmed overlay while in Unicode input mode</title>
<updated>2022-08-08T14:31:28Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-08T14:31:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e249b52abd59024e0a933f93b458d7bf4e780222'/>
<id>urn:sha1:e249b52abd59024e0a933f93b458d7bf4e780222</id>
<content type='text'>
</content>
</entry>
<entry>
<title>osc: add support for OSC 133;A (prompt markers)</title>
<updated>2022-06-16T17:02:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-15T16:44:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=bdb79e8b9fb36f627bb204ce2060dd5a877f3712'/>
<id>urn:sha1:bdb79e8b9fb36f627bb204ce2060dd5a877f3712</id>
<content type='text'>
This patch adds support for the OSC-133;A sequence, introduced by
FinalTerm and implemented by iTerm2, Kitty and more. See
https://iterm2.com/documentation-one-page.html#documentation-escape-codes.html.

The shell emits the OSC just before printing the prompt. This lets the
terminal know where, in the scrollback, there are prompts.

We implement this using a simple boolean in the row struct ("this row
has a prompt"). The prompt marker must be reflowed along with the text
on window resizes.

In an ideal world, erasing, or overwriting the cell where the OSC was
emitted, would remove the prompt mark. Since we don't store this
information in the cell struct, we can't do that. The best we can do
is reset it in erase_line(). This works well enough in the "normal"
screen, when used with a "normal" shell. It doesn't really work in
fullscreen apps, on the alt screen. But that doesn't matter since we
don't support jumping between prompts on the alt screen anyway.

To be able to jump between prompts, two new key bindings have been
added: prompt-prev and prompt-next, bound to ctrl+shift+z and
ctrl+shift+x respectively.

prompt-prev will jump to the previous, not currently visible, prompt,
by moving the viewport, ensuring the prompt is at the top of the
screen.

prompt-next jumps to the next prompt, visible or not. Again, by moving
the viewport to ensure the prompt is at the top of the screen. If
we're at the bottom of the scrollback, the viewport is instead moved
as far down as possible.

Closes #30
</content>
</entry>
<entry>
<title>search: don't modify search.start coord *before* finding next match</title>
<updated>2022-04-21T16:54:27Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-21T16:54:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9907d7bbe956840d75630702b6f48ee5be60f61f'/>
<id>urn:sha1:9907d7bbe956840d75630702b6f48ee5be60f61f</id>
<content type='text'>
The match logic uses the last start coordinate to determine which end
points in the selection to update. This sometimes fails when the start
coordinate has been changed by e.g. a key binding - the new start
coordinate is incorrectly matched against the old-but-modified start
coordinate, causing foot to e.g. *not* upate the selection start
coordinate.

Example:

  $ echo 'test\n\test\ntest'

Then do a scrollback search for 'test. The first match is found
correctly (the last 'test'), but searching for the previous match
(ctrl+r) does not select the middle 'test'.

Fix by passing the search direction to search_find_next(), and have
_it_ calculate the coordinate to start search. There are three possibilities:

* forward
* backward
* "backward", but at the same position

The first two are used when searching for next/prev match with ctrl+s
and ctrl+r. The last one is used when the search criteria is
updated. In this case, we don't want to move to the previous match,
*unless* the current match no longer matches.
</content>
</entry>
</feed>
