Commit Graph

304 Commits

Author SHA1 Message Date
nicm
b9392d5cb1 Do not wrap at end of text when positioning at end of match because the
length may include trailing spaces.
2020-09-22 08:41:27 +00:00
nicm
88b66e9e28 Free buffer earlier to avoid confusing some compilers, GitHub issue
2382.
2020-09-18 11:23:29 +00:00
nicm
869c0e860f Fix some warnings, GitHub issue 2382. 2020-09-16 18:37:55 +00:00
nicm
df7fbcd7a5 Change searching to behave more like emacs and so that regex searching
doesn't overlap when searching forwards.
2020-08-05 09:11:09 +00:00
nicm
8f1179d656 Handle padding cells correctly when searching, GitHub issue 2301. 2020-07-15 10:09:54 +00:00
nicm
afe4ea4250 Correctly move to previous line when looking for previous word, from
Derry Jing.
2020-06-16 07:28:57 +00:00
nicm
63c2ed1483 Add some formats for search in copy mode (search_present, search_match).
GitHub issue 2268.
2020-06-11 19:43:34 +00:00
nicm
4e5e2c19d0 Now that we mostly only search visible text, the rate limit on repeating
search does not seem to be necessary, remove it for the moment.
2020-06-05 07:44:42 +00:00
nicm
2154e1f4fb Search marks outside the visible text are not useful, so there is no
point in allocating a big buffer to store them - just allocate the
visible text size, and ignore any outside.
2020-06-04 21:40:27 +00:00
nicm
c4732af006 Some improvements to performance of searching:
- Do not allow searches to be repeated at intervals of less than 50
  milliseconds, to prevent a huge queue of repeat key presses blocking
  up everything for ages.

- If the search text hasn't changed, the match count can't have changed
  and there is no need to do a full search, so only search the visible
  text. This includes both scrolling and repeating the search.

- Do not redraw twice when jumping to the search location.

GitHub issue 2258.
2020-06-04 20:41:57 +00:00
nicm
dc74d2e054 Make the -no-clear command variants not clear the search marks either. 2020-06-04 10:24:14 +00:00
nicm
f5366ff828 Missing ; in previous. 2020-06-02 19:16:46 +00:00
nicm
5fbae8c8c6 Fire copy-pipe command even if there is no text, means it works if it
has side effects.
2020-06-02 19:10:26 +00:00
nicm
f3931497f8 Use CLOCK_MONOTONIC for timer measurement and add a timestamp to control
mode %output blocks.
2020-06-02 08:17:27 +00:00
nicm
49ec074271 Tidy up new UTF-8 code and make it more generic. 2020-05-25 18:19:29 +00:00
nicm
4589297e43 Do not attempt to divide by zero when working out copy position. 2020-05-25 12:12:58 +00:00
nicm
3a5219c6d0 Instead of storing all UTF-8 characters in the extended cell which means
that 14 bytes are wasted for each character in the BMP, only store
characters of three bytes or less in the cell itself and store others
(outside the BMP or with combining characters) in a separate global
tree. Can reduce grid memory use for heavy Unicode users by around 30%.
2020-05-25 09:32:10 +00:00
nicm
ff8dd150e0 Add a mark in copy mode. Set with set-mark command (bound to 'X') by
default and the mark and cursor position are swapped with 'jump-to-mark'
(bound to M-x). The line containing the mark is shown in
copy-mode-mark-style with the horizontal position in reverse.

From Anindya Mukherjee in GitHub issue 2209.
2020-05-16 16:10:28 +00:00
nicm
126bacb473 Do not loop forever when search finds an empty match, GitHub issue 2203. 2020-05-16 16:03:57 +00:00
nicm
592f141dee Fix next-matching-bracket logic, from Chris Barber. 2020-05-16 16:03:30 +00:00
nicm
6ea6d46d0a Store and restore cursor position when copy mode is resized, from
Anindya Mukherjee.
2020-05-16 15:49:20 +00:00
nicm
d056144aa1 Try to search the entire history first for up to 200 ms so a search
count can be shown. If it takes too long, search the visible text only.
2020-05-16 15:38:14 +00:00
nicm
9605b080f6 Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a
callback and use it to let popups draw directly through input_parse in
the same way as panes do, rather than forcing a full redraw on every
change.
2020-05-16 15:34:08 +00:00
nicm
2391fe23ab Copy mode search improvements:
- Add styles for the search marking styles (copy-mode-match-style and
  copy-mode-current-match-style).

- Show the current match (the one with the cursor on it) in a different style.

- Copying without a selection will copy the current match if there is one.
2020-05-16 15:11:52 +00:00
nicm
f03b61131b Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
  fg and bg are stored in the pane struct and act as the defaults that
  can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
  them in sync.
2020-05-16 15:01:30 +00:00
nicm
4e0a718666 Add extension terminfo(5) capabilities for margins. 2020-05-16 14:22:51 +00:00
nicm
b846ec2665 Only trim blank lines when the source pane is not the target pane,
otherwise the cursor moves which is a bit strange.
2020-04-20 06:08:37 +00:00
nicm
282a7a8d96 Make sure the cursor position is still on screen after we have trimmed
empty lines. Also improve some log messages.
2020-04-17 14:06:42 +00:00
nicm
5aba26f2cb Add a copy-command option and change copy-pipe and friends to pipe to it
if used without arguments, allows all copy key bindings to be changed to
pipe with one option.
2020-04-17 08:03:22 +00:00
nicm
b6dfca9b4d Don't miss the last line off the screen when writing after resize, from
Anindya Mukherjee.
2020-04-16 05:22:08 +00:00
nicm
fc1855f514 Clear the selection and repeat the search on refresh same as resize. 2020-04-15 19:06:49 +00:00
nicm
53a29a2ffa Instead of fixing with the cursor position when the copied screen is
created, resize it and let the resize/reflow code fix it up and return
it. Solves various problems with cursor position and resizing when in
copy mode. With Anindya Mukherjee.
2020-04-15 17:50:02 +00:00
nicm
b9a00cbe8a Leave the cursor above empty lines. 2020-04-14 19:07:10 +00:00
nicm
e11295f42d Adjust cursor and scroll positions when entering copy mode so that the
cursor line is still visible even if the source and target panes are
different heights.
2020-04-14 18:33:01 +00:00
nicm
3f7f9a0e20 Make client -c and -t handling common in cmd-queue.c and try to be
clearer about whether the client is the target client (must have a
session) or not.
2020-04-13 20:51:57 +00:00
nicm
c0602f357d Now that copy mode copies the pane content rather than keeping a
reference to it, it isn't necessary that the pane in copy mode is the
same as the one copying from. Add a -s flag to copy-mode to specify a
different pane for the source content. This means it is possible to view
two places in a pane's history at the same time in different panes, or
copy from a pane's history into an editor or shell in the same pane.

From Anindya Mukherjee.
2020-04-10 07:44:26 +00:00
nicm
26f5dfbe46 Fix history-bottom to use the right line when working out the length. 2020-04-09 14:30:28 +00:00
nicm
e9e5facb0e Some minor style nits. 2020-04-09 14:23:34 +00:00
nicm
b96ac80901 Some unnecessary assignments and unused variables. 2020-04-09 13:52:31 +00:00
nicm
77b827f879 Change copy mode to make copy of the pane history so it does not need to
freeze updates (which does not play nicely with some applications, a
longstanding problem) and will allow some other changes later. From
Anindya Mukherjee.
2020-04-06 17:51:34 +00:00
nicm
b65eab5505 Check previous line rather than an extra line, from Anindya Mukherjee. 2020-04-03 05:18:02 +00:00
nicm
a20d96000e Only search the visible part of the history when marking (highlighting)
search terms, much faster than searching the whole history.
2020-04-02 17:03:10 +00:00
nicm
567b27e10a Add a 10 second timeout to prevent searches taking too much time, from
Anindya Mukherjee.
2020-04-01 09:36:37 +00:00
nicm
cd30633d10 Do not go down the regex search path (which is expensive because we need
to convert the grid data into a string for regexec and reverse it to
find the grid position) if the search string does not contain any regex
special characters.
2020-04-01 08:07:05 +00:00
nicm
c129ed3233 Use a comparison to check for wrap and avoid an expensive modulus. 2020-04-01 07:52:07 +00:00
nicm
89d2a20e56 Performance improvements for regex searching, most notably:
- Use the grid data directly instead of copying it.

- Special case the most typical one byte character cells and use memcmp
  for multiple bytes instead of a handrolled loop.

- Hoist regcomp out of the loop into the calling functions.

GitHub issue 2143.

Also a man page from from jmc@.
2020-04-01 07:35:10 +00:00
nicm
b66d62d2d0 Do not go down the regex search path (which is expensive because we need
to convert the grid data into a string for regexec and reverse it to
find the grid position) if the search string does not contain any regex
special characters.
2020-04-01 08:07:05 +00:00
nicm
46092f2760 Use a comparison to check for wrap and avoid an expensive modulus. 2020-04-01 07:52:07 +00:00
nicm
46ed81fc45 Performance improvements for regex searching, most notably:
- Use the grid data directly instead of copying it.

- Special case the most typical one byte character cells and use memcmp
  for multiple bytes instead of a handrolled loop.

- Hoist regcomp out of the loop into the calling functions.

GitHub issue 2143.

Also a man page from from jmc@.
2020-04-01 07:35:10 +00:00
nicm
2624edde46 Add non-regex search variants to avoid the performance cost for people
with large histories or long lines.
2020-03-31 16:53:23 +00:00