Commit Graph

5227 Commits

Author SHA1 Message Date
Maxime Coste
64e306f64b Document command-fifo in changelog 2021-07-07 19:46:47 +10:00
Maxime Coste
5ed9e1b356 Catch errors while executing shell commands
Log error to debug buffer and Change the 'waiting for shell' face
to 'Error'.

Update the 'waiting for shell' message when the shell has exited
but Kakoune is still waiting on stdin/stdout/stderr to be closed.
2021-07-07 19:25:06 +10:00
Maxime Coste
3d7fb8ddbc Add support for $kak_command_fifo and $kak_response_fifo
Those fifos are accessible during %sh{...} blocks, the command fifo
executes commands written to it once the write end side is closed
(multiple open/write/close sequences are supported), the response
fifo is a simple helper fifo available to write response back to
the shell process

An example use of this feature is to request some list options
content from without being limited by the environment size:
```
%sh{
    echo "echo -to-file $kak_response_fifo -quoting shell -- %opt{some_list}" > $kak_command_fifo
    eval "set -- $(cat $kak_response_fifo)"
}
```
2021-07-07 19:25:06 +10:00
Maxime Coste
6215bff764 Decouple generate_env from actual ShellManager env var collection 2021-07-07 19:25:06 +10:00
Maxime Coste
0c92ec8a23 Merge remote-tracking branch 'Screwtapello/save-restore-window-title' 2021-07-07 19:16:07 +10:00
Dmitry Matveyev
dbfbb1b5a6 Restore terminal during suspend before changing alternate screen 2021-06-27 16:49:39 +06:00
Maxime Coste
c68f85659f Handle Ctrl+Z key later in the terminal input stack
The previous handling code was at a pretty random location and broke
terminals that could send <c-z> encoded in a non pure ascii way.

See #4238
2021-06-27 16:56:29 +10:00
Maxime Coste
f0f3c0f735 Merge remote-tracking branch 'SolitudeSF/mode' 2021-06-26 09:59:45 +10:00
Sidharth Kshatriya
c5a1ddeaff Better style 2021-06-24 19:53:38 +05:30
Sidharth Kshatriya
5244ecbe9b Also deal with variables named kak_quoted_* by using a more generic approach 2021-06-24 19:49:54 +05:30
Sidharth Kshatriya
0ca81e7cec Fix: Kakoune passed environment variables in shell invocations are repeated
If a %sh{} script refers to any variables multiple times they are all multiply
included in the environment. Example: if a %sh{} invocation refers to
${kak_buffile} 5 times, the environment will have "kak_buffile=..." repeated 5
times and so on. This repetition happens for each multiply used variable that
is passed into the environment.

The variable should, of course, be only passed into the environment once. This
commit should fix this issue.
2021-06-24 14:03:58 +05:30
Maxime Coste
be9b2de0ee Only compute command coordinates when necessary
Tracking the line/column of each token takes a surprising big part
of the command parsing logic runtime and is only necessary when we
hit an error.
2021-06-24 17:20:37 +10:00
Maxime Coste
49e2ecdcdb Fix invalid command profiling logic 2021-06-24 17:14:10 +10:00
SolitudeSF
9fff572aab
Restore terminal before switching from alternate screen 2021-06-18 08:22:59 +03:00
Tim Allen
7c48a72e11 src: Restore the window title when quitting or suspending Kakoune.
Fixes #4228.
2021-06-15 12:04:21 +10:00
Maxime Coste
95b0627e54 Fix focus_in/focus_out keys not having user friendly names 2021-05-28 20:32:12 +10:00
Maxime Coste
049b9a28d1 Fix File Buffer flag not being correctly applied 2021-05-28 20:31:28 +10:00
Maxime Coste
fb9dbfed2a Canonicalize <s-ascii> into uppercase in csi key parsing code
Fixes #4159
2021-05-28 20:15:56 +10:00
Maxime Coste
e4a23a64fa Support opening files bigger than 2 GiB
The real technical limit is with lines bigger than 2 GiB and buffers
with more than 2 Gi lines, refactor buffer loading to make it possible
to load those files.

Fix an overflow with the hash_data function at the same time
2021-05-28 17:03:41 +10:00
Maxime Coste
0cecea6593 Fix completion past explicitely closed tokens
This fixes an issue where completion would still be provided after
the closing character of a token, which could then get frustrating
combined with auto-insertion of completions.

For example, inserting `%{<newline>}` for a command-completed token
(such as the commands for a hook) would still trigger completion right
after the `}` and that completion would get auto-inserted **replacing**
that closing `}`.
2021-05-18 20:50:56 +10:00
Maxime Coste
47c0d20388 Request xterm 'modifyOtherKeys' mode to opt-in CSI u key reporting
Various terminal emulators now support this `CSI > 4 ; 1 m` sequence
to enable CSI u style reporting, opt into it on startup.

Closes #4103
2021-05-02 17:06:43 +10:00
Maxime Coste
db9ef82398 Rework session directory logic
Do not use a shared kakoune/ directory for all users to avoid the
complexity of having to set the sticky bit on that dir, resolve the
session directoy only once by using a static variable and an
immediately evaluated lambda.

This fixes an annoyance whenver using `su` and having Kakoune refuse
to start due to XDG_RUNTIME_DIR still being set.
2021-05-01 15:29:50 +10:00
Maxime Coste
2288be3257 Merge remote-tracking branch 'markus-oberhumer/ux-improve-prompt' 2021-05-01 14:37:54 +10:00
Markus F.X.J. Oberhumer
e57fe4fb90 Improve prompt handling
As a long time vi user I find it highly irritating that
you cannot backspace out of the command prompt.
2021-04-30 19:42:08 +02:00
Tim Allen
f78adeda49 src: Fix mouse modifier support in the ncurses UI.
For historical reasons, mouse events represent keyboard modifiers as a bitfield,
but keyboard events represent modifiers as a bitfield-plus-one. For example, a
mouse event with an Alt modifier will use the value 4, but a keyboard event will
use the value 5.

Previously, I refactored the parse_mask() helper to do the subtraction itself,
instead of requiring the caller to do it. This made keyboard-event decoding much
cleaner, but I didn't realise it broke mouse-event decoding. Now the subtraction
is done only for keyboard events.

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

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

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

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

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

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

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

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

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

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

Note that even though the terminal distinguishes between keypad and regular keys,
Kakoune maps keypad keys onto regular keys - keypad Enter is still <ret>, it
just supports more modifiers than the regular Enter key.
2021-03-26 15:43:42 +11:00
Tim Allen
f7c1702965 src/ncurses_ui: move the parse_mask() helper outside parse_csi().
It's useful for parsing modifier masks in all kinds of sequences, not just CSI
sequences. Also, since the modifier mask always has "1" as "no modifiers",
do the subtraction inside parse_mask() instead of when calling it.
2021-03-26 15:17:41 +11:00
hss
49f5917125 Rename separator-cursor to cursor-separator 2021-03-22 19:38:33 -04:00
hss
3e539c963e Don't use optionals for storing active separator string 2021-03-21 19:52:19 -04:00
hss
07e2b03c11 Only use separator-cursor for the first line number in a wrapped line 2021-03-20 21:53:31 -04:00