Commit graph

34 commits

Author SHA1 Message Date
Daniel Eklöf
38a682f0d0
render/grid: move grid reflow code to grid.c 2020-02-15 22:19:08 +01:00
Daniel Eklöf
ce8005545d
term: convert cell 'linefeed' attribute to a row 'linebreak' property
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.
2020-02-14 22:39:26 +01:00
Daniel Eklöf
0c90717249
grid: remove commented out code 2019-08-23 20:07:27 +02:00
Daniel Eklöf
7c7720a3ab
scrolling: optimize row access by assuming number of rows is a power of 2
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.
2019-08-22 17:33:23 +02:00
Daniel Eklöf
85ef9df586
render: add a 'clean' bit to each cell; only render cells that aren't clean
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.
2019-07-30 18:03:03 +02:00
Daniel Eklöf
f7519b5725
grid: swap rows doesn't mark rows as dirty 2019-07-23 17:56:07 +02:00
Daniel Eklöf
379f7cf646
grid: swap_row: drop requirement that row indices be positive 2019-07-10 19:17:53 +02:00
Daniel Eklöf
1ff1b3a71e
grid: don't pre-allocate the entire grid (with all scrollback lines)
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.
2019-07-10 16:27:55 +02:00
Daniel Eklöf
8f0d574dcb
grid: don't implement grid_swap_row() in the header file 2019-07-10 16:08:53 +02:00
Daniel Eklöf
4e25019ba6
wip: grid is now represented as a grid, not a linear array
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.
2019-07-08 13:57:31 +02:00
Daniel Eklöf
f2363c2391
grid: add a fast path to grid_memmove()
Recognize the case where both the destination and source can be fully
accessed, and to a plain memmove() in this case.
2019-07-07 17:10:30 +02:00
Daniel Eklöf
48528419c4
grid: grid_memset() -> grid_memclear() 2019-07-07 17:10:15 +02:00
Daniel Eklöf
1373d18dbc
logging: disable debug logging by default 2019-07-03 20:21:03 +02:00
Daniel Eklöf
a7a28ff581
scrolling: initial reverse scrolling support - no scroll regions 2019-07-03 10:45:49 +02:00
Daniel Eklöf
482f56b4a2
grid: implement a memmove-sort-of function
grid_memmove() moves cell data from one index to another, taking the
grid offset into account.
2019-07-01 19:18:52 +02:00
Daniel Eklöf
d70956da08
wip: use a sliding window instead of memmove() to scroll
Instead of memmoving a large amount of data on every scroll, use a
sliding window. That is, each time we scroll, we offset origin.
2019-07-01 12:23:38 +02:00
Daniel Eklöf
1ecd4a6ae1
Rename grid_* functions to term_* 2019-06-29 21:03:28 +02:00
Daniel Eklöf
3a97fce6d0
grid: attributes now track whether we've set a foreground/background color
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.
2019-06-26 19:44:31 +02:00
Daniel Eklöf
97420f13d8
scroll: let the render erase the scrolled up region
The grid scroll operation no longer inserts a DAMAGE_ERASE operation,
but instead manually clears the region. The render does the
corresponding thing.
2019-06-26 19:33:39 +02:00
Daniel Eklöf
a35738d96f
scroll-region: don't clear damage queue when changing scroll region
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.
2019-06-25 20:11:08 +02:00
Daniel Eklöf
0f76f4190a
grid: scroll reverse: hopefully done correct now 2019-06-24 20:49:37 +02:00
Daniel Eklöf
0e078f44b6
grid: scroll: fix start/end for erase region 2019-06-24 20:45:14 +02:00
Daniel Eklöf
2fe7145aff
scrolling region: wip 2019-06-23 21:12:32 +02:00
Daniel Eklöf
b0a2c54fe8
vt: wip: implement scrolling region
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.
2019-06-23 18:02:49 +02:00
Daniel Eklöf
fbf0db621c
vt: implement reverse scrolling (terminfo 'ri')
This currently duplicates the code paths for DAMAGE_SCROLL; there are
many similarities between the two, but also major differences...
2019-06-23 17:16:52 +02:00
Daniel Eklöf
a50be28b9d
grid: implement DAMAGE_SCROLL 2019-06-21 14:29:15 +02:00
Daniel Eklöf
0ddd96de0d
render: break up grid_render() 2019-06-19 14:37:42 +02:00
Daniel Eklöf
304f15d696
Use a 'damage' list to communicate what needs to be updated
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).
2019-06-19 14:17:43 +02:00
Daniel Eklöf
96731814da
grid: erase: memset() the entire range in one call 2019-06-19 10:58:24 +02:00
Daniel Eklöf
efc8cc4914
wip: initial scrolling support (no scrollback though) 2019-06-19 10:27:31 +02:00
Daniel Eklöf
71dde121e6
wip: initial input handling 2019-06-19 10:04:47 +02:00
Daniel Eklöf
50c43be0d9
grid: track both linear and row,col cursor 2019-06-17 21:15:20 +02:00
Daniel Eklöf
963b266cce
vt: handle cursor-at-right-edge
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.
2019-06-17 20:53:05 +02:00
Daniel Eklöf
4585df532c
wip: vt parsing: break out grid operating functions 2019-06-17 19:33:10 +02:00