Commit Graph

5401 Commits

Author SHA1 Message Date
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
Kylie McClain
dc1cf24846
buffer.hh: Fix building on musl+libc++
Fixes #3233.
2019-11-29 22:58:36 -05:00
Maxime Coste
4fdbf21ff8 Refactor diff to make allocating a diff vector optional
The diff interface now goes through a for_each_diff function that
uses a callback for each found diff.
2019-11-30 11:29:36 +11:00
Mikhail Pogretskiy
89b4996fd7 Update scroll behavior 2019-11-28 22:35:52 +07:00
Maxime Coste
b765fb4971 Merge remote-tracking branch 'lenormf/fix-mmap-size-check' 2019-11-28 20:35:52 +11:00
Maxime Coste
085e7dd09e Merge remote-tracking branch 'lenormf/patch-2' 2019-11-28 20:32:16 +11:00
Maxime Coste
2904d13420 Add a {\} marker to disable markup processing 2019-11-28 20:23:52 +11:00
Frank LENORMAND
7a384edeb0 src: Check the filesize before calling mmap() 2019-11-26 13:26:31 +01:00
Maxime Coste
fc9e0e8c6a Fix small info text not being displayed 2019-11-26 22:08:05 +11:00
Maxime Coste
a933cae7b9 Merge remote-tracking branch 'lenormf/complete-expansion-reg' 2019-11-26 21:35:05 +11:00
Maxime Coste
9716c7c82d Merge remote-tracking branch 'lenormf/complete-expansion-file' 2019-11-26 21:34:22 +11:00
Frank LENORMAND
7512f5eae6 src: Use begin() to get iterators
When compiling the code with `-Wp,-D_GLIBCXX_ASSERTIONS`, the process
gets aborted, likely because iterators to standard containers are
not obtained in a safe way.

Fixes #3226.
2019-11-25 11:34:39 +01:00
Maxime Coste
6f087e899b Complete rename-buffer with filenames
Fixes #3215
2019-11-24 18:11:29 +11:00
Maxime Coste
6fd486c65e Replace tab characters with spaces in info/echo
This is tricky to fix better than that as tabs make text length
dependent on where it will get displayed and what preceedes it.

Also fix an issue with empty info title

Fixes #2237
2019-11-24 18:11:29 +11:00
Maxime Coste
34f48cc851 Rework ncurses info display, crop content when overlflowing
Optmize the code to avoid allocating like crazy, unify various
info style rendering, crop content and display markers that there
is more text remaining.

Fixes #2257
2019-11-24 18:11:29 +11:00
Maxime Coste
19e1be8e0d Make wrap_lines a lazy range view
Avoid the need to allocate a vector by using the ranges
framework.
2019-11-23 21:50:58 +11:00
Frank LENORMAND
ae85753c41 src: Complete filenames in %file{} expansions 2019-11-23 08:59:44 +01:00
Frank LENORMAND
2cdf86d674 src: Complete register names in %reg{} expansions
Builtin registers have name aliases that can be completed upon when
using a `%reg{}` expansion from the prompt.
2019-11-23 08:47:14 +01:00
Maxime Coste
cb1b03c0db Add support for markup in info boxes
Fixes #2552
2019-11-22 21:50:51 +11:00
Maxime Coste
22d9ffa63a Fix crash when deleting buffers in a BufClose hook 2019-11-22 20:29:55 +11:00
Maxime Coste
82e5346904 Add a -atomic switch to write and change clang.kak to take advantage 2019-11-21 23:38:32 +11:00
Frank LENORMAND
15f6485327
src: Give a reason why :rename-buffer failed 2019-11-18 16:46:53 +00:00
Maxime Coste
c031a276d5 Fix recently introduced ncurses redraw artifact 2019-11-18 21:17:22 +11:00
Maxime Coste
ba621dedd6 Ignore SIGTTOU
We can get this signal while suspending if a parent process (say
git-commit) has already put us in the background. We still need
to reset the termios state to exit raw input mode and make the shell
usable.

Fixes #3069
2019-11-18 21:00:59 +11:00
Maxime Coste
d3c3e59bbf Fix search menu trimmed entry display 2019-11-17 22:53:27 +11:00
Maxime Coste
1de038a743 Move the forked server into a new session and process group
Fixes #3212
2019-11-17 22:44:49 +11:00
Frank LENORMAND
19f1754a2a src json: Limit the recursion depth to 100 2019-11-17 09:27:46 +01:00
Frank LENORMAND
7cdbe1d3d2 src: Move JSON parsing code to its own file
The `json_ui.cc` file contained both data-parsing and UI-related
code. This commit moves the JSON parsing code to its own `json.cc`
file, to separate concerns, make compilation faster when changes are
made to either UI or parsing code, and make the parsing code more
accessible to fuzzers.

The signature of the following function:

```
auto parse_json(StringView json);
```

was changed to:

```
JsonResult parse_json(StringView json);
```

to avoid `auto` deduction issues at compile-time.
2019-11-17 09:27:46 +01:00
Maxime Coste
5378dabdec Fix String::resize not zero-terminating 2019-11-17 09:50:18 +11:00
Maxime Coste
e33ba455c8 Re-merge clear_to_eol in draw 2019-11-13 22:17:08 +11:00
Jason Felice
0f58f01428 Fix display column computations
Closes #3201
2019-11-12 20:43:14 -05:00
Maxime Coste
a7d3976a10 Fix typo 2019-11-13 08:58:15 +11:00
Maxime Coste
e964b68ab8 Add support for selecting and exporting selections in display columns
Fixes #2724
2019-11-12 21:56:45 +11:00
Maxime Coste
7a8f57f97b Add support for a -codepoint switch to the select command 2019-11-12 21:21:24 +11:00
Jason Felice
5fae16faef Implement %val{selections_char_desc}
Fixes #3194
2019-11-12 20:54:32 +11:00
Maxime Coste
6eb820dc54 Fix use after free in enter_user_mode, use user.<name> for modename
Fixes #3192
2019-11-12 08:54:49 +11:00
Maxime Coste
5060a4733a Add mode information to next-key mode name
Currently expose an additional name, the format is up for
discussion.

Fixes #1855
Fixes #2569
Fixes #2672
2019-11-11 21:47:47 +11:00
Maxime Coste
f119fb9524 Aggregatify ConcatView 2019-11-10 12:04:44 +11:00
Jason Felice
87e5a2f512 Avoid copy constructing BufferCoord when comparing 2019-11-09 12:53:45 -05:00
Jason Felice
9692e491ac Fix bad comparison when parsing OSI sequences 2019-11-09 12:53:45 -05:00
Jason Felice
c589f475a5 Add override 2019-11-09 12:53:45 -05:00
Jason Felice
d26bb0ce2b Add static or const where useful 2019-11-09 12:53:45 -05:00
Jason Felice
49ca512733 Remove unused trim_whitespaces() 2019-11-09 12:53:45 -05:00
Maxime Coste
d85259f801 Merge remote-tracking branch 'eraserhd/selection-list-cleanup' 2019-11-09 08:50:09 +11:00
Maxime Coste
8e63aa1548 Check that stdout is a tty in ncurses ui 2019-11-09 08:19:45 +11:00
Jason Felice
c9fce9f83d Merge selection list parsing into selection_list_from_strings 2019-11-07 14:51:04 -05:00
Maxime Coste
f794a35de3 Merge remote-tracking branch 'Delapouite/parameterdesc' 2019-11-07 20:15:14 +11:00
Maxime Coste
3e7301ede7 Support \x and \u escapes in regex character classes
Change \u to use 6 digits to cover the full unicode range.

Fixes #3172
2019-11-06 20:48:48 +11:00
Frank LENORMAND
3816f1fa43 src: Make sure clients connect from a TTY
Fixes #3159
2019-11-05 20:24:08 +01:00
Maxime Coste
294a5b72e6 Fix some ncurses rendering issues 2019-11-05 17:36:21 +11:00
Maxime Coste
6f3124d678 Split clearing to end of line out of NCursesUI::Window::draw
Explicitely clear instead of relying on a brittle heuristic.
2019-11-05 08:04:58 +11:00
Maxime Coste
0f292d343b Use a specific WrapMarker face for wrap highlighter wrapped line marker 2019-11-04 21:49:54 +11:00
Delapouite
6f6b219787 Use single_param more and add double_params 2019-11-01 18:25:55 +01:00
Maxime Coste
a49ae162f4 Add a -verbatim switch to evaluate-commands for perfect forwarding
-verbatim will disable argument parsing in evaluate-commands, making
it possible to forward a single command to a different context without
triggering a reparsing of the arguments.

Fixes -try-client support in grep.kak

Closes #3153
2019-10-23 22:30:23 +11:00
Maxime Coste
362021c1d3 Merge remote-tracking branch 'lenormf/key-semicolon' 2019-10-23 22:10:06 +11:00
Maxime Coste
db2db951c3 Only allow minus at the begining of json numbers 2019-10-23 22:08:07 +11:00
Dan Rosén
c792986768 Teach JSON parser negative numbers 2019-10-22 21:14:38 +02:00
Frank LENORMAND
21614cb06e src: Create a <semicolon> named key
This commit allows using the <semicolon> expansion in commands, instead
of `\;`.

It makes commands look more elegant, and prevents new-comers from
falling into the trap of using <a-;> without escaping the semicolon.
2019-10-22 11:02:06 +02:00
Frank LENORMAND
c744b59f7d src: Add a window_range default expansion
This commit adds a `window_range` default expansion that holds the
coordinates and size of the buffer-space on the window.

Fixes #675
2019-10-20 21:35:50 +02:00
Maxime Coste
3c34de7fe7 Remove explicit sizes from make_array calls 2019-10-17 22:48:22 +11:00
Maxime Coste
dc536da513 Split clang/gcc specific arguments 2019-10-17 12:30:24 +11:00
Maxime Coste
6a893b4e56 Limit word completion menu filename length 2019-10-17 08:15:33 +11:00
Maxime Coste
c7f106a09b Slight code style change 2019-10-17 08:15:12 +11:00
Maxime Coste
e4fb70ebec Replace ModeChange hooks by ModePush and ModePop
Remove deprecated InsertBegin, InsertEnd, NormalBegin, NormalEnd
hooks.

Closes #2545
2019-10-16 20:45:53 +11:00
Maxime Coste
3a36a2486e Slight cleanup of the menu display code 2019-10-16 20:45:53 +11:00
Maxime Coste
081595fa2f Support specifying the user configuration with KAKOUNE_CONFIG_DIR
Fixes #3072
Closes #3081
2019-10-10 20:26:27 +11:00
Delapouite
2148b84274 Add unambiguous titles for infobox "enter combining operator"
fix #3089
2019-10-10 08:34:36 +02:00
Maxime Coste
a2993ea104 Check that stdin is readable before calling read
This should not be necessary, but it works around a bug in WSL.

Fixes #3112
2019-10-08 18:38:05 +11:00
Maxime Coste
2f1be14b5f Avoid negative initial coordinates
Fixes #3111
2019-10-03 21:18:51 +10:00
Maxime Coste
aa6a7e544d Fix some clang warnings 2019-09-26 20:22:27 +10:00
Maxime Coste
1d9a9bc308 Remove unneeded NCursesUI::Window::mark_dirty and redraws
A bug in client.cc was always forcing full redraws of the windows,
leading to much more terminal output traffic than necessary.
2019-09-26 20:14:08 +10:00
Maxime Coste
7f141e83ce Additional NCursesUI code cleanups 2019-09-25 22:46:39 +10:00
Maxime Coste
2eccbbbe6f Avoid unnecessary allocations in NCursesUI::Window::draw calls
Pass an ArrayView<DisplayAtom> instead of a DisplayLine& so that
the newly common case of passing a single atom does not require
constructing a Vector.
2019-09-25 22:46:39 +10:00
Maxime Coste
f855deaf8b Refactor NCursesUI::Window to reduce the exposed methods
This should make an alternate implementation simpler as less state
has to be tracked.
2019-09-25 22:46:39 +10:00
Maxime Coste
9c2d2ad694 Do not set O_NONBLOCK on stdin
It is not necessary, and impacts also writing to stdout, leading
to broken display on old ncurses versions.

Fixes #3087
2019-09-25 20:33:01 +10:00
Maxime Coste
de3ff78b22 Restore stdin status flags on suspend and quit
Those flags are shared with the parent process, so the non-block
flag added impacts their execution.
2019-09-24 23:28:11 +10:00
Maxime Coste
f066014d33 Merge remote-tracking branch 'laelath/suppress-init-list-lifetime-warning' 2019-09-22 22:41:25 +10:00
Maxime Coste
df6d0355d6 Add support for parsing SS3 key sequences
As discussed on #3087, fixes part of that issue.
2019-09-22 09:16:47 +10:00
Justin Frank
8094ded9b5 Added -Wno-init-list-lifetime to CXXFLAGS 2019-09-17 13:38:17 -07:00
Maxime Coste
8cca77c949 Accept docstrings with last line not fully indented
When trimming indent, the last line, if only containing
whitespaces does not need to match the indent, so that
this indentation style works:

    -docstring %{
        indented string
    }
2019-09-17 21:48:00 +10:00
Maxime Coste
c787128a7c Restore palette before suspend 2019-09-16 21:57:53 +10:00
Maxime Coste
bfc07b53a2 Correctly restore terminal state on suspend 2019-09-16 07:38:24 +10:00
Maxime Coste
afd5006e8b Small style tweak 2019-09-16 07:38:24 +10:00
Maxime Coste
9235238191 Fix input coming in packets characters being dropped 2019-09-16 07:38:24 +10:00
Maxime Coste
006083c6f8 Fix multi-client server suspend 2019-09-16 07:38:24 +10:00
Maxime Coste
f43ac3d78b Fix broken input after suspend 2019-09-16 07:38:24 +10:00
Maxime Coste
e52b93b31a Setup terminal raw mode without going through ncurses 2019-09-16 07:38:24 +10:00
Maxime Coste
f2f99580f8 Get rid of ncurses based input parsing in favor of custom code 2019-09-16 07:38:24 +10:00
Maxime Coste
fc3a1b6973 Make arrow keys normal mode mappings instead of commands 2019-09-15 19:40:38 +10:00
Maxime Coste
858ae14f76 Allow scrolling while dragging mouse
Closes #2052
2019-09-15 10:27:00 +10:00
Maxime Coste
46581f1c65 Fix printing of F12 key 2019-09-08 22:54:41 +10:00
Jean-Louis Fuchs
9d897a6092 Rank a word-boundary after a non-word-boundary 2019-09-07 22:53:29 +02:00
Maxime Coste
a440869573 Fix modifiers support with mouse events 2019-09-07 22:49:30 +10:00
Maxime Coste
04b5d44b3c Rework custom CSI parsing code and add support for SGR (1006) mouse
This will support parsing mouse coordinates bigger than 255 - 32.
And get correct release support.
2019-09-07 22:29:05 +10:00
Maxime Coste
4cc187a54f Remove unneeded uses of NCurses WINDOW*
intrflush and meta have a WINDOW* parameter that is documented as
always ignored.
2019-09-05 00:25:27 +10:00
Maxime Coste
afd45c6755 Extract most ncurses calls into NCursesUI::Window methods
Try to isolate ncurses as much as possible to explore alternate
terminal UI implementation.
2019-09-05 00:25:27 +10:00
Maxime Coste
4c4eb61c18 Introduce FunctionRef to replace std::function when not storing
std::function is not necessary when we just want to pass a type
erased callback that does not need to own its target. FunctionRef
provides that functionality for a much lower compile time cost.
2019-09-01 13:04:47 +10:00
Maxime Coste
b24be99fa3 Limit the amounts of calls to get_extra_word_chars
This is a relatively expensive function as it needs to resolve
an option, which uses dynamic_cast.
2019-08-31 13:14:46 +10:00
Maxime Coste
eeec8ade51 Merge remote-tracking branch 'eraserhd/pr/master/fix-kak-list-sessions' 2019-08-28 21:27:30 +10:00
Frank LENORMAND
cb2647878b src: Send the stop signal to the entire process group
Whenever a tool spawns the editor (e.g. Git), suspending it with ^Z is not
enough to be sent back to the calling shell - another ^Z is necessary.

Fixes #3061
2019-08-21 10:32:35 +02:00
Jason Felice
8d76603df4 Fix kak -l when $XDG_RUNTIME_DIR is set 2019-08-20 16:13:21 -04:00
Maxime Coste
1f4b6c3f78 Merge remote-tracking branch 'lenormf/indented-docstrings' 2019-08-19 22:21:52 +10:00
Maxime Coste
2359df0f17 Make scrolling speed configurable
The UI now can send a 'Scroll' key, whose value is the scrolling
amount encoded as a signed integer. This replaces the MouseWheelUp
and MouseWheelDown keys.

The NCursesUI now has a ncurses_wheel_scroll_amount ui_option that
controls that amount, it can be negative to swap scrolling direction.

Fixes #3045
2019-08-19 22:16:39 +10:00
Maxime Coste
f1047181cb Fallback to wrapping in between 'word' when 'WORD' fails
First try to break at a whitespace, if that fails (likely because
that last WORD is too long for the wrapping width), then try to
wrap at a 'word' boundary (on a non alphanumeric character).

Fixes #3048
2019-08-12 18:40:56 +10:00
Jason Felice
0e4a4acf61 Use $XDG_RUNTIME_DIR
Falls back on old mechanism if `XDG_RUNTIME_DIR` is not set.

The ability to specify a session as "<user>/<name>" was removed, since
it isn't possible to compute the value of `XDG_RUNTIME_DIR` for another
user, we wouldn't have access to it if we could, and it would be awkward
to support this feature only when `XDG_RUNTIME_DIR` is unset.  Also,
`rename-session` did not work when another user's session was specified.

Closes #3019
2019-08-05 11:57:07 -04:00
Maxime Coste
1c6aa9baed Fix bug in WrapHighlighter::do_compute_display_setup
Additional lines were not pulled correctly when a line was removed
due to its wrapping hiding the cursor.

Fixes #2999
2019-08-05 20:16:59 +10:00
Frank LENORMAND
da2f6c296a src: De-indent docstrings passed to command/option/mapping definitions
This commit implements formatting behaviour when the first character of a
docstring is a newline. In that case, the exact indentation level of the
next line will be removed from that line and all subsequent non-empty lines.

An error will be returned if a subsequent non-empty line does not have the
same indentation level.

The docstrings are always trimmed (surrounding whitespaces) whether the
first character is a newline or not, as was the case prior to this commit.

Example: the following declaration

```
define-command test -docstring %{
    test: do something

    Nothing really.
        More
            indented
                lines.
} nop
```

would be rendered as

```
test: do something

Nothing really.
    More
        indented
            lines.
```

Related to #2405
2019-07-25 12:28:04 +03:00
Maxime Coste
e42c81c8eb Ensure current context switches away from buffer on delete-buffer
Fixes #3025
2019-07-22 20:26:39 +10:00
Maxime Coste
39445f9acb save command history in execute-keys by default
This should make #3014 unnecessary
2019-07-21 12:29:52 +10:00
Maxime Coste
1a16590960 Slight code cleanup in prompt history handling 2019-07-21 12:20:47 +10:00
Maxime Coste
b83c09509e Merge branch 'master' of http://github.com/jo-he/kakoune 2019-07-21 12:15:48 +10:00
Maxime Coste
b18ca12882 More functional style for '*' code 2019-07-21 12:14:25 +10:00
Maxime Coste
c54e0ec873 Merge remote-tracking branch 'lenormf/fix-2994' 2019-07-21 12:10:22 +10:00
Maxime Coste
be3d0f8b33 Filter non-extra_word_chars completion candidates using Codepoints
Fixes #3010
2019-07-09 19:36:57 +10:00
Maxime Coste
c2e43ee42c Use -O0 for debug builds
-Og is not nice enough to work with in gdb, control jumps around
in too unpredictible ways due to inlining.
2019-07-09 19:27:55 +10:00
Joachim Henke
556d58a073 allow for mapping the Insert key 2019-07-07 18:38:46 +02:00
Maxime Coste
3a7d0b67fa Merge remote-tracking branch 'lenormf/fix-history-size' 2019-07-07 09:14:25 +10:00
Maxime Coste
9e62d2c345 Merge branch 'master' of http://github.com/jo-he/kakoune 2019-07-07 09:13:11 +10:00
Joachim Henke
4c61f82fb2 fix a few typos 2019-07-06 17:37:30 +02:00
Tobias Kortkamp
16bb55edee
Fix build on FreeBSD
file.cc:390:21: error: use of undeclared identifier 'rename'; did you mean 'devname'?
    if (replace and rename(temp_filename, zfilename) != 0)
                    ^~~~~~
                    devname
/usr/include/stdlib.h:277:7: note: 'devname' declared here
char    *devname(__dev_t, __mode_t);
         ^
file.cc:390:28: error: cannot initialize a parameter of type '__dev_t' (aka 'unsigned long') with an lvalue of type 'char [1024]'
    if (replace and rename(temp_filename, zfilename) != 0)
                           ^~~~~~~~~~~~~
/usr/include/stdlib.h:277:22: note: passing argument to parameter here
char    *devname(__dev_t, __mode_t);
                        ^
2 errors generated.

---

highlighters.cc:1110:13: error: use of undeclared identifier 'snprintf'; did you mean 'vswprintf'?
            snprintf(buffer, 16, format, std::abs(line_to_format));
            ^~~~~~~~
            vswprintf
/usr/include/wchar.h:139:5: note: 'vswprintf' declared here
int     vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
highlighters.cc:1110:22: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [16]'
            snprintf(buffer, 16, format, std::abs(line_to_format));
                     ^~~~~~
/usr/include/wchar.h:139:35: note: passing argument to parameter here
int     vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                      ^
2 errors generated.

---

json_ui.cc:60:13: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
            sprintf(buf, "\\u%04x", *next);
            ^~~~~~~
            swprintf
/usr/include/wchar.h:133:5: note: 'swprintf' declared here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
json_ui.cc:60:21: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [7]'
            sprintf(buf, "\\u%04x", *next);
                    ^~~
/usr/include/wchar.h:133:34: note: passing argument to parameter here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                     ^
json_ui.cc:74:9: error: use of undeclared identifier 'sprintf'
        sprintf(buffer, R"("#%02x%02x%02x")", color.r, color.g, color.b);
        ^
3 errors generated.

---

regex_impl.cc:1039:9: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
        sprintf(buf, " %03d     ", count++);
        ^~~~~~~
        swprintf
/usr/include/wchar.h:133:5: note: 'swprintf' declared here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
regex_impl.cc:1039:17: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [20]'
        sprintf(buf, " %03d     ", count++);
                ^~~
/usr/include/wchar.h:133:34: note: passing argument to parameter here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                     ^
regex_impl.cc:1197:17: error: use of undeclared identifier 'puts'
    { if (dump) puts(dump_regex(*this).c_str()); }
                ^
regex_impl.cc:1208:18: note: in instantiation of member function 'Kakoune::(anonymous namespace)::TestVM<Kakoune::RegexMode::Forward>::TestVM' requested here
        TestVM<> vm{R"(a*b)"};
                 ^
regex_impl.cc:1197:17: error: use of undeclared identifier 'puts'
    { if (dump) puts(dump_regex(*this).c_str()); }
                ^
regex_impl.cc:1283:56: note: in instantiation of member function 'Kakoune::(anonymous namespace)::TestVM<5>::TestVM' requested here
        TestVM<RegexMode::Forward | RegexMode::Search> vm{R"(f.*a(.*o))"};
                                                       ^
regex_impl.cc:1197:17: error: use of undeclared identifier 'puts'
    { if (dump) puts(dump_regex(*this).c_str()); }
                ^
regex_impl.cc:1423:57: note: in instantiation of member function 'Kakoune::(anonymous namespace)::TestVM<6>::TestVM' requested here
        TestVM<RegexMode::Backward | RegexMode::Search> vm{R"(fo{1,})"};
                                                        ^
5 errors generated.

---

remote.cc:829:9: error: use of undeclared identifier 'rename'; did you mean 'devname'?
    if (rename(old_socket_file.c_str(), new_socket_file.c_str()) != 0)
        ^~~~~~
        devname
/usr/include/stdlib.h:277:7: note: 'devname' declared here
char    *devname(__dev_t, __mode_t);
         ^
remote.cc:829:16: error: cannot initialize a parameter of type '__dev_t' (aka 'unsigned long') with an rvalue of type 'const char *'
    if (rename(old_socket_file.c_str(), new_socket_file.c_str()) != 0)
               ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:277:22: note: passing argument to parameter here
char    *devname(__dev_t, __mode_t);
                        ^
2 errors generated.

---

string_utils.cc:126:20: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
    res.m_length = sprintf(res.m_data, "%i", val);
                   ^~~~~~~
                   swprintf
/usr/include/wchar.h:133:5: note: 'swprintf' declared here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
string_utils.cc:126:28: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [15]'
    res.m_length = sprintf(res.m_data, "%i", val);
                           ^~~~~~~~~~
/usr/include/wchar.h:133:34: note: passing argument to parameter here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                     ^
string_utils.cc:133:20: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
    res.m_length = sprintf(res.m_data, "%u", val);
                   ^~~~~~~
                   swprintf
[...]
2019-07-06 08:53:47 +02:00
Frank LENORMAND
78129150c9 src: Cap the maximum size of history registers
History registers (for prompt commands, pipe primitive commands etc) are
populated interactively by the users, and currently have no size limit.

This commits silently drops the oldest entries in the storage space to
allow at most 100 entries, to prevent long-running editing sessions from
hogging memory for data most likely never used.
2019-07-02 16:36:12 +03:00
Frank LENORMAND
b040bf8b81 src: Use all selections to generate a pattern upon hitting *
This commit makes the `*` and <a-*> primitives compose a search pattern
comprised of all the current selections, as opposed to only the main one.

All selections are OR'd into the default search register, which makes it
convenient to search for several identifiers already selected.

To retain the old behaviour, the following mappings can be used:

```
map global normal * ': exec -draft -save-regs "" %{<space>*}<ret>'
map global normal <a-*> ': exec -draft -save-regs "" %{<space><a-*>}<ret>'
```

Fixes #2994
2019-07-01 19:53:08 +03:00
Maxime Coste
2ff9fd8d92 Kakoune v2019.07.01 2019-07-01 22:07:29 +10:00
Maxime Coste
aff3e7d5b7 Merge remote-tracking branch 'lenormf/fix-2907-2' 2019-06-29 09:54:51 +10:00
Maxime Coste
eae92c9ae3 Merge remote-tracking branch 'codesoap/rename_moduleload' 2019-06-29 09:52:20 +10:00
Maxime Coste
e4d6bff5ec Fix quoting of tuple options
Fixes #2990
2019-06-27 22:42:12 +10:00
codesoap
ca2741fe20 Rename ModuleLoad hook to ModuleLoaded
This clarifies, that the hook is run *after* the module is loaded.
2019-06-25 19:16:47 +02:00
Frank LENORMAND
4c7bc9179b src: Enforce case sensitivity when parsing function keys
The `parse_keys()` function is case insensitive when parsing function keys,
while the `key_to_str()` function always returns a capitalized key
description.

When users hook on the lowercase name of a function key,
e.g. `NormalKey <f10>`, and later hit that same key in normal mode, the
`key_to_str()` will convert it to the uppercase description ("<F10>").

This results into a hook with a lowercase regex predicate being unsuccessfully
matched against an uppercase key description by the hook manager, which
works on a case sensitive basis.

One solution could be to uppercase all function key descriptions passed as
hook filter upon declaration, but detecting that is not trivial as the
filter can contain more than just the simple <f\d+> data, e.g.

---
hook global InsertKey '<(?<name>\w+)>' %{…}
---

Another simpler solution that this commit implements is to allow only <F\d+>
descriptions in `parse_keys()`, and hope users will know not to use the
lowercase notation when declaring hooks.

Fixes #2907
2019-06-24 18:17:49 +03:00
Maxime Coste
034e726068 Unify register saving/restoring to a Vector
The previous "optimized" history register logic was unfortunately
not restoring correctly as the order of entries in the history
register could have been mutated.
2019-06-24 19:08:48 +10:00
Maxime Coste
6e09f677f4 Fix silly typo 2019-06-23 18:11:16 +10:00
Maxime Coste
a2fce67e9d Put -Og flag in CXXFLAGS, not CPPFLAGS 2019-06-23 16:30:42 +10:00
Maxime Coste
177f38afd1 Merge remote-tracking branch 'eraserhd/debug-optimizations' 2019-06-23 12:05:21 +10:00
Maxime Coste
469818c6f9 Tweak history restoring behaviour 2019-06-23 12:05:09 +10:00
Maxime Coste
e613292568 Use register to store prompt history 2019-06-23 12:05:09 +10:00
Maxime Coste
a9e778fcc7 Add support for echo -quoting (raw|kakoune|shell) switch 2019-06-23 12:04:21 +10:00
Maxime Coste
4b7b5d077c Make quoting opt-in by using $kak_quoted_... 2019-06-23 12:04:21 +10:00
Maxime Coste
8b2906a14d Refactor option_to_string quoting support, introduce Quoting::Raw 2019-06-19 23:04:16 +10:00
Maxime Coste
125b1924ce Move dropped free windoes to the window trash 2019-06-18 21:49:41 +10:00
Maxime Coste
5888e23e02 Do not add window pointing to deleted buffers in the free window list
Fixes #2975
2019-06-16 19:12:35 +10:00
Maxime Coste
984472f681 Merge remote-tracking branch 'lenormf/fix-2966' 2019-06-15 10:48:49 +10:00
Maxime Coste
adf77c3e1d Merge remote-tracking branch 'eraserhd/fifo-fixes' 2019-06-15 10:45:55 +10:00
Frank LENORMAND
936c21da70 src: Make sure the iterator is inbound before decrementing it
Fixes #2966
2019-06-14 09:17:56 +03:00
Jason Felice
0642058b3e Fix emission of BufReadFifo events
The hook parameter should not be adjusted for the prevention of
scrolling.  Also, ensure that the last BufReadFifo is triggered if we
encounter an error or EOF after appending some data to the buffer.

Closes #2946
2019-06-11 10:11:28 -04:00
Maxime Coste
14fb71b16c Refuse to overwrite an existing session socket 2019-06-11 20:13:03 +10:00
Maxime Coste
d2dac558e7 Add a gather overload that infer element type 2019-06-10 21:57:06 +10:00
Maxime Coste
a1758bfcb0 Merge remote-tracking branch 'eraserhd/minor-remote-fixes' 2019-06-04 19:06:56 +10:00
Jason Felice
b82cf38338 Refactor message writing 2019-05-29 09:50:00 -04:00
Maxime Coste
1ebea85e6f Do not merge selections on backspace in insert mode
Fixes #2861
2019-05-29 23:12:04 +10:00
Maxime Coste
7efdbb456d Null terminate gdb auto-load script
Fixes #2929
2019-05-29 22:40:16 +10:00
Maxime Coste
262ef9b4e3 Fix BufferedWriter triggering std::terminate on exception when writing
Fixes #2932
2019-05-29 20:28:06 +10:00
Maxime Coste
7de3ea786f Fix trailing slash removal code with root directory 2019-05-29 20:14:42 +10:00
codesoap
a0e0229f20 Fix the man path for OpenBSD 2019-05-28 11:21:29 +02:00
codesoap
6788b3ae27 Avoid using gzips '-k' for compatibility
OpenBSD's gzip doesn't have '-k', but file redirection should work
everywhere.
2019-05-28 11:21:29 +02:00
Maxime Coste
a1f0bae53a Do not try to send remaining data on a closed socket
Fixes #2906
2019-05-23 12:42:38 +10:00
Jason Felice
a527aea465 Add -Og for debug builds
On my system, some optimizations are on by default (NixOS), resulting in
variables being optimized out on debug builds.  It *seems to be*
something about a "_FORTIFY_SOURCE" feature?  In any case, `-Og` is
documented as "Optimize debugging experience".
2019-05-21 08:44:26 -04:00
Robert Melton
a5bc91d67e Merge remote-tracking branch 'upstream/master' into path-improvements 2019-05-21 04:19:13 -04:00
Maxime Coste
3b3a69b2f5 Fix compilation on older gcc / clang
This was already fixed on the menu-completions branch but an previous
commit version was wrongly cherry-picked.

Fixes #2914
2019-05-21 13:22:02 +10:00
Robert Melton
a43313c6ce Strip all trailing slashes in real_path and compact_path 2019-05-19 19:52:05 -04:00
Maxime Coste
c972dfd2d7 Introduce Menu completion flags to auto select best candidate 2019-05-17 19:52:22 +10:00
Maxime Coste
4916471029 Add completion support to load-module 2019-05-13 17:34:45 +10:00
Maxime Coste
91386a535c Support discarding selections in exec/eval -itersel
Only fail if all selections are discarded.
Fixes #2841
2019-05-13 17:34:43 +10:00
Maxime Coste
834f6916da Do not keep a reference to ParametersDesc inside ParameterParser
This should fix #2900
2019-05-10 23:46:16 +10:00
Maxime Coste
f96547719d Merge remote-tracking branch 'Delapouite/parse_lines' 2019-05-01 03:48:48 +10:00
Alex Leferry 2
910ace1611 Fix typo 2019-04-28 16:46:10 +02:00
Maxime Coste
229768841b Fix parsing of faces with a base but no attributes 2019-04-28 00:35:52 +01:00
Delapouite
947e071066 Let parse_lines ensure that there's at least 1 line with \n 2019-04-27 19:29:16 +02:00
Maxime Coste
f6e58e7271 Fix crash when finishing insert completion with no completion candidates 2019-04-26 11:49:55 +01:00
Maxime Coste
0cc89b2b9f Merge remote-tracking branch 'laelath/provides-requires' 2019-04-25 11:59:42 +01:00
Maxime Coste
1c8f1cbc2f Fix wrapping of words with 'wrap col - indent < word len < wrap col'
Add a test case for those, and refactor bits of the wrap highlighter.

This explains part of the needed complexity in #2820.
2019-04-24 11:40:57 +01:00
Maxime Coste
64ddd43be9 Only wrap before words that are shorter than the wrapping length
Closes #2820
2019-04-24 10:53:33 +01:00
Maxime Coste
c1471d38f1 Merge remote-tracking branch 'eraserhd/remote-refactors' 2019-04-24 09:01:00 +01:00
Maxime Coste
4e24ba86cc Change faces alias to be a base that can be modified
Using <fg>,<bg>+<attr>@<base> will apply the given fg color,
bg color and attributes on top of base dynamically. Simply giving
<base> is a shorthand for default,default@<base>.

Inspired by the discussion in #2862
2019-04-23 23:15:23 +01:00
Jason Felice
99be3ff5e2 Use helper template struct in MsgReader
This makes reads for all types, including String, Vector, and Optional,
use the same interface in MsgReader.
2019-04-22 10:49:12 -04:00
Maxime Coste
aec58b968b Small code cleanup in Face struct definition 2019-04-18 14:37:24 +02:00
Maxime Coste
06d4ee578e Update changelog 2019-04-17 08:38:52 +02:00
Maxime Coste
78419bc76f Remove InsertCompletionSelect hook 2019-04-17 08:38:52 +02:00
Maxime Coste
9118a18d5d Change completions option docstring element to be an arbitrary command
We can have the previous behaviour by just passing the docstring to
`info -placement menu`.
2019-04-17 08:38:52 +02:00
Maxime Coste
02fc42a12a Rename info -placement to info -style and support modal style
Fixes #1375
Closes #1380
2019-04-17 08:38:52 +02:00
Maxime Coste
ace499ecb1 Pass selected completion text to InsertCompletionHide 2019-04-16 15:56:07 +02:00
Maxime Coste
0bff4851d9 Support '-placement menu' switch in the info command
Expose insert completion menu documentation via the info command.
2019-04-15 17:22:48 +02:00
Maxime Coste
6d83828dab Support name captures in dynregex highlighters
Fixes #2856
2019-04-16 00:18:15 +10:00
Maxime Coste
6b79c1e000 Support named captures in hooks
Fixes #2857
2019-04-15 23:56:49 +10:00
Maxime Coste
ac73f7c27f Run ClientClose hook before exiting the client itself
Closes #2849
2019-04-13 15:40:43 +10:00
Maxime Coste
91337d6091 Make it possible to edit an existing scratch buffer again
And make `edit! -scratch *scratch*` for the recreation of an empty
buffer.

Fixes #2852
2019-04-12 13:52:26 +10:00
Maxime Coste
ef1fd3acb9 Prevent conversion to client on suspend from disconnecting other clients
clear the client manager in the to be converted process without
sending exit messages as the forked server will still be there.

Fixes #2847
2019-04-12 13:23:38 +10:00
Justin Frank
c40bb6fc00 Evaluate modules in an empty context 2019-04-08 17:06:56 -07:00
Justin Frank
7866d88131 Added ModuleLoad hook that uses the module name as the parameter 2019-04-08 17:05:55 -07:00
Justin Frank
6092852640 Added 'provide-module' and 'require-module' commands 2019-04-08 17:02:44 -07:00
Justin Frank
670f8192c8 Set up command boilerplate for provide-module and require-module 2019-04-08 17:02:44 -07:00
Maxime Coste
f732ea4efb Refactor ClientManager::clear 2019-04-08 22:32:30 +10:00
Maxime Coste
675dbfbe8b Auto generate buffer name when using edit -scratch with no name
This will make it easier to create a temporary scratch buffer to
work in without having troubles with name collisions.

Fixes #849
2019-04-08 22:16:44 +10:00
Maxime Coste
c8839e7904 Add a ClientCreate and ClientClose hook
As discussed in #2830.
Closes #2500.
2019-04-08 21:59:32 +10:00
Maxime Coste
d0df1ffe71 update version notes and changelog 2019-04-07 09:51:27 +10:00
Maxime Coste
41f19f8dc9 Add support for %file{...} expansions
This should make the use case exposed in #2836 implementable.
2019-04-07 09:43:40 +10:00
Maxime Coste
744778be30 Add a -to-file <filename> switch to the echo command
As discussed in #2836
2019-04-07 09:32:17 +10:00
Maxime Coste
835f2239a7 Run WinClose hook when clearing all free windows
Fixes #2830
2019-04-04 22:06:17 +11:00
Maxime Coste
cc788c888e Fix detection of client ungraceful disconnection 2019-04-04 13:10:38 +11:00
Maxime Coste
d91e017803 Buffer writes in blocks of 4Kb when writing buffers to files
Could make kakoune more compatible with tools looking for file
modifications by reducing the amount of writes done.

As discussed in #2812
2019-04-01 22:57:55 +11:00
Maxime Coste
baae0c899b Add -timestamp switch support to the select command
Fixes #2829
2019-04-01 22:11:18 +11:00
Maxime Coste
b8cf457e82 Add Optional::map and Optional::cast methods
Cool kids call that monadic interface if I understood correctly.
2019-04-01 22:09:32 +11:00
Delapouite
0fe8e59abc Add missing flags to debug buffers output 2019-03-27 19:30:41 +01:00