aboutsummaryrefslogtreecommitdiff
path: root/grid.c (follow)
Commit message (Collapse)AuthorAgeLines
* unicode-combining: store seen combining chains "globally" in the term structDaniel Eklöf2020-05-03-22/+1
| | | | | | | | | | | | | | | | | | | | Instead of storing combining data per cell, realize that most combinations are re-occurring and that there's lots of available space left in the unicode range, and store seen base+combining combinations chains in a per-terminal array. When we encounter a combining character, we first try to pre-compose, like before. If that fails, we then search for the current base+combining combo in the list of previously seen combinations. If not found there either, we allocate a new combo and add it to the list. Regardless, the result is an index into this array. We store this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell. When rendering, we need to check if the cell character is a plain character, or if it's a composed character (identified by checking if the cell character is >= COMB_CHARS_LO). Then we render the grapheme pretty much like before.
* unicode-combine: remove utf8proc dependencyDaniel Eklöf2020-05-02-4/+4
| | | | | | | | | | | | We only used utf8proc to try to pre-compose a glyph from a base and combining character. We can do this ourselves by using a pre-compiled table of valid pre-compositions. This table isn't _that_ big, and binary searching it is fast. That is, for a very small amount of code, and not too much extra RO data, we can get rid of the utf8proc dependency.
* unicode-combining: completely remove unicode combining characters when feature is disabledDaniel Eklöf2020-05-01-0/+8
|
* grid: reflow: copy combining charactersDaniel Eklöf2020-05-01-0/+9
|
* grid: add per-cell combining charactersDaniel Eklöf2020-05-01-1/+5
| | | | | | | | | | The data is *not* added to the cell struct, since that one is too performance critical. Instead, the data is added as a separate array in the row struct. This allows our performance critical code paths that e.g. clear cells to perform as before.
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-2/+1
|
* grid: reflow: make tracking_points array 'const'Daniel Eklöf2020-04-17-1/+1
| | | | | The elements aren't, and cannot be, const. But the array itself can, and should be.
* grid: reflow: caller may now pass a list of coordinates that should be translatedDaniel Eklöf2020-04-17-1/+6
|
* grid: reflow: generalize cursor coordinate translationDaniel Eklöf2020-04-17-26/+41
| | | | | | | | | | | Define a list of "tracking points" - coordinates that should be translated while reflowing. Add the cursor coordinates to this list. When a coordinate have been translated, it is removed from the list. This means we don't have to create a copy of the 'cursor' coordinate struct.
* grid: reflow: remove commented out codeDaniel Eklöf2020-04-17-2/+0
|
* grid: reflow: turn line-wrapping code into a macroDaniel Eklöf2020-04-17-24/+19
|
* grid: reflow: don't randomly insert hard linebreaksDaniel Eklöf2020-04-17-0/+2
| | | | | Not sure why I added this code; maybe to workaround issues caused by the fact that the cursor position wasn't properly translated.
* grid: grid_reflow() now translates cursor coordinatesDaniel Eklöf2020-04-16-7/+51
|
* sixel: improve handling of images when reflowing the gridsDaniel Eklöf2020-03-13-0/+35
| | | | | | | | | | | Update the sixels' 'row' attribute when re-flowing a grid, to ensure it is rendered at the correct place. This should work in most cases, but will break when the cell size has changed (e.g. font size increase/decrease, or a DPI change). This patch also moves the sixel image list from the terminal struct into the grid struct. The sixels are per-grid after all.
* grid: grid_reflow(): may be called with old_rows/cols == new_rows/colsDaniel Eklöf2020-02-25-1/+1
| | | | TODO: avoid calling grid_reflow() in this case.
* render/grid: move grid reflow code to grid.cDaniel Eklöf2020-02-15-1/+145
|
* term: convert cell 'linefeed' attribute to a row 'linebreak' propertyDaniel Eklöf2020-02-14-0/+1
| | | | | | | | | | | | | | | | To do text reflow, we only need to know if a line has been explicitly linebreaked or not. If not, that means it wrapped, and that we should *not* insert a linebreak when reflowing text. When reflowing text, when reaching the end of a row in the old grid, only insert a linebreak in the new grid if the old row had been explicitly linebreaked. Furthermore, when reflowing text and wrapping a row in the new grid, mark the previous row as linebreaked if either the last cell was (the last column in the last row) empty, or the current cell (the first column in the new row) is empty. If both are non-empty, then we assume a linewrap.
* grid: remove commented out codeDaniel Eklöf2019-08-23-6/+1
|
* scrolling: optimize row access by assuming number of rows is a power of 2Daniel Eklöf2019-08-22-14/+23
| | | | | | | | | | | | | | | | | | | With this assumption, we can replace 'a % b' with 'a & (b - 1)'. In terms of instructions, this means a fast 'and' instead of a slow 'div'. Further optimize scrolling by: * not double-initializing empty rows. Previously, grid_row_alloc() called calloc(), which was then followed by a memset() when scrolling. This is of course unnecessary. * Don't loop the entire set of visible rows (this was done to ensure all visible rows had been allocated, and to prefetch the cell contents). This isn't necessary; only newly pulled in rows can be NULL. For now, don't prefetch at all.
* render: add a 'clean' bit to each cell; only render cells that aren't cleanDaniel Eklöf2019-07-30-0/+2
| | | | | | | | | | | This patch takes a bit from the foreground color value in a cell (todo: split up foreground/background into bitfields with a separate field for 'foreground/background' has been set), and only re-renders cells that aren't marked as clean. Note: we use a 'clean' bit rather than a 'dirty' bit to make it easy to erase cells - we can (keep doing) do that by simply memsetting a cell range to 0.
* grid: swap rows doesn't mark rows as dirtyDaniel Eklöf2019-07-23-3/+0
|
* grid: swap_row: drop requirement that row indices be positiveDaniel Eklöf2019-07-10-2/+3
|
* grid: don't pre-allocate the entire grid (with all scrollback lines)Daniel Eklöf2019-07-10-0/+19
| | | | | | | | | | The row array may now contain NULL pointers. This means the corresponding row hasn't yet been allocated and initialized. On a resize, we explicitly allocate the visible rows. Uninitialized rows are then allocated the first time they are referenced.
* grid: don't implement grid_swap_row() in the header fileDaniel Eklöf2019-07-10-78/+13
|
* wip: grid is now represented as a grid, not a linear arrayDaniel Eklöf2019-07-08-1/+2
| | | | | | | | | | | | The grid is now represented with an array of row *pointers*. Each row contains an array of cells (the row's columns). The main point of having row pointers is we can now move rows around almost for free. This is useful when scrolling with scroll margins for example, where we previously had to copy the lines in the margins. Now it's just a matter of swapping two pointers.
* grid: add a fast path to grid_memmove()Daniel Eklöf2019-07-07-0/+13
| | | | | Recognize the case where both the destination and source can be fully accessed, and to a plain memmove() in this case.
* grid: grid_memset() -> grid_memclear()Daniel Eklöf2019-07-07-2/+2
|
* logging: disable debug logging by defaultDaniel Eklöf2019-07-03-1/+1
|
* scrolling: initial reverse scrolling support - no scroll regionsDaniel Eklöf2019-07-03-10/+13
|
* grid: implement a memmove-sort-of functionDaniel Eklöf2019-07-01-0/+33
| | | | | grid_memmove() moves cell data from one index to another, taking the grid offset into account.
* wip: use a sliding window instead of memmove() to scrollDaniel Eklöf2019-07-01-0/+34
| | | | | Instead of memmoving a large amount of data on every scroll, use a sliding window. That is, each time we scroll, we offset origin.
* Rename grid_* functions to term_*Daniel Eklöf2019-06-29-303/+0
|
* grid: attributes now track whether we've set a foreground/background colorDaniel Eklöf2019-06-26-8/+0
| | | | | | | | | This means we don't have to explicitly set the foreground/background to the grid's default colors whenever we reset/clear a cell, and we can instead simply memset() the entire cell to 0. This also means the renderer has to get the default color when rendering a cell without a foreground/background color set.
* scroll: let the render erase the scrolled up regionDaniel Eklöf2019-06-26-25/+19
| | | | | | The grid scroll operation no longer inserts a DAMAGE_ERASE operation, but instead manually clears the region. The render does the corresponding thing.
* scroll-region: don't clear damage queue when changing scroll regionDaniel Eklöf2019-06-25-119/+96
| | | | | | | | | | | | | | | | | | | | | | Vim, for example, changes the scroll region every time you scroll a single line. Thus, resetting the damage queue is slow. This reworks the damage handling of scroll updates: * Split damage queue into two: one for scroll operations and one for update/erase operations. * Don't separate update/erase operations inside/outside the scroll region * Store the current scroll region in the scroll damage operation. This allows us to stack multiple scroll operations with different scroll regions. * When updating update/erase operations after a scroll operation, split the update/erase operations if necessary (the current scroll operation may have a scroll region different from before, thus forcing us to split existing update/erase operations. * The renderer no longer erases after a scroll. The scroll operation also adds an erase operation. This also means that erase operation are subject to adjustments by later scroll operations.
* grid: scroll reverse: hopefully done correct nowDaniel Eklöf2019-06-24-3/+3
|
* grid: scroll: fix start/end for erase regionDaniel Eklöf2019-06-24-3/+4
|
* scrolling region: wipDaniel Eklöf2019-06-23-44/+95
|
* vt: wip: implement scrolling regionDaniel Eklöf2019-06-23-29/+21
| | | | | | | | | | This is largely untested, but existing scrolling code has been converted to using a terminal-global scrolling region that is defined as start-end of the scrollable region. This is compared to the old code where the scrolling region where defined in terms of marginals, counted in lines from top and from bottom.
* vt: implement reverse scrolling (terminfo 'ri')Daniel Eklöf2019-06-23-21/+74
| | | | | This currently duplicates the code paths for DAMAGE_SCROLL; there are many similarities between the two, but also major differences...
* grid: implement DAMAGE_SCROLLDaniel Eklöf2019-06-21-10/+79
|
* render: break up grid_render()Daniel Eklöf2019-06-19-1/+2
|
* Use a 'damage' list to communicate what needs to be updatedDaniel Eklöf2019-06-19-8/+85
| | | | | | | | | | Instead of having each cell in the grid track it's own dirtiness, grid operations now append "damage" to a list. This list is consumed every time we render the grid. This allows us to special case some operations, like erase (and in the future, scroll).
* grid: erase: memset() the entire range in one callDaniel Eklöf2019-06-19-3/+5
|
* wip: initial scrolling support (no scrollback though)Daniel Eklöf2019-06-19-0/+24
|
* wip: initial input handlingDaniel Eklöf2019-06-19-30/+14
|
* grid: track both linear and row,col cursorDaniel Eklöf2019-06-17-7/+66
|
* vt: handle cursor-at-right-edgeDaniel Eklöf2019-06-17-0/+1
| | | | | | When printing to the right-most-cell, don't advance the cursor. Instead, set a flag that indicates that the *next* print should line-wrap.
* wip: vt parsing: break out grid operating functionsDaniel Eklöf2019-06-17-0/+34