Commit graph

77 commits

Author SHA1 Message Date
Daniel Eklöf
5bac3cfa2c
selection: use edge-triggered FDM handlers 2020-01-10 19:24:04 +01:00
Daniel Eklöf
40bb63e206
selection: finalize: ignore whether selections are 'enabled' or not
This fixes an issue where a "forced" selection (shift being pressed
while slave is tracking mouse events) would not finalize if the user
released shift *before* releasing the mouse button.
2020-01-06 11:59:26 +01:00
Daniel Eklöf
457eb573c4
selection: update: don't dirty cells that don't change state
Previously when updating a selection, we would unmark *all* cells in
the old selection, and then mark all cells in the new selection.

This caused *all* cells to be dirtied and thus re-rendered.

Avoid this, by adding a temporary state to the cells' selected state.

Before unmarking the old selection, pre-mark the new selection using a
temporary state.

When unmarking the old selection, ignore cells in this temporary state.
When marking the new selection, ignore cells in this temporary
state (except clearing the temporary state).
2020-01-06 11:56:18 +01:00
Daniel Eklöf
6833abf33c
selection: foreach_selection_*: must wrap row number
Fixes occasional crashes when we're at the end of the grid and
selection wraps around.
2020-01-05 15:38:45 +01:00
Daniel Eklöf
a83c9e2813
selection: min_bufsize_for_extraction: add one extra column for *all* rows 2020-01-04 14:06:39 +01:00
Daniel Eklöf
4c78b0203e
selection: rename selection_cell_count -> min_bufsize_for_extraction 2020-01-04 13:56:52 +01:00
Daniel Eklöf
e6f0483294
selection: cell count now adds one extra column per row, for \n
When we extract text, we may insert '\n' at the end of each line (or
last column of selection, for block selections).

These newlines doesn't occupy any physical cells, and thus we
must **make** room for them in the extraction buffer.
2020-01-04 13:53:30 +01:00
Daniel Eklöf
6ee86be1bf
selection: fix bug where first column on all rows but the first was lost
When extracting text from the selection, we lost the first column on
all rows but the first.

This is because the algorithm changed slightly when we moved to
foreach_selection(); the end-of-line detection is now done on the
first column of the new line, instead of the last column on the
previous line.
2020-01-04 13:19:30 +01:00
Daniel Eklöf
e28cb989d8
selection: simplify extraction by converting to UTF-8 at the end
Instead of converting a cell at a time to UTF-8, copy the wide
characters as is, and then convert everything at once at the end.
2020-01-04 13:09:06 +01:00
Daniel Eklöf
975a35ae16
selection: extract_selection now uses foreach_selected()
This "automagically" adds support for block selections, since
foreach_selected already handles block selections.
2020-01-04 13:01:00 +01:00
Daniel Eklöf
2a531327dd
selection: selection_cancel() now sets 'kind' to SELECTION_NONE 2020-01-04 12:09:09 +01:00
Daniel Eklöf
f12b1473fd
selection: store cell 'selected' state in the cells' attributes
Instead of having the renderer calculate, for each cell, whether that
cell is currently selected or not, make selection_update() mark/unmark
the selected cells.

The renderer now only has to look at the cells' 'selected'
attribute. This makes the renderer both smaller and faster.
2020-01-04 12:03:04 +01:00
Daniel Eklöf
d706e68280
selection: track selection type; normal or block selection 2020-01-03 23:29:45 +01:00
Daniel Eklöf
c6e46bbfac
selection: remove unneeded wayland display roundtrips 2020-01-03 21:01:07 +01:00
Daniel Eklöf
2f475d7b44
selection: optimize \r\n -> \n when receiving clipboard data
Instead of first memmoving, possibly lots of data lots of times, the
received buffer, and _then_ calling the callback, simply call the
callback multiple times, and just skip the \r character(s).
2019-12-15 12:11:12 +01:00
Daniel Eklöf
198529525c
selection: break out isword() to a new file 2019-12-03 19:16:58 +01:00
Daniel Eklöf
2208f4304b
term: add term_mouse_grabbed()
When this returns true, it means we have keyboard focus and are
grabbing the mouse (for e.g. selections), regardless of whether the
client has enabled mouse tracking or not.
2019-11-30 17:06:15 +01:00
Daniel Eklöf
edb78575c7
selection: forced selection requires keyboard focus
Up the requirements for enabling "forced" selection (that is, allowing
selections even though mouse tracking has been disabled).

* Require keyboard focus (if we don't have it, then the shift-key
  isn't is for us)
* Don't just require shift being pressed, but that all other modifiers
  are *not* pressed.
2019-11-30 11:59:47 +01:00
Daniel Eklöf
903581b7eb
async: first synchronous write may succeed partially
When trying to write (to e.g. the slave, or to a clipboard receiver),
we first try to send the data synchronously, and only if that fails do
we switch to asynchronous mode.

However, the first synchronous may (in fact, is likely to) succeed
partially.
2019-11-28 19:20:25 +01:00
Daniel Eklöf
fc7069e1a6
selection: text_to_clipboard: assert the clipboard serial is not 0 2019-11-22 21:55:47 +01:00
Daniel Eklöf
f9e7ae8a89
selection: selection_to_clipboard: exit early on no-selection
When there's no selection, exit early to avoid trying to get grid data
from row -1.
2019-11-22 21:55:47 +01:00
Daniel Eklöf
da92abef31
selection: we already have a direct pointer to the clipboard struct 2019-11-22 21:55:46 +01:00
Daniel Eklöf
b31c18c741
selection: buffer may be empty if only empty cells where selected 2019-11-16 10:56:10 +01:00
Daniel Eklöf
15b12f45c6
scan-build: fix a couple of minor warnings from a scan-build run 2019-11-05 10:39:36 +01:00
Daniel Eklöf
b17358bd0a
selection: make text_from_{clipboard,primary} async 2019-11-05 09:09:51 +01:00
Daniel Eklöf
dd57418494
selection: initialize 'ctx' before jumping into its scope 2019-11-05 08:51:10 +01:00
Daniel Eklöf
b15032d223
selection: text_from_{clipboard,primary}: add 'done' callback
This callback is *always* called, including when there has been an
error.

This is in preparation for making text_from_{clipboard,primary}
asynchronous.
2019-11-05 08:49:32 +01:00
Daniel Eklöf
9cd22dc398
selection: async send: handle POLLHUP 2019-11-05 08:40:39 +01:00
Daniel Eklöf
1207ad1502
selection: free strdup:ed clipboard data on fdm failure 2019-11-05 08:40:24 +01:00
Daniel Eklöf
8824e3823e
selection: remove debug assert 2019-11-05 08:40:01 +01:00
Daniel Eklöf
bb9dad18f4
selection: typedef not needed here (copy-paste from fdm.h) 2019-11-05 08:39:39 +01:00
Daniel Eklöf
dbb51ed4c9
selection: we don't set user data on primary/clipboard data sources 2019-11-04 14:11:18 +01:00
Daniel Eklöf
cebeb390e4
selection: try to write selection data synchronously first
Only if we fail to write everything do we switch to asynchronous mode.
2019-11-04 14:00:51 +01:00
Daniel Eklöf
60c3ff8737
selection: send primary/clipboard data asynchronously
TODO: try writing synchronously first
2019-11-04 13:11:15 +01:00
Daniel Eklöf
9f1525aef7
Rename: vt_to_slave() -> term_to_slave() 2019-11-03 00:52:24 +01:00
Daniel Eklöf
1adab32906
term: wayland struct is now not a part of the terminal struct
We do however need access to it, so provide a pointer. The difference
is that now we can have a *single* wayland instance, but multiple
terminal instances.
2019-10-27 18:51:14 +01:00
Daniel Eklöf
9f0b1f94c2
wayland: change all wayland callbacks to take a wayland pointer
Instead of passing the terminal to the wayland callbacks, pass a
'struct wayland' pointer.
2019-10-27 18:43:07 +01:00
Daniel Eklöf
c9455d5f21
kbd: move into wayland 2019-10-27 17:10:32 +01:00
Daniel Eklöf
5ca1ee701b
wayland: move clipboard/primary structs into the wayland struct
These are application global and very wayland specific
2019-10-27 16:15:32 +01:00
Daniel Eklöf
3ca6f9fe0b
selection: replace \r\n with \n in pasted text 2019-10-16 21:14:45 +02:00
Daniel Eklöf
16f15d1a36
selection: primary: don't require compositor to implement it 2019-09-25 19:26:55 +02:00
Daniel Eklöf
58d0657a97
selection: allow selections while searching scrollback 2019-08-27 20:57:58 +02:00
Daniel Eklöf
75830ba016
selection: regression: last cell wasn't included in copied text 2019-08-10 20:22:02 +02:00
Daniel Eklöf
15afd26716
osc: implement copy/paste to/from primary 2019-08-09 21:27:51 +02:00
Daniel Eklöf
70b6d9d7d2
input: don't paste from primary if client is mouse tracking 2019-08-09 21:26:34 +02:00
Daniel Eklöf
28a8b18c5e
selection: allow selection when mouse tracking is enabled *if* shift is pressed 2019-08-08 17:58:24 +02:00
Daniel Eklöf
481a1cd678
selection/input: triple click selects an entire row 2019-08-06 19:32:06 +02:00
Daniel Eklöf
c06f141189
term: cancel selection when scrolling wraps
If we scroll enough, we'll eventually end up wrapping around the
entire scrollback buffer. At this point, a selection is no longer
valid, so cancel it.

Note: this was very obvious when scrolling in the alt screen, since
its scrollback buffer is what you see on the screen (i.e. it has no
scrollback).
2019-08-05 20:16:17 +02:00
Daniel Eklöf
1e08d93528
selection: ensure start < end in finalize
When the selection is finalized, swap start/end if necessary, to make
sure start <= end.
2019-08-05 20:15:18 +02:00
Daniel Eklöf
c62ce72778
selection: mark-word using spaces only as word separator
When the user double-clicks with ctrl pressed, we now select the word
under the cursor using spaces only as word separator.
2019-08-05 19:02:27 +02:00