Commit graph

4264 commits

Author SHA1 Message Date
Daniel Eklöf
0945e71572
search: find_next(): correctly wrap row number 2021-05-17 18:14:10 +02:00
Daniel Eklöf
5e621bbdb9
search: match_to_end_of_word(): use a local macro to bump coord 2021-05-17 18:14:10 +02:00
Daniel Eklöf
1c8bdf34ce
search: match_to_end_of_word(): use has_wrapped_around() while extracting text 2021-05-17 18:14:10 +02:00
Daniel Eklöf
11f7a6616b
search: match_to_end_of_word(): we always extend the selection with at least one character 2021-05-17 18:14:10 +02:00
Daniel Eklöf
7cf0e2aae4
search: match_to_end_of_word(): skip newlines when copying from extraction buffer 2021-05-17 18:14:10 +02:00
Daniel Eklöf
e460727afd
search: match_to_end_of_word(): refactor
Rewrite match_to_end_of_word() in terms of

* selection_find_word_boundary_right()
* extract_begin() + extract_one() + extract_finish()

This adds a small overhead, in that extract_*() allocates an internal
buffer, from which we then immediately copy, into our newly resized
prompt buffer.

On the other hand, this makes the matching behavior more consistent
with regular mouse selections, and we don’t have to keep two very
similar match-to-next-word-boundary implementations in sync.
2021-05-17 18:14:10 +02:00
Daniel Eklöf
1bc9fd5fe1
extract: add extract_finish_wide(), and optionally skip stripping trailing empty cells
extract_finish() returns the extracted text in UTF-8, while
extract_finish_wide() returns the extracted text in Unicode.

This patch also adds a new argument to extract_finish{,_wide},
that when set to true, skips stripping trailing empty cells.
2021-05-17 18:14:09 +02:00
Daniel Eklöf
eab874eb06
selection: expose find_word_boundary_{left,right}() 2021-05-17 18:14:09 +02:00
Daniel Eklöf
e415f85829
search: find_next(): proper check for scrollback wrap around
Besides disallowing matches that crosses the scrollback wrap-around,
this also fixes a crash when the trying to search beyond the last
output, when the scrollback history hasn’t yet been completely filled.
2021-05-17 18:14:09 +02:00
Daniel Eklöf
f87a13bbd2
Merge branch 'box-drawing-use-pixman' 2021-05-17 18:09:16 +02:00
Daniel Eklöf
8473deeed3
box-drawing: pre-calculate the LIGHT and HEAVY thicknesses 2021-05-17 17:58:30 +02:00
Daniel Eklöf
3dbb906325
box-drawing: always pass ‘buf’ as the first parameter
This way, the compiler doesn’t have to waste instructions on
re-ordering the parameters
2021-05-17 17:58:30 +02:00
Daniel Eklöf
25ce458281
box-drawing: don’t inline _thickness()
It results in quite a lot of floating point instructions being emitted
in almost every box drawing function we have...
2021-05-17 17:58:30 +02:00
Daniel Eklöf
b48414e72c
box-drawing: use fill_boxes() instead of fill_rectangles() 2021-05-17 17:58:30 +02:00
Daniel Eklöf
b771a28d17
box-drawing: increase brightness of solid shades 2021-05-17 17:58:30 +02:00
Daniel Eklöf
e7109d6b77
config: add tweak.box-drawing-solid-shades=yes|no
When enabled, shades are rendered as solid blocks, using a darker
variant of the current foreground color.

When disabled, shades are instead rendered in a checker box pattern,
using the foreground color unmodified.

Default is enabled.
2021-05-17 17:58:30 +02:00
Daniel Eklöf
c0bd152218
box-drawing: use an a8 buffer when primary font is antialiased
This causes relevant box drawing characters (diagonals, arcs etc) to
be antialiased as well.
2021-05-17 17:58:30 +02:00
Daniel Eklöf
9264d6695c
box-drawing: change_buffer_format: abort on pixman failure 2021-05-17 17:58:30 +02:00
Daniel Eklöf
99a3b034c3
box-drawing: apply antialiasing to LIGHT ARCs
When drawing on an a8 buffer, apply antialiasing to LIGHT ARCs. This
is done by supersampling; draw to a 4 times bigger buffer, then
downsample, where each downsampled pixel is the average of the
corresponding 4x4 pixel from the supersampled buffer.

We also need to take supersampling into account while adjusting the row
and col when pixel aligning the arcs with the regular
horizontal/vertical lines.

The shape of the ARCs can still be improved. Still, this is a much
needed improvement over the current implementation.

Closes #279
2021-05-17 17:58:30 +02:00
Daniel Eklöf
3d97b8c113
box-drawing: draw_pixman_shade(): named struct initialization 2021-05-17 17:58:29 +02:00
Daniel Eklöf
977d37396f
box-drawing: fix typo: missing ‘.’ in struct member initialization 2021-05-17 17:58:29 +02:00
Daniel Eklöf
6937b1add8
box-drawing: shades can now be rendered either using solid color, or checker box
For now, switching is done using a static variable. In the future,
this could be a user option.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
d495da03e1
box-drawing: temporary “fix” for LIGHT ARCs with a8 buffers
We don’t have a method to draw the arcs using pixman yet. Work around
this by replacing the a8 buffer with an a1 buffer, and render the arcs
using our old, non-antialiased, way.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
5dd8a70905
box-drawing: swap amount of shade for LIGHT and DARK shades
The DARK shade is the one most dense, and thus the one that looks
brightest.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
b280928084
box-drawing: draw shades as “antialiased” blocks
When rendering to an a8 surface, render shades using “transparent”
pixman rectangles.

When these glyphs are composited with a color, the resulting look is
the color, but darkened.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
d6898dcc42
box-drawing: use pixman_image_fill_boxes() for rect() 2021-05-17 17:58:29 +02:00
Daniel Eklöf
e05a510a7c
box-drawing: implement LIGHT diagonal lines using pixman
Use trapezoids to rasterize the diagonal lines.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
19fa1b30b8
box-drawing: rect(): implement using pixman
Use pixman_image_fill_rectangles() to render rectangles. Duh!
2021-05-17 17:58:29 +02:00
Daniel Eklöf
155537c2de
box-drawing: {h,v}line: implement using pixman
Use pixman_image_fill_rectangles() to render horizontal and vertical
lines.

Despite the name, this *is* the appropriate function to use, since our
lines *do* have a thickness, and thus *are* rectangles.
2021-05-17 17:58:29 +02:00
Daniel Eklöf
e03257d342
box-drawing: U+256C - BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL: add missing corner
The inner corner, where the upper/left lines meet, were missing
2021-05-17 17:58:29 +02:00
Daniel Eklöf
8d09ba5bd2
box-drawing: include pixman image in the buffer we’re passing around 2021-05-17 17:58:29 +02:00
Daniel Eklöf
ed60c66522
Merge branch 'reflow-performane-no-new-row-initialization'
Part of #504
2021-05-17 17:57:47 +02:00
Daniel Eklöf
1aa4a31c6f
grid: reflow: free old rows as soon as we’re done with them
This reduces the memory cost of reflowing text, as we no longer needs
to hold both the old and the new grid, in their entirety, in memory at
the same time.
2021-05-17 17:57:41 +02:00
Daniel Eklöf
11c7990ec8
grid: reflow: don’t initialize newly allocated rows
We’re going to write to it immediately anyway. In most cases, *all*
newly allocated, and zero-initialized, cells are overwritten.

So let’s skip the zero-initialization of the new cells.

There are two cases where we need to explicitly clear cells now:

* When inserting a hard line break - erase the remaining cells
* When done, the *last* row may not have been completely written -
  erase the remaining cells
2021-05-17 17:57:41 +02:00
Daniel Eklöf
ba23ee73e5
Merge branch 'font-scaling-factor-wrong'
Closes #509
2021-05-17 17:56:02 +02:00
Daniel Eklöf
2afc678236
term: get rid of term->font_scale, use term->scale only
We only needed term->font_scale to be able to detect scaling factor
changes (term->font_scale != term->scale).

But, we already have the old scaling factor in all places where
term_font_dpi_changed() is called, so let’s pass the old scaling
factor as an argument instead.
2021-05-17 17:55:49 +02:00
Daniel Eklöf
e7c01f3e52
changelog: fonts sometimes not being reloaded with the correct scaling factor 2021-05-17 17:55:49 +02:00
Daniel Eklöf
0e7e7b769b
render: simply check for an invalid (not set) scaling factor 2021-05-17 17:55:49 +02:00
Daniel Eklöf
0935428695
term: remove get_font_scale()
get_font_scale() was used to get the new scaling factor when loading
fonts. This was then compared to the last seen font scaling factor. If
there was no difference, the fonts were not reloaded.

The problem was, the initial term->scale was set differently. This
sometimes led to term->scale=2, while get_font_scale() return 1. That
meant, fonts were initially scaled by 2 (when dpi-aware=no). Later,
when mapped on an output (and thus term->scale being set to 1), the
fonts weren’t reloaded with the correct scaling factor since the
cached term->font_scale value was already 1.

Since term->scale always reflects the *new* scaling factor when
term_font_dpi_changed() is called, use that directly, and remove
get_font_scale().

Also rename the following functions:

* font_should_size_by_dpi() -> font_size_by_dpi_for_scale()
* font_size_by_dpi() -> font_sized_by_dpi()
* font_size_by_scale() -> font_sized_by_scale()
2021-05-17 17:55:39 +02:00
Daniel Eklöf
3405a9c81c
Merge branch 'reflow-performance'
Part of #504
2021-05-16 18:48:19 +02:00
Craig Barnes
cf3eeff951 Merge branch 'vt-anywhere-fix2' 2021-05-16 11:50:19 +01:00
Daniel Eklöf
a0ab4f3f1c
Merge branch 'sixel-dont-shrink-below-sra-size' 2021-05-16 11:05:59 +02:00
Daniel Eklöf
e0f1a4ae33
sixel: don’t *ever* shrink image below its SRA size
If the image was accompanied with a “Set Raster Attributes” (SRA)
command, make sure we *never* shrink the image below the size
specified in the SRA.

Images are normally shrunk when their bottom rows are fully
transparent. This enables sixels that aren’t a multiple of 6 to be
emitted, without also emitting an SRA command.

But if there *is* an SRA command, obey it.

Verified against XTerm-367
2021-05-16 11:00:32 +02:00
Craig Barnes
d37b2a7f7b Update term->vt.state for each iteration of vt_from_slave() loop
Otherwise it may be stale when read by the anywhere() function.
2021-05-15 19:20:36 +01:00
Daniel Eklöf
8d1b724056
grid: reflow: qsort_r() is not portable
Replace with qsort() + global variable. Not thread safe!
2021-05-15 13:37:46 +02:00
Daniel Eklöf
aa1f589e3f
grid: include <stdlib.h>, for qsort_r() 2021-05-15 13:32:10 +02:00
Daniel Eklöf
c7e51bdf72
grid: reflow: always run qsort_r(), handle rows == 0 in tp_cmp() instead 2021-05-15 13:00:46 +02:00
Daniel Eklöf
528e91aece
grid: take scrollback start into account when sorting the tracking points array
The row numbers in the tracking points are in absolute
numbers. However, when we walk the old grid, we do so starting in the
beginning of the scrollback history.

We must ensure the tracking points are sorted such that the *first*
one we see is the “oldest” one. I.e. the one furthest back in the
scrollback history.
2021-05-15 12:54:59 +02:00
Daniel Eklöf
60a55d04ac
grid: fix 32-bit compilation 2021-05-15 12:11:58 +02:00
Daniel Eklöf
a5d7f2e592
grid: reflow: tag tracking point if-statements with likely/unlikely 2021-05-15 11:44:13 +02:00