Commit Graph

5282 Commits

Author SHA1 Message Date
Maxime Coste
24c23af341 Remove unnecessary fflush call 2021-08-05 10:57:35 +10:00
Maxime Coste
7b126704c7 Fallback to 80x24 terminal size when ioctl fails or returns 0x0
Fixes #4286
2021-08-04 20:51:50 +10:00
Maxime Coste
1b7616b3fc Use a BufferedWriter to output in the terminal ui instead of stdio
Clearer control of buffering and flushing
2021-08-01 20:07:20 +10:00
Maxime Coste
1728274803 Add a format_with format function that takes a FunctionRef append 2021-07-31 09:45:05 +10:00
Maxime Coste
a566a22cbc Expose BufferedWriter 2021-07-31 09:44:24 +10:00
Maxime Coste
914f4f8c19 Fix FunctionRef copy construction
The template constructor was mistaken as a copy constructor.
2021-07-31 09:43:49 +10:00
Maxime Coste
b57dc7c512 Code style tweak for Regex implementation TestVM 2021-07-31 08:55:52 +10:00
Maxime Coste
cf52379422 Do not run unit tests in release builds
They mostly rely on assertions that are disabled in those builds
anyway.
2021-07-26 16:57:07 +10:00
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