Commit graph

271 commits

Author SHA1 Message Date
Craig Barnes
104fe2fa55 Fix some spelling mistakes 2020-08-15 19:39:00 +01:00
Daniel Eklöf
20f0334e13
config: add mouse specific bind actions
This extends the "normal" bind action enum with mouse specific
actions.

When parsing key bindings, we only check up to the last valid keyboard
binding, while mouse bindings support *both* key actions and mouse
actions.

The new actions are:

* select-begin: starts an interactive selection
* select-extend: interactively extend an existing selection
* select-word: select word under cursor
* select-word-whitespace: select word under cursor, where the only
  word separating characters are whitespace characters.

The old hard-coded selection "bindings" have been converted to instead
use these actions, via default bindings added to the configuration.
2020-08-14 07:38:55 +02:00
Daniel Eklöf
44557dc7cf
input: don't crash on mouse motion events on the render timer surface 2020-08-14 07:35:01 +02:00
Daniel Eklöf
8808dd28f2
selection: adjust start point when the selection changes direction
Without this, the initial cell will always be selected, regardless of
how the selection is moved to the left or right.

With this patch, the initial cell will only be selected while the
selection is being made in the original direction. Changing direction
of the selection moves the start point to next/previous character.
2020-08-12 19:42:21 +02:00
Craig Barnes
f1fce96a1d config: handle allocation failure explicitly 2020-08-04 23:28:16 +01:00
Daniel Eklöf
4919ccbc70
term: remove unusued 'damage' list 2020-08-04 18:07:22 +02:00
Daniel Eklöf
d4ee9be4d7
config: add 'hide-when-typing'
When enabled, the mouse cursor is hidden when the user types in the
terminal. It is un-hidden when the user moves the mouse, or when the
window loses keyboard focus.
2020-07-31 17:09:06 +02:00
Daniel Eklöf
f6533a71e4
user-notification: 'productify' the user-warning system
* Rename user_warning to user_notification
* Add warning and error types (in addition to the existing deprecated)
* Simplify logic when emitting a user notification after forking; we
  don't need to copy the notification data since we're in a new
  process and have total control over that memory.
2020-07-30 18:58:54 +02:00
Daniel Eklöf
b3d0215c38
term: add capability to print warnings *inside* the terminal
This is intended to be used to print e.g. deprecation warnings inside
the terminal, *before* the shell is started.
2020-07-29 19:42:12 +02:00
Daniel Eklöf
295083059c
Merge branch 'master' into diagonal-dpi 2020-07-28 20:01:56 +02:00
Daniel Eklöf
76350c568e
term: term_surface_kind(): recognize the scrollback indicator sub-surface 2020-07-26 12:37:12 +02:00
Daniel Eklöf
b08db1ef97
term: store current font DPI as a float instead of an integer
FontConfig's DPI is a double, and using a float instead of an integer
results in higher resolution.
2020-07-26 07:45:03 +02:00
Daniel Eklöf
47e8c337dc
Merge branch 'master' into pipe-grid-to-external-tool 2020-07-16 17:50:34 +02:00
Daniel Eklöf
e1e52c706a
term: remove unused struct definition 'rgb' 2020-07-16 11:52:51 +02:00
Daniel Eklöf
4d17423ed1
term: add term_scrollback_to_text() and term_view_to_text()
These functions extract the current view, or the entire scrollback as
an UTF-8 encoded byte buffer.
2020-07-15 11:33:37 +02:00
Daniel Eklöf
2539e3cbb2
extract: extract_one: make arguments const 2020-07-15 11:31:38 +02:00
Daniel Eklöf
970a42a6dd
term: don't re-render last cursor cell if cursor was hidden 2020-07-15 08:21:41 +02:00
Daniel Eklöf
df2927e088
term: print: write special value CELL_MULT_COL_SPACER to extra cells
When printing a multi-column character, write CELL_MULT_COL_SPACER
instead of '0' to both padding cells (when character doesn't fit at
the end of the line), and to the cells following the actual character.
2020-07-14 16:49:11 +02:00
Daniel Eklöf
5c99e8013b
term: rename COMB_CHARS_LO,HI -> CELL_COMB_CHARS_LO,HI 2020-07-14 16:41:57 +02:00
Daniel Eklöf
b9719673a1
term: rename term_formfeed() -> term_carriage_return() 2020-07-14 09:29:10 +02:00
Daniel Eklöf
09bdf20aa0
render: keep lock while pushing dirty rows to worker queue
Instead of locking the queue for each dirty row we append, and
signaling a condition variable, just keep the lock while going through
the visible rows.

Release the lock once done.

Since we take the lock *before* posting the 'start' semaphore, all
workers will be waiting for the lock to be released.

Then, one at a time they'll get the lock and pick a row to
render. The queue will never get empty - when all rows have been
rendered, each worker will pick a 'frame done' "job" from the queue,
and break the rendering loop.
2020-07-13 13:27:23 +02:00
Daniel Eklöf
2bdd0a7c80
render: remove most of the special handling of cursor rendering
Previously, we had to explicitly render the old cursor cell *before*
applying scrolling damage.

We then rendered all the dirty rows, *without* rendering the cursor -
even if the cursor cell was among the dirty rows.

Finally, when everything else was done, we explicitly rendered the
cursor cell.

This meant a lot of code, and unnecessary render_cell() calls, along
with unnecessary wl_surface_damage_buffer() calls.

This was a necessary in the early design of foot, but not anymore.

We can simply mark both the old cursor cell, and the current one, as
dirty and let the normal rendering framework render it. All we need to
do is pass the cursor column to render_row(), so that it can pass
has_cursor=true in the appropriate call to render_cell(). We pass -1
here for all rows, except the cursor's row, where we pass the actual
cursor column.

With this, there's no need to calculate whether the cursor is visible
or not; just mark it's cell as dirty, and if that row is visible, the
normal rendering will take care of it.

This also simplifies the state needed to be saved between two frames;
we only need a row pointer, and the cursor column index.

Part of https://codeberg.org/dnkl/foot/issues/35
2020-07-12 12:56:10 +02:00
Daniel Eklöf
7d8974f930
term: remove term_has_kbd_focus(), use term->kbd_focus instead 2020-07-11 09:06:20 +02:00
Daniel Eklöf
8c72e9434e
term: cache kbd-focused state, just like we cache visual focus state
There's one difference however, when we receive a kbd unfocus call,
*all* seats must have us unfocused before we actually change the
state.
2020-07-11 09:04:46 +02:00
Daniel Eklöf
4e48d550ef
multi-seat: improve handling of multiple (mouse) pointers
* xcursor always set for all pointers
* xcursor sometimes not updated when it should be
* mouse grabbed state wasn't per seat, but global (i.e. "does at least
  one seat enable mouse grabbing")
* selection enabled state wasn't per seat
2020-07-09 09:52:11 +02:00
Daniel Eklöf
58415428cf
multi-seat: re-enable mouse button+motion reporting support 2020-07-08 18:16:43 +02:00
Daniel Eklöf
c470825067
wip: multi-seat support
Compiles and runs, but mouse, clipboard and other things have been
disabled.
2020-07-08 16:45:26 +02:00
Daniel Eklöf
69e4213e4a
term: don't use deprecated fcft_size_adjust()
When resizing the font on-the-fly, we now do a complete
font-reload (this is basically what fcft_size_adjust() did anyway).

To get the correct size, we maintain the current size ourselves.

We get the initial size from the user-provided font pattern, by
converting the string to an FcPattern, and using FcPatternGet() to
retrieve both the FC_SIZE and FC_PIXEL_SIZE attributes. These
attributes are then removed from the pattern, and the pattern is
converted back to a string.

The terminal struct maintains a copy of the font sizes. These are
initially set to the sizes from the config.

When the user resizes the font, the terminal-local sizes are
adjusted. To ensure the primary and user-configured fallback fonts are
resizes equally much, convert any pixel sizes to point sizes at this
point.

When the font size is reset, we reload the font sizes from the
config (thus once again returning actual pixel-sizes, if that's what
the user has configured).
2020-07-07 10:44:55 +02:00
Daniel Eklöf
a259eda535
config: add 'blink' option to cursor section in footrc
This option controls whether the default cursor should blink or
not. The default is to *not* blink.
2020-06-30 17:45:34 +02:00
Daniel Eklöf
dec796f525
sixel: if the client has specified a size, do not change that
We used to auto-resize images to always be a multiple of 6.

This is incorrect. The client may, for example, have specified a size
to align the image to a cell boundary, which may not be a multiple of
6.

Furthermore, in e.g. Jexer, which splits up an image into stripes,
that the next image would "overwrite" the previous one. Since the next
image was started on a cell row that the previous image had overflowed
into.
2020-06-11 18:40:52 +02:00
Daniel Eklöf
9452aff020
vt: initial version of UTF-8 decoding built-in into the VT parser 2020-06-07 16:16:50 +02:00
Daniel Eklöf
21e9031420
sixel: don't erase image when printing text *next* to it. 2020-06-06 13:59:46 +02:00
Daniel Eklöf
789617d5ad
term: don't double fork new terminal windows
Instead, register their PIDs with the new reaper module and let it
handle them.
2020-05-21 20:17:29 +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
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
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
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
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
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
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
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
e478874dd9
term: remove unneeded utf8.left member 2020-04-27 15:06:23 +02:00
Daniel Eklöf
e9ed3025a8
damage: remove 'scroll' sub struct
There is no other types of damage but scroll damage.
2020-04-26 12:47:19 +02:00
Daniel Eklöf
7194f65ae9
fcft: adjust to fcft-2.0 API changes
* font_*() -> fcft_*()
* struct font -> struct fcft_font
* struct glyph -> struct fcft_glyph
* enum subpixel_order -> enum fcft_subpixel
2020-04-21 19:29:36 +02:00
Daniel Eklöf
6f83ef81e5
render: use output's subpixel mode when rasterizing glyphs 2020-04-20 18:38:55 +02:00
Daniel Eklöf
89559d5466
grid: move 'cursor' state from terminal to grid
This way, the 'normal' and 'alt' grids have their own cursor state,
and we don't need to switch between them.
2020-04-16 18:51:14 +02:00
Daniel Eklöf
598ac4bcd0
Merge branch 'master' into scroll-damage-performance 2020-03-27 21:16:42 +01:00
Daniel Eklöf
758fd9fd58
client: add --maximized and --fullscreen
We now create a copy of the config for each client, and updates it
with the values passed from the client.

Since we're not actually cloning it (and e.g. strdup() all strings
etc) we can't call conf_destroy() to free it, but need to free just
the strings we've replaced.
2020-03-27 21:14:49 +01:00