Commit Graph

5122 Commits

Author SHA1 Message Date
Maxime Coste
9fec1b3faf Buffer: Remove m_line_count field from BufferIterator
It seems unlikely this would give performance gain, as buffer
lines are always accessed when we read that field, leading to
all the necessary data already being in memory. Removing it
reduces the size of a BufferIterator, which are already pretty
hefty objects.
2018-10-30 23:18:41 +11:00
Maxime Coste
6271d0d9ff Merge remote-tracking branch 'eraserhd/refactor-surround' 2018-10-29 19:27:18 +11:00
Delapouite
44ce4bc069 Remove extra spaces for switches list in info 2018-10-28 13:34:19 +01:00
Ruslan Prokopchuk
b65a6493aa replace usage of the deprecated 'e' face attribute with the new 'F' one
and update set-face docstring
2018-10-28 08:52:14 +11:00
Jason Felice
feea0064d8 Simplify surround selection
This has the same effect with fewer conditions, and I think it also
specifies the intent more closely this way.
2018-10-27 13:49:45 -04:00
Maxime Coste
3b40ab82f4 Kakoune v2018.10.27 2018-10-27 09:26:50 +11:00
Justin Frank
0d49c925e3 Keep doc/kak.1 when running make-install 2018-10-23 18:15:01 -07:00
Maxime Coste
365407c37a Merge remote-tracking branch 'Delapouite/previous-char' 2018-10-24 08:13:45 +11:00
Delapouite
ec0926c312 Change next_key title for <a-f>, <a-t>, <a-F> and <a-T> 2018-10-23 19:09:01 +02:00
Maxime Coste
207291219c Merge remote-tracking branch 'maximbaz/fix-makefile-manpage' 2018-10-23 20:20:32 +11:00
Maxime Coste
7c00165c23 Merge remote-tracking branch 'laelath/vertical-menu-option' 2018-10-23 20:18:56 +11:00
Maxim Baz
9f6518a031
Fix Makefile for manpage 2018-10-23 02:34:05 +02:00
Maxime Coste
e3668121f2 Merge remote-tracking branch 'lenormf/no-a2x' 2018-10-23 08:19:56 +11:00
Maxime Coste
dfc11d1c43 Refactor Hook management to have a well defined list of hooks
Hooks are now an enum class instead of passing strings around.
2018-10-23 08:15:53 +11:00
Frank LENORMAND
60b24c6a32 doc: Convert the man page to the TROFF format
Fixes #2504
2018-10-21 14:04:25 +03:00
Maxime Coste
72bdd7900f Move LineRangeSet to line_modification.hh 2018-10-21 12:10:21 +11:00
Maxime Coste
a383ce3045 Fix LineRangeSet::udpate not updating some traling ranges correctly
Fixes #2499
2018-10-21 11:49:30 +11:00
Justin Frank
c5a1225638 removed option and horizontal layout 2018-10-15 14:07:39 -07:00
Justin Frank
a1e3fa02e6 added option for vertical menu layout in the ncurses ui 2018-10-15 14:07:39 -07:00
Maxime Coste
da13b5f814 Fix handling of capture matching in region highlighter
Also extend the highlight/regions test to validate that.
Thanks to lenormf for reviewing my change and finding this bug.
2018-10-15 21:21:12 +11:00
Maxime Coste
71e27c73af Cleanup RegexHighlighter code and drop cache when it becomes too big
The RegexHighlighter range cache can get pretty big in nested
regions use cases, and maintaining it can become pretty costly,
so if it hits a certain size, just drop it.

Should improve performances in #2454
2018-10-14 09:48:39 +11:00
Maxime Coste
194a5db5d6 maintain a list of valid ranges for region highlighting
This should greatly reduce memory usage by only caching matches
for ranges that needs to be highlighted, in the case where multiple
regions are nested, this means only the topmost region needs to parse
and cache the whole buffer, other regions highlighter will only ensure
the lines for the ranges they are called up are cached.

Fixes #2454
2018-10-14 09:48:39 +11:00
Maxime Coste
dd0e4310a7 Slight code refactoring in RegionsHighlighter 2018-10-14 09:48:39 +11:00
Maxime Coste
5922299083 Merge remote-tracking branch 'Delapouite/complete_alias' 2018-10-14 09:46:35 +11:00
Maxime Coste
d652ec9ce1 Cleanup regex lookarounds implementation and reject incompatible regex
Fixes #2487
2018-10-10 22:47:59 +11:00
Delapouite
3a36490ef1 Add alias completer to unalias command 2018-10-08 22:07:13 +02:00
Maxime Coste
9024d41d64 Fix integer overflow leading to bad memory access in regex execution
Fixes #2481
Fixes #2480
2018-10-08 12:43:12 +11:00
Maxime Coste
ed84a2d60c Buffer begin and end are not end-of-words
Buffer begin never has a word character before, and end is always
preceeded by an end-of-line.

Fixes #2420
2018-10-08 12:40:52 +11:00
Maxime Coste
eba40028b9 Update startup messsage and changelog.asciidoc 2018-10-06 10:55:26 +10:00
Maxime Coste
5bdcfab018 Merge remote-tracking branch 'laelath/shell-command-completion' 2018-10-06 10:47:23 +10:00
Maxime Coste
0d20e57e29 Small style tweak 2018-10-06 10:44:56 +10:00
Maxime Coste
98da5dd13a Merge remote-tracking branch 'eraserhd/notify_fatal_error-undefined-behavior' 2018-10-06 10:23:10 +10:00
Maxime Coste
e8ac3395f5 Reduce memory usage of cached matches for RegionsHighlighter
This adds a limitation that capture matching on regions only works
if the regions start/end/recurse match is less than 65635 byte long.
With this limitation we can reduce the RegexMatch struct size to 16
bytes instead of 32.

This is still not good enough,but should slightly improve high memory
usage as reported in #2454
2018-10-06 10:16:20 +10:00
Jason Felice
c78cd84ea4 Fix undefined behavior in notify_fatal_error 2018-10-05 10:10:14 +01:00
Justin Frank
ab6bc41358 Added shell command completion support to define-command and prompt
This commit also introduces a regression in that I decided that the best way to
avoid overly long and confusing names was to rename the current shell-*
switches to script-*, and have the shell command completion be
shell-completion.

renamed script-{completion,candidates} to shell-script-*

Updated docs with new switch names

Added -shell-completion switch to x11-repl and kitty-repl
2018-10-03 09:46:31 -07:00
Justin Frank
f3f52fc818 show_matching_char highlighter use the matching_pairs options 2018-10-01 23:37:25 -07:00
Frank LENORMAND
2d44712766 src: Implement <a-m> and <a-M>
Closes #2425
2018-09-30 19:56:37 +03:00
Frank LENORMAND
6b7200e4d5 src: Move <a-m> to <a-_> 2018-09-30 19:45:20 +03:00
Frank LENORMAND
3d79107773 src: Drop selections that only contain whitespace on _
Fixes #2387
2018-09-27 14:47:26 +03:00
Olivier Perret
93f913705a Misc fixes 2018-09-24 09:54:21 +02:00
Delapouite
b60613259c Add a way to unmap all keys of a given mode at once 2018-09-23 19:40:38 +02:00
Maxime Coste
1631a7d8d9 Replace the Exclusive face attribute with Final
Final is more granular, it consists of FinalFg (f), FinalBg (g)
and FinalAttr (a) which control if a face's fg, bg, or attributes
fully overwrite the previous face (instead of merging) and if
following faces apply on top of this face or not.

Fixes #2388 if the Whitespace face has the FinalFg flag.
2018-09-23 23:27:14 +10:00
Maxime Coste
5d0ea2936d Ignore errors in write_stdout
Fixes #2418
2018-09-23 17:16:09 +10:00
Maxime Coste
fa993768da Merge remote-tracking branch 'eraserhd/script-docs' 2018-09-23 17:06:25 +10:00
Maxime Coste
9c1c763a37 Reject hook names that are not alphanumeric _ or - or start with -
Fixes #2414
2018-09-22 22:11:21 +10:00
Maxime Coste
3f4c86b12f Merge remote-tracking branch 'Delapouite/rename-completions' 2018-09-22 22:02:58 +10:00
Jason Felice
6c4593b18a Document that -f starts with whole file selected 2018-09-21 10:01:20 -04:00
Delapouite
d8747bc1e0 Add completion for rename-buffer, rename-client and rename-session 2018-09-20 19:01:47 +02:00
Jan-Jaap Korpershoek
35dca5866c Update documentation of region highlighter to match change in 2e0e206951 2018-09-16 19:38:18 +02:00
Maxime Coste
0c3d9ccd20 Change remove-hooks to take a regular expression
All hooks whose group match this regex will be removed.

Fixes #2380.
2018-09-12 21:26:21 +10:00
Maxime Coste
8536adc5ac Merge remote-tracking branch 'eraserhd/2367-surround-with-tight-nesting' 2018-09-12 20:57:59 +10:00
Maxime Coste
d3be78cca2 Only commit undo groups when buffer was modified
This fixes an interaction with kak-lsp that would trigger undo group
commit when setting a buffer option value.
2018-09-12 20:02:57 +10:00
Jason Felice
83244af106 Don't skip opening brace twice when finding closing
Fixes #2367
Fixes #2129
2018-09-09 10:15:41 -04:00
Frank LENORMAND
377e09abd9 src: Check that Once hooks to remove exist
Fixes #2370.
2018-09-09 13:12:47 +03:00
Maxime Coste
14f9f4c468 Fix use after delete in RemoteClient FDWatcher callback
Fixes #2357
2018-09-07 09:09:07 +10:00
Maxime Coste
15bb23865a Join highlighter parameters with a '_' to autogenerate their name 2018-09-07 09:09:07 +10:00
Maxime Coste
d73ec20285 Kakoune v2018.09.04 2018-09-04 08:22:28 +10:00
Maxime Coste
b8dbe6135c Remove leading v in archive names when generating releases 2018-09-04 08:22:28 +10:00
Maxime Coste
37e2558413 Add readline word erase bindings, throw in clipboard for good measure
Add <c-w> and <a-d> (along with <c-W> and <a-D> that work on WORDs),
and <c-y> which pastes the transient clipboard contant (which saves
big erase, such as word erase and line end/begin erase).

Fixes #2355
2018-09-04 07:55:56 +10:00
Maxime Coste
b581a4fbed Merge remote-tracking branch 'Delapouite/sync-exit-status' 2018-09-03 22:33:20 +10:00
Maxime Coste
4b7e77ae00 Change line editing bindings to match readline's
In the end, no better solution materialized so far, and custom
Kakoune line editing bindings are hard to remember. Using well
known readline bindings seems just more convenient.

Closes #800, although it does not contain all the binding proposed
by it (I might accept a few additional ones, such as <c-w>, but not
too much, I still see that as a hack pending a nicer solution).
2018-09-03 22:15:28 +10:00
Delapouite
5e75f748a2 docs: add missing -sync and exit status in autoinfo and doc page 2018-09-03 08:25:08 +02:00
Maxime Coste
a8c792706d Fix setting a prefix list option with an empty list
Fixes #2335
2018-08-30 20:27:10 +10:00
Maxime Coste
df655422d1 Merge remote-tracking branch 'Screwtapello/support-user-map-options' 2018-08-30 20:10:00 +10:00
Maxime Coste
ee39649d3a Merge remote-tracking branch 'Screwtapello/fix-slow-word-wrap' 2018-08-30 20:09:13 +10:00
Maxime Coste
872ecd472c Merge remote-tracking branch 'Delapouite/auto_complete' 2018-08-30 20:07:08 +10:00
Maxime Coste
a0ac3c8c4c Merge remote-tracking branch 'occivink/source-with-args' 2018-08-30 20:04:07 +10:00
Maxime Coste
fcaa4314f7 Merge branch 'patch-1' of https://github.com/John-Colvin/kakoune 2018-08-30 20:03:51 +10:00
Shachaf Ben-Kiki
5238c2d93d Extend source command to support parameters.
Parameters are accessible in %arg{n}, as with define-command.
2018-08-30 10:00:13 +02:00
Maxime Coste
68aba9e353 Use shell specific quoting for env vars
Add a test case to validate roundtrips between Kakoune and the
shell.
2018-08-29 07:53:59 +10:00
John Colvin
94a3b85745 Missing space at eol in write CommandDesc 2018-08-28 11:59:43 +01:00
Tim Allen
82c01c5dd3 Speed up wrapping at word boundaries.
Previously, when wrapping lines at word boundaries, we would iterate forwards
for "wrap-width" characters, then iterate backwards until we found a word-break,
which was horribly slow.

Now we record the last word-boundary we saw as we iterate forwards, getting a
result in one pass.

Fixes #2339.
2018-08-28 17:43:16 +10:00
Delapouite
c2bd4b38a0 Add toggling capabilities for <c-o> in Insert and Prompt mode
Ref #2121
2018-08-27 22:08:38 +02:00
Maxime Coste
9fdf1f1168 Merge remote-tracking branch 'ricochet1k/master' 2018-08-27 08:13:07 +10:00
Maxime Coste
b06ba627b2 Refactor whitespace highlighter into a struct 2018-08-27 08:05:00 +10:00
Maxime Coste
a32d7069c6 Try to complete command switches when an argument starts with '-'
Fixes #1467
2018-08-26 12:29:11 +10:00
Matt Peterson
d0a8426272 Use $USER if getpwuid fails 2018-08-24 10:50:59 -04:00
Frank LENORMAND
1da0af26c9 src: Make sure buffers are saved regardless of the client count
Due to a copy-paste mistake, the `:kill` command in a session with
multiple clients was the equivalent of a force-kill (`:kill!`).

This commit makes sure all buffers are saved before killing the
session, unless the force flag is specified.
2018-08-21 17:27:17 +03:00
Tim Allen
49ef9968c0 Support user-defined "str-to-str-map" options. 2018-08-21 18:24:14 +10:00
Frank LENORMAND
9a111b5ebe src: Improve error messages in RPC requests parsing
Cast errors in RPC requests currently make the client quit with an
error saying "uncaught exception", since `Kakoune::bad_value_cast`
exceptions are not explicitely handled.

This commit tries to catch ill-formatted requests and return a more
human-friendly error message, without quitting the client.
2018-08-18 09:28:30 +03:00
Maxime Coste
293610a432 Add a test case for -once hooks and code style tweaks 2018-08-16 21:09:51 +10:00
Maxime Coste
4387b1ac90 Merge remote-tracking branch 'lenormf/fix-hook-once' 2018-08-16 18:46:26 +10:00
Frank LENORMAND
97abfd403d src: Forbid empty menu entries
Empty entries in menus look weird, and don't serve any purpose. Empty
commands are still allowed.
2018-08-11 10:03:57 +03:00
Maxime Coste
f706b8c9be Add a -version switch to Kakoune
Closes #1035
2018-08-09 11:24:11 +02:00
Frank LENORMAND
e84dcf72c0 src: Allow hooks to be run only once
This commit implements the -once flag on the `:hook` command, which
automatically removes a hook after it was run, to avoid having to
declare a group and remove it in the hook implementation.

Closes #2277
2018-08-06 15:14:20 +03:00
Maxime Coste
472a5732e2 An empty string is not a valid number
Fixes #2284
2018-08-04 11:10:19 +01:00
Maxime Coste
3b77398c5b Add an assert to catch newpad returning a nullptr 2018-07-31 13:15:39 +01:00
Maxime Coste
075d1048ab Avoid invalid access to Optional
If the UI is not ok, the exit status of the client might not be
available. Return -1 in that case.
2018-07-30 10:32:38 +01:00
Maxime Coste
d2509e54f2 Fix compilation with gcc-5
Gcc-5 seems to have a bug in its handling of template variable.

Fixes #2267
2018-07-30 07:15:17 +01:00
Maxime Coste
2c9daf2378 Merge remote-tracking branch 'Delapouite/map-key-completer' 2018-07-28 19:48:24 +10:00
Maxime Coste
eef2ea5136 Lazily iterate over words instead of gathering them in a vector 2018-07-26 23:05:00 +10:00
Maxime Coste
eefe26b48b Fix shared string registry ref count stats 2018-07-26 22:20:19 +10:00
Maxime Coste
7cf3cbde8e Cleanup some trailing whitespaces and double semicolon 2018-07-26 21:56:34 +10:00
Maxime Coste
737807dde2 Replace a few loops with ranges 2018-07-26 21:23:06 +10:00
Maxime Coste
0919679e0d Make TransformView iterator's category match its underlying's
In particular, this make gathering a transformed range to a vector
faster because we can use the random access nature of underlying
iterator to get the size to allocate in the vector upfront.
2018-07-26 20:58:55 +10:00
Maxime Coste
62fa783bfd Fix missing override specifier 2018-07-26 20:16:48 +10:00
Maxime Coste
7905382b74 Obtain a new window for a client before releasing the current one
Creating a window potentially runs hooks, which themselves could
trigger shell evaluation, which could handle urgent input events
such as a resize, while waiting for the shell to finish. When that
happens, the client had a temporarily null window as it had already
released its own window.

Fixes #2225
2018-07-25 21:23:22 +10:00
Maxime Coste
a5f53dccb7 Micro optimize command parsing by avoiding utf8 decoding
Balanced quoted parsing does not need to decode utf8, neither does
unquoted word parsing. This improves startup time a bit, helping
for issue #2152
2018-07-25 20:58:07 +10:00
Maxime Coste
918fe6ddd8 Fix uninitialized context flags 2018-07-25 20:57:47 +10:00
Maxime Coste
0d6e04257b Fix memory leak in regex execution 2018-07-25 20:57:11 +10:00
Maxime Coste
b1187cf91d Quote every option type but integral types
Opt-in quoting was a bad choice, lets default to opt-out with
all integral types non quoted.
2018-07-24 20:26:24 +10:00
Maxime Coste
5f825cf0f5 Merge remote-tracking branch 'lenormf/fix-C-skip-empty-lines' 2018-07-23 21:14:23 +10:00
Maxime Coste
bbb508634e Support setting registers to empty lists
Note that empty registers still act as-if they contained a single
empty string.

Fixes #2228
2018-07-23 08:35:13 +10:00
Maxime Coste
f27700cc53 Restore SIGPIPE handler to default before spawning shell
Fixes #2238
2018-07-23 08:32:17 +10:00
Maxime Coste
6270ce4a80 Merge remote-tracking branch 'lenormf/fix-face-name-format' 2018-07-22 21:13:48 +10:00
Maxime Coste
3c51da4488 Merge remote-tracking branch 'lenormf/fix-development-version' 2018-07-22 15:58:41 +10:00
Maxime Coste
7b9f162e7d Opt-in types for quoting of option lists
This avoid quoting ints in int-lists for example, as they do not
risk containing whitespaces.

Fixes #2223
2018-07-22 15:51:32 +10:00
Frank LENORMAND
a2f9c68a7c src: Change the bullet point symbols in the version notes 2018-07-20 13:55:16 +03:00
Frank LENORMAND
60bd8df3c2 src: Don't print a number for the development version 2018-07-20 13:49:36 +03:00
Frank LENORMAND
2b0c143808 src: Allow face names to contain an underscore
Closes #2229
2018-07-20 09:47:30 +03:00
Frank LENORMAND
0b8899d1d4 src: Rename auto_complete to autocomplete
Removing the underscore seems to make the option name more
in line with the others (even though some do use a separator,
e.g. `disabled_hooks`).
2018-07-19 18:57:33 +03:00
Maxime Coste
7195100609 Re-introduce kill_session::exit_status, @lenormf was right
As discussed in #2186, in the end we need the exit status for the
case where the local client exited first (the server forked to
background) then another client trigger the kill command.
2018-07-19 19:27:56 +10:00
Maxime Coste
56a5dc66ff Merge remote-tracking branch 'lenormf/kill-clients-exit-code' 2018-07-19 18:42:22 +10:00
Maxime Coste
40a91b1120 Add a -debug '...' switch to Kakoune startup that sets the debug option
This gives an easy way to profile startup by running with -debug profile.
2018-07-19 18:36:49 +10:00
Maxime Coste
7ed5d53fe6 Fix RegexCompileFlags::Backwards having the same value as Optimize
That means every Optimized regex had the Backwards version
compiled as well, which doubled the time it took to compile them
and doubled the memory usage of regex.

This should improve #2152
2018-07-19 18:34:40 +10:00
Frank LENORMAND
5543a4d58c src: Propagate to clients the kill exit code
Fixes #2177
2018-07-19 10:54:49 +03:00
Maxime Coste
56912dd22c Merge remote-tracking branch 'icetan/buffer-reload-hook' 2018-07-19 08:29:22 +10:00
Maxime Coste
b1d5fda960 Reduce confusion in add-highlighter docstring
Closes #2222
2018-07-19 08:26:25 +10:00
Maxime Coste
c58457a3c0 Fix manual insert completion menu not getting automatically hidden
Fixes #2208
2018-07-15 11:46:02 +10:00
Maxime Coste
d23ac09fc1 Add support for <a-;> in prompt mode
Fixes #2096
Closes #2060
2018-07-15 11:17:16 +10:00
Maxime Coste
bde726d034 Change autoshowcompl to auto_complete with insert|prompt possible values 2018-07-15 11:10:32 +10:00
Maxime Coste
2f815511da Merge remote-tracking branch 'Screwtapello/fix-info-docstring' 2018-07-14 23:17:10 +10:00
Maxim Baz
3ca424d10f
Fix description of ui_options 2018-07-13 22:46:24 +02:00
Tim Allen
591a9ab093 The info command only takes one content string, not one-or-more. 2018-07-10 17:51:57 +10:00
Christopher Fredén
ae6c214f52
Add BufReload hook which is triggered on buffer reload 2018-07-09 14:20:52 +02:00
Maxime Coste
79ec8d0010 Rename highlighters that used an underscore to use a dash
For example `show_matching` is now `show-matching`.
2018-07-08 19:14:15 +10:00
Maxime Coste
1b5f665664 Refactor WrapHighlighter::next_split_pos to avoid non-linear complexity
Previous Implementation was constantly computing byte/column count
from the begining of the line, leading to a non-linear complexity
with respect to the length of a line.

Fixes #2146
2018-07-08 18:51:11 +10:00
Maxime Coste
51ec1194f1 Use a memory mapped file for sourcing 2018-07-08 17:25:12 +10:00
Maxime Coste
cde0c51cd6 Tweak comment to make it less ambiguous 2018-07-08 16:58:19 +10:00
Maxime Coste
b6933a2bdb Fix infinite loop on SIGHUP with the NCursesUI
Fixes #2126
2018-07-08 15:54:01 +10:00
Maxime Coste
f89ea657ef Fix asserts with -sync flag handling and slight code cleanup 2018-07-05 08:30:57 +10:00
Maxime Coste
63d4c8c311 Change a on end of line behaviour to be consistent
`a` will just jump on next line, `a` on last end of line opens a new
line beneath it.

Fixes #1164
2018-07-05 08:00:14 +10:00
Maxime Coste
55a5ec3bbd Tweak how highlighter names are auto-generated 2018-07-05 07:54:28 +10:00
Maxime Coste
2e0e206951 Make recurse regex opt-in with a -recurse switch instead of opt-out 2018-07-05 07:54:28 +10:00
Maxime Coste
f9fda70de6 Fix add-highlighter docstring 2018-07-05 07:54:28 +10:00
Maxime Coste
63d7984b89 Fix bug in recursive region highlighting 2018-07-05 07:54:28 +10:00
Maxime Coste
6993b0f347 Fix region highlighters validation that the delegate type exists 2018-07-05 07:54:28 +10:00
Maxime Coste
96c9718144 Parse unknown switches as positional for region highlighters 2018-07-05 07:54:28 +10:00
Maxime Coste
073b630e7a Prevent adding region/default-region highlighters to non-regions parents 2018-07-05 07:54:28 +10:00
Maxime Coste
711150f4ac Allow removing region from regions highlighter 2018-07-05 07:54:28 +10:00
Maxime Coste
1574748d4e Invalidate cache when RegionsHighlighter subregions are modified 2018-07-05 07:54:28 +10:00
Maxime Coste
64d0fd91ae Auto-generate highlighter name if only path is given 2018-07-05 07:54:28 +10:00
Maxime Coste
b0ccf97b44 Refactor RegionsHighlighters to define each region as a separate command 2018-07-05 07:54:28 +10:00
Maxime Coste
c9cdae4364 Add HashMap::items to access item list 2018-07-05 07:54:28 +10:00
Maxime Coste
d6b0297ac8 Fix ParameterParser::position_from with arbitrary indices 2018-07-05 07:54:28 +10:00
Maxime Coste
b4b335155e Refactor add-highlighter to make naming explicit
The highlighter name must be given as part of the path of the
highlighter, as the last element.

Fixes #1712
2018-07-05 07:54:28 +10:00
Maxime Coste
18dfecfa9d Introduce a "double_up" function for doubling up escaping 2018-07-05 07:54:28 +10:00
Maxime Coste
6a31d0ebc7 Fix auto escaping of command argument completion 2018-07-05 07:54:28 +10:00
Maxime Coste
7abf04babd Improve highlighting of Kakrc string regions
Unfortunately Strings that start with a quoted quote (like '''str')
are still incorrectly highlighted, a deeper refactoring of the regions
highlighter will be necessary.
2018-07-05 07:54:28 +10:00
Maxime Coste
eab98c88bd Refactor handling of startup info to make it configurable
A new `status_info_version` option allows user to disable info
message regarding changes that happened at that version or
earlier.
2018-07-05 07:54:28 +10:00
Maxime Coste
74e4925de0 Expand %reg{} inside double quotes only to the main selection value 2018-07-05 07:54:28 +10:00
Maxime Coste
124a5d4905 Tolerate restoring invalid coordinates from register
Clamp those selection after updating them to the current timestamp

Fixes #2078
2018-07-05 07:54:28 +10:00
Maxime Coste
ed123a2cc9 Reference the big breaking refactoring in the startup message 2018-07-05 07:54:28 +10:00
Maxime Coste
27163106c7 Make register expansions expand to the full register content
Now that we have a nice standard way to express lists of strings,
registers can be fully exposed. An new $kak_main_reg_... env var
was added to provide the previous behaviour which is relied on by
doc.kak.
2018-07-05 07:54:28 +10:00
Maxime Coste
d6c6ed9bbf Store each selection as a separate element in a register
It makes more sense to use the list nature of the register to store
the selections instead of storing them as a single string separated
by spaces.
2018-07-05 07:54:28 +10:00
Maxime Coste
8aba0b3cb4 Change set-register command to take a list of values
Registers are lists of strings, so this make it possible to set
the whole list instead of forcing registers to a single element
when going through the set-register command.
2018-07-05 07:54:28 +10:00
Maxime Coste
183f32803b Fix selection save/restore from registers post selection list syntax change 2018-07-05 07:54:28 +10:00
Maxime Coste
087a940fbe Add 'skip(size_t)' range utility to skip a number of elements 2018-07-05 07:54:28 +10:00
Maxime Coste
76093f252c Change env vars that are lists to use the general list syntax 2018-07-05 07:54:28 +10:00
Maxime Coste
8b2e5ea862 Make selection lists use the option list syntax 2018-07-05 07:54:28 +10:00
Maxime Coste
b548dd3a6f Change option lists to be specified as separate arguments on commands line
Option lists and maps are specified using separate arguments, avoiding
the need for additional escaping of their separator and reusing the
existing command line spliting logic instead.

As discussed on #2087, this should make it much easier to work with
list options, and make the general option system feel cleaner.
2018-07-05 07:54:28 +10:00
Maxime Coste
5eeec8bd4d Make expansion of strings support quoting of % by doubling up 2018-07-05 07:54:28 +10:00
Maxime Coste
c829595d01 Refactor command line parsing
Command line parsing now works as follow:

* Quoted strings ('...', "..." and %~...~ with '~' non nestable)
  use 'doubling-up' for escaping their delimiter, if the delimiter
  appears twice in a row, it is considered as part of the string and
  represent one delimiter character. So 'abc''def' == "abc'def". No
  other escaping takes place in those strings.

* Balanced strings (%{...}) do not support any kind of escaping, but
  finds the matching closing delimiter by taking nesting into account.
  So %{abc{def}} == "abc{def}".

* Non quoted words support escaping of `;` and whitespaces with `\`,
  `%`, `'` and '"` can be escaped with `\` at the start of the word,
  they do not need escaping (and will not be escaped) else where in
  a word where they are treated literally. Any other use of '\' is a
  literal '\'. So \%abc%\;\ def == "%abc%; def"

As discussed in #2046 this should make our command line syntax more
robust, provide a simple programmatic way to escape a string content
(s/<delim>/<delim><delim>/g), be well defined instead of ad-hoc
undocumented behaviour, and interact nicely with other common
escaping by avoiding escaping hell (:grep <regex> can in most case
be written with the regex unquoted).
2018-07-05 07:54:28 +10:00
Maxime Coste
24d8a58b0d Add -with-hooks to execute-keys and make -no-hooks evaluate-commands specific 2018-07-05 07:54:28 +10:00
Maxime Coste
9082564ab7 Make -with-maps only available for execute-keys command
It does not make a lot of sense to have this switch for
evaluate-commands.
2018-07-05 07:54:28 +10:00
Maxime Coste
5902c7b790 Do not save any registers by default in evaluate-commands 2018-07-05 07:54:28 +10:00
Maxime Coste
ec16969609 Do not reparse %sh{...} strings
Automatic reparsing of %sh{...}, while convenient in many cases,
can be surprising as well, and can lead to security problems:

'echo %sh{ printf "foo\necho bar" }' runs 'echo foo', then 'echo bar'.
we make this danger explicit, and we fix the 'nop %sh{...}' pattern.

To reparse %sh{...} strings, they can be passed to evaluate-commands,
which has been fixed to work in every cases where %sh{...} reparsing
was used..
2018-07-05 07:54:28 +10:00
Maxime Coste
3b9818c10b Merge remote-tracking branch 'lenormf/edit-readonly-flag' 2018-07-04 19:47:05 +10:00
Maxime Coste
86616c207d Merge remote-tracking branch 'lenormf/synchronized-write' 2018-07-04 19:46:40 +10:00
Frank LENORMAND
5309b7b5e5 src: Add a -sync flag to the write commands 2018-07-04 09:49:53 +03:00
Frank LENORMAND
dd17b20bbf src: Allow the edit command to create readonly buffers 2018-07-03 14:34:48 +03:00
dahlbaek
2a509ba73f Mark unused variables with the [[gnu::unused]] attribute 2018-07-02 19:33:52 +02:00
Frank LENORMAND
266ce73de7 src: Make C skip empty lines
This commits changes the way `C` behaves when the next line is empty:
instead of stopping the selection, it will now jump to the next line
that can hold a selection as big as the current one.

The primitive's count parameter holds the maximum amount of selections
that should be added to the current one.

Closes #2061
2018-06-30 14:39:15 +03:00
Frank LENORMAND
1cb51cacb7 src: Fix cycle hogging when using C at EOF 2018-06-30 11:53:28 +03:00
Frank LENORMAND
98b62304bb src: Make ! re-evaluate the command for each selection
Fixes #2138
2018-06-30 09:35:47 +03:00
Maxime Coste
43b72770ec Fix wrong logic for moving filedescriptors leading to closed stdin
With this fix, tests can now use /dev/null as stdin.

Fixes #2165
2018-06-28 22:56:50 +10:00
Olivier Perret
67655de947 Use a dedicated vm op for dot when match-newline is false 2018-06-24 12:41:50 +02:00
Olivier Perret
b5ee1db1c4 Use bit-flags for storing regex regex options 2018-06-24 12:41:50 +02:00
Olivier Perret
8edef8b3f1 Add support for regex flag to toggle dot-matches-newline 2018-06-24 12:41:50 +02:00
Maxime Coste
667777521b Refactor the way main selection is determined after rotating contents
Fixes #2133
2018-06-21 08:07:17 +10:00
dahlbaek
52a3e9a84d Pass in OpenBSD binary path using preprocessor option
Alternative to hard coding binary path for OpenBSD
2018-06-20 14:20:55 +02:00
Patrick Marchand
dc3e4823a5 Remove extraneous include for openbsd
Forgot to remove this before pushing.
2018-06-20 14:20:55 +02:00
Patrick Marchand
2789857f32 Adds openbsd support
Seems to work on openbsd 6.3-current but needs more testing. Had to
hardcode the binary path as openbsd considers getting the executable
path at runtime a security flaw.
2018-06-20 14:20:55 +02:00
Maxime Coste
3d4ee7d201 Tweak search style menu completion display 2018-06-20 20:20:11 +10:00
Maxime Coste
b82d31016b Do not draw menu if it would hide prompt content 2018-06-20 08:12:53 +10:00
Maxime Coste
226db75aeb Change Search completion to display on top of the modeline 2018-06-19 21:02:24 +10:00
Maxime Coste
6dca67c674 Fix two <s-tab> requiered to access last completion in prompt
A single <s-tab> should be enough.
2018-06-19 07:40:52 +10:00
Delapouite
0bfdaf7d3e Improve unmap command key-completer 2018-06-15 15:16:08 +02:00
Maxime Coste
665d3fa196 Fix edit -fifo without -scroll when the buffer is already opened
Scrolling was taking place in that case even though it was not
desired.
2018-06-13 07:11:03 +10:00
Maxime Coste
ee19497d37 Fix crash when adapting window position post buffer modifications 2018-06-13 05:00:35 +10:00
Maxime Coste
0bdde991ea Remove unneeded Window::m_range post refactoring 2018-06-12 06:48:48 +10:00
Maxime Coste
0d3a1b5955 Try to keep window position fixed when buffer gets modified
Adapt window position to the changes that happened in the buffer
since last redraw.

Fixes #1989
2018-06-11 15:10:30 +10:00
Maxime Coste
df90ba5984 Extract update_ranges_ifn as a general utility function 2018-06-11 15:10:30 +10:00
Maxime Coste
539832bf29 Add position offset to Window to limit moves with search menu style
Window can be resized with an "offset_pos" flag, which means that
the resize took place on the top left corner of the window, leading
to a change in current window position. This is treated as temporary
and the position change is stored in a m_position_offset field.

That allows the ncurses UI to offset the position when it displays
a Search menu, so that the window does not constantly scroll when
the search menu open/closes. The window will only scroll if it needs
to in order to keep the main selectin visible.
2018-06-11 15:10:30 +10:00
Maxime Coste
60cf71bc24 Pass DisplaySetup through the HighlightContext 2018-06-11 15:10:30 +10:00
Maxime Coste
97af2ffc84 Merge remote-tracking branch 'alyssais/patch-2' 2018-06-03 12:19:09 +10:00
Maxime Coste
310e5e3bcd NCursesUI: Use only 3 line menu for MenuStyle::Search 2018-06-03 12:17:38 +10:00
Maxime Coste
2bdbf7e379 Add MenuStyle::Search that prevents the menu from hiding buffer text
Fixes #2042
2018-06-03 12:17:38 +10:00
Maxime Coste
56e5322b45 EventManager: Never block if a forced file descriptor is present 2018-06-03 12:17:38 +10:00
Maxime Coste
c63502c7c6 Code cleanup and slight refactor in NCursesUI menu code 2018-06-03 12:17:38 +10:00
Alyssa Ross
7685a657ca
Fix grammar in highlight error message 2018-06-01 13:02:38 +02:00
Delapouite
b60ed6ca53 docs: fix missing ] in wrap hl -marker switch docstring
Also add the related changelog entry
2018-05-30 18:11:19 +02:00
Alyssa Ross
2deb2c0294
Fix typos in add-highlighter range help 2018-05-28 13:19:12 +02:00
Maxime Coste
f06badcfd3 Fix clang compilation 2018-05-28 08:26:19 +10:00
Maxime Coste
b5693c6253 Refactor option_from_string to return directly the option value 2018-05-27 13:00:50 +10:00
Maxime Coste
2617f5e022 Add unit test for option parsing 2018-05-27 13:00:48 +10:00
Maxime Coste
f1c1de834a Add a -marker <marker_text> switch support to the wrap highlighter
This makes wrapped lines very explicit.

Fixes #2065
2018-05-26 22:22:00 +10:00
Maxime Coste
68fb3ba88f Rework fail command not to display command call stack
`fail` triggers "expected" errors, and hence should just display
the provided message.
2018-05-26 21:31:17 +10:00
Maxime Coste
54b62cbef7 Do not expose C++ typeid().name to user facing errors on wrong option type
Fixes #2079
2018-05-26 10:01:26 +10:00
Maxime Coste
9b89652b0b Fix potential assert on itersel selection restoration
We cannot guarantee after an itersel that selections are going to
still be in ascending order, but we were calling a SelectionList
constructor that was assuming this was the case.
2018-05-24 08:08:51 +10:00
Maxime Coste
4ef5c80724 Fix Kakoune client busy looping on SIGHUP
Pure clients never quitted when they got SIGHUP after recent changes
to add is_ok to UserInterface. run_client now tracks the UI state as
well and quits if the UI gets killed.
2018-05-23 08:16:35 +10:00
Maxime Coste
56e2174cf6 Do not reuse m_buffer_trash to store dying buffers in ~BufferManager
Doing that clears m_buffer_trash, deleting buffers contained there,
but we are not ready to have Buffer destructors running yet as we
did not clear the ClientManager, meaning we might have free windows
pointing to buffers in the buffer trash.
2018-05-21 20:30:24 +10:00
Maxime Coste
d4e36958f8 Gather options in a vector when running Buffer::on_option_changed
on_option_changed might trigger hooks that will mutate the option
managers, invalidating the iterators we use.
2018-05-21 20:07:25 +10:00
Maxime Coste
919b7ce645 Fix also the implementation of to_string(size_t) change 2018-05-21 20:01:19 +10:00
Maxime Coste
edc53de8cc Small code cleanup 2018-05-21 07:55:07 +10:00
Maxime Coste
b7dabf11f2 Fix incompatible to_string function declaration when size_t is unsigned int 2018-05-21 07:53:21 +10:00
Maxime Coste
ec0f8fe574 Extend try command to support multiple catches.
If a catch command fails, and another catch is availabe following
it, that following catch gets executed.
2018-05-19 14:15:16 +10:00
Maxime Coste
243cfbc4ae Fix behaviour of extending to next match when wrapping
If the search wraps to get to next match, drop that selection when
extending.
2018-05-19 14:15:16 +10:00
Maxime Coste
14d12fac04 Rename -allow-override switch to -override
Closes #2057
2018-05-19 14:15:16 +10:00
Maxime Coste
c9a8658671 Fix assert with window small enough so that no part of buffer is displayed
Fixes #2056
2018-05-19 14:15:16 +10:00
Maxime Coste
79b60f69a9 Small code cleanups 2018-05-17 22:55:53 +10:00
Maxime Coste
b22c8ad8c7 Fix potential missed redraws 2018-05-17 22:50:11 +10:00
Maxime Coste
b0577d07f6 Merge remote-tracking branch 'Screwtapello/newlines-after-json-errors' 2018-05-17 07:47:34 +10:00
Maxime Coste
9bd3231d9b Avoid needless constant allocation in StaticRegister::set 2018-05-17 07:41:32 +10:00
Maxime Coste
4cc9c9997e compute_line_modifications: avoid potentially long iteration 2018-05-17 07:41:32 +10:00
Maxime Coste
fcce76ba57 Handle all pending events before redrawing
If new events happen while handling events, take care of those
new events as well before redrawing.
2018-05-17 07:41:32 +10:00
Tim Allen
0af53fb0dc Print a newline after errors in the JSON UI.
This makes them just a little easier to read.
2018-05-16 23:26:05 +10:00
Maxime Coste
75eb293f98 Rename Context::Flags::Transient to Context::Flags::Draft
Draft is well establish and all draft context are transient.
2018-05-14 08:23:00 +10:00
Maxime Coste
b204e773d4 Do not push jumps implicitely in transient contexts
This should improve performance in draft contexts.
2018-05-14 08:23:00 +10:00
Maxime Coste
288cf6de73 Fix performance problem when generating many values for # register
Fixes #2008
2018-05-09 23:02:53 +10:00
Maxime Coste
327d8ad759 Mark Client, Window, Buffer and OptionManager as final
Avoids warning about non virtual destructor calls on them,
as they have a vtable due to OptionManagerWatcher.
2018-05-09 23:01:40 +10:00
Maxime Coste
e8c648b7b7 Store the timestamp at which a display buffer was generated
Coordinates inside a display buffer are only valid for a certain
buffer content, they cannot be used once the buffer has been
modified.

Fixes #2034
2018-05-08 21:56:44 +10:00
Maxime Coste
148d6c205b Fix wrong behaviour in select surrounding
Fixes #2030
2018-05-07 22:17:57 +10:00
Maxime Coste
7a841dcca7 Remove out of date noexcept(false) on MessageWriter destructor
This made sense when the writer was trying to send the message
in its destructor, but this is not the case anymore.
2018-05-05 07:59:13 +10:00
Maxime Coste
da1d78a3c2 Do not let exception propagate out of register restoring lambda
It is called during a std::vector destruction, which is noexcept,
leading to terminate being called.
2018-05-05 07:57:37 +10:00
Maxime Coste
7325ad216c Add support for explicit menu selection from the UI
the JsonUI now supports a "menu_select(int)" RPC call that should
trigger explicit selection of the provided item index.

As discussed for issue #2019.
2018-05-03 22:28:20 +10:00
Maxime Coste
c2637f08d9 JsonUI: Add support for a "mouse" RPC calls from the UI
As discussed on issue #2019
2018-05-03 22:27:59 +10:00
Maxime Coste
a19ce37634 Tweak the way register restorers are created to try to fix OSX compilation 2018-05-03 08:14:15 +10:00
Maxime Coste
74f90c1fc5 Refactor buffer undo tree
Store the undo tree as an array of undo nodes, instead of as a
pointer based tree.
2018-05-02 22:34:55 +10:00
Maxime Coste
4288f0fb3a Move ScopedEdition to context_wrap
No need to create it both in context_wrap and in the called function.
2018-05-01 22:49:01 +10:00
Maxime Coste
286a244aa2 Replace RegisterRestorer with a on_scope_end + lambda 2018-05-01 22:48:14 +10:00
Maxime Coste
6777c14697 Make OnScopeEnd valid even when non-copy elided
OnScopeEnd was relying on copy elision to avoid temporary destructor
calls that would run the scope end function too soon.
2018-05-01 22:47:06 +10:00
Maxime Coste
1fb53ca712 Fix wrong use of constexpr 2018-04-30 07:41:31 +10:00
Maxime Coste
e4f90e5ed2 Fix tests after changes to json_ui output 2018-04-29 23:06:24 +10:00
Maxime Coste
bcecb2f877 Fix crash on quitting 2018-04-29 22:59:20 +10:00
Maxime Coste
178d2d3cd3 Rework the way UI can trigger a client quitting
Add a UserInterface::is_ok method and return false on
SIGHUP/stdin closing/socket dropping

This should be cleaner and more robust than the previous SIGHUP
handling code.

Fixes #1594
2018-04-29 22:31:57 +10:00
Maxime Coste
57112b0845 Rename move to move_cursor
move is pretty ambiguous and hard to find due to std::move.
2018-04-29 22:31:57 +10:00
Maxime Coste
8e555cb992 JsonUI: add support for set_ui_options RPC call
As discussed on #2019
2018-04-29 20:45:53 +10:00
Maxime Coste
2fa553e728 Remove implicit conversion from String to DisplayAtom/DisplayLine 2018-04-29 20:45:53 +10:00
Maxime Coste
787ca7f19b Regex: small code style tweak 2018-04-29 19:58:18 +10:00
Maxime Coste
1e8026f143 Regex: Use only 128 characters in start desc and encode others as 0
Using 257 was using lots of memory for no good reason, as > 127
codepoint are not common enough to be treated specially.
2018-04-29 19:58:18 +10:00
Maxime Coste
528ecb7417 Regex: Use a custom 'DualThreadStack' structure to hold thread info
Instead of using two vectors, we can hold both current and next
threads in a single buffer, with stacks growing on each end.

Benchmarking shows this to be slightly faster, and should use less memory.
2018-04-29 19:58:18 +10:00
Delapouite
8b00d763e0 Docs: add exhaustive list of scoped objects 2018-04-28 17:41:24 +02:00
Maxime Coste
3afa32935f Merge remote-tracking branch 'Delapouite/unnamed-client' into HEAD 2018-04-28 09:30:35 +10:00
Maxime Coste
a1b8864c77 Merge remote-tracking branch 'lenormf/regex-format-string' into HEAD 2018-04-28 09:29:57 +10:00
Maxime Coste
2b9ec411d3 fix potential overflow in dump_regex 2018-04-28 09:29:15 +10:00
Frank LENORMAND
9bac04d35f regex_impl: Fix a potential format string flaw 2018-04-27 09:24:22 +03:00
Maxime Coste
8438b33175 Add a debug regex command to dump regex instructions 2018-04-27 08:35:09 +10:00
Maxime Coste
f10eb9faa3 Use indices instead of pointers for saves/instruction in ThreadedRegexVM
Performance seems unaffacted, but memory usage should be lowered
as the Thread struct is 4 bytes instead of 16.
2018-04-27 08:35:09 +10:00
Maxime Coste
4eb6740794 Add a -always switch to hook command to ignore hooks disabled
Hooks specified as always will run regardless of the hook disabled
status.
2018-04-26 08:28:11 +10:00
Maxime Coste
2d96fbed7c Reserve data for # register 2018-04-25 21:19:04 +10:00
Maxime Coste
2fc5a0317c Refactor RegexIterator::next to directly use a ThreadedRegexVM 2018-04-25 21:20:32 +10:00
Maxime Coste
fa17c46653 Regex: Refactor ThreadedRegexVM state handling
Remove ExecState to store threads inside the ThreadedRegexVM so that
memory buffers can be reused between executions. Extract an ExecConfig
struct with all the data thats execution specific to avoid storing
it needlessly inside the ThreadedRegexVM.
2018-04-25 21:19:04 +10:00
Delapouite
746b9acb96 Change client default name: "unnamed0" → "client0" 2018-04-23 11:42:11 +02:00
Stephen Hassard
eca53db2bf remove dragonflybsd specific logic since pkg-config works perfectly fine now 2018-04-22 09:12:45 -07:00
Maxime Coste
0b773ac26c Complete word from the current buffer in regex_prompt
This allows to use Kakoune fuzzy matching to get the words we
are looking for.
2018-04-19 07:58:42 +10:00
Maxime Coste
f545ff7727 Move get_word_db to word_db.cc 2018-04-19 07:58:42 +10:00
Maxime Coste
e207bd30d4 Extract a for_n_best algorithm from completion function
Provide the heap based n-best algorithm through a nice interface.
2018-04-19 07:58:42 +10:00
Maxime Coste
c2759ac526 Fix handling of local client quitting during its creation
If the local client was quitted during its creation (using -e quit
for example), we could have been accessing a null pointer afterwards.

Make the rest of the code aware that local_client might be null.
2018-04-19 07:56:37 +10:00
Maxime Coste
0f38be544c Makefile: use git-describe to get the version string
That means we can just tag releases and the version will be taken
from the tag to generate the tarball.
2018-04-14 13:05:59 +10:00
Maxime Coste
7f6a6ab1d3 Update startup message and include released version in it
Having released version information in that message will be useful
to allow user to know which breaking changes apply to them.
2018-04-14 13:04:45 +10:00
Maxime Coste
5fa19f4d7f NCursesUI: Add support for shifted function keys
Shifted function keys are not well standardized around terminals,
Shift F(N) usually returns F(X) + N, with X=12 on xterm, X=10 on
rxvt-unicode... Default to X=12 and make it configuable through
the ncurses_shift_function_key ui_option.

This fixes what #1898 tried to.
2018-04-11 20:39:57 +10:00
Tim Allen
50e422659b Add support for the shift modifier.
Because keyboard layouts vary, the shift-modifier `<s-…>` is only supported
for special keys (like `<up>` and `<home>`) and for ASCII lowercase where
we assume the shift-modifier just produces the matching uppercase character.
Even that's not universally true, since in Turkish `i` and `I` are not an
uppercase/lowercase pair, but Kakoune's default keyboard mappings already
assume en-US mappings for mnemonic purposes.

Mappings of the form `<s-x>` are normalized to `<X>` when `x` is an ASCII
character. `<backtab>` is removed, since we can now say `<s-tab>`.
2018-04-11 15:15:45 +10:00
Maxime Coste
d846400279 Redraw window when the face definition changed
Hash the current face state and store that hash to check for changes.
2018-04-10 20:35:23 +10:00
Maxime Coste
9c82f6586c FaceRegistry: Support referencing a named face from a parent scope 2018-04-10 19:57:16 +10:00
Maxime Coste
a2978bff25 Makefile: formatting fix 2018-04-10 19:02:32 +10:00
Maxime Coste
d571c207e6 Make version available through $kak_version and debug info 2018-04-09 17:06:02 +10:00
Maxime Coste
fc86acd9f0 Makefile: add a dist target to generate a tarball 2018-04-09 16:57:15 +10:00
Maxime Coste
57baad4afd Make FaceRegistry scoped
set-face now takes a scope argument, and faces can be overridden on
a buffer or window basis.

colorscheme apply on global scope, which should be good enough for
now.

Fixes #1411
2018-04-07 16:27:50 +10:00
Maxime Coste
6adb28ec12 Ignore current buffer when completing the :buffer command
Closes #1901
Fixes #1782
2018-04-07 16:27:44 +10:00
Maxime Coste
6f58c278bf Merge remote-tracking branch 'Delapouite/no-such' 2018-04-07 12:33:15 +10:00
Maxime Coste
23853f499e Add some safety static_asserts to remote read/write functions 2018-04-07 12:32:31 +10:00
Delapouite
cb02186c77 Make error messages more consistent 2018-04-06 16:56:53 +02:00
Maxime Coste
3c03129c46 Make compute_display_setup methods const 2018-04-06 09:16:59 +10:00
Maxime Coste
21603983c5 Add new buffers at the back of the buffer list
This will be reverted if we discover why we were doing things the
over way around.

Fixes #1881
2018-04-05 10:31:41 +10:00
Maxime Coste
f018a29b58 Merge remote-tracking branch 'Delapouite/declare-option' 2018-04-05 09:23:33 +10:00
Maxime Coste
71a1893a5e Fix some trailing spaces and a tab that sneaked into the code base 2018-04-05 08:52:33 +10:00
Maxime Coste
2f799b1acf NCurses: Tolerate failure to open /dev/tty and to ioctl for resize
Not sure what to do when that happens, but asserting and quitting
is not necessarily the best option, try to tolerate it.

Fixes #1972
2018-04-04 14:01:24 +10:00
Maxime Coste
6ee60ff9d7 Prompt: add <a-!> to expand the typed expansions in current line
Fixes #1952
2018-04-04 11:00:25 +10:00
Maxime Coste
ff073bcce1 Merge remote-tracking branch 'lenormf/fix-ncurses' 2018-04-01 14:42:44 +11:00
Maxime Coste
ea66465144 Restore previous status line after notifying wait for shell
Fixes prompt getting erased by the wait for shell message, and
having to manually trigger a redraw to see it again.
2018-04-01 10:08:54 +11:00
Frank LENORMAND
e06d048d2f src: Make code more readable, assert function calls that shouldn't fail
Should help clarify what the issue is in #1972.
2018-03-31 15:00:19 +03:00
Maxime Coste
0baf562c93 Support full redraws during shell execution and handle resize there
Fixes #1973
2018-03-30 09:58:18 +11:00
Maxime Coste
f6f2dafaf7 Make set -add replace existing value when applied to a map option 2018-03-30 09:26:39 +11:00
Delapouite
7f3a308b60 Add status message when commiting an undo group in insert mode 2018-03-29 22:54:03 +02:00
Maxime Coste
fab3dc642a Merge remote-tracking branch 'Delapouite/on-key' 2018-03-28 21:41:17 +11:00
Maxime Coste
ebc700ee17 Fix uninitialized m_empty_text StringView in LineEditor 2018-03-28 20:48:50 +11:00
Delapouite
1b7b3fea09 Fix typo in on-key command description 2018-03-28 07:33:43 +02:00
Delapouite
fc3f0f40b7 Give more hints in "option not found" error. 2018-03-27 19:14:41 +02:00
Maxime Coste
1f6c2b87ff Support count in <a-s> to split on groups of n lines
Fixes #1966
2018-03-27 22:33:58 +11:00
Maxime Coste
e8093a12a0 Simplify command debug code 2018-03-27 08:25:47 +11:00
Maxime Coste
0a833371ab Prompt: Do not call callback in on_enabled
Schedule it for later, when we get "idle". It currently can lead to
crashed because after the callback, the current mode might be different,
leading to a crash when doing the ModeChange hook call.
2018-03-27 07:40:44 +11:00
Maxime Coste
3d3a37a80c Fix 'O' not putting the cursor on the correct line 2018-03-27 07:28:25 +11:00
Maxime Coste
253790be51 Formatting fix 2018-03-26 19:50:51 +11:00
Maxime Coste
5ba27c18a4 Fix operator priority order error 2018-03-26 19:19:47 +11:00
Maxime Coste
59c883d02f Avoid visiting the same directory multiple times in insert filename completion 2018-03-25 20:28:26 +11:00
Maxime Coste
6d3fe30bf6 Allow explicit filename completion with empty prefix 2018-03-25 19:03:54 +11:00
Maxime Coste
a6b1d142fa Cleanup client name validation code 2018-03-25 16:53:27 +11:00
Maxime Coste
49c52b025f Remove contains_that and use any_of to be closer to the c++ stdlib 2018-03-25 16:47:19 +11:00
Maxime Coste
435b5b7ff9 Unify code that validates identifiers in Kakoune
Session/Client/User modes names are now requiered to be "identifiers"
they must be in [a-zA-Z0-9_-]. Option names are the same except they
do not allow '-' as they need to be made available through the env vars
and '-' is not supported there.

Fixes #1946
2018-03-25 16:35:33 +11:00
Maxime Coste
beb2cef7f9 Document rotate selection breaking change in startup message 2018-03-25 11:39:26 +11:00
Maxime Coste
ec7f3738ee Move rotate selection and rotate selection contents to ) and <a-)>
Backward rotation are supported with (.

Fixes #1210
2018-03-25 11:39:26 +11:00
Maxime Coste
683ce8e83b Use 1 and -1 for Forward/Backward Direction to simplify code 2018-03-25 11:25:55 +11:00
Maxime Coste
59e9108812 indent selector: When line is empty, find indent from surrounding lines
Look for the first non empty line preceeding the current line, or
if not found, the first non empty line following it.

Fixes #1904
2018-03-25 10:25:56 +11:00
Maxime Coste
81f605709c Remove parse_filename overload and use a default parameter 2018-03-25 07:55:39 +11:00
Maxime Coste
a732037b53 Support % in path option to mean current buffer directory
In the end, % is not that painful to work with as its only set seldomly,
and we usually dont need to use expansion at the same time. Moreover, it
just requires a single \ to be escaped.

Fixes #1562
2018-03-23 08:22:34 +11:00
Maxime Coste
db7b43acd5 Restore client name after converting to client
When Kakoune forked the sever to background, the newly converted
to client process (the original client/server process) was not
preserving its previous client name.
2018-03-23 07:36:18 +11:00
Maxime Coste
1cdeace128 Merge remote-tracking branch 'Delapouite/doc-commands' 2018-03-21 06:42:31 +11:00
Maxime Coste
5c1a5c6d15 Revert "Throw when trying to remove a child highlighter that does not exists"
This reverts commit 56237aa8f8.

Throwing seems more correct, but it breaks lots of existing scripts.
reverting for now until we have a nice solution.
2018-03-20 20:11:15 +11:00
Delapouite
00cb49438a Docs: add missing [<switches>] in commands signatures 2018-03-20 09:13:09 +01:00
Maxime Coste
bec849ae14 Tolerate empty filenames in real_path 2018-03-20 05:56:20 +11:00
Maxime Coste
f7f84b7402 NCursesUI: Rework menu_show to shrink menu height when needed
Closes #1886
2018-03-20 05:54:19 +11:00
Maxime Coste
826977eb1b Fix remove of highlighters with trailing / in their name
Fixes #1914
2018-03-20 05:35:37 +11:00
Maxime Coste
56237aa8f8 Throw when trying to remove a child highlighter that does not exists 2018-03-20 05:35:15 +11:00
Maxime Coste
b27d4afa8d Regex: Only allow SyntaxCharacter and - to be escaped in a character class
Letting any character to be escaped is error prone as it looks like
\l could mean [:lower:] (as it used to with boost) when it only means
literal l.

Fix the haskell.kak file as well.

Fixes #1945
2018-03-20 04:57:47 +11:00
Maxime Coste
6e695e37be Fix real_path again 2018-03-19 20:49:05 +11:00
Maxime Coste
6d8747b886 Fix introduced bug in real_path 2018-03-19 06:28:06 +11:00
Maxime Coste
9518f279fb Tweak option documentation helper to support -add
Fixes #1939
2018-03-19 03:04:50 +11:00
Maxime Coste
8a7e844207 NCursesUI: refactor info_show code
Show MenuDoc info on the left of the menu if necessary. Cleanup the
code.
2018-03-19 01:23:32 +11:00
Maxime Coste
cf37623f1a Refactor read_fd '\r' removal logic 2018-03-18 23:43:18 +11:00
Maxime Coste
ac91a79b12 Fix implementation of real_path to handle non-existing directories in /
Fixes #1937
2018-03-18 23:23:00 +11:00
Maxime Coste
7ba4ef897b Fix crash on expanding command line strings 2018-03-18 04:58:15 +11:00
Maxime Coste
0a2807e652 RangesHighlighter: a range that goes up to buffer end is not valid 2018-03-16 23:25:37 +11:00
Maxime Coste
08df409a53 RankedMatch: Do not compare word boundary match count on single word matches
As the computation of word boundary matches is separate from the
actual subsequence matching, we sometimes have candidate that match
as a single word while still having multiple word boundary matches.

For example, with query "expresins", candidate "expressionism's"
will match as single word ("expressins" is a subsequence of
"expressionism"), and will have two word boundaries match (it does
match the last "s", which is considered as a separate word).

This should not be taken into account when compared against
candidate "expresions", which should be considered a better
match.

Fixes #1925
2018-03-15 23:20:03 +11:00
Maxime Coste
6f2b093eec NCursesUI: Show full menu rather than triming to respect anchor 2018-03-13 15:18:06 +11:00
Maxime Coste
a480e566dc ranges: Add transform overload taking directly a pointer to member
This overload will forward to the general transform implementation
using std::mem_fn to generate a callable.
2018-03-13 14:24:03 +11:00
Maxime Coste
c82bf31378 NCursesUI: Use accumulate algorithm to gather the longest element in menu 2018-03-13 14:14:16 +11:00
Maxime Coste
bfaf52f8c0 Do not jump to buffer start on g. with no previous modifications 2018-03-13 14:00:57 +11:00
Delapouite
d5d23834f6 Handle hyphens in user-mode names
Fix #1921
2018-03-11 14:58:53 +01:00
Maxime Coste
e66073bc94 Detect infinit recursion in reference highlighting
Reference highlighters allow for potential mutual recursion between
highlighters. This is usually fine, but if the recursion happens on
the same buffer range, it means we will recurse infinitely.

Fixes #1920
2018-03-11 11:44:10 +11:00
Maxime Coste
4584ecac77 Move WORD text object to <a-w>
It improves consistency and it looked like there was support for that
change on github.
Fixes #1861
2018-03-10 00:25:19 +11:00
Maxime Coste
f801d0064a Merge remote-tracking branch 'Delapouite/hls' 2018-03-10 00:07:03 +11:00
Maxime Coste
9125b01fa8 Detect no-op replaces and do not act on them
This avoids recording no-op undo groups.
2018-03-09 23:07:05 +11:00
Delapouite
abc2d28570 Docs: extend explanations about line_flags, ranges and replace-ranges 2018-03-06 12:15:55 +01:00
Maxime Coste
9c85d9b389 Support changing autoreload option directly from the reload message
Pressing Y or N will set the buffer (or window, if it is set at that
scope) autoreload option to the corresponding value, avoiding infinite
loops where a file getting constantly modified prevents the user from
using Kakoune.
2018-03-05 11:17:57 +11:00
Maxime Coste
07113e7ee5 Add a GlobalSetOption hook 2018-03-05 10:39:14 +11:00
Maxime Coste
642b711d94 Merge remote-tracking branch 'Delapouite/scratch' 2018-03-05 07:10:57 +11:00
Maxime Coste
fb65fa60f8 Regex: take the full subject range as a parameter
To allow more general look arounds out of the actual search range,
pass a second range (the actual subject). This allows us to remove
various flags such as PrevAvailable or NotBeginOfSubject, which are
now easy to check from the subject range.

Fixes #1902
2018-03-05 05:48:10 +11:00
Maxime Coste
d9e44dfacf Regex: Remove helper functions from regex_impl.hh
They were close duplicates from the ones in regex.hh and not used
anywhere else.
2018-03-05 03:10:47 +11:00
Maxime Coste
6c4faf2050 Merge remote-tracking branch 'fsub/unused-lambda-capture' 2018-03-05 00:39:56 +11:00
Maxime Coste
a2fc89a6ec Remove SelectionList::update_timestamp()
This single line member function was only used once, inline it
directly.
2018-03-04 10:35:24 +11:00
Maxime Coste
2fd42fe5fc Insert: Do not move end of line on open line (o/O)
Change the logic of open line commands so that if a selection lies
on the end of line character of the line from which we open a new
line, that selection does not move.

If we have two clients, A and B, with B's cursor on the eol character
of line L, and A hits `o` while on line L, B's cursor should stay
on the same (logical) line. Previous behaviour would make B's cursor
jump on the newly inserted line.
2018-03-04 10:32:21 +11:00
fsub
44d381ce79 Remove unused lambda capture 2018-03-03 17:57:51 +01:00
Delapouite
c4eb4438d2 Remove <scope> from user-modes commands 2018-03-02 09:28:27 +01:00
Maxime Coste
7a54c0edfe Update status message with new breaking changes 2018-03-01 15:36:25 +11:00
Maxime Coste
28716ec058 Change x behaviour to select full line first even if on EOL
x will always first select current line fully, and only then select
next line.
2018-03-01 15:34:31 +11:00
Maxime Coste
f907e6cc46 Reintroduce complex selection merging behaviour
Selection merging is necessary if we want X to work nicely when we are
on EOL (jumping to next line is as nice as it could be, and we are much
more often on EOL nowadays).
2018-03-01 15:21:55 +11:00
Maxime Coste
7dfd439263 Merge remote-tracking branch 'Delapouite/user-mode-lock' 2018-03-01 14:04:52 +11:00
Maxime Coste
2193947b71 InsertCompleter: refactor line completer implementation 2018-02-28 15:40:42 +11:00
Maxime Coste
4e6b24eea2 Merge remote-tracking branch 'Delapouite/line_complete' 2018-02-28 15:32:31 +11:00
Maxime Coste
44a5082aaf Commands: Refactor generate_switches_doc 2018-02-28 15:32:11 +11:00
Maxime Coste
a6fd70c456 Ranges: Fix copiability of some range view iterators
Some iterators were refering to to their view with a const ref, this
was making them non-copiable. Change those const ref into const pointers
in order to fix that.
2018-02-28 15:16:49 +11:00
Maxime Coste
edee85a847 Merge remote-tracking branch 'aver-d/option_display' 2018-02-28 15:09:26 +11:00
Maxime Coste
d498a059c4 Prompt: update completions after inserting register or raw ke 2018-02-28 15:05:38 +11:00
Maxime Coste
bebc81ebe1 RefPtr: use inconditional noexcept specification on destructor
The conditional specification could end up being recursive,
assume destructors must be (as is the C++ default) noexcept.
2018-02-28 15:04:00 +11:00
Delapouite
a6a1c34288 Add -lock switch to enter-user-mode command 2018-02-27 19:55:00 +01:00
Delapouite
0568836943 Add support for line completion in all buffers
- via completers option with line=all vs line=buffer
- via <c-x> L mapping
2018-02-27 09:48:49 +01:00
Delapouite
98fcf8a497 Add [scratch] indicator in context info 2018-02-27 08:22:46 +01:00
Maxime Coste
b4dc16010d Fix out of bound read in ParameterParser::get_switch
The empty string case was not correctly handled.
Fixes #1883
2018-02-26 15:20:19 +11:00
Maxime Coste
18f0902824 Merge remote-tracking branch 'Delapouite/sels' 2018-02-26 11:34:05 +11:00
aver-d
f43635c4df Ease reading of command-line options
This change displays command-line options in grid format. Each
parameter is indented with two spaces and then padded to maintain
vertical alignment of each description.

I think the visual spacing makes the options much easier to
read. This is particularly important for people new to Kakoune who
use `-help` as a way to become familiar with the program.
2018-02-25 01:46:50 +00:00
Maxime Coste
6453ce7394 RefPtr: Add some more noexcept specifications 2018-02-25 00:20:10 +11:00
Maxime Coste
67424aae1e Remove avoidance of end of lines
Various places in Kakoune code used to modify selections so that
cursors would not lie on an end of line. Remove those to increase
Kakoune's consistency and simplicity.

Now that end of lines are highlighted separately, they should not
be handled specially in most commands.
2018-02-25 00:05:05 +11:00
Maxime Coste
171e787063 Update startup message to notify about h/l change 2018-02-24 23:16:39 +11:00
Maxime Coste
2a60af25dc Allow l/h to cross line boundaries
l and h are now respectively "next character" and "previous character"
2018-02-24 23:16:39 +11:00
Maxime Coste
6a6e71dc0f Highlight cursors differently when they lie on an end of line
When on an end of line, certain behaviours can be surprising, for
example delete will join the following line (which makes sense, and
is consistent, but hard to predict if we do not know the cursor is
on and end of line).

As Kakoune is moving more and more towards treating end of lines
as any other character, making it clear when the cursor lies on
them seems like a good way to reduce surprise.
2018-02-24 21:32:01 +11:00
Maxime Coste
a0de41d165 goto last change: do not try to avoid end of lines
Avoiding end of line is a behaviour we avoid (pun intended) more and more
in Kakoune source code, now that end of lines are regularly selected, it
makes no sense to just to next line when last modification lies on an EOL
(and it probably did not make much sense back when that code was written).
2018-02-24 21:09:09 +11:00
Maxime Coste
a25d6171d3 Fix crash in select_sentence when not selection to end
select_sentence could create a buffer iterator preceeding the
buffer begin, leading to a crash trying to read line -1.
2018-02-24 20:22:23 +11:00
Maxime Coste
efce8e0ce6 Revert "Do not save last command/pipe/regex in register when history is disabled"
This reverts commit 55621fb4cc.

This should not be necessary as :exec/eval already save those registers
and reset them by default, and it breaks the ability to use those
registers during an eval/exec (as the commands behave differently)
2018-02-24 19:58:40 +11:00
Maxime Coste
4d11bb20c3 Always collapse jumps in exec/eval, remove -collapse-jumps switch
There does not seem to be any reasonable use cases of not collapsing
jumps when the input is not comming from the user. Always collapse
them.

It could make sense to move jump collapsing out of context_wrap as
in general any action not comming directly from the user should
collapse them, at the moment a comment or mapping will not collapse
jumps, which is unfortunate.
2018-02-24 19:02:15 +11:00
Maxime Coste
933ac4d3d5 Regex: Improve comments and constify some variables
Reword various comments to make some tricky parts of the regex
engine easier to understand.
2018-02-24 17:40:08 +11:00
Maxime Coste
af21d4ca1e regex: track CompiledRegex::StartDesc in the Regex memory domain 2018-02-24 16:29:24 +11:00
Delapouite
e568231fe3 Display number of combined/saved/restored selections in status 2018-02-23 22:58:44 +01:00
Maxime Coste
e9c18ebff6 Merge remote-tracking branch 'lenormf/fix-makefile' 2018-02-23 08:10:11 +11:00
aver-d
da009b0ef5 Fix typos in C++ string literals
informations, dont, incrementaly, alignement
2018-02-22 20:28:01 +00:00
Frank LENORMAND
01c1b4fd69 src makefile: Fix the --static flag passed to pkg-config 2018-02-22 15:56:14 +03:00
Maxime Coste
99d1fee44c Merge remote-tracking branch 'Delapouite/trim' 2018-02-22 22:06:27 +11:00
Maxime Coste
13ac0e367d NCursesUI: Rework menu placement to fix missing menu on small window 2018-02-22 22:04:04 +11:00
Maxime Coste
35d68d2f82 Fix crash when iterating through options on window creation
Window::on_option_changed calls hooks, which can do anything
including adding/removing options in the various option managers

Fixes #1863
2018-02-21 22:47:41 +11:00
Maxime Coste
69a0ad09b4 Rewrite OptionManager::flatten_options to use ranges
Avoid accumulating the flattened options into a vector, generate
a lazy range that will give the proper list.
2018-02-20 23:32:51 +11:00
Maxime Coste
6d111d4bd7 Re-introduce aliases in command name completion
Aliases are considered again in command name completion, but only
if they are more than 3 charactes long. This should prevent cluttering
with aliases while still letting long ones being completed.
2018-02-20 23:32:31 +11:00
Maxime Coste
6239357e99 ranges: Support temporary parameters passed to concatenated 2018-02-20 21:55:06 +11:00
Maxime Coste
fec34c3748 Json: Fix buffer overflow when reading json finishing with { or [
Fixes #1860
2018-02-20 07:42:10 +11:00
Maxime Coste
2c0eba9d95 user-modes: Fix incorrect use of keymap mode
The keymap mode was passed to on_next_key_with_autoinfo, which
means the mapping was applied directly by the InputHandler.

That led to the first key being interpretted as a mapping, then
all following keys being executed normally, as if typed in the
parent mode of the user mapping.
2018-02-19 21:03:29 +11:00
Maxime Coste
76f5fb937c Fix bug in command parsing post refactoring
Fixes #1857
2018-02-19 08:29:04 +11:00
Maxime Coste
fc60e29870 Small code tweaks regarding user modes 2018-02-18 20:24:34 +11:00
Maxime Coste
f88195d2d9 Merge remote-tracking branch 'Delapouite/user-mode' 2018-02-18 20:20:35 +11:00
Maxime Coste
eb2e44e0eb Makefile: use PKG_CONFIG to get static compilation flags as well 2018-02-18 15:43:28 +11:00
Maxime Coste
536fa29ed5 CommandManager: unescape % while parsing the string 2018-02-18 14:56:52 +11:00
Maxime Coste
dc30b0e6d6 Do not support general commands in filter mode 2018-02-18 14:54:21 +11:00
Maxime Coste
84d70f8aeb normal mode: Fail if ':' is pressed with no CommandManager 2018-02-18 14:53:37 +11:00
Maxime Coste
5924694bda ShellManager: init from a static list of env vars
No need to go through a static list and then copy them one by
one in a vector.
2018-02-18 14:52:29 +11:00
Maxime Coste
d9cddf41f2 BufferManager: Support missing ClientManager 2018-02-18 14:50:24 +11:00
Maxime Coste
10c6c59a26 Buffer: avoid expensive option flattening in on_registred with NoHooks 2018-02-18 14:48:24 +11:00
Maxime Coste
74fd602569 '*' uses escaping of meta characters instead of \Q and \E
Fixes #1825
2018-02-17 20:36:07 +11:00
Maxime Coste
bde1f5349d CommandManager: refactor parsing of commands to iterate through tokens
Avoid storing a big vector of tokens, read them one by one, and
store only the current command.
2018-02-15 23:24:19 +11:00
Delapouite
fccfc76e89 Add trim_selections primitive 2018-02-13 14:35:10 +01:00
Delapouite
6b447a0ecb Add declare-user-mode / enter-user-mode commands 2018-02-12 14:19:58 +01:00
Maxime Coste
f3c19ba7fa Prevent whitespaces in command names
Fixes #1843
2018-02-11 20:35:21 +11:00
Maxime Coste
a822bcd6e0 Do not specify utf8 InvalidPolicy when we are using the default value
It was specified only in two call sites, and everywhere now only uses
the pass policy, which is the default.
2018-02-11 17:39:19 +11:00
Maxime Coste
66fe2d84da Refuse modification of ReadOnly buffers and make Debug buffer readonly
The debug buffer is a bit special as lots of events might mutate it,
permitting it to be modified leads to some buggy behaviour:

For example, `pipe` uses a ForwardChangeTracker to track buffer
changes, but when applied on a debug buffer with the profile flag
on, each shell execution will trigger an additional modification
of the buffer while applying the changes, leading to an assertion
failing as changes might not be happening in a forward way anymore.

Trying to modify a debug buffer will now raise an error immediatly.
2018-02-11 13:06:19 +11:00
Maxime Coste
3584e00d19 Regex: Use a template argument instead of a regular one for "forward"
forward (which controls if we are compling for forward or backward
matching) is always statically known, and compilation will first
compile forward, then backward (if needed), so by having separate
compiled function we get rid of runtime branches.
2018-02-09 22:45:53 +11:00
Maxime Coste
aa9f7753e8 Regex: minor code cleanup 2018-02-09 22:19:56 +11:00
Maxime Coste
cb16e52179 FaceRegistry: pass face names as StringViews instead of const String& 2018-02-09 22:08:29 +11:00
Maxime Coste
e46a5697e5 Add a limit to the size of selection with which we will try to diff on pipe
Limit to 100K of data for now, as we diff at the byte level.
2018-02-09 21:47:18 +11:00
Maxime Coste
bbf62d1779 diff: try to improve code readability 2018-02-09 21:31:10 +11:00
Maxime Coste
b7a3d80bde CommandManager: Use byte rather than columns for token positions
Not only are display columns rarely used to give error positions,
but they make the parsing much slower as for each token we need to
compute the column in the line.
2018-02-09 20:30:33 +11:00
Maxime Coste
e2c1d44a7f Fix parsing of percent tokens with unicode separators 2018-02-06 20:29:08 +11:00
Maxime Coste
4a96926c4b Handle errors while reloading buffer gracefully
Fixes #1831
2018-02-05 20:27:32 +11:00
Maxime Coste
f592768d3a Remove the New flag from a buffer after reloading it
If we reload a buffer, it means its underlying file exists, hence the
New flag does not make sense anymore. It could be that the file appeared
on the filesystem in the meantime.
2018-02-05 20:18:51 +11:00
Maxime Coste
05f57ace07 CommandManager: parse command lines as utf8 instead of ascii
Fixes #1829
2018-02-04 09:21:15 +11:00
Maxime Coste
52016d32bc Makefile: Only check for pkg-config when on a system that uses it
This fixes compilation on OSX where pkg-config is not installed
by default.
2018-02-03 13:37:09 +11:00
Maxime Coste
90c16d2b0d Profile the time it takes to source a file
`:source` command will now generate timings if profile is enabled
in the debug option, to help find which script can be slow to load.

This should help for #1823
2018-02-01 09:03:16 +11:00
Maxime Coste
e41b4ee65d Change m to search until the end of the buffer instead of end of line
Fixes #1774
 # Please enter the commit message for your changes. Lines starting
2018-01-31 11:10:18 +11:00
Maxime Coste
81eb2ee428 Do not strip whitespaces with '*'
Stripping whitespaces there is a failed experiment as it breaks the
ability to use multi-selections consistently: Using '*' followed by some
`N` to add following matches, we end up with mismatched selections
due to whitespace stripping the original selection still contains
whitespaces where all the new ones do not. Once we get to this state,
most selection commands will give different results for the initial
selection and the other ones, breaking predictible multiselection use,
one of the cornerstones of Kakoune editing model.
2018-01-31 09:31:18 +11:00
Maxime Coste
c30a954dfc ncurses: change handling of <c-z> suspend to improve terminal state
reset the mouse state so that the terminal can take back control
of the mouse while Kakoune is suspended, and does not emit focus
events anymore.

Fixes #1816
2018-01-30 10:46:34 +11:00
Maxime Coste
9c25e955df Use '/' register as the default register for <a-k> and <a-K>
Fixes #1808
2018-01-26 14:15:18 +11:00
Maxime Coste
bf73cb0109 Reset normal mode before hiding the reload buffer info box
Reseting normal mode will enable normal mode, which will trigger
a check for buffer modification. We do not want that check to
happen as we are trying to close the info box. Doing that mode
reset first will prevent the check from happening (as the info
box is already displayed), and will correctly hide it afterwards.

Fixes #1809
2018-01-26 13:45:36 +11:00
aver-d
29a7cd3ab4 Insert complete: Remove path info with one buffer
This change is useful when using `set scope completers word=buffer`,
instead of the default word=all.

If candidates all come from the same buffer, then the path/filename
information is the same and therefore unnecessary. This change
prevents the same path from being repeated, and the buffer's
source code is less obscured.

More generally, there could be an option to disable the path
information entirely in all cases, but for now this change seems
a reasonable solution until any such option exists.
2018-01-25 17:49:02 +00:00
Maxime Coste
220be30f02 Support multiline selections in C/<a-C>
Fixes #1725
2018-01-24 10:33:22 +11:00
Maxime Coste
299e22ca7c Do not block when waiting for next event if we have pending input
Handle next event should never block if we have already accumulated
input that we want to process. As we can accumulate new input in
lots of places (everytime we run a shell process for example, we
might end up reading input keys. That can be triggered during the
mode line generation which takes place during display of the window)

Fixes #1804
2018-01-21 12:00:40 +11:00
Maxime Coste
d22c989984 Rename InputModeChange hook to ModeChange
InputModeChange is a bit long to type and its pretty clear in Kakoune
that "Mode" means "Input mode", so use a shorter and as clear name.
2018-01-21 10:34:09 +11:00
Maxime Coste
07dfcd336d Fallback to getpwuid in the unlikely case $HOME is underfined
Add a homedir() helper function, and document the $kak_config
env var.
2018-01-20 11:19:23 +11:00
Maxime Coste
e7cbf38af7 Introduce a $kak_config env var containing the Kakoune user config dir
Makes it easier for users who want to locate their kakrc file, and
does not require to go through shell expansion to get it as
"${XDG_CONFIG_DIR:-${HOME}/.config}/kak"

Fixes #1740
2018-01-19 10:05:08 +11:00
Maxime Coste
55621fb4cc Do not save last command/pipe/regex in register when history is disabled 2018-01-19 09:48:57 +11:00
Maxime Coste
eeacb8b5a8 Use the _str and _sv string literals more often 2018-01-18 09:00:54 +11:00
Maxime Coste
b4f8497f8d Slight code refactor in InputHandler::handle_key 2018-01-15 10:25:58 +11:00
Maxime Coste
e74b581b0a Save/restore main selection from/to strings
Always consider that the first selection in the list is the main
one, save selections that way.

This approach was suggested by PR #1786 but the implementation here
is different, and is used more generally whenever we save selections
to strings.

This is also the prefered way to work only on the main selection:
save selections with Z, reduce to main with <space>, restore with z.

Closes #1786
Fixes #1750
2018-01-12 07:51:19 +11:00
Maxime Coste
2366af29e2 Slight refactor of jump collapsing code 2018-01-12 07:50:52 +11:00
Maxime Coste
827aab1386 Merge remote-tracking branch 'Delapouite/print_status' 2018-01-12 07:03:21 +11:00
Maxime Coste
af4cc11404 Merge remote-tracking branch 'lenormf/fix-makefile' 2018-01-12 07:02:40 +11:00
Delapouite
7ecc3d343f Remove extraneous face when clearing status line 2018-01-11 15:26:42 +01:00
Frank LENORMAND
202c977b3d src makefile: Abort compilation when pkg-config is not in PATH
Fixes #1792
2018-01-11 10:41:19 +03:00
Maxime Coste
bf66302d29 Small code style tweak 2018-01-11 13:57:33 +11:00
Maxime Coste
996d8abef4 Write new buffers even when unmodified
Fixes #1794
2018-01-08 09:42:26 +11:00
Maxime Coste
49e028b847 Add information on InputModeChange hook in the startup message 2017-12-29 10:00:45 +11:00
Maxime Coste
6333ae207f Correctly set the NotBeginOfSubject/NotEndOfSubject flags for regex matching
Fixes #1778
2017-12-29 09:55:53 +11:00
Maxime Coste
6851604546 Regex: Add a RegexExecFlags::NotEndOfSubject flag 2017-12-29 09:55:38 +11:00
Delapouite
74898120ed Add session name filtering for KakBegin hook 2017-12-21 22:22:33 +01:00
Maxime Coste
9b83589b18 Completion: Use a heap to gather the best matches instead of sorting
Generalize the behaviour of `shell-candidates` to insert completion,
gather the best 100 matches by using a heap and poping max a hundred
times.
2017-12-21 12:55:29 +11:00
Maxime Coste
a38d6cc3f0 Highlighter: In general, highlight replaced ranges
Fixes #1251
2017-12-21 12:26:25 +11:00
Maxime Coste
0814bb2962 InputHandler: Preserve no-hooks on insert mode from single command normal mode
Fixes #1775
2017-12-21 10:30:45 +11:00
Maxime Coste
e0b28fa421 Introduce InputModeChange hook
InputModeChange <old mode>:<new mode> is intended to replace the various
<Mode>Begin/<Mode>End hooks.

Fixes #1772
2017-12-18 11:09:54 +11:00
Delapouite
b81c6b5840 Use existing window reference in view mode 2017-12-17 14:42:09 +01:00
Maxime Coste
d8dc7d7f39 Go back to getpwuid call to get user name from user id
Unfortunately, reading /etc/passwd is not enough.
2017-12-15 08:19:56 +11:00
Maxime Coste
cafecda230 Window: avoid positionning window on a negative column
Fixes #1741
2017-12-15 08:17:35 +11:00
Maxime Coste
4b06c09c68 Make edit command work fine when running from an empty context
This way, the kind of context we get from a piped command allows
for opening a buffer and working with it directly.
2017-12-12 18:22:05 +11:00
Maxime Coste
ce2c0e54f4 Detect invalid coordinates in selection_from_string
Fixes #1751
2017-12-12 18:08:40 +11:00
Maxime Coste
0033491d69 InsertCompleter: Respected ignored_filename option in filename completer 2017-12-09 22:03:19 +11:00
Maxime Coste
a33d18e125 Go back to getpwuid call on OSX
Reading /etc/passwd on OSX does not give us the full list of users.

Fixes #1758
2017-12-09 12:13:02 +08:00
Maxime Coste
bedb98220c Ranges: add unit test and fix corner case in split view 2017-12-07 01:58:19 +08:00
Maxime Coste
2f48bbf6ff Tweak unescape template function to unescape the escape char as well
Test that more thouroughly in the unit tests.
2017-12-07 01:56:02 +08:00
Maxime Coste
99636c6230 Remove Vector returning split functions, use range adaptor
Do not allocate temporary vectors to store splitted data, use the
'split' range adaptor along with transform(unescape) to provide the
same feature with less allocations.
2017-12-06 17:18:44 +08:00
Maxime Coste
70e2122ae6 InsertCompleter: only accept words matching the target buffer word definition
The words we store in the WordDB are dependent on the extra_word_chars
options, which can be different for different buffers. When completing
words in a buffer based on the WordDB from another buffer, some candidates
might contains characters that are not considered word character for
the target buffer, ignore those words.
2017-12-06 14:15:36 +08:00
Maxime Coste
86fcc55e53 RankedMatch: Make punctuation ordered *before* alphanumeric characters 2017-12-06 13:58:34 +08:00
Maxime Coste
936b95ac34 Ensure that normal mode restores disabled hook status on disabled
Fixes #1744
2017-12-06 12:59:31 +08:00
Maxime Coste
274367116a Replace uses of getpwuid which is incompatible with static linking
Introduce a get_user_name function which parses '/etc/passwd' to find
the username associated with a user id.
2017-12-04 15:19:57 +08:00
Maxime Coste
73a239d3be Text-Objects: Use regex to select surroundings
Fixes #925
2017-12-03 17:15:24 +08:00
Maxime Coste
9a4b5de772 Regex: Introduce backward_regex_search helper function 2017-12-03 17:12:33 +08:00
Maxime Coste
b34bb6b794 Regex: make RegexIterator iterable and able to iter backwards 2017-12-02 14:02:41 +08:00
Maxime Coste
413f880e9e Regex: Support forward and backward matching code in the same CompiledRegex
No need to have two separate regexes to handle forward and backward
matching, just passing RegexCompileFlags::Backward will add support
for backward matching to the regex. For backward only regex, pass
RegexCompileFlags::NoForward as well to disable generation of
forward matching code.
2017-12-01 19:57:02 +08:00
Maxime Coste
7bfb695c45 Regex: Do not allow private use codepoints literals
We use them to encode non-literals in lookarounds, so they can
trigger bugs.

Fixes #1737
2017-12-01 16:37:18 +08:00
Maxime Coste
8d892eeb62 Regex: use StartDesc to early out when not searching
Early out as well if we do not find any potential start position.
2017-12-01 15:03:03 +08:00
Maxime Coste
65b057f261 Regex: rename StartChars to StartDesc
It only contains chars for now, but its still more generally
describing where matches can start.
2017-12-01 14:46:18 +08:00
Maxime Coste
b91f43b031 Regex: optimize parsing a bit 2017-11-30 14:32:29 +08:00
Maxime Coste
c1f0efa3f4 Regex: smarter handling of start chars computation for character class 2017-11-30 14:19:41 +08:00
Maxime Coste
839da764e7 Regex: avoid unneeded allocations and moves by reusing MatchResults storage 2017-11-29 14:07:04 +08:00
Maxime Coste
380ff553b5 Wrap: try to rework and simplify the algorithms further
Fixes #1731
2017-11-28 19:04:21 +08:00
Maxime Coste
ae0911b533 Regex: Various small code tweaks 2017-11-28 01:03:54 +08:00
Maxime Coste
4598832ed5 Regex: optimize compilation by reserving data 2017-11-28 00:59:57 +08:00
Maxime Coste
a52da6fe34 Regex: Tweak is_ctype implementation style 2017-11-28 00:13:42 +08:00
Maxime Coste
d142db80f2 Fix compute_modified_ranges corner case that would crash on undo
Fixes #1506
Fixes #1215
2017-11-27 20:29:01 +08:00
Maxime Coste
8b40f57145 Regex: Replace generic 'Matchers' with specialized functionality
Introduce CharacterClass and CharacterType Regex Op, and optimize
their evaluation.
2017-11-25 18:14:15 +08:00
Maxime Coste
0d44cf9591 Regex: do not decode utf8 in accept calls as they always run on ascii 2017-11-25 18:13:27 +08:00
Maxime Coste
ec6ecd5772 Add an InsertCompletionSelect hook
InsertCompletionSelect will be called whenever the selected insert
completion changes. If the original text is selected back, the hook
parameter will be empty. If another candidate is selected, the hook
parameter will be its text content.

Fixes #1676
2017-11-25 13:57:47 +08:00
Maxime Coste
1ae96c977c Small formating tweak 2017-11-25 13:46:55 +08:00
Maxime Coste
318e77b25e Highlighters: Introduce unique highlighter support
Some highlighters, such as wrap or line numbers, are not intended
to be used multiple times on the same display. Add support for unique
ids that are used by highlighters to disable themselves if another
unique highlighter with the same id is supposed to override them.

The usual highlighter "precedence" takes, place, that it, that most
nested highlighter will the the one to run (window in priority to
buffer in priority to global).
2017-11-25 12:53:33 +08:00
Delapouite
66250a06eb Rename KeyMapInfo → KeymapInfo 2017-11-24 10:34:56 +01:00
Maxime Coste
6084490a6e Merge remote-tracking branch 'Delapouite/remaining-buffers' 2017-11-24 16:37:53 +08:00
Maxime Coste
5a0332ac87 Window: fix buffer_coord when a line buffer range is empty
Fixes #1711
2017-11-24 16:36:37 +08:00
Maxime Coste
c0cec3e7c1 Merge remote-tracking branch 'fsub/warnings' 2017-11-23 12:30:24 +08:00
fsub
66ca53466f Remove unused lambda captures
This eliminates some warnings emitted by clang++.
2017-11-22 18:43:54 +01:00
Maxime Coste
179a1f6aa1 dynregex: slight code refactor, moving a helper function to lambda 2017-11-22 15:57:59 +08:00
Maxime Coste
77b367b3e0 Wrap: simplify logic a bit and fix case where too many lines got displayed
Fixes #1710
2017-11-21 13:01:02 +08:00
Delapouite
be94505e46 Add modified buffers count in error message of non-force quit 2017-11-20 19:25:47 +01:00
Maxime Coste
b57a53dfbf Merge remote-tracking branch 'Delapouite/common_prefix' 2017-11-20 17:30:28 +08:00
Delapouite
62912c6586 Remove extraneous common_prefix in input_handler
Related to: 52525a156f
2017-11-20 10:21:23 +01:00
Delapouite
bf222a0628 Docs: add missing -i <suffix> command line flag 2017-11-19 11:43:08 +01:00
Kylie McClain
3e1a4df3fb Makefile: Add ability to disable compressing manpage
Some distributions don't compress them.
2017-11-19 01:53:40 -05:00
Kylie McClain
ab390a02dc Makefile: use PKG_CONFIG, not pkg-config 2017-11-17 23:11:06 -05:00
Maxime Coste
706c1672d5 Normal: add <a-S> to select first and last char of selection
Fixes #550
2017-11-13 17:36:04 +08:00
Maxime Coste
5f5188a89c Merge remote-tracking branch 'Delapouite/jump-count' 2017-11-13 16:37:24 +08:00
Delapouite
a071e5b226 Add count support to jumps (<c-o> and <c-i>). Add jumps tests 2017-11-13 08:38:43 +01:00
Maxime Coste
615fe0368c Options: rework conversion to string of prefixed lists
* use the list_separator variable instead of hard coding ':'
* fix trailing separator when converting empty prefixed list to string
* correctly escape the prefix in case it contains a separator
2017-11-13 11:45:28 +08:00
Maxime Coste
078f0b5c90 option_types.hh: fix unfulfilled dependencies of the header 2017-11-13 11:27:55 +08:00
Maxime Coste
ffb639bf96 Regex: add unit test for #1693 2017-11-13 01:12:05 +08:00
fsub
0dd8a9ba93 Fix #1693: typo in RegexParser::character_class() 2017-11-12 17:35:03 +01:00
Maxime Coste
b298e01390 NCurses: use the general face merging function to handle default face
Merge attributes as well, and reuse an existing function instead of
reimplementing the same logic again.

Closes #1684
2017-11-12 23:02:40 +08:00
Maxime Coste
208f9641ef Remote: when converting to client, suspend *after* connecting
Also, do not quit server while there is a connection being accepted
Fixes #1690
2017-11-12 22:28:13 +08:00
Maxime Coste
00e0630272 Move Array and ConstexprVector to a constexpr_utils.hh header 2017-11-12 13:01:18 +08:00
Maxime Coste
5cfccad39c Regex: Use MemoryDomain::Regex for captures and MatchResults contents 2017-11-12 12:30:21 +08:00
Maxime Coste
c9b43d3634 Regex: directly store instruction pointer in Thread struct 2017-11-11 15:15:13 +08:00
Maxime Coste
b1115f7469 Wrap: fix scrolling to keep cursor visible logic 2017-11-10 21:17:05 +08:00
Maxime Coste
0942cd5084 InputHandler: handle of last insert keys happening in nested modes
Move recording of keys to the input handler itself instead of the
Insert mode so that eventual nested modes (potentially introduced
by <a-;> will get their keys recorded as well).

Fixes #1680
2017-11-08 14:39:52 +08:00
Maxime Coste
04993de687 Fix pipe logic in the case where the selections were accessed in the cmdline
When using an env var that needed the selections in the pipe command line,
say $kak_selection, the selection update code would run, modifying the
selections to adapt to eventual changes. But the rest of the pipe logic
was assuming the selections would not change, leading to bugs.
2017-11-08 00:02:49 +08:00
Maxime Coste
d45f16b6c8 Buffer: change clamp logic to preserve ordering
clamp could change ordering between a coordinate past the end.

Say in a buffer with 1 line of 2 char:
{0, 1} was clamped to {0, 1}
{1, 0} was clamped to {0, 0}

That was reversing their ordering, and might be the root cause
of the bug lurking in undo range computation.
2017-11-07 23:56:24 +08:00
Maxime Coste
80ce768994 Slight code cleanup in change update functions 2017-11-07 20:00:45 +08:00
Maxime Coste
2b6c84fc40 Add missing include in remote.cc
strerror is defined in <string.h>
2017-11-06 12:45:14 +08:00
Maxime Coste
0a081b9f31 Do not allow rename-session to introduce '/' in session names 2017-11-06 11:55:56 +08:00
Maxime Coste
52f4af6a83 Merge remote-tracking branch 'lenormf/fix-private-commands-in-register' 2017-11-05 12:22:28 +08:00
Maxime Coste
6bac767124 CommandManager: tweak naming 2017-11-04 16:02:21 +08:00
Maxime Coste
7f51e51fcb Introduce matching_pairs option that controls the pairs used by m 2017-11-04 15:53:53 +08:00
Frank LENORMAND
8900690288 src: Don't save whitespace-led commands in the : register 2017-11-04 09:18:26 +03:00
Maxime Coste
aa82a90c39 Remote: stricter validation of the session names
Creating a session will not accept any slashes in the session path,
connecting to an existing session will accept at most one slash to
allow for specifying the session of a different user.

Fixes #1635
2017-11-04 12:01:25 +08:00
Maxime Coste
aa9bcf08fc Code style tweak 2017-11-04 12:01:23 +08:00
Maxime Coste
9b216e0e79 Merge remote-tracking branch 'lenormf/fix-rc-aliases' 2017-11-03 19:32:30 +08:00
Maxime Coste
400ef6d48c Wrap: rework logic to avoid infinite loop with multiple wrap highlighters
The display is still going to be wrong, as wrapping is going to take place
multiple times, but Kakoune should not freeze anymore.
2017-11-03 19:30:31 +08:00
Maxime Coste
9d6420caae Remove uneeded forward declaration 2017-11-03 19:24:58 +08:00
Frank LENORMAND
9127ed0d55 src rc: Rename exec/eval into execute-keys/evaluate-commands 2017-11-03 11:09:45 +03:00
Maxime Coste
39e63cf518 Append '/' to highlighter group completion candidates 2017-11-02 18:05:18 +08:00
Maxime Coste
730e5725e9 Wrap: change indent atom to be a replaced empty buffer range
Avoid confusing the column highlighters.
2017-11-02 11:08:03 +08:00
Maxime Coste
fd95af0e3e Add informations on -indent in wrap highlighter docstring 2017-11-02 11:04:15 +08:00
Maxime Coste
4fabba3d12 doc.kak: Render documentation internally instead of relying on man
doc.kak now behaves as a basic asciidoc renderer. Asciidoc is unfortunately
still a dependency to generate the manpage of the `kak` command.
2017-11-02 10:03:24 +08:00
Maxime Coste
53069bcb2d Ensure line-specs and range-specs options are sorted internally 2017-11-02 09:51:15 +08:00
Maxime Coste
329f5fca0e Fix trailing spaces in highlighters.cc 2017-11-02 01:28:28 +08:00
Maxime Coste
6f2088cbc4 Wrap: Add -indent switch support that wraps preserving line indent 2017-11-02 01:28:28 +08:00
Maxime Coste
ed65d86c72 Rename doc/manpages to doc/pages
That fact we use man for these is an implementation detail.
2017-11-01 19:05:37 +08:00
Maxime Coste
25dac6b24e Document the regex impl switch in the startup message 2017-11-01 14:18:13 +08:00
Maxime Coste
51de90f366 Regex: Remove boost related code 2017-11-01 14:09:39 +08:00
Maxime Coste
c74becc6af Regex: fix RegexCompileFlags not being an enum class 2017-11-01 14:05:15 +08:00
Maxime Coste
2d901dc76f Regex: slight readability improvement and workaround a potential gcc bug 2017-11-01 14:05:15 +08:00
Maxime Coste
f07375fb27 Regex: remove dead code 2017-11-01 14:05:15 +08:00
Maxime Coste
2c2073b417 Regex: Tweak struct layouts of ParsedRegex data 2017-11-01 14:05:15 +08:00
Maxime Coste
bbd7e604dc Regex: Remove "Ast" from names in the ParsedRegex
It does not add much value, and makes names longer.
2017-11-01 14:05:15 +08:00
Maxime Coste
18a02ccacd Regex: Optimize parsing and compilation
AstNodes are now POD, stored in a single vector, accessed through
their index. The children list is implicit, with nodes storing only
the node index at which their child graph ends.

That makes reverse iteration slower, but that is only used for reverse
matching regex, which are uncommon. In the general case compilation
is now faster.
2017-11-01 14:05:15 +08:00
Maxime Coste
aea2de885d Regex: minor cleanup of the regex parsing code 2017-11-01 14:05:15 +08:00
Maxime Coste
6e0275e550 Regex: small code cleanup in the Save compilation code 2017-11-01 14:05:15 +08:00
Maxime Coste
9e15207d2a Regex: put the other char boolean inside the general start char map 2017-11-01 14:05:15 +08:00
Maxime Coste
7c3bc48627 Fix ConstexprVector::resize 2017-11-01 14:05:15 +08:00
Maxime Coste
60e32d73ff Regex: Fix handling of all unicode codepoint as start chars 2017-11-01 14:05:15 +08:00