Commit graph

459 commits

Author SHA1 Message Date
Daniel Eklöf
e9c3d03837
config: add colors.jump_labels and colors.urls
* colors.jump_labels configures the foreground and background colors
  used when rendering URL jump labels. Defaults to “regular0
  regular3” (i.e. black on yellow).

* colors.urls configures the color to use when highlighting URLs in
  URL mode. Note that we aren’t currently doing any
  highlighting... Defaults to regular3 (i.e. yellow).
2021-02-07 16:33:33 +01:00
Daniel Eklöf
fcbb5a0bf7
config: use a packed bitfield for “use custom color” flags 2021-02-07 16:33:33 +01:00
Daniel Eklöf
013b26d212
render: urls: tweak positioning
Don’t offset the labels too much vertically, _or_ horizontally.
2021-02-07 16:33:32 +01:00
Daniel Eklöf
d69497efe4
render: reduce URL jump label margins 2021-02-07 16:33:32 +01:00
Daniel Eklöf
eb0b244c89
render: url labels: don’t position outside window 2021-02-07 16:33:32 +01:00
Daniel Eklöf
44b7758416
render: urls: positioning: place a bit further away from the starting position 2021-02-07 16:33:31 +01:00
Daniel Eklöf
2cc84db979
urls: initial support for detecting URLs and rendering jump-labels
The jump labels work, but is currently hardcoded to use xdg-open
2021-02-07 16:33:31 +01:00
Tadeo Kondrak
95c0c89cac
Send text_input_rectangle requests for text-input 2021-01-28 22:22:01 -07:00
Daniel Eklöf
3a7588bc99
config: promote tweak.resize-delay-ms to a real, supported option 2021-01-26 19:32:21 +01:00
Daniel Eklöf
a2b3ab6d9e
render: remove unneeded parantheses 2021-01-26 19:32:07 +01:00
Daniel Eklöf
b4f1f72585
render: don’t center content while doing an interactive resize 2021-01-26 19:32:07 +01:00
Daniel Eklöf
2dc774fb17
render: remove debug logging 2021-01-26 19:32:07 +01:00
Daniel Eklöf
c82cb8bcc7
render: codespell: tiemout -> timeout 2021-01-26 19:32:07 +01:00
Daniel Eklöf
9a1df7bb03
render: delay TIOCSWINSZ while doing an interactive resize
Instead of disabling content centering, delay the TIOCSWINSZ (a.k.a
delay sending the new dimensions to the client) by a small amount
while doing an interactive resize.

Non-interactive resizes are still immediate.

For now, force a resize when the user stops the interactive
resize. This ensures the client application receives the new
dimensions immediately.

It still works without the last, forced, resize, but there typically
be a small delay until the client application receives the final
dimensions.

Closes #301
Closes #283
2021-01-26 19:32:06 +01:00
Daniel Eklöf
3948145d66
render: don’t center content while we’re being resized
Doing so causes the content to jump around while interactively
resizing the window.
2021-01-26 19:32:06 +01:00
Daniel Eklöf
a763531775
ime: fix rendering of pre-edit cursor when positioned after the pre-edit string
We failed to convert the byte-indices to cell indices, resulting in a
box cursor covering the entire pre-edit string.

Note that in addition to fixing the translation from byte index to
cell index, the rendered had to be updated to dirty one extra cell
from the original grid.

Without this, we left trailing cursors behind us when the user deleted
text from the pre-edit string.
2021-01-26 19:30:34 +01:00
Daniel Eklöf
8f3fcf8275
search: ad-hoc workaround for combining characters with positive x-offsets
When rendering the search input box, do the same ad-hoc workaround for
combining characters with a positive x-offset as we do when rendering
normal grid cells.

In this case, we don’t *know* when we’re dealing with combining
characters. But we can detect zero-width characters. For these, check
their glyph’s x-offset. If positive, adjust it like we do when
rendering combining glyphs in the main grid, to ensure the glyph is
positioned over the _previous_ character, not the next.
2021-01-26 19:29:55 +01:00
Jan Beich
f2ad02aaab
render: set thread name in a portable way
prctl is Linux-only but pthread_setname_np is same as PR_SET_NAME.
Solaris and FreeBSD >= 13 have pthread_setname_np similar to Linux.
DragonFly, OpenBSD, FreeBSD < 13 lack pthread_setname_np but provide
pthread_set_name_np which doesn't return a value. NetBSD requires 3
arguments for pthread_setname_np where the last one is void *.

render.c:8:10: fatal error: 'sys/prctl.h' file not found
 #include <sys/prctl.h>
          ^~~~~~~~~~~~~
render.c🔢9: error: implicit declaration of function 'prctl' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0)
        ^
render.c🔢15: error: use of undeclared identifier 'PR_SET_NAME'
    if (prctl(PR_SET_NAME, proc_title, 0, 0, 0) < 0)
              ^
2021-01-23 09:52:40 +01:00
Craig Barnes
e56136ce11 debug: rename assert() to xassert(), to avoid clashing with <assert.h> 2021-01-16 20:16:00 +00:00
Daniel Eklöf
a6fc8b5da4
config: line-height, letter-spacing: values are in pt by default, but we allow px
If the value is specified without a unit, then the value is assumed to
be in points, subject to DPI scaling.

The value can optionally have a ‘px’ suffix, in which case the value
is treated as a raw pixel count.
2021-01-11 09:31:08 +01:00
Daniel Eklöf
3eba48d74b
render: offset all glyphs with {horizontal,vertical}-letter-offset 2021-01-11 09:31:06 +01:00
Daniel Eklöf
ba48109a9b
Merge branch 'center-grid-content'
Closes #273
2021-01-07 12:08:31 +01:00
Daniel Eklöf
124759bd2c
render: sixel: fix assertion: x/y coords may be outside visible area
But when they are, width/height must be 0.
2021-01-06 16:57:07 +01:00
Daniel Eklöf
e14c592f39
config: add optional ‘center’ argument to ‘pad’
When set, the grid contents is centered in the window. I.e. the
left/right and top/bottom margins are equal (+- 1px).

This causes the content to “jump” while doing an interactive resize,
but may still be preferred in e.g. a tiling WM.

Closes #273
2021-01-06 11:17:29 +01:00
Daniel Eklöf
dc676f96ce
render: codespell: accomodate -> accommodate 2021-01-04 19:49:24 +01:00
Daniel Eklöf
482690e5fb
render: draw combining characters on top of colored bitmap glyphs (emoji) 2021-01-04 18:32:55 +01:00
Craig Barnes
39b2e46e72 Use wrappers from macros.h instead of bare GCC attributes/pragmas 2021-01-03 08:56:47 +00:00
Daniel Eklöf
5cc2f94668
Merge branch 'box-drawing'
Closes #198
2021-01-03 00:08:08 +01:00
Daniel Eklöf
ae6d8e0c7f
render: mark cell overflowed into as dirty
When tweak.allow-overflowing-double-width-glyphs=yes, then certain
glyphs are allowed to overflow into the neighbouring cell.

However, if the cell “owning” the double-width glyph is erased (_only_
that cell), then the cell overflowed into is not redrawn, causing
part of the double-width glyph to remain on screen.

To avoid checking for these glyphs when printing to the terminal (i.e
at parse time), simply mark both cells as dirty when we render the
overflowing glyph.

Yes, this means that the cells will always be re-rendered. We count on
them only making up a small portion of the screen.
2021-01-02 22:31:07 +01:00
Daniel Eklöf
25d2b03a5c
box-drawing: SEXTANTS, U+1fb00-1fb3b 2021-01-01 21:09:37 +01:00
Daniel Eklöf
7acdb3a0dd
box-drawing: add infrastructure for rendering box drawing characters ourselves
* ‘term’ struct contains an array of 160 fcft glyph pointers
* the glyph pointers are lazily allocated when we need to draw a box
  drawings character
* Filtering out box drawings characters is easy - they are (except
  unicode 13, which isn’t handled yet )all in a single range.
2021-01-01 21:09:31 +01:00
Daniel Eklöf
339acc57cf
render: fix rounding error when calculating background color with alpha
We use pre-multiplied alpha color channels, but were having bad
rounding errors due to the alpha divider being truncated to an
integer.

The algorithm for pre-multiplying a color channel is:

  alpha_divider = 0xffff / alpha
  pre_mult_color = color / alpha_divider

In order to fix the rounding errors, we could turn ‘alpha_divider’
into a double.

That however would introduce a performance penalty since now we’d need
to do floating point math for each cell.

The algorithm can be trivially converted to:

  pre_mult_color = color * alpha / 0xffff

Since both color and alpa values are < 65536, the multiplication is
“safe”; it will not overflow an uint32_t.

Closes #249
2020-12-20 12:25:12 +01:00
Daniel Eklöf
ae01caee8c
render: ime: ensure cursor is visible 2020-12-08 19:17:46 +01:00
Daniel Eklöf
b270f221d0
render: search: render IME pre-edit text correctly, hopefully 2020-12-07 20:44:15 +01:00
Daniel Eklöf
bcfc468fd0
render: ime: adjust cursor cell index when adjusting glyph offset 2020-12-07 20:44:15 +01:00
Daniel Eklöf
d46dcd8ef5
render: ime: wip: pre-edit 2020-12-07 20:44:14 +01:00
Daniel Eklöf
7c420004fb
render: search: don’t access term->search.buf[] directly 2020-12-07 20:44:14 +01:00
Daniel Eklöf
1ea3674029
render: codespell: cound -> count 2020-12-07 20:44:13 +01:00
Daniel Eklöf
b4a0f5b13b
render: search: glyph_offset is in *cells*, cursor position in *characters*
When calculating the offset into the search string, from where to
start rendering, take into account that the cursor position is
in *characters*, and the glyph-offset is in *cells*.
2020-12-07 20:44:13 +01:00
Daniel Eklöf
5ffa65a2e3
render: search: wcsnlen() -> wcswidth() 2020-12-07 20:44:13 +01:00
Daniel Eklöf
a552610fdb
render: search: handle multi-column characters 2020-12-07 20:44:13 +01:00
Daniel Eklöf
dca35215d0
render: search: render colorized glyphs (emojis) correctly 2020-12-07 20:44:13 +01:00
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