<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/grid.c, branch 1.14.0</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.14.0</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.14.0'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2023-03-28T21:45:18Z</updated>
<entry>
<title>fix typos</title>
<updated>2023-03-28T21:45:18Z</updated>
<author>
<name>Harri Nieminen</name>
<email>moiman@posteo.net</email>
</author>
<published>2023-03-28T21:31:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ae26915916731813edc2aefeb18a5754e8c79cd4'/>
<id>urn:sha1:ae26915916731813edc2aefeb18a5754e8c79cd4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid_free(): allow being called with grid == NULL</title>
<updated>2022-10-18T16:30:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-18T16:30:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c4f08a3b9a7c6d6fc27f68e5a5c273975d42de76'/>
<id>urn:sha1:c4f08a3b9a7c6d6fc27f68e5a5c273975d42de76</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: resize: assert grid-&gt;cur_row is not NULL after a grid resize</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-09T14:12:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=18ef36523f55cb8c8a6a9a9c3269274cc08c0a29'/>
<id>urn:sha1:18ef36523f55cb8c8a6a9a9c3269274cc08c0a29</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>grid: reflow: assert there aren’t any open URIs on the last row</title>
<updated>2022-08-29T19:03:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-29T19:03:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=454c82f0f59fea5307fbb570954db26f05ddbd09'/>
<id>urn:sha1:454c82f0f59fea5307fbb570954db26f05ddbd09</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: reflow: don’t line-wrap the last row</title>
<updated>2022-08-29T18:47:33Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-29T18:47:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5c86358cd1f830c01333326423f862879f9cd6a0'/>
<id>urn:sha1:5c86358cd1f830c01333326423f862879f9cd6a0</id>
<content type='text'>
Before this patch, we would line-wrap the last row, just like any
other row, and then afterwards try to reverse this, by adjusting the
offset and free:ing and NULL:ing the "last row".

The problem with this is if the scrollback is full. In this case, the
row we’re freeing is the first row in the scrollback history. This
means we’ll crash as soon as the viewport is moved to the top of the
scrollback.

The fix is fairly, simple. Skip the post-processing logic, and instead
detect when we’re line-wrapping the last row, and skip the call to
line_wrap().

This way, the last row in the new grid corresponds to the last row in
the old grid.
</content>
</entry>
<entry>
<title>grid: when setting the new viewport, ensure it’s correctly bounded</title>
<updated>2022-08-29T18:46:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-29T18:46:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=13281f327bcbe4a4799bea2122b77829f0004774'/>
<id>urn:sha1:13281f327bcbe4a4799bea2122b77829f0004774</id>
<content type='text'>
Do this by using scrollback relative coordinates, and ensure the new
viewport is not larger than (grid_rows - screen_rows), as that would
mean the viewport crosses the scrollback wrap-around.
</content>
</entry>
<entry>
<title>grid: get rid of empty row at the bottom after reflowing</title>
<updated>2022-08-05T16:26:37Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-08-05T16:26:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=aaf5894ad9272698cfafeb8e299b925fb9554417'/>
<id>urn:sha1:aaf5894ad9272698cfafeb8e299b925fb9554417</id>
<content type='text'>
When the window is resized and we reflow the text, we ended up
inserting an empty row at the bottom.

This happens whenever the actual last row has a hard linebreak (which
almost always is the case); we then end the reflow with a line break,
causing an extra, empty, row to be allocated and inserted.

This patch fixes this by detecting when:

1) the last row is empty
2) the next to last row has a hard line break

In this case, we roll back the last line break, by adjusting the new
offset we just calculated, and free:ing the empty row.

TODO: it would be nice if we could detect this in the reflow loop
instead, and avoid doing the last line break all together. I haven’t
yet been able to find a way to do this correctly.

Closes #1108
</content>
</entry>
<entry>
<title>grid: reflow: require col count &gt; 0 when skipping line truncation</title>
<updated>2022-06-30T17:47:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-30T17:47:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0c60bb3f295936dff04f56d28ab5dcb4db898a54'/>
<id>urn:sha1:0c60bb3f295936dff04f56d28ab5dcb4db898a54</id>
<content type='text'>
When reflowing the grid, we truncate lines with a hard linebreak after
the last non-empty cell. This way we don’t reflow trailing empty cells
to a new line when resizing the window to a smaller size.

However, “logical” lines (i.e. those without a hard linebreak)
are *not* truncated. This is to ensure we don’t trim empty cells in
the middle of a logical line spanning multiple physical lines.

Since newly allocated rows are initialized with linebreak=false, we
need to ensure _those_ are still truncated - otherwise all that empty
space under the current prompt will be reflowed.

Note that this is a temporary workaround. The correct solution, I
think, is to track whether a line has been printed to or not, and
simply ignore (not reflow) lines that haven’t yet been touched.
</content>
</entry>
<entry>
<title>Revert "grid: invert the default value of ‘linebreak’, from false to true"</title>
<updated>2022-06-30T17:37:01Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-30T17:37:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=37f094280b06cf207b5720fa1a36ff7199225e6b'/>
<id>urn:sha1:37f094280b06cf207b5720fa1a36ff7199225e6b</id>
<content type='text'>
This reverts commit cdd46cdf85b1087ac7465c646bb05078f1bbe85b.
</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>grid: reflow: don’t trim trailing empty cells from logical lines</title>
<updated>2022-06-11T10:02:20Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-01T17:29:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9567694bab7149afbb4e4fcc4c754272a8d25aba'/>
<id>urn:sha1:9567694bab7149afbb4e4fcc4c754272a8d25aba</id>
<content type='text'>
When a line in the old grid (the one being reflowed) doesn’t have a
hard linebreak, don’t trim trailing empty cells.

Doing so means we’ll “compress” (remove) empty cells between text
if/when we revert to a larger window size.

The output from neofetch suffers from this; it prints a logo to the
left, and system information to the right. The logo and the system
info column is separated by empty cells (i.e. *not* spaces).

If the window is reduced in size such that the system info is pushed
to a new line, each logo line ends with a number of empty cells. The
next time the window is resized, these empty cells were
ignored (i.e. removed).

That meant that once the window was enlarged again, the system info
column was a) no longer aligned, and b) had been pulled closer to the
logo.

This patch doesn’t special case trailing empty cells when the line
being reflowed doesn’t have a hard linebreak. This means e.g. ‘ls’
output is unaffected.

Closes #1055
</content>
</entry>
<entry>
<title>grid: invert the default value of ‘linebreak’, from false to true</title>
<updated>2022-06-11T10:02:20Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-06-01T17:28:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=cdd46cdf85b1087ac7465c646bb05078f1bbe85b'/>
<id>urn:sha1:cdd46cdf85b1087ac7465c646bb05078f1bbe85b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: add abs-to-sb and sb-to-abs utility function</title>
<updated>2022-04-25T17:57:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-25T17:57:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b4f666118febfc95bf97e31aa1e39e3df9522dfa'/>
<id>urn:sha1:b4f666118febfc95bf97e31aa1e39e3df9522dfa</id>
<content type='text'>
These functions convert row numbers between absolute coordinates and
“scrollback relative” coordinates.

Absolute row numbers can be used to index into the grid-&gt;rows[] array.

Scrollback relative numbers are ordered with the *oldest* row first,
and the *newest* row last. That is, in these coordinates, row 0 is the
*first* (oldest) row in the scrollback history, and row N is the
*last* (newest) row.

Scrollback relative numbers are used when we need to sort things after
their age, when determining if something has scrolled out, or when
limiting an operation to ensure we don’t go past the scrollback
wrap-around.
</content>
</entry>
<entry>
<title>grid: reflow: add TODO to detect selection on re-used rows, and cancel it</title>
<updated>2022-02-07T14:06:55Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-02-07T12:57:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0800515c04ba52b5b31c43d326bd590fe6cb5954'/>
<id>urn:sha1:0800515c04ba52b5b31c43d326bd590fe6cb5954</id>
<content type='text'>
</content>
</entry>
<entry>
<title>replace gettimeofday with clock_gettime</title>
<updated>2022-01-15T16:05:45Z</updated>
<author>
<name>Pranjal Kole</name>
<email>pranjal.kole7@gmail.com</email>
</author>
<published>2022-01-15T09:26:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0da19a81bc9a94f83bfcf8c5af0e3571f751cf38'/>
<id>urn:sha1:0da19a81bc9a94f83bfcf8c5af0e3571f751cf38</id>
<content type='text'>
POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the
use of clock_gettime(2) instead.

CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is
unaffected by manual changes in the system clock. This makes it better
for our purposes, namely, measuring the difference between two points in
time.

tv_sec has been casted to long in most places since POSIX does not
define the actual type of time_t.
</content>
</entry>
<entry>
<title>grid: reload pointers into the uri range vector after inserting</title>
<updated>2021-12-08T16:41:29Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-12-08T16:41:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2e8c9c2fe5bc393c1f7d931b78ab671cef91b277'/>
<id>urn:sha1:2e8c9c2fe5bc393c1f7d931b78ab671cef91b277</id>
<content type='text'>
Inserting elements into the URI range vector typically triggers a
vector resize. This is done using realloc(). Sometimes this causes the
vector to move, thus invalidating all existing pointers into the
vector.
</content>
</entry>
<entry>
<title>grid: uri_range_erase(): unittest: try erasing a row without any URIs</title>
<updated>2021-11-28T10:05:00Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-28T10:05:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2fe2dfa847a2fdc3563d53a1a1a81e1853868c4f'/>
<id>urn:sha1:2fe2dfa847a2fdc3563d53a1a1a81e1853868c4f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>grid: uri_range_erase: walk the ranges backwards</title>
<updated>2021-11-28T10:03:07Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-28T09:56:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=66b8c92c30667327ce7b5de3cbc068be67b3719a'/>
<id>urn:sha1:66b8c92c30667327ce7b5de3cbc068be67b3719a</id>
<content type='text'>
This way, ranges are deleted last-to-first, thus avoiding memmoving
multiple ranges over and over again when erasing e.g. a full line.
</content>
</entry>
<entry>
<title>grid: remove useless assertion</title>
<updated>2021-11-27T17:15:59Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-11-27T17:15:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=747da83c765d8df4c369d3a9bf82ea87ce9f1284'/>
<id>urn:sha1:747da83c765d8df4c369d3a9bf82ea87ce9f1284</id>
<content type='text'>
  grid.c:1041:24: warning: comparison of unsigned expression in ‘&gt;= 0’ is always true [-Wtype-limits]
</content>
</entry>
</feed>
