Commit Graph

5401 Commits

Author SHA1 Message Date
Maxime Coste
7394307a3d Merge remote-tracking branch 'nojhan/feat_padding-options' 2021-04-28 08:11:15 +10:00
nojhan
a9d33a8796 fix ncurses' padding option
- Use less iterations when drawing padding fill with multiple characters.
- Use column_length to handle null-width character as no character.
2021-04-27 15:27:57 +02:00
Markus F.X.J. Oberhumer
27d6361210 Improve UX: better error message about debug buffer on startup errors
Minuscule things like these can make a huge difference if you are
a first time user of a new text editor.
2021-04-27 12:52:10 +02:00
Ben Judd
272b70298e elif over "else if" 2021-04-19 11:53:19 -07:00
Maxime Coste
f7be47fb95 Merge remote-tracking branch 'Icantjuddle/fix_deprexated_mallinfo_call' 2021-04-19 20:56:55 +10:00
Maxime Coste
1683f7f5f5 Merge remote-tracking branch 'Icantjuddle/add_hash_unit_test' 2021-04-19 20:54:43 +10:00
Ben Judd
b09eb5e010 Comments 2021-04-18 16:28:11 -07:00
Ben Judd
56875088d4 comments 2021-04-18 16:06:05 -07:00
Maxime Coste
94c0162da7 Merge remote-tracking branch 'Screwtapello/support-keypad-keys' 2021-04-18 17:06:53 +10:00
Maxime Coste
b34bd239fa Merge remote-tracking branch 'alexherbo2/fix-edit-readonly' 2021-04-18 16:29:44 +10:00
Ben Judd
db3203fe59 mallinfo is deprecated in favor of mallinfo2 2021-04-17 13:49:21 -07:00
Ben Judd
161ca6d4d1 hash unit tests. 2021-04-17 13:19:35 -07:00
Taupiqueur
aa6ec5987c Fix edit -readonly command not setting readonly option 2021-04-14 02:36:25 +02:00
Tw
41833d7b7d fix line completion with prefix
There's a bug in current line completion, fix it.

Signed-off-by: Tw <tw19881113@gmail.com>
2021-04-11 11:54:48 +08:00
nojhan
daa63ba879 [feat] add ui_options: padding_char & padding_fill
In some cases, it may be difficult to easily spot the area out of the buffer
(bad color scheme, small font, superimposed windows).

This patch adds two ncurses ui_options to bypass this problem:
- `ncurses_padding_char`, to configure the padding character,
- `ncurses_padding_fill`, to indicate whether to fill the padding line
  (or to display a single character).

The default config is the legacy one (a single "~").
2021-04-05 20:21:48 +02:00
nojhan
ba344be51f fix show-whitespace: add missing NNBSP character
- Add the Narrow No-Break SPace (0x202F, NNBSP) to the list of handled
  spaces in the show-whitespace highlighter.
- Do not add an aditional option, just handle it like NBSP, with the same highlight character.
2021-03-31 15:28:23 +02:00
Maxime Coste
4be6df9d02 Parse more data at each fifo buffer read 2021-03-31 17:19:20 +11:00
Maxime Coste
da9a196fa0 Profile individual command runtime
Different approach than the one suggested by eraserhd

Closes $4095
2021-03-31 17:17:22 +11:00
Maxime Coste
d1e19727ff Tweak completion quoting behaviour once again
Quote by wrapping in quotes if we are replacing the whole token,
using backspaces if the completion only adds to it.

This ensure that the inserted completion will be correctly parsed
once validated.

Fixes #4121
2021-03-31 17:15:31 +11:00
Tim Allen
3aaf32f48f src/ncurses_ui: Teach Kakoune about all the numeric keypad keys.
Kakoune now knows about all the keypad keys listed in:

https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-PC-Style-Function-Keys
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-VT220-Style-Function-Keys

The VT220-style encodings are used to for modified numeric keys when NumLock is
off. For example, consider the 8/Up key:

| Modifiers       | Sequence    | Notes             |
|-----------------|-------------|-------------------|
| Unmodified      | CSI A       | Ordinary up arrow |
| Shift           | SS3 2 x     | Shift-8           |
| NumLock         | 8           | Ordinary 8        |
| Shift + NumLock | CSI 1 ; 2 A | Shift-Up          |

Note that even though the terminal distinguishes between keypad and regular keys,
Kakoune maps keypad keys onto regular keys - keypad Enter is still <ret>, it
just supports more modifiers than the regular Enter key.
2021-03-26 15:43:42 +11:00
Tim Allen
f7c1702965 src/ncurses_ui: move the parse_mask() helper outside parse_csi().
It's useful for parsing modifier masks in all kinds of sequences, not just CSI
sequences. Also, since the modifier mask always has "1" as "no modifiers",
do the subtraction inside parse_mask() instead of when calling it.
2021-03-26 15:17:41 +11:00
hss
49f5917125 Rename separator-cursor to cursor-separator 2021-03-22 19:38:33 -04:00
hss
3e539c963e Don't use optionals for storing active separator string 2021-03-21 19:52:19 -04:00
hss
07e2b03c11 Only use separator-cursor for the first line number in a wrapped line 2021-03-20 21:53:31 -04:00
hss
73ecd3356f Compare column_length of line-number separators 2021-03-20 21:33:53 -04:00
hss
8df2bb8bd5 Use optionals more wisely in line-numbers 2021-03-20 02:48:33 -04:00
hss
f16783b0a8 line-number: Add option to use a different separator on the current line 2021-03-19 23:23:01 -04:00
Maxime Coste
545db22ae4 Fix typo in file.cc 2021-03-12 09:10:19 +11:00
Maxime Coste
8e463e63ea Do not use replace write method when writing to a non-regular file
Fixes #4098
2021-03-11 20:48:44 +11:00
Maxime Coste
d5282735f2 Always redraw after getting some user input 2021-03-11 09:08:35 +11:00
Maxime Coste
4a59018dcd Do not select on non-urgent fd when handling only urgent events
This avoids 100% CPU usage when we have pending fifo input while running
a shell process, as we will not end-up busy looping in pselect but not
reading the available data due to being only processing urgent events.
2021-03-11 09:02:02 +11:00
Maxime Coste
0b234f7f67 Merge remote-tracking branch 'eraserhd/fifo-performance-fixes' 2021-03-11 07:49:20 +11:00
Jason Felice
d3824f3211 Use inplace_merge() for ranges 2021-03-09 10:13:31 -05:00
Jason Felice
c9be6730f6 Binary search for first range to change 2021-03-08 16:55:43 -05:00
Maxime Coste
f6c8ebc4d0 Refactor pipe reader/writer 2021-03-04 20:59:15 +11:00
Maxime Coste
da80a8cf6a Raise ThreadedVM initial thread capacity to 16
Threads are 4 bytes, an initial capacity of 4 led to allocating 16
bytes, raising that to 64 bytes seems quite reasonable.
2021-03-03 20:51:24 +11:00
Maxime Coste
f4a639e078 Re-use the Regex VM when completing filenames to reduce allocations
By re-using the VM we avoid re-allocating the threads and saves
buffers over and over again. We can just re-use the ones from the
previous matching.
2021-03-03 20:33:02 +11:00
Maxime Coste
eb292f1f00 Re-tweak command name completion behaviour
It turns out the fix for #4061 was breaking auto-selection with
space of command names.
2021-03-02 20:20:58 +11:00
Jacob Collins
9dfab2f1fb Follow ECMA specification for regex whitespace
Changes the behaviour of the \s and \h character classes to include
all WhiteSpace and LineTerminator characters defined in the ECMA
specification.
 - <https://262.ecma-international.org/11.0/#sec-white-space>
 - <https://262.ecma-international.org/11.0/#sec-line-terminators>
 - <https://262.ecma-international.org/11.0/#sec-characterclassescape>

Fixes #4034
2021-02-25 11:03:18 -05:00
Maxime Coste
7c321e121d Tweak requoting behaviour
Only requote when completion is replacing the whole token

Do not requote command names as they should not require it, tag
them as quoted.

Fixes #4061
2021-02-25 21:04:06 +11:00
Maxime Coste
978dfe4bdf Fix splitting display line in front of a replaced range
When a replaced buffer range atom was starting exactly at the
location we wanted to split onto the code would split *after*
that atom instead of before.

Fixes #4052
2021-02-16 12:35:25 +11:00
Maxime Coste
fa3aa3c1a3 Add + key to duplicate selections and <a-+> to merge overlapping ones
This is an experiment and might get reverted if overlapping selections
prove too cumbersome.

Fixes #4041
2021-02-15 09:01:14 +11:00
Maxime Coste
e6905552cf Fix CSI u support for escape key 2021-02-11 20:23:08 +11:00
Maxime Coste
26cf5cd1dc Fix resizing strings to -1 length
Fixes #4042
2021-02-01 20:16:30 +11:00
Maxime Coste
7751c7e188 Check XDG_RUNTIME_DIR owner before creating session directory
This avoids an issue when using `su` and running Kakoune which creates
a session directory owned by root and prevents the user from creating
more sessions.
2021-01-26 09:28:24 +11:00
Maxime Coste
74fc52b3de Write to stderr if execve fails
This should be rare but should not happen silently, this way it will
show in the parent process debug buffer.
2021-01-22 17:22:15 +11:00
Maxime Coste
04a64e6e29 Fix performance issue in show-matching highlighter on big buffers
Stop searching for the matching character when getting out of view
instead of going until the buffer edge.
2021-01-22 17:21:59 +11:00
Maxime Coste
0fd5a9d995 Slight code cleanup in generate_env 2021-01-22 17:21:59 +11:00
Tim Allen
a7ed1f03fb Distinguish <c-h> and Backspace on terminals where that is possible.
Different terminals send different codes to indicate backspace, usually one of
\x08 or \x7f, so Kakoune blindly treated both as backspace. However, a given
terminal is only likely to use one of those, and mnemonic control codes like
<c-h> are a precious resource so we should endeavour to keep backspace and
<c-h> separate when we can. Luckily, termios tells us what code our terminal is
currently using, and Kakoune already reads the information at startup, so we can
just use that information.

Thanks to @krobelus for figuring out the C++ syntax required.

Fixes #3863.
2021-01-15 18:49:53 +11:00
Maxime Coste
df7b33bc7b Merge branch 'master' of http://github.com/Woolworths/kakoune 2021-01-04 09:50:45 +11:00
Maxime Coste
49d1d4666d Merge remote-tracking branch 'cole-h/trim-only-one-newline' 2021-01-04 09:45:53 +11:00
Cole Helbling
7cde146807
command_manager: only remove last eol in %sh{} expansions
This makes it possible to keep significant EOL in shell expansions (e.g.
for use with clipboard helpers).
2021-01-02 19:53:40 -08:00
Maxime Coste
f1e45579a6 Merge remote-tracking branch 'jimt/master' 2021-01-03 11:15:11 +11:00
Maxime Coste
a0c23ccb72 Add missing limits includes
Fixes #4003
2021-01-03 10:58:09 +11:00
Jim Tittsler
a7fb4c042a Fix message typo 2021-01-01 15:15:27 +09:00
Maxime Coste
958a943121 Avoid non-POSIX ln -r switch
Fixes #3985
2020-12-25 12:07:13 +11:00
Cole Helbling
266e388c6b
commands: add "registers" subcommand to :debug
This prints all non-empty registers and their value(s) to the `*debug*`
buffer.
2020-12-23 14:22:44 -08:00
Jean Abed
650a7143be remove unused variable changes_tracker 2020-12-22 21:31:11 +11:00
Maxime Coste
e50b5fe137 Add Timer::disable() to be more explicit than set_next_date(TimePoint::max()) 2020-12-20 11:32:15 +11:00
Maxime Coste
74c337df5d Add a libexec/ directory and use it to find the kak command
Add that libexec directory to the PATH instead of the current kak
binary directory to avoid impacting other commands.

The libexec directory currently only contains a symlink back to
the Kakoune binary.
2020-12-09 09:13:45 +11:00
Maxime Coste
489404befa Merge remote-tracking branch 'occivink/no-sel-remaining-alt-space' 2020-12-05 08:47:04 +11:00
Olivier Perret
f2fb5a3214 Throw no_selections_remaining when using <a-space>
This makes it possible to use the mechanism introduced by 91386a53
2020-12-03 21:42:14 +01:00
Maxime Coste
95606d2336 Avoid potential use after free of the mode name
This can be an issue with NextKey that now does not have a static
mode name.
2020-12-01 21:56:55 +11:00
Maxime Coste
586f79c30d Ensure InputModes are kept alive during their idle logic
Various paths can run arbitrary commands (callbacks, hooks) which
could lead to the InputMode being popped off the mode stack, but
contrarily to the on_key method, we had no guarantees to be kept
alive.

Add a keep_alive RefPtr to this to ensure the mode survives till
the end.

Fixes #3915
2020-12-01 20:00:38 +11:00
Maxime Coste
a8d43ce6ce Merge remote-tracking branch 'AndrewVos/ignore-indent-on-line-completion' 2020-11-22 16:52:37 +11:00
Andrew Vos
f3f3f80624
Ignore indent when completing lines
When doing line completion, we previously used to not complete the line
if it had different indent to the potential completion.

This commit changes the behaviour to ignore indentation when completing lines.
2020-11-20 20:00:46 +00:00
Maxime Coste
161aa918df Restore auto-select on return, add a flag to disable that for commands
Fixes #3849 Again
2020-11-18 19:56:05 +11:00
Maxime Coste
14dbe63b4f Revert "Auto-insert prompt menu completions on <ret> if any text was entered"
Unfortunately this breaks some pretty useful use cases, such as inserting a
command ending with a new-line (as it now leads to an addtional command being
auto-completed on validation)

This reverts commit aab0be529f.
2020-11-17 07:03:14 +11:00
Maxime Coste
b09a0f5779 Merge remote-tracking branch '6112/msys2-wcwidth' into master 2020-11-11 07:36:44 +11:00
Maxime Coste
3ae2a5c2f6 Fix performance issue with word completion
When pasting many words with <a-p> we can end-up with a huge
concatenated word and many selections, the previous code ended
up iterating from each selection cursor to that word start and
end to find the word under the cursor.

This could lead to performance issue as each selection would
trigger iteration on that huge word. This is unnecessary as
word completion has a word length limit, so we now take it into
account to avoid iterating to far from the cursor position.
2020-11-07 10:42:51 +11:00
Maxime Coste
b1745ee8d3 Fix performance issue when pasting many selection
The previous code was advancing from the general insertion point
for all selection, instead of iterating only once from insertion
point until the end of inserted text.
2020-11-07 10:14:18 +11:00
Maxime Coste
94ac3084e1 Handle reading from stdin returning 0
0 means stdin was closed, this is quite unexpected as we would usually
get a SIGHUP, but it looks like in some rare case this happens and
it leads to an infinite loop trying to handle stdin events (as it
will always be readable from now on).

Fixes #3557
2020-11-02 22:54:54 +11:00
Maxime Coste
aab0be529f Auto-insert prompt menu completions on <ret> if any text was entered
Previously we would only auto-insert if the current token had some
text, but this breaks auto-selection of the first match.

Fixes #3849
2020-11-01 10:32:44 +11:00
Tim Allen
c039879c82 src/ncurses_ui.cc: Teach Kakoune about ctrl-symbol keys.
Previously, Kakoune only handled ctrl-codes less than 27, representing them as
lower-case ASCII codes. For regular keys like <c-a>, that worked fine. However,
NUL became the unorthodox <c-`> and other ctrl-symbols (<c-\>, <c-]>, <c-_>)
weren't supported at all.

Now NUL is rendered as the more comfortable <c-space>, and the other ctrl-symbol
codes are properly decoded.

Fixes #2553.
2020-10-31 01:20:49 +11:00
Maxime Coste
90043e7df0 Replace write -atomic with write -method <method>
`-atomic` becomes `-method replace` and `-method overwrite` is now
supported explicitely instead of only available through the
writemethod option.

Fixes #3827
2020-10-27 20:20:18 +11:00
Maxime Coste
9a5cf2fc9f Support explicit register for :, |, ! and $ commands
Giving an explicit register uses its content for the default value
to use if the user does not enter anything. This enables:

`set-register a %{commands}; execute-keys '"a:<ret>'`
`set-register a %{shell script}; execute-keys '"a|<ret>'`
...

This provides a nice way to avoid the need to escape keys to use
those normal mode commands.

Fixes #3825
2020-10-20 21:56:51 +11:00
Maxime Coste
354cfd3b8f Disable auto-insertion of menu completion when no text was entered
This avoids a frustrating behaviour where Kakoune autoinserts the first
command name when hitting <space> after a ; in a command line. It also
fixes the empty prompt case that was auto-completed instead of executing
the default command.
2020-10-20 21:43:34 +11:00
Maxime Coste
4d22b405d6 Notify prompt completion changes in startup message 2020-10-20 21:05:26 +11:00
Nicolas Ouellet-payeur
4a59db1bd1 Fix wcwidth() compile error with MSYS2
We try to detect when compiling under Cygwin, so we can set the
_XOPEN_SOURCE define which lets us use wcwidth(). We look for the
string "CYGWIN" in the uname, which looks like:

    CYGWIN_NT-10.0

MSYS2 is also based on Cygwin, so all of the above should still work.
However, we detect Cygwin by looking for the string "CYGWIN" in the
uname. In MSYS2, the uname looks like:

    MSYS_NT-10.0-18362

This patch looks for the string "_NT" instead of the string "CYGWIN"
in the uname, since it's common to both environments. This fixes a
compilation error on MSYS2.
2020-10-19 09:36:25 -04:00
Maxime Coste
65587d1eee Auto-insert best completion on space for menu completions
The menu flag signifies that only the completions are valid arguments,
hence it makes sense to auto insert the best one on space.

Because full match is always considered the best match in completion
ranking, this should always have a reasonable behaviour.

This makes it harder to enter a hidden command, but completion can
always be disabled via <c-o> or by quoting in those rare cases.
2020-10-19 21:43:03 +11:00
Maxime Coste
2cd323b314 Allow quiting last client with unsaved buffer in daemon mode
Because the server will out-live that client's disconnection it
is still ok to have modified buffers, the server will complain
on `kill`.

Fixes #3801
2020-10-19 20:39:25 +11:00
Maxime Coste
97e88b6087 Remove the rename-client's nc alias
Closes #3789
2020-10-19 20:30:33 +11:00
Maxime Coste
def37a6ff4 Merge remote-tracking branch 'm-kru/vhdl' into master 2020-10-19 20:06:25 +11:00
Maxime Coste
f549190a98 Add support for explicit completion in prompt mode 2020-10-19 19:36:58 +11:00
Maxime Coste
f6c67f7831 Code cleanup in insert completer 2020-10-12 12:41:52 +11:00
Maxime Coste
246a32797a Fix region regexes incorrectly matching ^$ at end of line
Because no flags were set for regex matching, the regex engine was
assuming that the subject string past-the-end matched a end-of-line.
As the subject string already ended with a \n character, the regex
engine processing of the "past-the-end" position would match '^$'
as ^ matched past the existing \n and $ matched the assumed
end-of-line.

Fixes #3799
2020-10-12 12:41:21 +11:00
Maxime Coste
6a9b34e5c8 Merge branch 'add-illumos' of http://github.com/luka-devnull/kakoune into master 2020-09-30 19:38:52 +10:00
Maxime Coste
5d17e1132f Ensure that the capture group actually matched in select_matches
We were creating selections from default constructed iterators,
which happened to have 0,0 coords and led to out-of-order selection
lists.

Fixes #3757
2020-09-22 21:14:40 +10:00
luka null
1296922d66 Add illumos/Solaris support 2020-09-18 05:22:25 -05:00
Maxime Coste
ec3d7c3104 Add support for removing from options
`set -remove ...` will remove from the current option value, substracting
from int, removing elements from vectors and maps.
2020-09-09 21:00:30 +10:00
Maxime Coste
e0d2602e6a Kakoune 2020.09.01 2020-09-01 20:37:20 +10:00
Maxime Coste
1fd1a0052d Trigger InsertCompletionHide hook when switching to explicit completion
Previously we would just bypass that hook making it impossible to
act on the inserted text when triggering an explicit completion after
inserting text from the previous completer.
2020-08-30 10:35:15 +10:00
Maxime Coste
f56c1107e0 Fix face attributes to string conversion with F shorthand
Previously a `F` attribute would end up being converted to Ffga which
is confusing as F *means* fga.
2020-08-30 10:12:21 +10:00
Maxime Coste
1020438462 Clear inserted_ranges after updating insert completions candidates
They were getting out-of-sync with the stored timestamp, leading
to invalid ranges being computed and crashes.

Fixes #3666
Fixes #3571
2020-08-18 20:35:48 +10:00
Maxime Coste
40aa687601 Do not fork in daemon mode
Leave that to the shell or external service management tools

Fixes #3618
2020-08-17 19:56:00 +10:00
Maxime Coste
669048f458 Rename DefinedHighlighters to SharedHighlighters
Matches the user facing name and seems more correct.
2020-08-08 11:19:02 +10:00
Maxime Coste
5aa657b150 Merge remote-tracking branch 'eraserhd/runtime-var' 2020-08-06 20:15:38 +10:00
Jason Felice
a52822d965 Override runtime by setting $KAKOUNE_RUNTIME 2020-08-04 11:48:34 -04:00
Maxime Coste
2c437cfa02 Kakoune 2020.08.04 startup info 2020-08-04 19:40:43 +10:00
Johannes Altmanninger
266fe6f659 Support count argument for [s and ]s
Part of #795
2020-08-02 11:30:14 +02:00
Johannes Altmanninger
98a1afcab0 Support count argument for [p and ]p
Part of #795
2020-08-02 11:30:14 +02:00
Maxime Coste
39ad6a5bda Do not flush input buffer in UI creation
Fixes #3635
2020-08-02 16:19:13 +10:00
Maxime Coste
e3f3297334 Fix alpha of merged faces 2020-07-31 15:45:52 +10:00
Maxime Coste
c2516f02f6 Do not trigger RegisterModified hooks on register about to be restored
This greatly reduces the amount of hooks triggered.
2020-07-21 20:27:42 +10:00
Maxime Coste
47ba36c66e Add a RegisterModified hook
This one has been a long time coming, I am still concerned this could
impact performance a lot. This hook does *not* trigger for capture
registers (0-9) or any other dynamic registers (that are not writable).

Fixes #859
2020-07-19 12:56:55 +10:00
Maxime Coste
5df8073c3c Code style tweaks 2020-07-19 12:54:41 +10:00
Maxime Coste
60dda1a597 Handle SIGTERM as a graceful exit, similar to the :kill! command
Do not backup modified files, go through graceful destruction of
singletons.

Fixes #3528
2020-07-07 20:41:40 +10:00
Maxime Coste
8abf18209e Fix selections getting unsorted on scroll
Fixes #3478
2020-07-05 10:13:57 +10:00
Maxime Coste
f2cc7bc891 Add User hook support 2020-07-04 13:48:27 +10:00
Igor Böhm
d79b005323 Fix 'error: non-constant-expression cannot be narrowed...'
ncurses_ui.cc:759:59: error: non-constant-expression cannot be narrowed from type 'unsigned int' to 'Key::MouseButton' in initializer list [-Wc++11-narrowing]
                return mouse_button(mod, Key::MouseButton{code}, coord, c == 'm');
                                                          ^~~~
2020-06-28 23:32:12 +02:00
Maxime Coste
d3374e7e5f Refactor mouse press/release handling to support 3 buttons
Change button to be an additional parameter instead of having separate
events for left/right buttons.

Fixes #3471
2020-06-28 19:48:55 +10:00
Maxime Coste
fc3e5ea419 Refactor how InsetCompletionHide hook parameter is computed
Keep track of inserted ranges instead of trying to re-derive them.

Fixes #3556
2020-06-27 13:33:50 +10:00
Maxime Coste
f5127f8b22 Merge remote-tracking branch 'lenormf/key-percent' 2020-06-25 20:58:26 +10:00
Maxime Coste
d4487d3bfc A module is not loaded after failing during load
distinguish the loading from loaded state, detect recursive loading.
2020-06-16 19:08:10 +10:00
Maxime Coste
f75d49e9ef Do not include non-primitive option value in *SetOption hook filter
Only include the value for int/str/bool options, for the rest just
write '<option name>=...'.

This should reduce the cost of some patterns such as repeatedly adding
a value inside a list option.

It seems very unlikely that the actual value would be matched by
a hook regex string for non primitive types.
2020-06-09 21:38:47 +10:00
Maxime Coste
66f15cf4ad Fix select wiping captures
It turns out `v = std::move(v)` with v a std::vector is not a no-op,
it clears the vector.
2020-06-07 14:12:54 +10:00
Frank LENORMAND
24c5169400 src: Introduce a <percent> named key
Similarly to the <semicolon> key, make it easier to write
`:execute-keys` commands by replacing <percent> with `%`.

Highlighters can keep escaping the sign when regular expressions are
not quoted, but built-in scripts that use `%` as an editing primitive
have been modified to use the named key, for clarity.
2020-06-03 15:42:38 +03:00
Maxime Coste
0fba373d1d Replace some tag dispatch with if constexpr 2020-06-01 20:46:48 +10:00
Maxime Coste
ec4980df34 Merge commit 'krobelus/05-highlight-replace-ranges-crash^' 2020-05-30 09:18:35 +10:00
Maxime Coste
08e0b663f7 Fix unintended interpretation of ranges length syntax
Ranges specified with a +<length> were inconsistent, with +0 meaning
an empty range, while +1 meant a two character long range (first character
+ the following one). Change that to mean a single character.

Fixes #3479
2020-05-29 12:25:57 +10:00
Maxime Coste
63371da8aa Avoid to_remove vector in select helper function
Remove the need to allocate anything when removing selections.
2020-05-29 12:00:02 +10:00
Maxime Coste
94f33bb638 Add a range based remove_if overload 2020-05-29 11:59:03 +10:00
Johannes Altmanninger
13a6aa2fbd refactor: remove extra semicolons 2020-05-28 20:04:32 +02:00
Maxime Coste
109abbeed4 Fix invalid regions with begin > end being generated
Fixes #3495
2020-05-28 20:58:46 +10:00
Maxime Coste
aad20f6576 Merge remote-tracking branch 'krobelus/paragraph-begin-oob' 2020-05-19 19:17:03 +10:00
Maxime Coste
af175d2e7e Output debug memory stats in a nice table 2020-05-19 17:16:37 +10:00
Johannes Altmanninger
fc63eef695 Fix crash when selecting previous paragraph at buffer begin
Fixes #3489

When there are multiple empty lines between a paragraph and the cursor
(C in the example below), <a-[>p skips over one of them. Prevent the
check for the extra newline from going out of bounds.

```
a paragraph

C	after <a-[>p, the first two lines will be selected
```
2020-05-17 14:15:48 +02:00
Johannes Altmanninger
08509cb408 Refactor: use is_eol() as elsewhere in this function 2020-05-17 14:11:45 +02:00
Maxime Coste
5fd548d5cf Fix use of unportable MSG_CMSG_CLOEXEC 2020-05-17 21:28:40 +10:00
Maxime Coste
151eb3299d Fix CSI u parsing of some special keys 2020-05-12 08:50:27 +10:00
Maxime Coste
60154300f9 Support piping data to client stdin
Pass the client stdin fd to the server and open a fifo buffer
from it.

Fixes #3394
2020-05-10 19:30:13 +10:00
Maxime Coste
2104af0771 Fix select_sentence going past the end of the buffer
Fixes #3472
2020-05-10 15:13:15 +10:00
Maxime Coste
f4efde7e08 Merge remote-tracking branch 'krobelus/kak-c-initial-buffer-pos' 2020-05-03 13:20:44 +10:00
Maxime Coste
2fca4e5643 Fix traling whitespaces 2020-05-02 13:02:10 +10:00
Maxime Coste
ccecd5bd8e Add support for alpha channel in colors
This makes it easier to define faces that lighten/darken whatever
they apply on.
2020-05-02 12:57:36 +10:00
Johannes Altmanninger
c010f14a7c Fix +line:col initial buffer position when connecting to session
A command line argument like +line[:column] can be used to specify a
target line and column for the first file.

This did not work when connecting to a session, because the client
opens its file parameter with `-e "edit file1; edit file2"` which is
executed after the initial buffer position is set. Work around this by
passing the position to the first file and avoid moving the cursor
in unrelated files.

Reproduce:

	kak -s foo
	kak -c foo +4:11 README.asciidoc
2020-05-01 10:05:37 +02:00
Maxime Coste
ceff2286af Fix clang compilation 2020-04-27 17:41:09 +10:00
Maxime Coste
35e8e12b12 Merge branch 'netbsd-1' of https://github.com/krytarowski/kakoune 2020-04-27 17:40:33 +10:00
Maxime Coste
954373d3cf Support multi-line replace-ranges
This likely has lots of rough edges, but should be an initial proof
of concept to support folding.
2020-04-27 17:39:21 +10:00
Maxime Coste
cb119251bc Do not replace partially selected ranges in replace-ranges highlighter
Partially selected ranges should not be replaced to make it possible
to see what is actually selected.
2020-04-27 17:39:21 +10:00
Maxime Coste
0fdfbdfd15 Fix highlighting empty ranges at end of line and begin of line 2020-04-27 14:31:26 +10:00
Maxime Coste
fde4c60dd9 Factor option based highlighters 2020-04-27 14:31:26 +10:00
Kamil Rytarowski
22931bdc1f Fix get_kak_binary_path() for NetBSD
Pass correct mib[] to sysctl(3).
2020-04-23 03:24:24 +02:00
Maxime Coste
a33b938652 Fix issue with select object and empty matches 2020-04-21 13:21:35 +10:00
Maxime Coste
562ee6143a Parse ascii newline/tab/escape as special keys instead of control keys
Fixes #3439
2020-04-13 12:44:15 +10:00
Maxime Coste
8000cd092f Fix internal command naming 2020-04-13 12:24:45 +10:00
Maxime Coste
91e3a58a3a Merge remote-tracking branch 'lenormf/fix-3410' 2020-04-13 11:09:08 +10:00
Maxime Coste
0fb479f0c2 Merge branch 'netbsd' of http://github.com/niacat/kakoune 2020-04-09 07:42:53 +10:00
Maxime Coste
f7a2ecfacb Support empty ranges in replace-ranges highlighter 2020-04-06 11:23:47 +10:00
Maxime Coste
c585107ab5 Add -override support to add-highlighter
This allow replacing a highlighter in place, not loosing its current
position in its parent.

Fixes #3436
2020-03-30 21:04:01 +11:00
Maxime Coste
b42885ef71 Fix empty strings not being zero terminated 2020-03-29 20:28:56 +11:00
Maxime Coste
8f30e37507 Untie focus reporting and mouse handling 2020-03-27 07:54:21 +11:00
nia
7d4a83a449 || -> or for consistency 2020-03-22 11:00:27 +00:00
nia
28982aae92 Fix build on NetBSD 2020-03-22 10:49:06 +00:00
Maxime Coste
3c265acd6c Remove posB from information given by the diff algorithm
posB is always the sum of previous add len and previous keep len,
so very easy to keep track of.
2020-03-20 20:27:50 +11:00
Maxime Coste
401ef84a4b Remove uses of reverse_iterator in diff implementation 2020-03-20 20:24:42 +11:00
Frank LENORMAND
07d702e419 src: Fix a compilation bug with g++-8
The Ubuntu Disco distribution comes with `g++` v8 installed by default,
which is not able to deduce the return type of a particular call to
`transform()`.

This commit explicitly declares the return type to mitigate that
problem, and allow the file to compile.

Fixes #3410
2020-03-17 09:00:29 +03:00
Maxime Coste
1b28a19058 Merge remote-tracking branch 'Anfid/scroll-test' 2020-03-15 12:32:54 +11:00
Maxime Coste
09375edf54 Merge remote-tracking branch 'occivink/arrange-buffers' 2020-03-15 12:18:04 +11:00
Maxime Coste
7545fa58ae Fix invalid access to deleted line when updating insert completion
The computation of the completion end position was taking place too
early, before we checked if the buffer did get modified.

Fixes #3349
2020-03-14 13:49:52 +11:00
Maxime Coste
31caae20eb Allow reading from fifo in readonly buffers
readonly is supposed to prevent the user from modifying the buffer
and it can be useful to generate a readonly fifo buffer.

Fixes #3398
2020-03-14 12:58:22 +11:00
Maxime Coste
8c2ef4965a Merge remote-tracking branch 'lenormf/fix-completion-escaping' 2020-03-13 08:08:17 +11:00
Maxime Coste
83a17227a5 Merge remote-tracking branch 'lenormf/fix-Makefile-compiler-string' 2020-03-13 08:06:42 +11:00
Maxime Coste
a53d501f7b Merge remote-tracking branch 'lenormf/fix-3399' 2020-03-13 08:05:04 +11:00
Maxime Coste
149da2064d Handle invalid utf8 in command line a bit better
Reduce the amount of decoding by working directly on
bytes.

Fixes #3388
2020-03-13 08:02:58 +11:00
Frank LENORMAND
7b28e68d6c src: Don't escape completion candidates with \
Completion candidates are currently escaped with a backslash `\`
character, which leads to ugly interactive commands on the prompt,
especially when they contain space characters.

This commit makes completion candidates be escaped by simple quoting.

Examples:

    candidate\ with\ spaces
    \%opt{foo}
    \"dquote
    \'quote

become:

    'candidate with spaces'
    '%opt{foo}'
    '"dquote'
    '''quote'
2020-03-12 22:24:44 +03:00
Frank LENORMAND
789caf89a3 rc Makefile: Fix the predicate to detect g++
Some distributions replace the expected "GCC" tag with their own name
and version, causing the Makefile not to include a compiler flag.
2020-03-12 17:04:34 +03:00
Joachim Henke
3881dc1e7a restore F1 key handling 2020-03-04 09:06:46 +01:00
Maxime Coste
610be9ac20 Fix invalid memory access in unit-tests 2020-03-04 12:08:16 +11:00
Maxime Coste
e3a5856284 Only replace chars >= 0 in fix_atom_text
If char is signed, the test was invalid

Fixes #3389
2020-03-03 20:16:31 +11:00
Maxime Coste
7a9292be58 Merge remote-tracking branch '6112/clippy-delay' 2020-03-03 07:49:02 +11:00
Maxime Coste
0a66eb9c47 Expand env vars as list of strings
This makes it possible to do :select `%val{selections_decs}` and to
correctly combine $kak_quoted with those.
2020-03-02 20:53:28 +11:00
Nicolas Ouellet-Payeur
10d887583f Make on_next_key_with_autoinfo() respect idle_timeout
The prompt and autocomplete normally wait for `idle_timeout` before showing
suggestions, however commands like `g`, `v`, or the lead-key show Clippy
instantly.

This fixes the issue by making `on_next_key_with_autoinfo()` wait for
`idle_timeout` before displaying suggestions.

Fixes mawww/kakoune#3365
Fixes mawww/kakoune#2066
2020-02-27 10:36:15 -05:00
Maxime Coste
b8eef27e04 Enable terminal application keypad mode 2020-02-26 17:45:52 +11:00
Maxime Coste
af6885c0c9 Control character end at 0x1F 2020-02-26 07:59:05 +11:00
Maxime Coste
df844c6243 Do not replace spaces in prompt text 2020-02-25 20:09:25 +11:00
Olivier Perret
5c116ab850 Add a new 'arrange-buffers' to let users change the order of the buflist 2020-02-24 09:41:46 +01:00
Maxime Coste
93a889bd44 Merge remote-tracking branch 'lenormf/complete-register-names' 2020-02-22 08:39:35 +11:00
Maxime Coste
bc8a9d82c3 Use Control Picture codepoints in prompt for all codepoints < 0x22
Fixes #3333
2020-02-22 08:39:21 +11:00
Maxime Coste
3ef8a6160d Small code style tweak in ranges.hh 2020-02-18 19:28:41 +11:00
Maxime Coste
60782b3dc9 Make diff implementation able to work on different iterator types 2020-02-18 19:26:01 +11:00
Maxime Coste
16e814d99e Merge remote-tracking branch 'lenormf/fix-makefile' 2020-02-16 10:40:45 +11:00
Maxime Coste
4438895cd5 Merge remote-tracking branch 'lenormf/startup_info-no_kakrc' 2020-02-16 10:40:12 +11:00
Maxime Coste
df4f71aaed Merge remote-tracking branch 'lenormf/fix-write-switches' 2020-02-15 18:34:18 +11:00
Maxime Coste
940b1b6175 Fix invalid memory access when getting the main entry of empty registers
Fixes #3370
2020-02-15 15:42:08 +11:00
Frank LENORMAND
744336ef2b src: Only remove objects and dependencies for the current target 2020-02-09 19:12:40 +01:00
Frank LENORMAND
e06d61a3e0 src: Allow :write-all to use -atomic, fix usage
It seems that when -atomic was implemented for `:write`, the usage
strings were not updated to reflect that a new flag was available.

The `write-all` command didn't benefit from the implementation of
the new flag despite also writing files - this commit fixes that.
2020-02-09 17:07:47 +01:00
Frank LENORMAND
c0cb5db6a4 src: Let :set-register complete register names
This commit allows the `set-register` command to suggest candidates
named after punctuated registers, similarly to %reg{…} expansions.
2020-02-09 15:31:08 +01:00
Frank LENORMAND
7790e31eb8 src: Don't show startup information when opening a file
Follow-up to #3317
2020-02-07 12:27:54 +01:00
Maxime Coste
e9cf0f23f2 Fix regex start desc computation for case insensitive ranges
Fixes #3345
2020-02-07 07:37:29 +11:00
Maxime Coste
fbd75d91ec Merge remote-tracking branch 'maximbaz/notes-formatting' 2020-02-07 07:02:32 +11:00
Maxime Coste
8b633aa79a Merge remote-tracking branch 'jo-he/master' 2020-02-07 07:01:17 +11:00
Maxime Coste
a105111593 Merge remote-tracking branch 'lenormf/startup_info-no_kakrc' 2020-02-07 07:00:25 +11:00
Frank LENORMAND
1ebab6c269 src: Show the startup information in no-load mode
This commit allows the changelog to be shown at startup even when
the editor was run with the -n flag.
2020-02-05 11:39:23 +01:00
Maxime Coste
e348219fee Merge remote-tracking branch 'omasanori/startup_info_version' 2020-02-05 20:51:17 +11:00
geppettodivacin
39a2ab84fa Use ReverseView to perform fewer allocations
The first attempt at a bug fix for @ symbols in selection buffer names
worked, but it was very inefficient. In particular, it allocated three
different vectors, and we really only needed the correct elements.
Manipulating iterators to give us the right slices of the existing
vector is far more efficient.

By reversing the original content and taking the last two, we're able to
get the number of selections and main selection without too much hassle.
The buffer name is everything from the start of the content to the
selection count. This gets us through with only one vector allocation.

Credit to @mawww for the optimization idea and for fixing my types.
2020-02-02 22:12:18 -06:00
geppettodivacin
5596b4b2b9 Add support for @ symbols in selection buffer
The selection descriptions use the format
`<buffer>@<timestamp>@<main_index>`. This fails when file paths have `@`
symbols in them: the parser splits on `@` symbols and finds more values
than it expects.

We here modify the behavior to require *at least* two @ symbols, using
the last two for `<timestamp>` and `<main_index>` and leaving the
remaining text for the <buffer>. This should work for any number of `@`
symbols, since `<timestamp>` and `<main_index>` are numbers and should
never contain `@` symbols.
2020-01-26 16:03:03 -06:00
Masanori Ogino
144380de8c Fix version comparison in show_startup_info.
The description of startup_info_version in the manual says "only messages
relating to a Kakoune version greater than this value will be displayed,"
but showed messages relating to the version equal to that value.

This change aligns the code with the manual and makes a workaround that set
startup_info_version next to the original version (ex. 20200117) unnecessary.

Signed-off-by: Masanori Ogino <masanori.ogino@gmail.com>
2020-01-21 14:51:18 +09:00
Joachim Henke
4914029712 fix several control key combinations in st 2020-01-20 12:51:06 +01:00
Maxim Baz
8f350ad5a9
Bring the italic formatting back 2020-01-20 09:46:11 +01:00
Joachim Henke
2deeb9df52 make the Insert key work in st 2020-01-19 16:22:34 +01:00
Maxim Baz
4dce836c5a
Fix version notes formatting 2020-01-16 13:23:13 +01:00
Maxime Coste
9ca479ed40 Kakoune v2020.10.16 2020-01-16 20:52:20 +11:00
Maxime Coste
b85365bff8 Reset SIGHUP handler on NCursesUI destruction
SIGHUP handler could trigger crashes if the EventManager was
already destructed when it was triggered.

Fixes #3288
2020-01-11 17:22:33 +11:00
Maxime Coste
6badd74790 Fix compilation on 32bit platforms
Fixes #3284
2020-01-09 20:13:02 +11:00
Maxime Coste
f808539dea Update inserted range when generating InsertCompletionHide hook param
The buffer might have been mutated in the mean time.

Fixes #3270
2020-01-08 20:33:26 +11:00
Maxime Coste
b37638dda4 Split RegexHighlighters matches per requested buffer ranges
When a region calls the regex highlighter, it is incorrect to share
the regex cache as it means we can get matches that span multiple
regions.

Fixes #3041
2020-01-05 18:58:32 +11:00
Maxime Coste
80ffc4d34f Merge remote-tracking branch 'fsub/rxvt' 2020-01-05 10:03:37 +11:00
Maxime Coste
b6f4985c10 Use markup for startup-info message 2020-01-04 12:12:38 +11:00
Maxime Coste
e6b98744c6 Restore support for line wrapping info boxes
Fixes #3280
2020-01-04 11:41:16 +11:00
Maxime Coste
8b6ed26e8c Few style changes on history exposition code 2020-01-02 22:36:26 +11:00
Maxime Coste
43dc494e5c Merge remote-tracking branch 'eraserhd/history-api' 2020-01-02 21:13:43 +11:00
Jason Felice
b03b51d27a Add 'history' and 'uncommitted_modifications' expansions 2020-01-01 19:47:29 -05:00
Maxime Coste
a17a0345cf Fix replacing at begining of buffer
Fixes #3275
2019-12-31 12:49:24 +11:00
Maxime Coste
22bfbd06af Redraw relevant clients after adding/removing highlighters 2019-12-28 11:27:04 +11:00
Maxime Coste
7c1d4f5bd6 Avoid unnecessary std::function 2019-12-28 10:47:16 +11:00
Maxime Coste
456fbd1315 Refactor fifo buffer reader code 2019-12-28 10:32:15 +11:00
Maxime Coste
62b4780e07 Fix command error line/column reporting 2019-12-24 08:34:24 +11:00
Maxime Coste
1946b6b09c Merge remote-tracking branch 'jkonecny/master-backport-fedora-spec' 2019-12-19 13:45:27 +11:00
Maxime Coste
a3445232a4 Update fs status post buffer write 2019-12-19 13:39:30 +11:00
Jiri Konecny
e6c7a8e44f
Make possible to change compression for make dist
This will make possible to get the same archive from make dist as from
GitHub archives. GitHub archives do not support current bzip2.
2019-12-18 17:59:18 +01:00
Maxime Coste
b68490ef11 Cleanup replaced range selection logic
Do not access Buffer::m_changes to find the inserted range, return
it directly from Buffer::insert and Buffer::replace. This fixes a
wrong behaviour where replacing at eof would lose the selected end
of line (as the implementation does not actually replace that end
of line)
2019-12-18 11:36:17 +11:00
Maxime Coste
878a7fbb90 Fix window_range expansion
It relied on the buffer first char being visible, and could trigger
segfaults when that was not the case.
2019-12-16 14:09:20 +11:00
Maxime Coste
efabe28173 Fix WinResize hook getting triggered during urgent event processing
WinResize hooks could be triggered during shell evaluation, leading
to any state potentially getting mutated after a shell evaluation
call.
2019-12-16 14:07:22 +11:00
Tim Allen
b09653ccc5 highlighters.cc: Add a '-min-digits' flag to the number-lines highlighter.
Fixes #3260.
2019-12-15 13:36:25 +11:00
Maxime Coste
dfc67dd582 Code style tweak 2019-12-15 10:47:20 +11:00
fsub
e7e7289813 Support rxvt style s-F3 to s-F10 2019-12-14 23:17:34 +01:00
fsub
3aab032797 Support rxvt style s-F11 and s-F12
Rxvt emits `\E[23$` and `\E[24$` for `F21` and `F22` (alias `s-F11` and
`s-F12` provided that `ncurses_shift_function_key` is set to `10`),
respectively.
2019-12-14 20:03:48 +01:00
Maxime Coste
874717885a Code style tweak in insert_output 2019-12-14 09:20:01 +11:00
Maxime Coste
32157a5809 Merge remote-tracking branch 'lenormf/reevaluate-exclamation-point' 2019-12-14 09:13:43 +11:00
Maxime Coste
53cef671fc Merge remote-tracking branch 'Screwtapello/tmux-keys' 2019-12-12 12:02:51 +11:00
Tim Allen
170762b4d9 src/ncurses_ui.cc: Add support for VT220-style Home and End keys.
Because we now support a bunch of different conventions for these keys, let's
add some citations for the benefit of future maintainers.

Fixes #3252.
2019-12-11 22:53:15 +11:00
Tobias Kortkamp
fc2b5c5f7b
Fix build on FreeBSD again
json_ui.cc:29:9: error: use of undeclared identifier 'sprintf'
        sprintf(buffer, R"("#%02x%02x%02x")", color.r, color.g, color.b);
        ^
1 error generated.

Regressed by 7cdbe1d3d2
2019-12-10 18:13:08 +01:00
Maxime Coste
9ace7b584d Kakoune v2019.12.10 2019-12-10 21:36:03 +11:00
Maxime Coste
15df0fc781 Add -scratch and -file switches to the rename-buffer command 2019-12-07 15:40:57 +11:00
Maxime Coste
42094209fd Update New flag and last save timestamp on buffer rename
Fxies #3244
2019-12-07 15:40:55 +11:00
Maxime Coste
023a65eeac Optimize regex in command 2019-12-05 21:11:12 +11:00
Maxime Coste
eb5af59d55 Restore regex optimization pass by introducing basic block analysis
Run the peephole optimizer on each basic block, avoiding the
previous issue that some instructions could move across their
boundaries.
2019-12-05 21:10:14 +11:00
Maxime Coste
d539e8fb89 Do not decode utf-8 when looking for regex next start
There is no need to decode as we know any non-ascii characters will
be treated as Other in the StartDesc.
2019-12-04 22:33:11 +11:00
Maxime Coste
ee2985739b Merge remote-tracking branch 'lenormf/window-range' 2019-12-04 21:16:11 +11:00
Maxime Coste
5c5d881c11 Merge remote-tracking branch 'lenormf/reload-buffer-hash' 2019-12-04 21:14:15 +11:00
Frank LENORMAND
e1bd076f5e src: Reload buffers when their contents' hash changes
Instead of triggering a reload event when the timestamp of a buffer's
underlying file changes, do so when its contents are actually modified.
2019-12-03 17:05:24 +01:00
Maxime Coste
0b66aa8dda Document that fg face is optional 2019-12-03 21:17:33 +11:00
Maxime Coste
36dce6a2d0 Merge remote-tracking branch 'lenormf/split-json' 2019-12-03 21:13:35 +11:00
Maxime Coste
5c1433ee65 Merge remote-tracking branch 'Laaas/patch-1' 2019-12-03 21:11:14 +11:00
Maxime Coste
b5baac4336 Merge remote-tracking branch 'lenormf/fix-doc-face-base' 2019-12-03 20:59:40 +11:00
Maxime Coste
a6a5d866a5 Merge remote-tracking branch 'somasis/master' 2019-12-03 20:59:33 +11:00
Frank LENORMAND
d32a660863 src: Document the base face syntax in :set-face 2019-12-02 11:37:31 +01:00
Frank LENORMAND
63092d12c0 src: Fix the build on Mac
When compiled on Mac with `clang`, the following error occurs at
compile-time:

```
./diff.hh:56:28: error: no member named 'min' in namespace 'std'
    const int max_D = std::min((M + N + 1) / 2 + 1, cost_limit);
                      ~~~~~^
```
2019-12-01 21:55:55 +01:00
Maxime Coste
2623366514 Pass inserted text ranges in InsertCompletionHide hook parameter
Fixes #2898
2019-12-01 21:05:02 +11:00