Commit graph

47 commits

Author SHA1 Message Date
Daniel Eklöf
ebf0a11fa0
render: add render_refresh() 2019-07-24 20:11:41 +02:00
Daniel Eklöf
10a7b94804
render: bug: previous cursor wasn't always redrawn correctly
The main problem is knowing:

* The correct *cell* (to be able to render the *content* when erasing
  the old cursor)
* Whether the cursor has moved (to determine whether to stop the
  rendering loop or not)
* Where on the *screen* the cursor is/was (since the terminal may be
  partly scrolled back)

This patch stores three static variables:

* last_cursor is used to compare against current cursor to see if the
  cursor has moved or not
* last_cursor_on_screen is the actual screen coordinates the cursor
  was rendered at (typically the same as last_cursor, but may be
  offset by the view)
* last_cursor_cell is a pointer to the cell to render
2019-07-24 18:15:24 +02:00
Daniel Eklöf
bf4847d3e0
conf: allow the user to configure a fixed cursor color
The default is to reverse the foreground/background colors in the cell
with the cursor.

But, if the user configures a specific set of cursor colors, those
will always be used, regardless of other cell attributes (dim, reverse
etc).

The cursor color is specified as two color values, 'text' and
'cursor'.

The block cursor uses the 'cursor' color as background, and the 'text'
color for the glyph.

All other cursor styles uses the 'cursor' color for the cursor, but
uses the cell's foreground color for the glyph (meaning,
dim/reverse/etc applies).
2019-07-23 18:54:58 +02:00
Daniel Eklöf
ed5df194b8
render: implement cursor styles 'bar' and 'underline' 2019-07-22 20:07:34 +02:00
Daniel Eklöf
428b31f071
term: group 'blink' state together in a struct 2019-07-22 19:17:57 +02:00
Daniel Eklöf
196f9d67c2
term: group 'flash' state together in a struct 2019-07-22 19:15:56 +02:00
Daniel Eklöf
e21ab8cf33
blink: implement 'blink' 2019-07-21 20:11:20 +02:00
Daniel Eklöf
0dd8951cb3
flash: implement 'flash'
Use our own escape sequence for the 'flash' terminfo entry.

Implemented by arming a timer FD and setting a boolean that indicates
we're currently "flashing".

The renderer draws a semi-transparent yellowish layer over the entire
window when "flashing" is active.
2019-07-21 19:14:19 +02:00
Daniel Eklöf
86faed473d
render: make "new buffer" a debug log message, not warning 2019-07-21 15:36:32 +02:00
Daniel Eklöf
29d855d7c6
term: prepare for configurable colors; add color variables to terminal 2019-07-21 10:58:09 +02:00
Daniel Eklöf
6e69cf9562
glyph-cache: generate at startup, never update while rendering 2019-07-18 13:03:21 +02:00
Daniel Eklöf
d2e0ba3670
render: comments 2019-07-18 10:47:09 +02:00
Daniel Eklöf
71c7219b35
render: make frame rendering time measuring optional 2019-07-18 10:35:27 +02:00
Daniel Eklöf
6e55be1557
render: cache generated glyphs for regular ASCII characters
To avoid having to re-generate glyphs, cache the glyphs.

For now, we only cache ASCII characters, as this allows us to lookup
the cache by simply indexing with the character (into a 256-entry
array).
2019-07-18 10:33:58 +02:00
Daniel Eklöf
c9803a2018
render: break out color conversion 2019-07-18 10:04:13 +02:00
Daniel Eklöf
0ca20e3e6c
render: time how long time it takes to render a frame 2019-07-18 09:33:49 +02:00
Daniel Eklöf
6bce2bed00
render: use cairo_rel_line_to() 2019-07-16 21:54:48 +02:00
Daniel Eklöf
d71c5f15a1
render: shorten foreground/background local variable names 2019-07-16 19:52:45 +02:00
Daniel Eklöf
06f9495ae2
render: implement strikeout 2019-07-16 15:08:02 +02:00
Daniel Eklöf
d93ca2f654
render: implement 'underline' 2019-07-16 14:20:39 +02:00
Daniel Eklöf
441337645a
render: implement 'dim' 2019-07-16 13:25:57 +02:00
Daniel Eklöf
ccc8ef9606
terminal: foreground/background in cell attributes are now uint32_t
This reduces the cell size, and thus improves the cache behavour
2019-07-16 13:17:51 +02:00
Daniel Eklöf
7dd80b08b3
render: bug: don't render cursor when hide cursor is enabled 2019-07-11 17:38:01 +02:00
Daniel Eklöf
632790d5d8
selection: selections can be made, and are rendered
* Start selection on mouse button down
* Update selection on motion
* Button release cancels selection if there were no motion after start
* Renderer detects cells inside the selection and inverts their colors
2019-07-11 17:38:01 +02:00
Daniel Eklöf
4ffd93ca4c
render: reduce scrollback line count
More than 1000 lines and we start exhibiting bad cache behavior
2019-07-10 18:49:34 +02:00
Daniel Eklöf
b1f8dd75d6
cell: we only need 4 bytes for the longest utf8 sequence
We don't *have* to NULL-terminate the utf8 string. So don't. This
makes the cell glyph 4 bytes exactly, which is better for alignment
and cache usage.
2019-07-10 18:47:32 +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
e01060caf9
render: damage the *view* too, when resizing 2019-07-10 14:34:43 +02:00
Daniel Eklöf
4cef8ed2cc
render: reset 'normal' grid's view correctly 2019-07-10 14:34:32 +02:00
Daniel Eklöf
1bb5afeb0a
render: don't render cursor if it is not in view 2019-07-10 09:55:50 +02:00
Daniel Eklöf
bcd111d203
wip: initial scroll back support
Can scroll up and down, and stops when the beginning/end of history is
reached.

However, it probably breaks when the entire scrollback buffer has been
filled - we need to detect when the view has wrapped around to the
current terminal offset.

The detection of when we've reached the bottom of the history is also
flawed, and only works when we overshoot the bottom with at least a
page.

Resizing the windows while in a view most likely doesn't work.

The view will not detect a wrapped around scrollback buffer. I.e. if
the user has scrolled back, and is stationary at a view, but there is
still output being produced. Then eventually the scrollback buffer
will wrap around. In this case, the correct thing to do is make the
view start following the beginning of the history. Right now it
doesn't, meaning once the scrollback buffer wraps around, you'll start
seeing command output...
2019-07-09 16:26:36 +02:00
Daniel Eklöf
0d24fcafd0
render: store frame callback pointer in terminal struct
This allows us to free it when exiting
2019-07-09 09:23:32 +02:00
Daniel Eklöf
d7bb83022d
cleanup 2019-07-09 09:18:58 +02:00
Daniel Eklöf
0f14b5298e
render: copy old contents to new grids when resizing
Eventually, we'll add text reflow here as well.
2019-07-09 09:12:41 +02:00
Daniel Eklöf
6d48f0f2a5
render: hackerman 2019-07-08 20:25:41 +02:00
Daniel Eklöf
1e2a7e77f0
rgba: drop alpha channel support 2019-07-08 15:56:15 +02:00
Daniel Eklöf
69e7744e5d
render: use CAIRO_OPERATER_SOURCE to draw glyphs
This is *much* faster.
2019-07-08 15:51:44 +02:00
Daniel Eklöf
f1fa5a4a37
render: use doubles instead of ints 2019-07-08 15:28:33 +02:00
Daniel Eklöf
587a9c6ffe
render: use pointers to rgba foreground/background colors
This is faster, since we don't have to copy several large doubles when
swapping the colors.
2019-07-08 15:27:44 +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
c35e10bd9a
render: collect glyphs over *all* update damages 2019-07-07 21:55:31 +02:00
Daniel Eklöf
050f7ea6ea
render: performance: don't stack allocate glyph sequence 2019-07-06 18:31:14 +02:00
Daniel Eklöf
77e349d20d
render: reverse video only reverses the default background/foreground 2019-07-05 20:36:03 +02:00
Daniel Eklöf
b26e03fced
csi: implement reverse video 2019-07-05 20:12:40 +02:00
Daniel Eklöf
fd25018cdd
render: fill area outside the cell grid with default bg color 2019-07-05 15:53:53 +02:00
Daniel Eklöf
1a341a56cc
render: load cursor theme from XCURSOR_THEME and XCURSOR_SIZE 2019-07-05 10:44:09 +02:00
Daniel Eklöf
1947d33868
render: break out rendering functions to render.{c,h} 2019-07-05 10:16:56 +02:00