Commit graph

244 commits

Author SHA1 Message Date
Daniel Eklöf
d9e1aefb91
term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definition
Instead of using CELL_SPACER for *all* cells that previously used
CELL_MULT_COL_SPACER, include the remaining number of spacers
following, and including, itself. This is encoded by adding to the
CELL_SPACER value.

So, a double width character will now store the character itself in
the first cell (just like before), and CELL_SPACER+1 in the second
cell.

A three-cell character would store the character itself, then
CELL_SPACER+2, and finally CELL_SPACER+1.

In other words, the last spacer is always CELL_SPACER+1.

CELL_SPACER+0 is used when padding at the right margin. I.e. when
writing e.g. a double width character in the last column, we insert a
CELL_SPACER+0 pad character, and then write the double width character
in the first column on the next row.
2021-05-14 14:41:02 +02:00
Daniel Eklöf
0da766e505
selection: don’t strip formatting C0 control characters in bracketed paste mode
It’s ok to let the receiving end handle formatting C0 control
characters in bracketed paste mode.

In fact, we *must* let them through. Otherwise it is impossible to
paste e.g. tabs into editors and similar applications.
2021-02-12 15:59:07 +01:00
Craig Barnes
3c86af52c2 Convert all but 2 remaining uses of xassert(false) to BUG("...") 2021-02-10 09:01:51 +00:00
Daniel Eklöf
eff8481cdc
selection: remove selection_enabled()
Its name did not reflect its semantics. Since it was only used in a
single place, “inline” it there, and get rid of it.
2021-02-02 09:52:22 +01:00
Daniel Eklöf
81fb756ea7
selection: don’t replace \r\n and \n with \r in bracketed paste mode 2021-01-27 10:44:28 +01:00
Daniel Eklöf
49d6dbd761
selection: remove duplicate ‘ESC’ in switch case 2021-01-26 19:31:23 +01:00
Daniel Eklöf
e70776fc8c
selection: DEL is 0x7f, not 0x1f 2021-01-26 19:31:23 +01:00
Daniel Eklöf
9e5ef6efac
selection: codespell: stript -> strip 2021-01-26 19:31:23 +01:00
Daniel Eklöf
357af41d7e
selection: strip non-formatting C0, BS, HT and DEL from pasted text 2021-01-26 19:31:21 +01:00
Daniel Eklöf
b31d0c080b
selection: unbreak text/uri-list decoding: we’re not using \r, not \n
Before passing the pasted text to the decoder, we now replace \r\n,
and \n, with \r.

The URI decoder was looking for a \n, which meant we failed to split
up the list and instead pasted a single “multi-line” URI.
2021-01-26 19:31:12 +01:00
Daniel Eklöf
5168aa72cd
selection: replace \r\n and \n with \r, and strip \e from pasted text
Closes #305
Closes #306
2021-01-26 19:31:12 +01:00
Daniel Eklöf
4f578189cc
config: add ‘none’ as a possible value for ‘selection-target’
When ‘selection-target’ is set to ‘none’, selecting text does not copy
the text to _any_ clipboard.

This patch also refactors the value parsing to be data driven.
2021-01-23 10:43:59 +01:00
Daniel Eklöf
07f6b3b1af
selection: copy selected text to the target configured by ‘selection-target’
Closes #288
2021-01-23 10:43:59 +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
767bd4f1db
config: add ‘select-extend-character-wise’ bind action
This forces the (new) selection mode to be character-wise when
extending a word- or line-wise selection.

Default key binding is ctrl+RMB.
2021-01-14 16:29:29 +01:00
Daniel Eklöf
3be80622ef
selection: uri decode: move zero-length check into decode_one_uri() 2021-01-12 14:56:47 +01:00
Daniel Eklöf
c8bcce83d5
selection: add a ‘finish’ function, called at the end of receiving clipboard data
This is necessary to decode the final URI in a text/uri-list offer if
it hasn’t been newline terminated.
2021-01-12 14:45:41 +01:00
Daniel Eklöf
e3e3ffc67c
selection: URI decoder: break out decoding of a single URI 2021-01-12 14:45:04 +01:00
Daniel Eklöf
21dbb44a30
selection: extend-block: update pivot point and selection direction 2021-01-06 11:14:11 +01:00
Daniel Eklöf
3a34eda8cc
selection: extend: don’t copy to primary - it is done when RMB is released 2021-01-06 11:13:52 +01:00
Daniel Eklöf
b09197ea07
selection: extend: re-calculate pivot point 2021-01-06 11:07:19 +01:00
Daniel Eklöf
f236dc7701
selection: break out pivot point adjustment for character-wise selections 2021-01-06 10:54:53 +01:00
Daniel Eklöf
3a9172342f
selection: combine enum selection_kind with selection_semantic 2021-01-06 10:53:27 +01:00
Daniel Eklöf
4849e8f874
selection: update: line-wraps are ok while moving pivot start/end point
This fixes an assertion triggered when selecting the upper left cell
and dragging down.

We would end up trying to decrement the pivot end point, hitting an
assertion that only is valid while skipping spacers.

Remove the assertion, and allow pivot points to be moved across line
wraps, but take care not to move outside the visible screen area.
2021-01-04 19:48:44 +01:00
Daniel Eklöf
56f6e450b0
selection: update: get start-row pointer *after* modifying the start row index 2021-01-04 19:48:43 +01:00
Daniel Eklöf
fb9a95494d
selection: update: simplify: multi-column chars don’t span line-wraps 2021-01-04 19:48:43 +01:00
Daniel Eklöf
2b195d2cc3
selection: wrap pivot_{start,end}->row before accessing grid row array 2021-01-04 19:48:43 +01:00
Daniel Eklöf
8113d2205d
selection: cancel: reset pivot coordinates 2021-01-04 19:48:43 +01:00
Daniel Eklöf
683f63c929
selection: update: find_word_boundary_{left,right}: coordinates are screen local 2021-01-04 19:48:43 +01:00
Daniel Eklöf
c851aae9d6
selection: find_word_boundary_{left,right}: try to make the code more readable 2021-01-04 19:48:42 +01:00
Daniel Eklöf
3863a61ba6
selection: find_word_boundary_{left,right}: handle multi-column characters 2021-01-04 19:48:42 +01:00
Daniel Eklöf
b22091a8c9
selection: find_word_boundary{left,right}: what we match depends on initial character
If the initial character is a space, find the next non-space
character.

If the initial character is a delimiter, find the next non-delimiter
character (space, or word character).

If the initial character is neither (i.e, it is a word character),
find the next non-word character.
2021-01-04 19:48:42 +01:00
Daniel Eklöf
2fd7b2fbd4
selection: allow selections to pivot around a range instead of a point
Extend selection pivoting to allow selections to pivot around a
range.

Use this in word- and row-based selections to pivot around the initial
word/row that was selected.

This mimics the behavior of at least urxvt and xterm.
2021-01-04 19:48:42 +01:00
Daniel Eklöf
c821914e67
selection: find_word_boundary{left,right}: handle composed characters 2021-01-04 19:48:41 +01:00
Daniel Eklöf
736ff0421c
selection: find_word_boundary_{left,right}: treat spacers as word chars 2021-01-04 19:48:41 +01:00
Daniel Eklöf
3afc5a723e
selection: use selection_start() to initialize word/row-based selection
This removes the selection_mark_word() and selection_mark_row()
functions. To start a word/row-based selection, use selection_start()
with SELECTION_SEMANTIC_{WORD,ROW}
2021-01-04 19:48:41 +01:00
Daniel Eklöf
3dd6b7e4ef
selection: don’t finalize selection when starting a word/row-based selection 2021-01-04 19:48:41 +01:00
Daniel Eklöf
bef69cb961
selection: remember whether word-wise selection uses spaces only for delimiters 2021-01-04 19:48:41 +01:00
Daniel Eklöf
55ecf29a36
selection: wip: update selection row-wise when initial selection was by row 2021-01-04 19:48:40 +01:00
Daniel Eklöf
30de262d29
selection: wip: update selection word-wise when initial selection was by word 2021-01-04 19:48:26 +01:00
Daniel Eklöf
ff96ce1e91
input: rework mouse button/motion handling
Store a list of currently pressed buttons, and which surface they
belong to (i.e. which surface that received the press).

Then, in motion events (with a button pressed, aka drag operations),
send the event to the “original” surface (that received the press).

Also send release events to the originating surface.

This means a surface receiving a press will always receive a
corresponding release. And no one will receive a release event without
a corresponding press event.

Motion events with a button pressed will *always* use the *first*
button that was pressed. I.e. if you press a button, start dragging,
and then press another button, we keep generating motion events for
the *first* button.
2020-12-12 19:05:24 +01:00
Daniel Eklöf
9e1746cc29
selection: do not try to paste un-handled mime types
Closes #230
2020-11-30 20:04:17 +01:00
Daniel Eklöf
043b741008
selection: offer clipboard content in more mime types 2020-11-30 20:02:47 +01:00
Daniel Eklöf
2281ee852a
selection: fix enum type
enum selection_scroll_direction is used when extending a selection by
auto-scrolling the terminal content while the mouse is outside the
grid.

What we want is enum selection_direction.
2020-11-06 20:12:15 +01:00
Daniel Eklöf
a8fb51a34c
selection: explicitly set direction when right-click extending
Fixes an issue where right-click-and-dragging to extend a selection
caused one cell being removed from the selection.

Closes #180
2020-11-04 19:01:59 +01:00
Daniel Eklöf
43f293f22e
selection: do mime-type based decoding before passing data to callback
The intention here is to make *all* text_from_clipboard() and
text_from_primary() callers benefit from mime-type base
decoding (e.g. URI list decoding).

Previously, the decoding was done *in* the callback, which meant only
the “default” clipboard/primary selection paste functions, and DnD,
recognized URI lists.
2020-11-01 11:52:11 +01:00
Daniel Eklöf
102d4975a1
selection: dnd: fix wl_data_offer_destroy() race
At the end of a drag-and-drop operation, we need to call
`wl_data_offer_finish()`.

We *must* ensure the data offer hasn’t been destroyed before
that. This could previously happen if the compositor decided to send a
regular clipboard offer *after* we had started a drop operation,
but *before* it had finished. The dnd offer was then destroyed when
the clipboard offer was received, causing us to crash in
`wl_data_offer_finish()`.

To handle this, let the receive_offer_context take over ownership of
the data_offer pointer, and “manually” destroy it *after* calling
`wl_data_offer_finish()` in `receive_dnd_done()`.

Note: we should not, and can not, do the same thing for regular
clipboard and primary selection offers; such offers can be used
multiple times and should *not* be destroyed after a single copy
operation.
2020-10-31 10:36:11 +01:00
Daniel Eklöf
bb43695426
codespell: fix misspelled words 2020-10-28 19:34:49 +01:00
Daniel Eklöf
be22fefdc7
selection: add support for different mime-types
Add support for `text/plain`, `text/plain;charset=utf-8` and
`text/uri-list` to regular copy operations (both from clipboard and
primary selection) and drag-and-drop operations.
2020-10-28 19:16:04 +01:00
Daniel Eklöf
9580c04dd3
selection: debug log of data offer mime-types and actions 2020-10-26 21:19:07 +01:00