Commit graph

59 commits

Author SHA1 Message Date
Daniel Eklöf
fe882bddba
font: populate glyph cache (ASCII characters only) when instantiating font 2019-07-28 21:03:38 +02:00
Daniel Eklöf
9e57ba2108
font: add font_glyph_for_utf8()
This function fills in a struct glyph with glyph bitmap data for the
provided utf-8 character (essentially a FT_Bitmap wrapped in a cairo
surface).
2019-07-28 20:37:59 +02:00
Daniel Eklöf
175dc9cf94
cairo-ft: remove all usages of cairo-ft 2019-07-28 12:45:01 +02:00
Daniel Eklöf
27dca15caf
render: use FreeType face from font, instead of from cairo's scaled font 2019-07-28 12:11:44 +02:00
Daniel Eklöf
cb02c9cf41
font: load FreeType face, and set it's pixel sizes 2019-07-28 12:09:22 +02:00
Daniel Eklöf
90d357befb
render: poc: use freetype to render glyphs
Initial POC that uses freetype to render the glyphs. The bitmap
produced by freetype contains the alpha value.

We use this bitmap in a mask surface and then draw the final glyph
with cairo by applying the source rgb using the OVER operator and the
freetype generated alpha mask as surface mask.

Note that we only support grayscale antialiasing (and no
antialiasing).

We are probably not setting the antialias options correctly either.
2019-07-26 18:54:14 +02:00
Daniel Eklöf
709c29c7c4
render: reset "last cursor" when resizing
The cell pointer is likely invalid since we realloc the
grids. Besides. we're redrawing the entire window anyway.
2019-07-26 18:51:47 +02:00
Daniel Eklöf
269e04fa1b
render: flush glyph sequence after erase previous cursor
If not, we may have scrolled when we later flush the glyph sequence,
causing the glyph to be rendered in wrong location.
2019-07-26 18:50:41 +02:00
Daniel Eklöf
bb3e33948f
render: add render_row() 2019-07-24 20:31:21 +02:00
Daniel Eklöf
a712ca40e1
render: minor 2019-07-24 20:26:32 +02:00
Daniel Eklöf
f93384b9c9
render: move local static variables into the terminal struct 2019-07-24 20:21:41 +02:00
Daniel Eklöf
4838763d18
render: move frame_callback to term.render 2019-07-24 20:11:49 +02:00
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