aboutsummaryrefslogtreecommitdiff
path: root/selection.c (unfollow)
Commit message (Collapse)AuthorLines
2020-02-14term: convert cell 'linefeed' attribute to a row 'linebreak' propertyDaniel Eklöf-1/+1
To do text reflow, we only need to know if a line has been explicitly linebreaked or not. If not, that means it wrapped, and that we should *not* insert a linebreak when reflowing text. When reflowing text, when reaching the end of a row in the old grid, only insert a linebreak in the new grid if the old row had been explicitly linebreaked. Furthermore, when reflowing text and wrapping a row in the new grid, mark the previous row as linebreaked if either the last cell was (the last column in the last row) empty, or the current cell (the first column in the new row) is empty. If both are non-empty, then we assume a linewrap.
2020-02-11selection: handle line break at last column correctlyDaniel Eklöf-1/+2
Insert a newline into the selection even if the last column contained a printable character, *if* that column also has linefeed=1.
2020-01-10Revert "selection: use edge-triggered FDM handlers"Daniel Eklöf-3/+3
This reverts commit 5bac3cfa2cb6a1e7b6eb0012c134bd2e844fcf61.
2020-01-10selection: use edge-triggered FDM handlersDaniel Eklöf-3/+3
2020-01-06selection: finalize: ignore whether selections are 'enabled' or notDaniel Eklöf-3/+0
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-06selection: update: don't dirty cells that don't change stateDaniel Eklöf-18/+47
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-05selection: foreach_selection_*: must wrap row numberDaniel Eklöf-2/+6
Fixes occasional crashes when we're at the end of the grid and selection wraps around.
2020-01-04selection: min_bufsize_for_extraction: add one extra column for *all* rowsDaniel Eklöf-7/+4
2020-01-04selection: rename selection_cell_count -> min_bufsize_for_extractionDaniel Eklöf-2/+2
2020-01-04selection: cell count now adds one extra column per row, for \nDaniel Eklöf-3/+11
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-04selection: fix bug where first column on all rows but the first was lostDaniel Eklöf-10/+12
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-04selection: simplify extraction by converting to UTF-8 at the endDaniel Eklöf-21/+25
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-04selection: extract_selection now uses foreach_selected()Daniel Eklöf-57/+105
This "automagically" adds support for block selections, since foreach_selected already handles block selections.
2020-01-04selection: selection_cancel() now sets 'kind' to SELECTION_NONEDaniel Eklöf-0/+5
2020-01-04selection: store cell 'selected' state in the cells' attributesDaniel Eklöf-24/+119
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-03selection: track selection type; normal or block selectionDaniel Eklöf-4/+9
2020-01-03selection: remove unneeded wayland display roundtripsDaniel Eklöf-2/+0
2019-12-15selection: optimize \r\n -> \n when receiving clipboard dataDaniel Eklöf-6/+14
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-03selection: break out isword() to a new fileDaniel Eklöf-21/+1
2019-11-30term: add term_mouse_grabbed()Daniel Eklöf-12/+1
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-30selection: forced selection requires keyboard focusDaniel Eklöf-1/+12
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-28async: first synchronous write may succeed partiallyDaniel Eklöf-4/+6
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-22selection: text_to_clipboard: assert the clipboard serial is not 0Daniel Eklöf-0/+1
2019-11-22selection: selection_to_clipboard: exit early on no-selectionDaniel Eklöf-0/+3
When there's no selection, exit early to avoid trying to get grid data from row -1.
2019-11-22selection: we already have a direct pointer to the clipboard structDaniel Eklöf-1/+1
2019-11-16selection: buffer may be empty if only empty cells where selectedDaniel Eklöf-0/+6
2019-11-05scan-build: fix a couple of minor warnings from a scan-build runDaniel Eklöf-0/+1
2019-11-05selection: make text_from_{clipboard,primary} asyncDaniel Eklöf-61/+84
2019-11-05selection: initialize 'ctx' before jumping into its scopeDaniel Eklöf-2/+2
2019-11-05selection: text_from_{clipboard,primary}: add 'done' callbackDaniel Eklöf-18/+33
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-05selection: async send: handle POLLHUPDaniel Eklöf-1/+4
2019-11-05selection: free strdup:ed clipboard data on fdm failureDaniel Eklöf-0/+4
2019-11-05selection: remove debug assertDaniel Eklöf-1/+0
2019-11-05selection: typedef not needed here (copy-paste from fdm.h)Daniel Eklöf-2/+0
2019-11-04selection: we don't set user data on primary/clipboard data sourcesDaniel Eklöf-4/+4
2019-11-04selection: try to write selection data synchronously firstDaniel Eklöf-35/+70
Only if we fail to write everything do we switch to asynchronous mode.
2019-11-04selection: send primary/clipboard data asynchronouslyDaniel Eklöf-36/+82
TODO: try writing synchronously first
2019-11-02Rename: vt_to_slave() -> term_to_slave()Daniel Eklöf-5/+5
2019-10-27term: wayland struct is now not a part of the terminal structDaniel Eklöf-21/+21
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-27wayland: change all wayland callbacks to take a wayland pointerDaniel Eklöf-4/+4
Instead of passing the terminal to the wayland callbacks, pass a 'struct wayland' pointer.
2019-10-27kbd: move into waylandDaniel Eklöf-1/+1
2019-10-27wayland: move clipboard/primary structs into the wayland structDaniel Eklöf-19/+16
These are application global and very wayland specific
2019-10-16selection: replace \r\n with \n in pasted textDaniel Eklöf-0/+16
2019-09-25selection: primary: don't require compositor to implement itDaniel Eklöf-0/+12
2019-08-27selection: allow selections while searching scrollbackDaniel Eklöf-1/+4
2019-08-10selection: regression: last cell wasn't included in copied textDaniel Eklöf-1/+1
2019-08-09osc: implement copy/paste to/from primaryDaniel Eklöf-66/+96
2019-08-09input: don't paste from primary if client is mouse trackingDaniel Eklöf-1/+1
2019-08-08selection: allow selection when mouse tracking is enabled *if* shift is pressedDaniel Eklöf-2/+1
2019-08-06selection/input: triple click selects an entire rowDaniel Eklöf-0/+8
2019-08-05term: cancel selection when scrolling wrapsDaniel Eklöf-0/+14
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-05selection: ensure start < end in finalizeDaniel Eklöf-6/+11
When the selection is finalized, swap start/end if necessary, to make sure start <= end.
2019-08-05selection: mark-word using spaces only as word separatorDaniel Eklöf-6/+10
When the user double-clicks with ctrl pressed, we now select the word under the cursor using spaces only as word separator.
2019-08-04selection: only disable selection when mouse drag/motion is onDaniel Eklöf-1/+2
This allows us to select text in e.g. man/less while still being able to use LESS=--MOUSE (i.e. enable scrolling with mouse).
2019-08-04selection: insert newlines only when last column is emptyDaniel Eklöf-7/+14
2019-08-02cell: pack more efficiently and store glyph as a wcharDaniel Eklöf-23/+26
The 'attributes' struct is now 8 bytes and naturally packed (used to be 9 bytes, artificially packed). 'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes, artificially packed). Furthermore, the glyph is stored as a wchar instead of a char*. This makes it easier (faster) to do glyph lookup when rendering.
2019-07-30selection: add a couple of word-breaking charactersDaniel Eklöf-4/+22
When "auto-selecting" a word, we used to only break on space characters. Now we break on a number of other characters as well.
2019-07-24render: add render_refresh()Daniel Eklöf-4/+2
2019-07-19selection: add text_from_clipboard()Daniel Eklöf-7/+26
This function reads data from the clipboard, and calls a user-provided callback for each chunk of clipboard data.
2019-07-19selection: add text_to_clipboard()Daniel Eklöf-6/+15
This function takes a string and makes it available to the clipboard.
2019-07-17selection: implement double-click-to-select-wordDaniel Eklöf-0/+69
2019-07-17selection: bug: apply grid's view offset when starting a selectionDaniel Eklöf-1/+1
2019-07-15Use vt_to_slave() instead of calling write(term->ptmx, ...) everywhereDaniel Eklöf-6/+7
2019-07-11selection: disable source listeners, since we don't currently use themDaniel Eklöf-0/+8
2019-07-11selection: implement copy *to* primaryDaniel Eklöf-6/+89
2019-07-11selection: add support for pasting *from* primaryDaniel Eklöf-0/+86
2019-07-11selection: add selection_from_primary() API (stub for now)Daniel Eklöf-0/+6
2019-07-11selection: cleanupDaniel Eklöf-4/+16
2019-07-11selection: calculate required length for clipboard textDaniel Eklöf-3/+12
2019-07-11selection: read until EOF when reading from clipboardDaniel Eklöf-6/+17
2019-07-11selection: it's an error to call offset_accept() on non-drag-and-dropDaniel Eklöf-3/+0
2019-07-11selection: handle partial writes and EINTR when writing to clipboardDaniel Eklöf-2/+16
2019-07-11selection: add support for pasting from clipboardDaniel Eklöf-1/+41
2019-07-11selection: initial copy-to-clipboard functionalityDaniel Eklöf-0/+232
2019-07-11selection: selection_finalize() ignores invalid selectionsDaniel Eklöf-0/+3
2019-07-11selection: spell 'finalize' correctlyDaniel Eklöf-1/+1
2019-07-11selection: invalidate *all* affected lines when updating selectionDaniel Eklöf-4/+14
2019-07-11selection: disable debug loggingDaniel Eklöf-1/+1
2019-07-11selection: disable selection when client has enabled mouse trackingDaniel Eklöf-0/+18
2019-07-11selection: add a selection APIDaniel Eklöf-0/+70