Commit Graph

145 Commits

Author SHA1 Message Date
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
2fa553e728 Remove implicit conversion from String to DisplayAtom/DisplayLine 2018-04-29 20:45:53 +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
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
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
f7f84b7402 NCursesUI: Rework menu_show to shrink menu height when needed
Closes #1886
2018-03-20 05:54:19 +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
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
13ac0e367d NCursesUI: Rework menu placement to fix missing menu on small window 2018-02-22 22:04:04 +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
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
Net
74202fab45 Rename br* colors to bright-* 2017-10-24 23:08:22 -04:00
Net
2b44e93f79 Support bright named colors 2017-10-22 14:30:49 -04:00
Maxime Coste
6ada6e6d77 Move all non-core string code to string_utils.{hh,cc} 2017-10-10 10:52:32 +08:00
Maxime Coste
ab6a999431 Rename containers.hh to ranges.hh (and Container to Range) 2017-08-29 15:23:03 +07:00
Maxime Coste
0dec1e3a91 Remove unused only_buffer mode for DisplayLine::trim 2017-06-09 15:30:13 +01:00
Maxime Coste
b030088d60 Re-hide hardware cursor, seems its causing troubles with various terminal emulator 2017-05-29 10:02:18 +01:00
Maxime Coste
76d3425bf9 Change ncurses_ui info box generation logic to use a Vector<String>
We were generating a string, then splitting it into lines, there is
no need for that, we can directly generate a vector of lines and
simplify the code.
2017-05-28 19:58:18 +01:00
Maxime Coste
72acb0177d Parse meta as 8 bit in Normal mode to fix the terminals using that
The solution is a bit hackish, as we only consider the 8th bit to
mean alt in normal mode, because its unlikely accentuated characters
are going to be mapped there. It fixes using Alt on xterm, and
probably on iterm2 as well (not requiring the meta-sends-esc config
change anymore)
2017-05-27 06:18:39 +01:00
Maxime Coste
2307cf500c Small formatting tweak 2017-05-26 08:38:12 +01:00
Maxime Coste
119a5b8442 Fix hardware cursor positioning in prompt when status bar is on bottom 2017-05-24 15:20:23 +01:00
Maxime Coste
91ed57c985 Make hardware cursor visible in ncurses ui 2017-05-18 06:28:08 +01:00
Maxime Coste
8fa7e67abc Use LineCount instead of int for ncurses assistant margin 2017-05-10 11:35:12 +01:00
Maxime Coste
a0752d8d46 Merge remote-tracking branch 'lenormf/fix-assistant-align' 2017-05-10 11:31:26 +01:00
Maxime Coste
34bf8c23e1 Fix uninitialised value for cursor mode 2017-04-19 21:23:16 +01:00
Maxime Coste
91bfd714e4 Place hardware terminal cursor at the current main cursor/prompt cursor position
Fixes #1318
Also fixes https://gitlab.com/gnachman/iterm2/issues/5408
2017-04-12 10:39:17 +01:00
Maxime Coste
94145f2a89 ncurses: When hiding the menu, recompute the info position 2017-04-04 08:36:21 +01:00
Frank LENORMAND
2aa5d3b016 src: Align the assistant in the middle of the popup 2017-03-14 19:06:09 +03:00
Maxime Coste
564da076a6 Merge remote-tracking branch 'lenormf/assistant-dilbert' 2017-03-10 12:06:35 +00:00
Frank LENORMAND
59b65bb9fb ncurses: Add a Dilbert assistant
Drawn by myself.
2017-03-08 20:03:29 +03:00
Maxime Coste
6373338c50 Replace uses of UnorderedMap with HashMap 2017-03-07 01:03:26 +00:00
Maxime Coste
4f18e56320 Fix non-returning parse_key lambda 2017-02-13 14:02:09 +00:00
Maxime Coste
34870eb353 Rework NCurses key parsing to properly handle <a-special key> 2017-01-30 13:38:56 +00:00
Maxime Coste
37fbe6c6eb Treat <c-h> as backspace in ncurses ui
Fixes #1030
2017-01-10 13:35:10 +00:00
Maxime Coste
dcd8f6ef01 Apply clang-tidy modernize to the codebase 2017-01-08 22:39:01 +00:00
Maxime Coste
b3674a2f03 Add Modal InfoStyle used for bufer reload info box
Modal info style wont be replaced by other info boxes.
NCursesUI will center that info box.

Fixes #1060
2017-01-04 11:39:51 +00:00
Maxime Coste
76c58aa022 Dont use constexpr to fix OSX compilation 2016-12-30 13:29:57 +00:00
Maxime Coste
190a04d6c8 Add a ncurses_change_colors option that can disable color palette change
Closes #1057
2016-12-30 07:01:13 +00:00
Maxime Coste
7defdd3039 Make FDWatcher support Read, Write and Except events, instead of just Read 2016-12-01 19:44:07 +00:00
Maxime Coste
3a81260917 Simplify greatly UI input handling
This round trip through an input callback expected to call
is_key_available and get_key was overcomplicated, just send the
keys as they arrive, the client is already buffering due to urgent
event mode.
2016-11-29 21:59:36 +00:00
Maxime Coste
d15cc02c01 Remove some unneeded headers from ncurses_ui.cc 2016-11-22 09:49:55 +00:00
Maxime Coste
c2989704d5 More correct handling of SIGHUP while suspended
Fixes #833
2016-11-14 00:49:34 +00:00
Maxime Coste
6889494869 Emit an OSC 104 on quit to reset color palette on supporting terminals
xterm and vte based terminals support it, unfortunately rxvt-unicode
does not yet.

Fixes #914
2016-11-05 11:43:25 +00:00
Maxime Coste
e8dcdb6072 Support Ctrl + mouse dragging to add a new selection
Fixes #838
2016-10-13 22:59:02 +01:00
Maxime Coste
f81b8c137b Replace non ascii chars with ? in xterm title, and limit to 511 chars
Closes #839
2016-10-04 20:13:15 +01:00
Maxime Coste
35559b65dd Support codepoints of variable width
Add a ColumnCount type and use it in place of CharCount whenever
more appropriate, take column size of codepoints into account for
vertical movements and docstring wrapping.

Fixes #811
2016-10-01 13:45:00 +01:00
Maxime Coste
439f168928 Use named keys for Return and Tab instead of <c-m> and <c-i>
Fixes #722
2016-07-05 20:08:13 +01:00