Commit graph

1969 commits

Author SHA1 Message Date
Daniel Eklöf
1d1eb89925
Merge branch 'space-optimize-combining-chars' 2020-05-03 11:36:20 +02:00
Daniel Eklöf
4d4df92f66
unicode-combining: limit maximum number of allowed composed chains 2020-05-03 11:31:59 +02:00
Daniel Eklöf
1ebdc01162
unicode-combining: detect when we've reached the chain limit
We currently store up to 5 combining characters in any given
base+combining chain.

This adds a check for when that limit is about to be exceeded. When
this happens, we log the chain + the new combining character.

Since things will break anyway, we simply overwrite the last combining
character.
2020-05-03 11:27:06 +02:00
Daniel Eklöf
b7ad4c2e2a
changelog: update 'unicode comining' entry - only parts of the feature are optional 2020-05-03 11:22:38 +02:00
Daniel Eklöf
9638d0213b
readme: update 'Unicode combining' 2020-05-03 11:21:31 +02:00
Daniel Eklöf
62e0774319
unicode-combining: store seen combining chains "globally" in the term struct
Instead of storing combining data per cell, realize that most
combinations are re-occurring and that there's lots of available space
left in the unicode range, and store seen base+combining combinations
chains in a per-terminal array.

When we encounter a combining character, we first try to pre-compose,
like before. If that fails, we then search for the current
base+combining combo in the list of previously seen combinations. If
not found there either, we allocate a new combo and add it to the
list. Regardless, the result is an index into this array. We store
this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell.

When rendering, we need to check if the cell character is a plain
character, or if it's a composed character (identified by checking if
the cell character is >= COMB_CHARS_LO).

Then we render the grapheme pretty much like before.
2020-05-03 11:03:22 +02:00
Daniel Eklöf
ae7383189a
osc: fix scaling of RGB formatted color specifiers 2020-05-02 23:07:26 +02:00
Daniel Eklöf
9eda632c97
osc: OSC 12: mimic xterm - a color value of 0 means use inverted fg/bg 2020-05-02 23:00:21 +02:00
Daniel Eklöf
db9b99e8ac
osc: fix 'OSC 12 ?' to return the cursor color, not the cursor text color 2020-05-02 22:58:30 +02:00
Daniel Eklöf
ac58d05c6b
osc: fix scaling of legacy formatted color specifiers 2020-05-02 22:57:12 +02:00
Daniel Eklöf
ef637fb5e8
render: don't re-instantiate the foreground pixman source 2020-05-02 22:14:48 +02:00
Daniel Eklöf
b10436e49b
vt: use signed integers to correctly detect when we're done 2020-05-02 20:01:43 +02:00
Daniel Eklöf
39024681ec
readme: sligh re-wording of the "Unicode combining" chapter 2020-05-02 19:57:18 +02:00
Daniel Eklöf
804642580e
meson: don't generate pre-compose table when -Dunicode-precompose=false 2020-05-02 18:43:13 +02:00
Daniel Eklöf
d8ebed0ee0
meson: only define FOOT_UNICODE_PRECOMPOSE if combining chars > 0 2020-05-02 18:42:47 +02:00
Daniel Eklöf
265a88c1ce
meson: generate unicode compose table
This replaces the pre-generated table used up until now.
2020-05-02 18:29:39 +02:00
Daniel Eklöf
a24a3520c7
script: generate-unicode-precompose: generate a complete header file 2020-05-02 18:25:15 +02:00
Daniel Eklöf
5a5b8140c4
readme: utf8proc is no longer a dependency 2020-05-02 17:36:22 +02:00
Daniel Eklöf
83e6b6df5d
changelog: try to fix link for Codebergs markdown parser 2020-05-02 17:35:04 +02:00
Daniel Eklöf
2df7b3c611
changelog: remove bad ']' in link 2020-05-02 17:34:19 +02:00
Daniel Eklöf
d945b68b73
unicode-combine: remove utf8proc dependency
We only used utf8proc to try to pre-compose a glyph from a base and
combining character.

We can do this ourselves by using a pre-compiled table of valid
pre-compositions. This table isn't _that_ big, and binary searching it
is fast.

That is, for a very small amount of code, and not too much extra RO
data, we can get rid of the utf8proc dependency.
2020-05-02 17:29:00 +02:00
Daniel Eklöf
8389c76549
unicode-combining: don't limit ourselves to the (western) diacritics blocks 2020-05-02 16:11:51 +02:00
Daniel Eklöf
3b29aa95c9
render: de-indent #if statement 2020-05-01 21:51:40 +02:00
Daniel Eklöf
4ae0e7c922
unicode-combining: pack struct 2020-05-01 21:47:38 +02:00
Daniel Eklöf
0c7a94dfdc
unicode-combine: leave a note saying we might need more than 2 combining chars 2020-05-01 20:19:46 +02:00
Daniel Eklöf
50543983ad
unicode-combine: only compose if we don't have any other combining characters
If the client sent the sequence SAB, where SA does NOT have a composed
representation, but SB does, the old code would compose SB and throw
away A.

This patch fixes this by only allowing a compose if there aren't
any pre-existing combining characters.
2020-05-01 20:17:37 +02:00
Daniel Eklöf
a6cd151cc7
meson: emit a 'summary()' at the end 2020-05-01 12:32:10 +02:00
Daniel Eklöf
99172e7f8e
Merge branch 'unicode-combining-for-real' 2020-05-01 12:06:09 +02:00
Daniel Eklöf
3474624c2c
unicode-combining: completely remove unicode combining characters when feature is disabled 2020-05-01 12:05:38 +02:00
Daniel Eklöf
66e5abdda3
term: combining characters: reduce max number of combining characters 2020-05-01 12:00:36 +02:00
Daniel Eklöf
9f3d07ff21
changelog: rewrite entry for combining characters 2020-05-01 12:00:01 +02:00
Daniel Eklöf
623329cf23
selection: extract text: also copy combining characters 2020-05-01 11:59:09 +02:00
Daniel Eklöf
76567e9ef0
render: render combining characters
This is basically just a loop that renders additional glyphs on top
off the base glyph.

Since we now need access to the row struct, for the combining
characters, the function prototype for 'render_cell()' has changed.

When rendering the combining characters we also need to deal with
broken fonts; some fonts use positive offsets (as if the combining
character was a regular character), while others use a negative
offset (to be used as if you had already advanced the pen position).

We handle both - a positive offset is rendered just like a regular
glyph. When we see a negative offset we simply add the width of a cell
first.
2020-05-01 11:56:13 +02:00
Daniel Eklöf
40bf01a8e6
grid: reflow: copy combining characters 2020-05-01 11:55:22 +02:00
Daniel Eklöf
cb5f80ec6a
vt: utf8: track combining characters that we failed to compose
When we detect a combining character, we first try to compose it with
the base character (like before).

When this fails, we instead add the combining character to the base
cell's combining characters array.

The reason for using a composed character when possible is twofold:
one, the rendered glyph will look better since it will be a single
glyph instead of two separate glyphs (possibly from different
fonts(!)). And two, for performance. A composed glyph is a single
glyph to render, while a decomposed glyph sequence means the renderer
has to render multiple glyphs for a single cell.
2020-05-01 11:52:40 +02:00
Daniel Eklöf
67614df9f9
term: print: reset combining characters for this cell
This is the *only* place combining characters are reset. In
particular, we do *not* reset them in a normal cell erase.

This is a performance design decision - clearing the combining
characters in erase is way too slow.

This way, we clear it only when we *have* to. Anything looking at the
combining characters must first ensure the base character is not 0.
2020-05-01 11:50:38 +02:00
Daniel Eklöf
b2c4115f3e
grid: add per-cell combining characters
The data is *not* added to the cell struct, since that one is too
performance critical.

Instead, the data is added as a separate array in the row struct.

This allows our performance critical code paths that e.g. clear cells
to perform as before.
2020-05-01 11:49:11 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
fc2e385d87
term: don't enable ptmx FDM callback until Wayland window has been configured
The way things works right now, we cannot enable the ptmx FDM callback
right away. We need to wait for the Wayland window to have been
configured.

Before the window is configured, we don't have a size, and no
grid. Thus, if we try to process ptmx data we'll crash since we have
no where to write it to.

So, registering the ptmx fd with the FDM is now delayed until we've
received the first 'configure' event from Wayland.
2020-04-30 17:22:57 +02:00
Daniel Eklöf
ae5af7bb06
term: start slave before loading fonts and starting rendering threads
This allows the client to load in parallel with our font loading,
which should improve startup time.
2020-04-30 11:39:41 +02:00
Daniel Eklöf
242bcb9550
main: only set LC_CTYPE
This is the only locale variable we need. This ensures LC_NUMERIC in
particular remains as "C", which is needed by fcft when instantiating
new fonts.
2020-04-29 20:09:41 +02:00
Daniel Eklöf
589e984b91
term: font size adjust: re-load fonts in parallel 2020-04-29 20:09:21 +02:00
Daniel Eklöf
1d67f37045
term: destroy: handle rendering threads not being initialized
We sort of already did this. However, we did not handle the case where
the thread array itself hadn't yet been allocated.
2020-04-29 20:08:19 +02:00
Daniel Eklöf
84e945a851
term: initialize rendering worker threads after instantiating fonts
This ensures the resources (e.g. stack) used by the transient threads
used to load the primary fonts can be re-used by the rendering worker
threads.
2020-04-29 20:07:21 +02:00
Daniel Eklöf
74d30dc410
csd: buttons: use default color table as default colors
If the user hasn't configured any CSD button colors, use the color
scheme's default colors for blue/green/red.
2020-04-29 20:06:16 +02:00
Daniel Eklöf
02d4a093bb
changelog: change -> changes 2020-04-28 22:11:12 +02:00
Daniel Eklöf
3adcbf7d4d
term: load primary fonts in parallel
Use four threads to load the four primary font variants - normal,
bold, italic and bold italic.

This speeds up initial startup, and reloading of fonts on a DPI
change.
2020-04-28 22:07:02 +02:00
Daniel Eklöf
2fd5a9ee8d
wayland: monitor unplug: call surface_leave() to handle terminal unmapping 2020-04-28 19:05:10 +02:00
Daniel Eklöf
9cfe720000
wayland: handle outputs disappearing
That is, deal with monitors being unplugged.

At least on Sway 1.4, surfaces are not unmapped before the output is
removed. Thus, in addition to free:ing the monitor resources, we also
need to update all terminals that are mapped on this output - remove
the output from their "mapped on" list.
2020-04-27 20:46:40 +02:00
Daniel Eklöf
37871aad84
wayland: group handle_global() together with handle_global_removed() 2020-04-27 20:18:03 +02:00