aboutsummaryrefslogtreecommitdiff
path: root/grid.c (follow)
Commit message (Collapse)AuthorAgeLines
* Codespell fixesDaniel Eklöf2023-10-03-2/+2
|
* sixel: re-scale images when the cell dimensions changeDaniel Eklöf2023-06-30-14/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* fix typosHarri Nieminen2023-03-28-1/+1
|
* grid_free(): allow being called with grid == NULLDaniel Eklöf2022-10-18-0/+3
|
* grid: resize: assert grid->cur_row is not NULL after a grid resizeDaniel Eklöf2022-10-10-0/+4
|
* render: delay reflow for ‘resize-delay-ms’ millisecondsDaniel Eklöf2022-10-10-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* grid: reflow: assert there aren’t any open URIs on the last rowDaniel Eklöf2022-08-29-0/+15
|
* grid: reflow: don’t line-wrap the last rowDaniel Eklöf2022-08-29-21/+3
| | | | | | | | | | | | | | | | | | 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.
* grid: when setting the new viewport, ensure it’s correctly boundedDaniel Eklöf2022-08-29-17/+11
| | | | | | 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.
* grid: get rid of empty row at the bottom after reflowingDaniel Eklöf2022-08-05-0/+20
| | | | | | | | | | | | | | | | | | | | | | | 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
* grid: reflow: require col count > 0 when skipping line truncationDaniel Eklöf2022-06-30-1/+1
| | | | | | | | | | | | | | | | | | 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.
* Revert "grid: invert the default value of ‘linebreak’, from false to true"Daniel Eklöf2022-06-30-11/+3
| | | | This reverts commit cdd46cdf85b1087ac7465c646bb05078f1bbe85b.
* osc: add support for OSC 133;A (prompt markers)Daniel Eklöf2022-06-16-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* grid: reflow: don’t trim trailing empty cells from logical linesDaniel Eklöf2022-06-11-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* grid: invert the default value of ‘linebreak’, from false to trueDaniel Eklöf2022-06-11-3/+11
|
* grid: add abs-to-sb and sb-to-abs utility functionDaniel Eklöf2022-04-25-0/+28
| | | | | | | | | | | | | | | | | These functions convert row numbers between absolute coordinates and “scrollback relative” coordinates. Absolute row numbers can be used to index into the grid->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.
* grid: reflow: add TODO to detect selection on re-used rows, and cancel itDaniel Eklöf2022-02-07-0/+7
|
* replace gettimeofday with clock_gettimePranjal Kole2022-01-15-9/+9
| | | | | | | | | | | | | 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.
* grid: reload pointers into the uri range vector after insertingDaniel Eklöf2021-12-08-2/+40
| | | | | | | 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.
* grid: uri_range_erase(): unittest: try erasing a row without any URIsDaniel Eklöf2021-11-28-0/+4
|
* grid: uri_range_erase: walk the ranges backwardsDaniel Eklöf2021-11-28-5/+4
| | | | | This way, ranges are deleted last-to-first, thus avoiding memmoving multiple ranges over and over again when erasing e.g. a full line.
* grid: remove useless assertionDaniel Eklöf2021-11-27-1/+0
| | | | grid.c:1041:24: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
* grid: resize without reflowing: use URI range utility functionsDaniel Eklöf2021-11-27-10/+13
|
* grid: uri_range_{append,insert}: pass range attributes as separate parametersDaniel Eklöf2021-11-27-64/+54
|
* grid: snapshot: use uri range utility functionsDaniel Eklöf2021-11-27-19/+14
|
* grid: uri_range_ensure_size(): add the requested amount of entriesDaniel Eklöf2021-11-27-1/+1
|
* grid: reflow: no need to keep a uri-range-idx variableDaniel Eklöf2021-11-26-14/+10
| | | | | | | | | The URI ranges are now an array, which means we can get the next URI range by incrementing the pointer. Instead of checking if range is not NULL, check that it isn’t the range terminator (which is NULL when we don’t have any ranges, and the first address *after* the last range otherwise).
* grid: resize without reflow: only verify URI ranges in debug buildsDaniel Eklöf2021-11-26-0/+2
|
* grid: bug: OSC-8 URIs were incorrectly skipped while resizing the alt screenDaniel Eklöf2021-11-26-1/+1
|
* osc8: replace grid_row_uri_range_add() with internal uri_range_append()Daniel Eklöf2021-11-26-151/+138
| | | | | | | | grid_row_uri_range_add() was only used while reflowing. In this case, we know the new URIs being added are always going at the end of the URI list (since we’re going top-to-bottom, left-to-right). Thus, we don’t need the insertion logic, and can simply append instead.
* osc8: uri ranges: use a dynamically re-sizable array instead of a tllistDaniel Eklöf2021-11-26-107/+295
|
* osc8: update URI ranges as we print data, *not* when the URI is closedDaniel Eklöf2021-11-25-35/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | At first, an OSC-8 URI range was added when we received the closing OSC-8 escape (i.e. with an empty URI). But, this meant that cursor movements while the OSC-8 escape was in effect wasn’t handled correctly, since we’d add a range that spanned the cursor movements. Attempts were made to handle this in the cursor movement functions, by closing and re-opening the URI. However, there are too many corner cases to make this a viable approach. Scrolling is one such example, line-wrapping another. This patch takes a different approach; emit, or update the URI range when we print to the grid. This models the intended behavior much more closely, where an active OSC-8 URI act like any other SGR attribute - it is applied to all cells printed to, but otherwise have no effect. To avoid killing performance, this is only done in the “generic” printer. This means OSC-8 open/close calls must now “switch” the ASCII printer. Note that the “fast” printer still needs to *erase* pre-existing OSC-8 URIs. Closes #816
* grid: refactor grid_row_uri_range_erase()Daniel Eklöf2021-11-21-43/+32
| | | | | | | | | | | | | | | | | | | | The old algorithm always created a new URI, followed by (maybe) removing the existing URI, when an URI needed to be modified. That is, if e.g. the tail of an URI was being erased, the old algorithm would create a new URI for the part of the URI that should remain, and then removed the old URI. This isn’t very effective. The new algorithm instead identifies all possible overlap cases, and handles each one differently: * URI ends *before* erase range starts - continue with the next URI without further checks * URI starts *after* the erase range ends - return, we’re done * Erase range erases the entire URI - remove the URI * Erase range erases a part in the middle - split the URI * Erase range erases the head of the URI - adjust the URI’s start * Erase range erases the tail of the URI - adjust the URI’s end
* grid: row_uri_range_erase(): assume caller has checked row->extra != NULLDaniel Eklöf2021-11-21-2/+1
|
* grid: add grid_row_uri_range_erase()Daniel Eklöf2021-11-21-5/+151
| | | | | | | | | This function handles erasing of an URI range. That is, a range of the row is being either erased, or overwritten (from the URI perspective, these two are the same thing). We handle both partial overwrites (split up, or truncate URI), as well as complete overwrites (remove URI).
* composed: store compose chains in a binary search treeDaniel Eklöf2021-06-24-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation stored compose chains in a dynamically allocated array. Adding a chain was easy: resize the array and append the new chain at the end. Looking up a compose chain given a compose chain key/index was also easy: just index into the array. However, searching for a pre-existing chain given a codepoint sequence was very slow. Since the array wasn’t sorted, we typically had to scan through the entire array, just to realize that there is no pre-existing chain, and that we need to add a new one. Since this happens for *each* codepoint in a grapheme cluster, things quickly became really slow. Things were ok:ish as long as the compose chain struct was small, as that made it possible to hold all the chains in the cache. Once the number of chains reached a certain point, or when we were forced to bump maximum number of allowed codepoints in a chain, we started thrashing the cache and things got much much worse. So what can we do? We can’t sort the array, because a) that would invalidate all existing chain keys in the grid (and iterating the entire scrollback and updating compose keys is *not* an option). b) inserting a chain becomes slow as we need to first find _where_ to insert it, and then memmove() the rest of the array. This patch uses a binary search tree to store the chains instead of a simple array. The tree is sorted on a “key”, which is the XOR of all codepoints, truncated to the CELL_COMB_CHARS_HI-CELL_COMB_CHARS_LO range. The grid now stores CELL_COMB_CHARS_LO+key, instead of CELL_COMB_CHARS_LO+index. Since the key is truncated, collisions may occur. This is handled by incrementing the key by 1. Lookup is of course slower than before, O(log n) instead of O(1). Insertion is slightly slower as well: technically it’s O(log n) instead of O(1). However, we also need to take into account the re-allocating the array will occasionally force a full copy of the array when it cannot simply be growed. But finding a pre-existing chain is now *much* faster: O(log n) instead of O(n). In most cases, the first lookup will either succeed (return a true match), or fail (return NULL). However, since key collisions are possible, it may also return false matches. This means we need to verify the contents of the chain before deciding to use it instead of inserting a new chain. But remember that this comparison was being done for each and every chain in the previous implementation. With lookups being much faster, and in particular, no longer requiring us to check the chain contents for every singlec chain, we can now use a dynamically allocated ‘chars’ array in the chain. This was previously a hardcoded array of 10 chars. Using a dynamic allocated array means looking in the array is slower, since we now need two loads: one to load the pointer, and a second to load _from_ the pointer. As a result, the base size of a compose chain (i.e. an “empty” chain) has now been reduced from 48 bytes to 32. A chain with two codepoints is 40 bytes. This means we have up to 4 codepoints while still using less, or the same amount, of memory as before. Furthermore, the Unicode random test (i.e. write random “unicode” chars) is now **faster** than current master (i.e. before text-shaping support was added), **with** test-shaping enabled. With text-shaping disabled, we’re _even_ faster.
* grid: reflow: ‘amount’ has already been added to ‘from’Daniel Eklöf2021-06-02-1/+1
|
* grid: reflow: URI range start: take over ownership of URI stringDaniel Eklöf2021-06-02-1/+2
| | | | | Instead of strdup:ing the URI, take over ownership. This is ok since the old URI range will be free:d anyway.
* grid: reflow: debug loggingDaniel Eklöf2021-06-02-12/+18
|
* grid: reflow: when determining row end coord, check *last* URI rangeDaniel Eklöf2021-06-02-1/+5
|
* grid: reflow: when determining row end coord, check *last* tracking pointDaniel Eklöf2021-06-02-2/+10
|
* grid: reflow: check the *entire* row for non-empty cellsDaniel Eklöf2021-06-02-1/+1
|
* grid: reflow: avoid unnecessary if-statements before chunking a rowDaniel Eklöf2021-06-02-8/+13
|
* grid: disable reflow timing by defaultDaniel Eklöf2021-06-02-1/+1
|
* grid: reflow: commentsDaniel Eklöf2021-06-02-1/+22
|
* grid: no need to keep the tp_col/uri_col variables aroundDaniel Eklöf2021-06-02-6/+3
|
* grid: fix col max calculation when row contains URI rangesDaniel Eklöf2021-06-02-1/+1
|
* grid: set tp/uri break flags explicitly when we know them to be trueDaniel Eklöf2021-06-02-6/+12
|
* grid: reflow: slightly simplified logic for end-coordinate calculationDaniel Eklöf2021-06-02-10/+8
|
* grid: reflow: rename _range -> rangeDaniel Eklöf2021-06-02-16/+16
|
* grid: reflow: remove dead codeDaniel Eklöf2021-06-02-135/+0
|
* grid: reflow: memcpy() chunks of cells, instead of single cell-by-cellDaniel Eklöf2021-06-02-1/+159
| | | | | | | | | | | | | | | | | | | | Instead of walking the old grid cell-by-cell, and checking for tracking points, OSC-8 URIs etc on each cell, memcpy() sequences of cells. For each row, find the end column, by scanning backward, looking for the first non-empty cell. Chunk the row based on tracking point coordinates. If there aren’t any tracking coordinates, or OSC-8 URIs on the current row, the entire row is copied in one go. The chunk of cells is copied to the new grid. We may have to split it up into multiple copies, since not all cells may fit on the current “new” row. Care must also be taken to not line break in the middle of a multi-column character.
* grid: don’t cut multi-column chars in half when resizing the alt screenDaniel Eklöf2021-06-02-1/+5
| | | | | | | | When we resize the alt screen, we don’t reflow the text, we simply truncate all the lines. When doing this, make sure we don’t truncate in the middle of a multi-column character.
* grid: reflow: uri-ranges: avoid looping URI ranges when reflowingDaniel Eklöf2021-05-23-54/+57
| | | | | | | | | | | | | | | | | | | | Since we know the following: * URI ranges are sorted * URI coordinates are unique * URI ranges don’t cross rows We can optimize URI range reflowing by: * Checking if the *first* URI range’s start coordinate is on the current column. If so, keep a pointer to it. * Use this pointer as source when instantiating the reflowed URI range * If we already have a non-NULL range pointer, check its end coordinate instead. * If it matches, close the *last* URI range we inserted on the new row, and free/remove the range from the old row. * When line breaking, we only need to check if the *last* URI range is unclosed.
* grid: row_add_uri_range: ensure the URIs are sortedDaniel Eklöf2021-05-22-1/+7
|
* grid: disable timing of resize operationsDaniel Eklöf2021-05-17-1/+1
|
* grid: reflow: free old rows as soon as we’re done with themDaniel Eklöf2021-05-17-3/+8
| | | | | | This reduces the memory cost of reflowing text, as we no longer needs to hold both the old and the new grid, in their entirety, in memory at the same time.
* grid: reflow: don’t initialize newly allocated rowsDaniel Eklöf2021-05-17-3/+9
| | | | | | | | | | | | | We’re going to write to it immediately anyway. In most cases, *all* newly allocated, and zero-initialized, cells are overwritten. So let’s skip the zero-initialization of the new cells. There are two cases where we need to explicitly clear cells now: * When inserting a hard line break - erase the remaining cells * When done, the *last* row may not have been completely written - erase the remaining cells
* grid: reflow: qsort_r() is not portableDaniel Eklöf2021-05-15-11/+15
| | | | Replace with qsort() + global variable. Not thread safe!
* grid: include <stdlib.h>, for qsort_r()Daniel Eklöf2021-05-15-0/+1
|
* grid: reflow: always run qsort_r(), handle rows == 0 in tp_cmp() insteadDaniel Eklöf2021-05-15-7/+5
|
* grid: take scrollback start into account when sorting the tracking points arrayDaniel Eklöf2021-05-15-9/+29
| | | | | | | | | | The row numbers in the tracking points are in absolute numbers. However, when we walk the old grid, we do so starting in the beginning of the scrollback history. We must ensure the tracking points are sorted such that the *first* one we see is the “oldest” one. I.e. the one furthest back in the scrollback history.
* grid: fix 32-bit compilationDaniel Eklöf2021-05-15-2/+4
|
* grid: reflow: tag tracking point if-statements with likely/unlikelyDaniel Eklöf2021-05-15-5/+5
|
* grid: reflow: use a sorted array for tracking pointsDaniel Eklöf2021-05-15-27/+66
| | | | | | | | | | | Instead of iterating a linked list of tracking points, for *each and every* cell in the old grid, use a sorted array. This allows us to step through the array of tracking points as we walk the old grid; each time we match a tracking point, we move to the next one. This means we only have to check a single tracking point for each cell.
* grid: reflow: no need to check for combining charactersDaniel Eklöf2021-05-14-21/+10
| | | | Since we no longer call wcwidth(), we don’t need the base character.
* grid: don’t depend on wcwidth()Daniel Eklöf2021-05-14-41/+45
| | | | | | | | | | | | | | | | Calling wcwidth() on every character in the entire scrollback history is slow. We already have the character width encoded in the grid; it’s in the CELL_SPACERs following a multi-column character. Thus, when we see a non-SPACER character, that isn’t in the last column, peek the next character. If it’s a SPACER, get the current characters width from it. The only thing we need the width for, is to be able to print padding SPACERS in the right margin, if the there isn’t enough space on the current row for the current character.
* term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definitionDaniel Eklöf2021-05-14-5/+5
| | | | | | | | | | | | | | | | | | | | | Instead of using CELL_SPACER for *all* cells that previously used CELL_MULT_COL_SPACER, include the remaining number of spacers following, and including, itself. This is encoded by adding to the CELL_SPACER value. So, a double width character will now store the character itself in the first cell (just like before), and CELL_SPACER+1 in the second cell. A three-cell character would store the character itself, then CELL_SPACER+2, and finally CELL_SPACER+1. In other words, the last spacer is always CELL_SPACER+1. CELL_SPACER+0 is used when padding at the right margin. I.e. when writing e.g. a double width character in the last column, we insert a CELL_SPACER+0 pad character, and then write the double width character in the first column on the next row.
* grid: add compile-time define to enable timing of the reflow operationDaniel Eklöf2021-05-14-0/+17
|
* grid: snapshot: don’t mark all cells as dirty - copy state from source gridDaniel Eklöf2021-02-26-3/+1
|
* csi: remove extra ‘;’Daniel Eklöf2021-02-26-1/+1
|
* grid: snapshot: copy scroll damageDaniel Eklöf2021-02-26-0/+3
|
* grid: grid_free(): free scroll damage listDaniel Eklöf2021-02-26-0/+1
|
* grid: add grid_snapshot()Daniel Eklöf2021-02-26-0/+82
| | | | This function deep copies a grid into a newly *allocated* grid struct.
* grid: add grid_free()Daniel Eklöf2021-02-26-0/+14
|
* grid: reflow_uri_ranges(): URI end point is *inclusive*Daniel Eklöf2021-02-25-1/+1
| | | | | | | | | Which means, when we match URI start and end points against the current column index, we must *not* use ‘if...else if’, but two ‘if... if’. Fixes an assertion when resizing a window with an URI range of just one cell.
* grid: refactor: break out allocation of ‘extra’ member to separate functionDaniel Eklöf2021-02-21-2/+7
|
* grid: refactor: use grid_row_add_uri_range()Daniel Eklöf2021-02-21-12/+3
|
* grid: add new function grid_row_add_uri_range()Daniel Eklöf2021-02-21-0/+9
|
* grid: resize_without_reflow: allocate ‘extra’ on-demand on ‘new’ rowsDaniel Eklöf2021-02-21-1/+2
| | | | | Even if we have URI ranges on the old row, all those ranges may lay outside the new grid’s range.
* grid: grid_resize_without_reflow: transfer URI rangesDaniel Eklöf2021-02-21-1/+21
|
* grid: reflow: translate URI rangesDaniel Eklöf2021-02-21-22/+137
| | | | | | | | | | URI ranges are per row. Translate by detecting URI range start/end coordinates, and opening and closing a corresponding URI range on the new grid. We need to take care when line-wrapping the new grid; here we need to manually close the still-open URI ranges (on the new grid), and re-opening them on the next row.
* grid: grid_row_free(): use grid_row_reset_extra()Daniel Eklöf2021-02-21-7/+1
|
* grid: enable rows to have ‘extra’ data associated with themDaniel Eklöf2021-02-21-0/+9
| | | | | | | | | | | This patch adds an ‘extra’ member to the row struct. It is a pointer to a struct containing extra data to be associated with this row. Initially, this struct contains a list of URL ranges. These define (OSC-8) URLs on this row. The ‘extra’ data is allocated on-demand. I.e. the pointer is NULL by default; it is *not* allocated by grid_row_alloc().
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-10/+10
|
* Print stack trace on assert() failure or when calling fatal_error()Craig Barnes2021-01-16-1/+1
| | | | | | Note: this uses the __sanitizer_print_stack_trace() function from the AddressSanitizer runtime, so it only works when AddressSanitizer is in use.
* grid: resize_without_reflow: don’t call min() on every loop iterationDaniel Eklöf2020-11-25-1/+1
|
* resize: don’t reflow text on alt screenDaniel Eklöf2020-11-25-9/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Alt screen applications normally reflow/readjust themselves on a window resize. When we do it too, the result is graphical glitches/flashes since our re-flowed text is rendered in one frame, and the application re-flowed text soon thereafter. We can’t avoid rendering some kind of re-flowed frame, since we don’t know when, or even if, the application will update itself. To avoid glitches, we need to render, as closely as possible, what the application itself will render shortly. This is actually pretty simple; we just need to copy the visible content over from the old grid to the new grid. We don’t bother with text re-flow, but simply truncate long lines. To simplify things, we simply cancel any active selection (since often times, it will be corrupted anyway when the application redraws itself). Since we’re not reflowing text, there’s no need to translate e.g. the cursor position - we just keep the current position (but bounded to the new dimensions). Fun thing: ‘less’ gets corrupted if we don’t leave the cursor at the (new) bottom row. To handle this, we check if the cursor (before resize) is at the bottom row, and if so, we move it to the new bottom row. Closes #221
* sixel: implement reflowDaniel Eklöf2020-10-09-54/+1
| | | | | | | Move sixel reflow from grid_reflow() to sixel_reflow(). This lets us use internal sixel functions to update the sixels. Note that grid_reflow() still needs to remap the sixelss coordinates.
* grid: reflow: re-insert sixels *after* new grid offset has been setDaniel Eklöf2020-10-09-40/+51
| | | | | | Also make sure to destroy sixels that are too big to fit in the scrollback. Fixes issues with the sixel list not being sorted correctly.
* grid: reflow: fix release build; ‘idx’ is only used in an assert()Daniel Eklöf2020-09-29-1/+2
|
* grid: reflow: handle viewport being too far down when enlarging the windowDaniel Eklöf2020-09-29-2/+17
| | | | | | If the viewport is close to the bottom, but not *at* the bottom, and we’re enlarging the window, the translated viewport will be too far down.
* grid: reflow: retain scrollback positionDaniel Eklöf2020-09-29-1/+10
| | | | Closes #142
* grid: reflow: make sure cursor is within the visible screen areaDaniel Eklöf2020-09-10-6/+4
| | | | | | | | Even though we translate the cursor position from the old grid coordinates to the new, the cursor may _still_ end up outside the visible area. Make sure it doesn’t.
* grid: reflow: calculate width of composed characters correctlyDaniel Eklöf2020-09-06-4/+20
| | | | | Before this patch, reflow called `wcwidth()` on our magic values for composed characters.
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-4/+5
|
* grid: reflow: don't insert <width> spacer cells for *every* empty cellDaniel Eklöf2020-08-04-7/+8
| | | | Only do it for the last, non-empty cell.
* grid: reflow: use macro print_spacer() to insert multi-column character spacersDaniel Eklöf2020-07-14-8/+11
|
* grid: reflow: handle multi column character spacersDaniel Eklöf2020-07-14-2/+22
| | | | | | | | | Ignore *old* cells containing spacers. Pad new grid with spacers if a multi-column character doesn't fit at the end of a line. Insert spacers after a multi-column character.
* grid: reflow: always emit *all* cells of a multi-column characterDaniel Eklöf2020-07-14-1/+7
|