aboutsummaryrefslogtreecommitdiff
path: root/selection.c (follow)
Commit message (Collapse)AuthorAgeLines
* selection: line-wise selection now handles soft line-wrappingDaniel Eklöf2021-09-30-16/+83
| | | | | | | | | | | Previously, soft-wrapped lines were not selected correctly, as the selection logic was hardcoded to simply select everything between the first and last column on the current terminal row. Now, we scan backward and forward, looking for hard-wrapped lines. This is similar to how word-based selection works. Closes #726
* selection: modify: no need to check for NULL before calling free()Daniel Eklöf2021-08-16-4/+1
|
* selection: modify: convert ‘keep_selection’ bitmask from uint64_t to uint8_tDaniel Eklöf2021-08-16-11/+11
|
* selection: modify: replace reset_context() macro with a functionDaniel Eklöf2021-08-16-9/+9
|
* selection: don’t require two cell attr bits for selection updatingDaniel Eklöf2021-08-16-24/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When updating the selection (i.e when changing it - adding or removing cells to the selection), we need to do two things: * Unset the ‘selected’ bit on all cells that are no longer selected. * Set the ‘selected’ bit on all cells that *are* selected. Since it’s quite tricky to calculate the difference between the “old” and “new” selection, this is done by first un-selecting the old selection, and then selecting the new, updated selection. I.e. first we clear the ‘selected’ bit from *all* cells, and then we re-set it on those cells that are still selected. This process also dirties the cells, to make sure they are re-rendered (needed to reflect their new selected/un-selected status). To avoid dirtying *all* previously selected, and newly selected cells, we have used an algorithm that first runs a “pre-pass”, marking all cells that *will* be selected as such. The un-select pass would then skip (no dirty) cells that have been marked by the pre-pass. Finally, the select pass would only dirty cells that have *not* been marked by the pre-pass. In short, we only dirty cells whose selection state have *changed*. To do this, we used a second ‘selected’ bit in the cell attribute struct. Those bits are *scarce*. This patch implements an alternative algorithm, that frees up one of the two ‘selected’ bits. This is done by lazy allocating a bitmask for the entire grid. The pre-pass sets bits in the bitmask. Thus, after the pre-pass, the bitmask has set bits for all cells that *will* be selected. The un-select pass simply skips cells with a one-bit in the bitmask. Cells without a one-bit in the bitmask are dirtied, and their ‘selected’ bit is cleared. The select-pass doesn’t even have to look at the bitmask - if the cell already has its ‘selected’ bit set, it does nothing. Otherwise it sets it and dirties the cell. The bitmask is implemented as an array of arrays of 64-bit integers. Each outer element represents one row. These pointers are calloc():ed before starting the pre-pass. The pre-pass allocates the inner arrays on demand. The unselect pass is designed to handle both the complete absence of a bitmask, as well as row entries being NULL (both means the cell is *not* pre-marked, and will thus be dirtied).
* search: reset match state when selection is cancelledDaniel Eklöf2021-07-22-0/+3
| | | | | | | | | | | | While we’re in scrollback search mode, the selection may be cancelled (for example, if the application is scrolling out the selected text). Trying to e.g. extend the search selection after this has happened triggered a crash. This fixes it by simply resetting the search match state when the selection is cancelled. Closes #644
* csi: erase scrollback: cancel selection if it touches the scrollbackDaniel Eklöf2021-07-18-3/+1
| | | | | | | | | | | | | | | | | This breaks out the scrollback erasing logic for \E[3J from csi.c, and moves it to the new function term_erase_scrollback(), and changes the logic to calculate the start and end row (absolute) numbers of the scrollback, and only iterate those, instead of iterating *all* rows, filtering out those that are on-screen. It also adds an intersection range check of the selection range, and cancels the selection if it touches any of the deleted scrollback rows. This fixes a crash when trying to render the next frame, since the selection now references rows that have been freed. Closes #633
* composed: store compose chains in a binary search treeDaniel Eklöf2021-06-24-20/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation stored compose chains in a dynamically allocated array. Adding a chain was easy: resize the array and append the new chain at the end. Looking up a compose chain given a compose chain key/index was also easy: just index into the array. However, searching for a pre-existing chain given a codepoint sequence was very slow. Since the array wasn’t sorted, we typically had to scan through the entire array, just to realize that there is no pre-existing chain, and that we need to add a new one. Since this happens for *each* codepoint in a grapheme cluster, things quickly became really slow. Things were ok:ish as long as the compose chain struct was small, as that made it possible to hold all the chains in the cache. Once the number of chains reached a certain point, or when we were forced to bump maximum number of allowed codepoints in a chain, we started thrashing the cache and things got much much worse. So what can we do? We can’t sort the array, because a) that would invalidate all existing chain keys in the grid (and iterating the entire scrollback and updating compose keys is *not* an option). b) inserting a chain becomes slow as we need to first find _where_ to insert it, and then memmove() the rest of the array. This patch uses a binary search tree to store the chains instead of a simple array. The tree is sorted on a “key”, which is the XOR of all codepoints, truncated to the CELL_COMB_CHARS_HI-CELL_COMB_CHARS_LO range. The grid now stores CELL_COMB_CHARS_LO+key, instead of CELL_COMB_CHARS_LO+index. Since the key is truncated, collisions may occur. This is handled by incrementing the key by 1. Lookup is of course slower than before, O(log n) instead of O(1). Insertion is slightly slower as well: technically it’s O(log n) instead of O(1). However, we also need to take into account the re-allocating the array will occasionally force a full copy of the array when it cannot simply be growed. But finding a pre-existing chain is now *much* faster: O(log n) instead of O(n). In most cases, the first lookup will either succeed (return a true match), or fail (return NULL). However, since key collisions are possible, it may also return false matches. This means we need to verify the contents of the chain before deciding to use it instead of inserting a new chain. But remember that this comparison was being done for each and every chain in the previous implementation. With lookups being much faster, and in particular, no longer requiring us to check the chain contents for every singlec chain, we can now use a dynamically allocated ‘chars’ array in the chain. This was previously a hardcoded array of 10 chars. Using a dynamic allocated array means looking in the array is slower, since we now need two loads: one to load the pointer, and a second to load _from_ the pointer. As a result, the base size of a compose chain (i.e. an “empty” chain) has now been reduced from 48 bytes to 32. A chain with two codepoints is 40 bytes. This means we have up to 4 codepoints while still using less, or the same amount, of memory as before. Furthermore, the Unicode random test (i.e. write random “unicode” chars) is now **faster** than current master (i.e. before text-shaping support was added), **with** test-shaping enabled. With text-shaping disabled, we’re _even_ faster.
* wip: grapheme shapingDaniel Eklöf2021-06-24-4/+4
|
* selection: add support for TEXT/STRING/UTF8_STRING mime-types in incoming offersDaniel Eklöf2021-06-09-6/+15
| | | | | | | | | We were already offering these mime types for our own clipboard data, but ignored them in incoming offers. Fixes paste issues from Geany. Closes #583
* selection: reset ‘empty_count’ after we’ve emitted the empty cellsDaniel Eklöf2021-06-05-0/+2
| | | | | | | | | | | | | | When marking and unmarking cells, we don’t highlight trailing empty cells. We do however highlight empty cells if they are followed by non-empty cells. I think this was an intentional choice. If one row ended with trailing empty cells, but *no* hard linebreak, then we’d continue on the next row, and emit all the empty cells once we hit a non-emtpy cell on the second row. But this is something that shouldn’t happen in any real-world use cases.
* selection: fix bad assertionDaniel Eklöf2021-06-02-2/+2
| | | | | When there are multiple multi-column characters back-to-back, the cell before the pivot end point may in fact be a SPACER+1 cell.
* selection: pay attention to hard linebreaks when search for word boundariesDaniel Eklöf2021-05-31-4/+18
| | | | | | | | | | | | | | | | | | | Double-clicking on a word in the left or right margin, would line-wrap the selection if there was a non-empty cell in the corresponding right/left margin on the prev/next line. Regardless of whether there was a hard linebreak or not. Script to reprouce: !/bin/bash cols=$(tput cols) printf "%*coo\nbar\n" $((${cols} - 2)) f Run, then double click either “foo” or “bar”. Neither should select the other part. Closes #565
* extract: move ‘strip_trailing_empty’ parameter from extra_finish() to extract_begin()Daniel Eklöf2021-05-17-2/+2
|
* extract: add extract_finish_wide(), and optionally skip stripping trailing empty cellsDaniel Eklöf2021-05-17-1/+1
| | | | | | | | extract_finish() returns the extracted text in UTF-8, while extract_finish_wide() returns the extracted text in Unicode. This patch also adds a new argument to extract_finish{,_wide}, that when set to true, skips stripping trailing empty cells.
* selection: expose find_word_boundary_{left,right}()Daniel Eklöf2021-05-17-12/+16
|
* term: rename CELL_MULT_COL_SPACER -> CELL_SPACER, and change its definitionDaniel Eklöf2021-05-14-13/+13
| | | | | | | | | | | | | | | | | | | | | 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.
* selection: don’t strip formatting C0 control characters in bracketed paste modeDaniel Eklöf2021-02-12-18/+25
| | | | | | | | 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.
* Convert all but 2 remaining uses of xassert(false) to BUG("...")Craig Barnes2021-02-10-7/+6
|
* selection: remove selection_enabled()Daniel Eklöf2021-02-02-10/+0
| | | | | Its name did not reflect its semantics. Since it was only used in a single place, “inline” it there, and get rid of it.
* selection: don’t replace \r\n and \n with \r in bracketed paste modeDaniel Eklöf2021-01-27-3/+14
|
* selection: remove duplicate ‘ESC’ in switch caseDaniel Eklöf2021-01-26-4/+0
|
* selection: DEL is 0x7f, not 0x1fDaniel Eklöf2021-01-26-1/+1
|
* selection: codespell: stript -> stripDaniel Eklöf2021-01-26-1/+1
|
* selection: strip non-formatting C0, BS, HT and DEL from pasted textDaniel Eklöf2021-01-26-0/+17
|
* selection: unbreak text/uri-list decoding: we’re not using \r, not \nDaniel Eklöf2021-01-26-1/+1
| | | | | | | | 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.
* selection: replace \r\n and \n with \r, and strip \e from pasted textDaniel Eklöf2021-01-26-3/+27
| | | | | Closes #305 Closes #306
* config: add ‘none’ as a possible value for ‘selection-target’Daniel Eklöf2021-01-23-0/+3
| | | | | | | 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.
* selection: copy selected text to the target configured by ‘selection-target’Daniel Eklöf2021-01-23-1/+14
| | | | Closes #288
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-47/+47
|
* config: add ‘select-extend-character-wise’ bind actionDaniel Eklöf2021-01-14-5/+17
| | | | | | | This forces the (new) selection mode to be character-wise when extending a word- or line-wise selection. Default key binding is ctrl+RMB.
* selection: uri decode: move zero-length check into decode_one_uri()Daniel Eklöf2021-01-12-2/+4
|
* selection: add a ‘finish’ function, called at the end of receiving clipboard dataDaniel Eklöf2021-01-12-0/+24
| | | | | This is necessary to decode the final URI in a text/uri-list offer if it hasn’t been newline terminated.
* selection: URI decoder: break out decoding of a single URIDaniel Eklöf2021-01-12-27/+29
|
* selection: extend-block: update pivot point and selection directionDaniel Eklöf2021-01-06-0/+6
|
* selection: extend: don’t copy to primary - it is done when RMB is releasedDaniel Eklöf2021-01-06-2/+0
|
* selection: extend: re-calculate pivot pointDaniel Eklöf2021-01-06-0/+30
|
* selection: break out pivot point adjustment for character-wise selectionsDaniel Eklöf2021-01-06-80/+111
|
* selection: combine enum selection_kind with selection_semanticDaniel Eklöf2021-01-06-15/+29
|
* selection: update: line-wraps are ok while moving pivot start/end pointDaniel Eklöf2021-01-04-8/+14
| | | | | | | | | | | 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.
* selection: update: get start-row pointer *after* modifying the start row indexDaniel Eklöf2021-01-04-5/+6
|
* selection: update: simplify: multi-column chars don’t span line-wrapsDaniel Eklöf2021-01-04-14/+8
|
* selection: wrap pivot_{start,end}->row before accessing grid row arrayDaniel Eklöf2021-01-04-5/+7
|
* selection: cancel: reset pivot coordinatesDaniel Eklöf2021-01-04-0/+2
|
* selection: update: find_word_boundary_{left,right}: coordinates are screen localDaniel Eklöf2021-01-04-4/+10
|
* selection: find_word_boundary_{left,right}: try to make the code more readableDaniel Eklöf2021-01-04-24/+24
|
* selection: find_word_boundary_{left,right}: handle multi-column charactersDaniel Eklöf2021-01-04-8/+40
|
* selection: find_word_boundary{left,right}: what we match depends on initial characterDaniel Eklöf2021-01-04-50/+66
| | | | | | | | | | | 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.
* selection: allow selections to pivot around a range instead of a pointDaniel Eklöf2021-01-04-26/+78
| | | | | | | | | | 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.
* selection: find_word_boundary{left,right}: handle composed charactersDaniel Eklöf2021-01-04-0/+24
|
* selection: find_word_boundary_{left,right}: treat spacers as word charsDaniel Eklöf2021-01-04-4/+16
|
* selection: use selection_start() to initialize word/row-based selectionDaniel Eklöf2021-01-04-92/+91
| | | | | | 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}
* selection: don’t finalize selection when starting a word/row-based selectionDaniel Eklöf2021-01-04-2/+0
|
* selection: remember whether word-wise selection uses spaces only for delimitersDaniel Eklöf2021-01-04-2/+4
|
* selection: wip: update selection row-wise when initial selection was by rowDaniel Eklöf2021-01-04-2/+23
|
* selection: wip: update selection word-wise when initial selection was by wordDaniel Eklöf2021-01-04-54/+85
|
* input: rework mouse button/motion handlingDaniel Eklöf2020-12-12-0/+2
| | | | | | | | | | | | | | | | | | | 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.
* selection: do not try to paste un-handled mime typesDaniel Eklöf2020-11-30-2/+6
| | | | Closes #230
* selection: offer clipboard content in more mime typesDaniel Eklöf2020-11-30-0/+10
|
* selection: fix enum typeDaniel Eklöf2020-11-06-1/+1
| | | | | | | | 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.
* selection: explicitly set direction when right-click extendingDaniel Eklöf2020-11-04-0/+6
| | | | | | | Fixes an issue where right-click-and-dragging to extend a selection caused one cell being removed from the selection. Closes #180
* selection: do mime-type based decoding before passing data to callbackDaniel Eklöf2020-11-01-119/+104
| | | | | | | | | | 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.
* selection: dnd: fix wl_data_offer_destroy() raceDaniel Eklöf2020-10-31-0/+5
| | | | | | | | | | | | | | | | | | | | | 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.
* codespell: fix misspelled wordsDaniel Eklöf2020-10-28-2/+2
|
* selection: add support for different mime-typesDaniel Eklöf2020-10-28-83/+315
| | | | | | 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.
* selection: debug log of data offer mime-types and actionsDaniel Eklöf2020-10-26-5/+5
|
* selection: implement support for drag-and-dropDaniel Eklöf2020-10-26-5/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | We accept COPY and MOVE actions, for text/plain;charset=utf-8 mime-types. To implement DnD, we need to track the current DnD data offer *and* the terminal instance it is (currently) targeting. To do this, a seat has a new member, ‘dnd_term’. On a DnD enter event, we lookup the corresponding terminal instance and point ‘dnd_term’ to it. On a DnD leave event, ‘dnd_term’ is reset. The DnD data offer is tracked in the terminal’s wayland window instance. It is reset, along with the seat’s ‘dnd_term’ on a DnD leave event. On a drop event, we immediately clear the seat’s ‘dnd_term’, to ensure we don’t reset it, or destroy the offer before the drop has been completed. The drop’s ‘done()’ callback takes care of destroying and resetting the DnD offer in the terminal’s wayland window instance. Closes #175
* selection: re-factor: break out code shared between clipboard/primary sendDaniel Eklöf2020-10-13-59/+21
| | | | | The send functions are called by the compositor when another application wants to paste data *from* foot.
* selection: auto-scroll: call cmd_scrollback_{up,down}() with number of rowsDaniel Eklöf2020-10-11-4/+2
| | | | | No need to loop and call cmd_scrollback_{up,down}() with ‘1’ each loop iteration; just call it with the total number of lines to scroll.
* selection: cancel: call selection_stop_scroll_timer()Daniel Eklöf2020-10-11-4/+1
| | | | | Instead of re-implementing the same logic, simply call selection_stop_scroll_timer().
* selection: auto-scroll: add SELECTION_SCROLL_NOT as a scroll ‘direction’Daniel Eklöf2020-10-11-2/+9
|
* selection: auto-scroll: selection keeps scrolling while mouse is outside gridDaniel Eklöf2020-10-11-0/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moving the mouse outside the grid while we have an on-going selection now starts a timer. The interval of this timer depends on the mouse’s distance from the grid - the further away the mouse is, the shorter interval. On each timer timeout, we scroll one line, and update the selection. Thus, the shorter the interval, the faster we scroll. The timer is canceled as soon as the mouse enters the grid again, or the selection is either canceled or finalized. The timer FD is created and destroyed on-demand. Most of the logic is now in selection.c. The exception is the calculation of the timer interval, which depends on the mouse’s position. Thus, this is done in input.c. The scroll+selection update logic needs to know a) which direction we’re scrolling in, and b) which *column* the selection should be updated with. If the mouse is outside the grid’s left or right margins, the stored mouse column will be -1. I.e. we don’t know whether the mouse is on the left or right side of the grid. This is why the caller, that starts the timer, must provide this value. The same applies to top and bottom margins, but since we already have the scroll *direction*, which row value to use can be derived from this.
* selection: use appropriate check for PRIMARY pasteSergey Nazaryev2020-10-10-2/+2
| | | | | | Assume it could be a copy-paste typo. We should check PRIMARY, not CLIPBOARD. Without this fix, we can't use PRIMARY until we copy anything to CLIPBOARD.
* config: add ‘[default].word-delimiters’Daniel Eklöf2020-10-09-4/+5
| | | | | | | | | | This option lets the user configure which characters act as word delimiters when selecting text. This affects both “double clicking”, and ‘ctrl-w’ in scrollback search mode. Closes #156
* selection: reset clipboard/primary->text after free:ing itDaniel Eklöf2020-09-17-0/+2
|
* selection: primary unset: don’t free text twiceDaniel Eklöf2020-09-17-1/+0
|
* selection: add selection_<type>_has_data()Daniel Eklöf2020-09-09-0/+12
| | | | | Returns true when there is data available for paste in the clipboard/primary selection.
* selection: add selection_<type>_unset()Daniel Eklöf2020-09-09-0/+41
| | | | These functions clear the current selection.
* codespell: selection: faild -> failedDaniel Eklöf2020-08-27-1/+1
|
* selection: don't initiate a paste when we're already pastingDaniel Eklöf2020-08-25-0/+10
|
* selection: must use term_paste_data_to_slave() for paste dataDaniel Eklöf2020-08-25-1/+1
|
* selection: clipboard callback: assert we're in sending-paste-data modeDaniel Eklöf2020-08-25-0/+1
|
* selection: block non-paste data from being sent to client while pastingDaniel Eklöf2020-08-25-3/+12
| | | | | | | | | | While pasting data from the clipboard, block *all* other data from being sent to the client. This includes keyboard and mouse events, but also replies for VT queries. This is particularly important when bracketed paste has been enabled, since then the client will interpret *everything* between the bracketed paste start and end as paste data.
* selection: add a 2 second timeout when receiving clipboard dataDaniel Eklöf2020-08-25-11/+78
| | | | | | | | When reading clipboard data, a malicious clipboard provider could stall us forever, by not sending any data, and not closing the pipe. This commit adds a timer_fd based timeout of 2 seconds. If the timer triggers, we abort the clipboard receive.
* selection: don't do "return function_returning_void()" in functions returning voidDaniel Eklöf2020-08-23-11/+22
|
* don't use empty struct initializersDaniel Eklöf2020-08-23-3/+3
|
* selection: don't highlight trailing empty cells in a selectionDaniel Eklöf2020-08-18-11/+55
| | | | | This makes it clear which cells contain spaces (that will be copied) or are empty (will *not* be copied).
* selection: extend: set ongoing to trueDaniel Eklöf2020-08-14-0/+2
|
* selection: finalize: clear ongoing selectionDaniel Eklöf2020-08-14-3/+3
| | | | | | | | | | Check for ongoing selection, and *clear* it before bailing out due to the selection not having an end-point. This fixes an issue where a selection was kept as ongoing, even though the button had been released. Typically triggered by clicking without moving the mouse; this started a new selection, then (tried to) finalize it, but failed since the selection didn't have an end-point.
* selection: update: don't update if there's no ongoing selectionDaniel Eklöf2020-08-14-0/+3
|
* config: add mouse specific bind actionsDaniel Eklöf2020-08-14-0/+7
| | | | | | | | | | | | | | | | | | | | 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.
* selection: improve handling of multi-column charactersDaniel Eklöf2020-08-13-13/+14
| | | | | * Don't assume multi-column characters are exactly *two* columns * Check for CELL_MULT_COL_SPACER values instead of using wcwidth()
* selection: handle multi-column characters when reversing selection directionDaniel Eklöf2020-08-13-16/+30
|
* selection: adjust start point when the selection changes directionDaniel Eklöf2020-08-12-0/+37
| | | | | | | | | 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.
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-5/+6
|
* config: add 'pipe-selected' key bindingDaniel Eklöf2020-07-31-4/+7
| | | | | | | This works just like pipe-visible and pipe-scrollback, but pipes the user-selected text, if any, to the external tool. Closes #51
* Merge branch 'master' into scrollback-position-indicatorDaniel Eklöf2020-07-27-8/+8
|\
| * selection: extending a selection is now interactiveDaniel Eklöf2020-07-27-8/+8
| | | | | | | | | | That is, a selection extension can be resized just like an ordinary extension.
* | input: margins are not selectableDaniel Eklöf2020-07-26-3/+4
|/ | | | | | | | | | | | | * Fix col/row calculation in pointer-enter event; we did not take the margins into account. * seat->mouse.col,row are now set to -1 if the cursor is inside the margins. That is, col/row are only ever valid when the mouse is actually over the grid, and not in the margins. * Use regular 'left-ptr' mouse cursor when mouse is inside the margins, to not make the user think he/she can start a selection. Besides making things clearer, this also fixes a crash that occurred if you started a selection in e.g. the right margin.
* selection: provide a const-wrapper for extract_one()Daniel Eklöf2020-07-15-1/+9
| | | | | extract_one() takes const pointers, while the callback argument to foreach() expects non-const.