Commit Graph

5274 Commits

Author SHA1 Message Date
Maxime Coste
cbba348a83 always inline custom operator new/delete to avoid spurious warnings
GCC 11 warns incorrectly about mismatched new/delete because it auto
inlines one but not the other, force inline those function to fix that.
2021-07-26 16:55:36 +10:00
Maxime Coste
15aa4fe137 Document the new write behaviour 2021-07-20 22:45:33 +10:00
Maxime Coste
7f41a277a0 Merge remote-tracking branch 'occivink/nop-ignore-unknown-switches' 2021-07-20 22:37:09 +10:00
Maxime Coste
40e3614cf4 Prevent overwriting existing file in :write <explicit filename>
Add a -force (equivalent to w!) switch that enables overwriting.
2021-07-20 22:30:41 +10:00
Maxime Coste
4d99434ddd Remove unnecessary forward declaration 2021-07-20 22:30:41 +10:00
Maxime Coste
3c1199f665 Add missing new/delete overload in UseMemoryDomain 2021-07-20 22:30:41 +10:00
Maxime Coste
63b67d0f31 Remove some unnecessary string copies in TerminalUI 2021-07-20 22:30:41 +10:00
Maxime Coste
e3957bb24c Generate different parse_quoted_balanced for each quote pair
This seems to slightly improve parse speed which is where kakoune
spends most of its time during startup.
2021-07-20 22:30:41 +10:00
Maxime Coste
a4dd89f214 Improve code-generation for Strings
Make String::Data use trivial copy of the short/long union to avoid
unnecessary branching there, inline release() as it can be elided by
the compiler on moved-from Strings.
2021-07-20 22:30:41 +10:00
Olivier Perret
55f9a69465 nop: ignore unknown switches instead of failing 2021-07-19 11:47:07 +02:00
Maxime Coste
c643cd4467 Fix blitting of windows halfway through double-width codepoint
Display a whitespace in place of the uncovered half of the codepoint.

(I know this is incorrect and we should be considering grapheme clusters
instead of codepoints, but this is a far bigger refactoring and another
can of worms to handle with terminal emulators).

Fixes #4262
2021-07-14 20:51:25 +10:00
Maxime Coste
ac6420ee8d Refactor TerminalUI::set_ui_options
Take advantage of Optional monadic operations
2021-07-12 10:25:59 +10:00
Maxime Coste
428ddeb97b Add 'terminal_synchronized' ui_option to opt-in synchronized output
Synchronized output does not work well with various terminals
(including the linux console). It should also be unnecessary when
not going through a slow link.

This will eventually be removed if it is not proven to be useful
to some users.
2021-07-12 10:25:59 +10:00
Jason Felice
5d497dc46e src: Support strikethrough faces 2021-07-12 10:25:59 +10:00
Maxime Coste
cbd0dc571b Fix crash when displaying a menu on a too small terminal
The code could position the menu at a negative line leading to
invalid array accesses.
2021-07-12 10:25:59 +10:00
Maxime Coste
76e5d11c8b Small cleanups in terminal ui 2021-07-12 10:25:59 +10:00
Maxime Coste
44deaeb4eb Do not trust saved active face when force redrawing 2021-07-12 10:25:59 +10:00
Maxime Coste
7bbc057cd7 Slight code simplification 2021-07-12 10:25:58 +10:00
Maxime Coste
b3025b87d0 Fix race on resize in terminal ui 2021-07-12 10:25:58 +10:00
Maxime Coste
86025f88c4 Fix force redraw handling
Fixes #3559
2021-07-12 10:25:58 +10:00
Maxime Coste
cd613da050 Tolerate bliting window that overflow the target
Although we try to avoid those, ensuring it never happens is tricky,
and tolerating them avoids the crash.

Fixes #3498
2021-07-12 10:25:58 +10:00
Kylie McClain
89e0b4b830 terminal_ui.cc: fix build on musl libc 2021-07-12 10:25:58 +10:00
Tim Allen
de065dad2d terminal_ui: restore termios settings before suspending Kakoune.
TerminalUI::suspend() is responsible for undoing all Kakoune's modifications to
the terminal state, actually suspending the process, then re-applying all the
modifications after Kakoune wakes back up.

Previously, the "undo" and "reapply" steps for termios settings were both after
the suspend point, so on some platforms they were incorrect when the user
arrived back at the shell prompt.

Now, the termios "undo" step is back before the suspend point, and the undo and
reapply steps should be in exactly reversed order.

Fixes #3488.
2021-07-12 10:25:58 +10:00
Tim Allen
e760f2df6b Use iTerm2 "synchronised update" sequences around redraws.
In terminals that support it, this sequence causes the terminal to not redraw
*its* output until the application has finished, reducing redraw flickering.

The sequence is defined in:

    https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec

...and is apparently also supported by kitty and libVTE.

Fixes #3482.
2021-07-12 10:25:58 +10:00
Maxime Coste
72271ce529 Handle skipped characters with erase line (EL) instead of insert blank (ICH)
insert blank seems to behave differently between terminals and would
be less efficient because it still has to shift all following characters
(that we will overwrite anyway).

Fixes #3437
2021-07-12 10:25:58 +10:00
Maxime Coste
b0dcb07540 Reduce amount of SGR escapes emitted by tracking the active face 2021-07-12 10:25:58 +10:00
Maxime Coste
63310370f8 Remove explicit whitespace padding in menu/info
Rely on the backend to clear content to eol
2021-07-12 10:25:58 +10:00
Maxime Coste
484cfae9d1 Use CSI @ instead of emitting lots of spaces
This greatly reduces the amount of data written for a redraw especially
on big terminals where most of the data is trailing blanks
2021-07-12 10:25:58 +10:00
Maxime Coste
8e1b79b1b7 Remove the concept of cursor in TerminalUI::Window 2021-07-12 10:25:58 +10:00
Maxime Coste
65fbabcb86 Fix another display corruption issue in the terminal output code 2021-07-12 10:25:58 +10:00
Maxime Coste
5c3b0b7503 Fix another terminal update issue in the latest code change
Fixes #3426
2021-07-12 10:25:58 +10:00
Maxime Coste
e6801867c7 Fix bug in terminal output line delete logic 2021-07-12 10:25:58 +10:00
Maxime Coste
5a31b9f351 Fix tab character that got introduced by mistake 2021-07-12 10:25:58 +10:00
Maxime Coste
68f0bcce7c Reduce the number of added/removed lines when redrawing screen
This should reduce flickering.
2021-07-12 10:25:58 +10:00
Maxime Coste
0506de8443 Fix compute_pos behaviour not to overflow by one line
Thanks to eraserhd for debugging this and proposing an initial fix.

Fixes #3414
Close #3418
2021-07-12 10:25:58 +10:00
Maxime Coste
5466f63eeb Use insert/remove lines escapes to reduce terminal traffic
Diff against known state and insert/erase relevant lines.

Erase everything first to avoid insertion invalidating lines that
get out of the terminal at bottom.
2021-07-12 10:25:58 +10:00
Maxime Coste
9e8f555a82 Only redraw updated lines 2021-07-12 10:25:58 +10:00
Maxime Coste
07750656a8 Blit all window together before outputing them to the tty
This should reduce flicker, by avoiding transient states where
info/menu windows are not displayed, and paves the way for proper
diffing of the screen.
2021-07-12 10:25:58 +10:00
Maxime Coste
03563d51aa Fix crash on resize in TerminalUI 2021-07-12 10:25:58 +10:00
Maxime Coste
7e66846172 Rename NCursesUI to TerminalUI 2021-07-12 10:25:58 +10:00
Maxime Coste
3b4d2b63c6 Remove references to ncurses in Makefile 2021-07-12 10:25:58 +10:00
Maxime Coste
c12699d2e9 Replace ncurses with a naive custom terminal backend 2021-07-12 10:25:58 +10:00
Maxime Coste
7622ebcc92 Quit server on SIGINT when it was not signaled by Kakoune itself
Fixes #3974
2021-07-12 10:08:17 +10:00
Maxime Coste
c30a0e0ca2 Inline String::Data no-copy constructor 2021-07-09 17:03:22 +10:00
Maxime Coste
2289f350df Remove command parsing Reader and just track a ParserState
The Reader abstraction was leading to suboptimal code by encouraging
decoding utf8 separately from advancing to next codepoint.
2021-07-09 17:03:22 +10:00
Maxime Coste
86c5e8f75b Avoid temporary vector in expand_token
Instead of return a vector, take the target vector as a parameter
and push tokens to it.
2021-07-09 17:03:22 +10:00
Maxime Coste
cd67f2cf11 Avoid copying token content strings in expand_token
We can move that data instead of copying
2021-07-09 17:03:22 +10:00
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