Commit graph

417 commits

Author SHA1 Message Date
Daniel Eklöf
9ce0edc8bb
render: ime: don’t render pre-edit string in grid while searching
While doing a scrollback search, the pre-edit string should be
rendered in the search box, not in the grid.

Note that we don’t yet support IME in scrollback search mode. This
patch simply prevents the pre-edit text being rendered in the grid,
in the “background”, while searching.
2020-12-07 20:44:12 +01:00
Daniel Eklöf
2078e1675d
render: ime: draw a ‘bar’ cursor when the pre-edit cursor’s begin == end 2020-12-07 20:44:11 +01:00
Daniel Eklöf
83d3ae10ae
render: ime: don’t render cursor if cursor begin == end 2020-12-07 20:44:10 +01:00
Daniel Eklöf
e9f99df2ab
render: ime: calculate on-screen cursor position ourselves
The position calculated by render_grid() may be -1,-1 if the cursor is
currently hidden.

This fixes a crash when trying to input IME while the cursor is
hidden.
2020-12-07 20:44:10 +01:00
Daniel Eklöf
4d90b200f1
render: ignore IME preedit state when deciding which cursor style to render 2020-12-07 20:44:10 +01:00
Daniel Eklöf
05083110c3
ime: make IME compile-time optional 2020-12-07 20:44:10 +01:00
Daniel Eklöf
8c3d48c5cd
ime: render pre-edit text
This is done by allocating cells for the pre-edit text when receiving
the text-input::done() call, and populating them by converting the
utf-8 formatted pre-edit text to wchars.

We also convert the pre-edit cursor position to cell positions (it can
cover multiple cells).

When rendering, we simply render the pre-edit cells on-top off the
regular grid. While doing so, we also mark the underlying, “real”,
cells as dirty, to ensure they are re-rendered when the pre-edit text
is modified or removed.
2020-12-07 20:44:10 +01:00
Craig Barnes
adde947fc5 config: replace union in config struct with simple width/height members 2020-11-30 02:24:38 +00:00
Daniel Eklöf
9a498038d6
resize: don’t reflow text on alt screen
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
2020-11-25 07:47:40 +01:00
Daniel Eklöf
90edc09697
render: don’t call term_arm_blink_timer() from multiple threads
We call term_arm_blink_timer() from render_cell(), which runs in
multiple threads.

This caused multiple blink timer FDs to be created and registered with
the FDM, later causing read failures after one of those FDs had been
closed again.

This rarely happened under normal circumstances, but was easy to
trigger when the whole screen was full of blinking text.

As a small optimization, we don’t bother taking the lock if the timer
FD already is valid.

This is safe, because:

1) If the timer FD isn’t valid, we take the lock and then call
    term_arm_blink_timer(), which again checks if the FD is already
    valid.

2) The blink timer FD cannot be closed while we’re rendering cells. It
   is only disabled in the FDM callback, which cannot execute while
   we’re rendering.
2020-11-23 19:26:00 +01:00
Daniel Eklöf
ecaa3b4135
render: no need to call attrs_to_font(), we already have a font reference 2020-11-22 19:29:43 +01:00
Daniel Eklöf
774dd75542
render: allow-overflow: require a space in the next cell
When checking if we should allow a single-width character double-width
glyph to overflow into the next cell, require the next cell to either
be empty, or contain a space.

Closes #203
2020-11-19 19:24:15 +01:00
Daniel Eklöf
690cf0ab54
render: dim/brighten: multiply/divide instead of add/subtract 2020-11-15 21:04:21 +01:00
Daniel Eklöf
2b8e2b3506
render: dim and brighten colors by adjusting luminance
To do this, we need to convert our RGB to HSL, adjust luminance, and
then convert back to RGB.
2020-11-15 20:05:01 +01:00
Daniel Eklöf
8e779b356e
render: remove debug output 2020-11-15 19:40:25 +01:00
Daniel Eklöf
ee5607b9eb
render: brighten color of bold text if default.bold-text-in-bright=yes
Closes #199
2020-11-14 11:22:35 +01:00
Daniel Eklöf
4b645376fd
render: improve sixel rendering performance
Up until now, we’ve always re-rendered the entire image (the part of
it that is visible at least), *every* time we render a frame.

This is not really needed. In many cases, the cells covered by the
image hasn’t been touched.

Rewrite the sixel rendering code to only render the part of the sixel
image that covers dirty cells.

This is done on a per-row basis. I.e. Each *row* of the image that
covers at least one dirty cell is re-rendered. For this to work, we
now also dirty all cells covered by the image when we emit the image.

Finally, for this to work, the sixels need to be rendered *before* we
do the normal grid render pass (since that will clear all dirty bits).
2020-11-13 16:54:40 +01:00
Daniel Eklöf
beaf220f39
tiocswinsz: fix compilation error on e.g. ppc64
On some platforms, TIOCSWINSZ has a very large value, >
0x80000000.

On some platforms, the `request` argument to `ioctl(3)` is an `int`.

For platforms where both of the above is true, gcc will warn (and
error out if compiled with `-Werror`) on:

  ioctl(fd, TIOCSWINSZ, ...)

To silence this warning, we need to cast `TIOCSWINSZ` to an
integer.

However, doing this on platforms where `request` is an `unsigned long`
will result in `TIOCSWINSZ` being sign-extended (and thus we end up
with an invalid value).

It seems that casting to `unsigned int` works in both cases; it
silences the long -> int conversion warning, while also preserving the
correct value in all cases.
2020-10-29 18:06:04 +01:00
Daniel Eklöf
4283e96865
render: blink switches between foreground and dimmed foreground 2020-10-22 18:41:47 +02:00
Daniel Eklöf
f928c1fa68
wayland: properly restore window size when being un-tiled
Bind to xdg-shell version 2 if available, as this enables us to
track our window’s ‘tiled’ state in the ‘configure’ events.

This in turn allows us to stash the ‘old’ window size when being
tiled, to be used again when restoring the window size when un-tiled.
2020-10-20 20:58:03 +02:00
Daniel Eklöf
f2da822e9a
render: resize: call sixel_reflow() after reflowing grids 2020-10-09 07:44:16 +02:00
Daniel Eklöf
7c6686221f
bell: optionally render margins in red when receiving BEL
Add anew config option, ‘bell=none|set-urgency’. When set to
‘set-urgency’, the margins will be painted in red (if the window did
not have keyboard focus).

This is intended as a cheap replacement for the ‘urgency’ hint, that
doesn’t (yet) exist on Wayland.

Closes #157
2020-10-08 19:55:32 +02:00
Daniel Eklöf
279341dd8e
render: apply opacity correctly when in reverse video mode 2020-10-08 19:53:11 +02:00
Daniel Eklöf
7ffd31e13a
render: remove render_refresh_margins() 2020-09-29 10:08:59 +02:00
Daniel Eklöf
b19e07ad1c
render: term->render.margins is used to explicitly tell us to re-render margins 2020-09-29 10:04:41 +02:00
Daniel Eklöf
2e7102c956
render: fix rounding errors when setting initial window size and scale != 1
An odd cell width/height sometimes resulted in an odd grid
size. Combined with a scaling factor of e.g. 2, that led to a rounding
error when converting pixel sizes to logical window sizes.

As a result, the _next_ configure event would cause us to loose a
pixel, which led to us dropping a row from the grid.
2020-09-17 17:37:58 +02:00
Daniel Eklöf
fdfdbba9a0
render: best-effort attempt to set initial window size in chars when scale != 1
The initial window size is set *before* we’re initially mapped. This
means we don’t (yet) know on which output we’ll be mapped. _That_
means we don’t know which scaling factor to use.

This implements a best effort attempt, where we use the “guessed”
scaling factor. This will always be correct in single-monitor
configurations, but may be wrong in multi-monitor setups with
different scaling factors.
2020-09-14 17:36:56 +02:00
Daniel Eklöf
3a308cc870
render: csd: hide buttons when title bar gets too small to fit them 2020-09-10 07:37:54 +02:00
Daniel Eklöf
eb6737ca25
Add -W,--window-size-chars, and foot.ini:initial-window-size-chars
* Add -W,--window-size-chars command line option
* Add initial-window-size-chars foot.ini option
* Add -w,--window-size-pixels command line option
* Add initial-window-size-pixels foot.ini option
* Deprecate -g,--geometry command line option in favor of
  -w,--window-size-pixels
* Deprecate geometry option in foot.ini in favor of
  initial-window-size-pixels
2020-09-08 19:41:00 +02:00
Daniel Eklöf
e81d23befc
Merge branch 'tweak-damage-everything' into master 2020-09-07 19:44:54 +02:00
Daniel Eklöf
19ec06b999
Merge branch 'reflow-multi-column-composed-characters' into master 2020-09-07 19:41:42 +02:00
Daniel Eklöf
6e4d29ef71
render: change minimum window size from 4x20 -> 1x2 (rows/cols) 2020-09-07 19:34:06 +02:00
Daniel Eklöf
61f950f77a
grid: reflow: calculate width of composed characters correctly
Before this patch, reflow called `wcwidth()` on our magic values for
composed characters.
2020-09-06 19:14:46 +02:00
Daniel Eklöf
d040284cc7
config: add tweak.damage-whole-window
When enabled, foot will ‘damage’ the entire window, instead of just
the modified/updated rows.

This will force the compositor to redraw/blend the whole window.

This can be used to workaround an issue with fractional scaling in
Gnome, where random thin lines may appear.
2020-09-06 17:52:07 +02:00
Daniel Eklöf
b71016c25d
render: optionally enable heuristics that deal with private usage area chars
Try to detect double-width *glyphs* for single-width *characters*, and
allow them to overflow into the next cell.

This is only done for single-width chars with a glyph width that is at
least 1.5 cells wide, but at most 3 cells.

The feature is gated by the new
‘tweak.allow-overflowing-double-width-glyphs’, and is disabled by
default.

Closes #116
2020-09-03 17:37:44 +02:00
Daniel Eklöf
b76d196569
render: ’redraw_margins’ is now a parameter to grid_render()
render_refresh_margins() now passes ’true’ here, instead of re-setting
term->render.last_buf to NULL.
2020-09-01 08:01:48 +02:00
Daniel Eklöf
2488c3935b
render: implement render_refresh_margins()
For now, it will reset term->render.last_buf to NULL, and then calls
grid_render() to do a full screen refresh.
2020-09-01 07:33:44 +02:00
Daniel Eklöf
32e2173b5d
Merge branch 'scrollback-indicator-positioning' into master
Closes #108
2020-08-27 19:52:47 +02:00
Daniel Eklöf
c8d0dc5750
render: scrollback indicator: only leave room for search box when necessary 2020-08-26 19:12:12 +02:00
Daniel Eklöf
1109865c8e
render: scrollback indicator: subtract visible rows from populated rows
This prevents the indicator from starting too high up when the number
of used scrollback rows is low.
2020-08-26 19:10:00 +02:00
Daniel Eklöf
cc24c5f2e0
render: scrollback position: only count _used_ scrollback lines
When calculating where in the scrollback history we are, we previously
did this against the total number of scrollback lines. I.e. the
`scrollback.lines` setting in `footrc`.

Now, we count only the used/allocated scrollback lines.

Note that the initial indicator position might still seem to start a
bit high up, if the number of used scrollback lines is low. This is
because we use the *top* of the screen for the current position. Thus,
we'll never be at the bottom (except for the special case when
we're *really* at the bottom).
2020-08-25 18:45:04 +02:00
Daniel Eklöf
dabdffafa5
don't use empty struct initializers 2020-08-23 10:07:00 +02:00
Craig Barnes
104fe2fa55 Fix some spelling mistakes 2020-08-15 19:39:00 +01:00
Daniel Eklöf
b0d41324d6
render: render the render timer *before* committing the main surface 2020-08-14 07:52:08 +02:00
Daniel Eklöf
640445acb4
render: render-timer: position sub-surface similar to the scrollback indicator 2020-08-14 07:48:40 +02:00
Daniel Eklöf
823a7c0318
render: oops... swprintf() needs to number of *chars*, not *bytes* 2020-08-13 18:46:57 +02:00
Daniel Eklöf
6e0171ee44
render: fix printf-errors in 32-bit builds 2020-08-13 18:40:10 +02:00
Daniel Eklöf
17070a0d54
config: add tweak.render-timer option
This can be set to 'none' (the default), 'osd', 'log' or 'both'.

When 'osd' is enabled, we'll render the frame rendering time to a
sub-surface after each frame.

When 'log' is enabled, the frame rendering time is logged on stderr.
2020-08-13 18:35:17 +02:00
Daniel Eklöf
5e36ebdef8
config: make selection foreground/background colors configurable
The default is still to inverse the regular foreground/background
colors.

If the user sets *both* of the new options, selection-foreground and
selection-background, those colors will *always* be used for selected
cells, instead of inverting the regular foreground/background colors.
2020-08-12 19:41:50 +02:00
Daniel Eklöf
187fe3a586
render: fix compilation errors in 32-bit builds
timeval.tv_usec is an 'unsigned long long' on 32-bit
2020-08-11 17:29:56 +02:00