Commit Graph

4877 Commits

Author SHA1 Message Date
Maxime Coste
9c2d2ad694 Do not set O_NONBLOCK on stdin
It is not necessary, and impacts also writing to stdout, leading
to broken display on old ncurses versions.

Fixes #3087
2019-09-25 20:33:01 +10:00
Maxime Coste
de3ff78b22 Restore stdin status flags on suspend and quit
Those flags are shared with the parent process, so the non-block
flag added impacts their execution.
2019-09-24 23:28:11 +10:00
Maxime Coste
f066014d33 Merge remote-tracking branch 'laelath/suppress-init-list-lifetime-warning' 2019-09-22 22:41:25 +10:00
Maxime Coste
df6d0355d6 Add support for parsing SS3 key sequences
As discussed on #3087, fixes part of that issue.
2019-09-22 09:16:47 +10:00
Justin Frank
8094ded9b5 Added -Wno-init-list-lifetime to CXXFLAGS 2019-09-17 13:38:17 -07:00
Maxime Coste
8cca77c949 Accept docstrings with last line not fully indented
When trimming indent, the last line, if only containing
whitespaces does not need to match the indent, so that
this indentation style works:

    -docstring %{
        indented string
    }
2019-09-17 21:48:00 +10:00
Maxime Coste
c787128a7c Restore palette before suspend 2019-09-16 21:57:53 +10:00
Maxime Coste
bfc07b53a2 Correctly restore terminal state on suspend 2019-09-16 07:38:24 +10:00
Maxime Coste
afd5006e8b Small style tweak 2019-09-16 07:38:24 +10:00
Maxime Coste
9235238191 Fix input coming in packets characters being dropped 2019-09-16 07:38:24 +10:00
Maxime Coste
006083c6f8 Fix multi-client server suspend 2019-09-16 07:38:24 +10:00
Maxime Coste
f43ac3d78b Fix broken input after suspend 2019-09-16 07:38:24 +10:00
Maxime Coste
e52b93b31a Setup terminal raw mode without going through ncurses 2019-09-16 07:38:24 +10:00
Maxime Coste
f2f99580f8 Get rid of ncurses based input parsing in favor of custom code 2019-09-16 07:38:24 +10:00
Maxime Coste
fc3a1b6973 Make arrow keys normal mode mappings instead of commands 2019-09-15 19:40:38 +10:00
Maxime Coste
858ae14f76 Allow scrolling while dragging mouse
Closes #2052
2019-09-15 10:27:00 +10:00
Maxime Coste
46581f1c65 Fix printing of F12 key 2019-09-08 22:54:41 +10:00
Jean-Louis Fuchs
9d897a6092 Rank a word-boundary after a non-word-boundary 2019-09-07 22:53:29 +02:00
Maxime Coste
a440869573 Fix modifiers support with mouse events 2019-09-07 22:49:30 +10:00
Maxime Coste
04b5d44b3c Rework custom CSI parsing code and add support for SGR (1006) mouse
This will support parsing mouse coordinates bigger than 255 - 32.
And get correct release support.
2019-09-07 22:29:05 +10:00
Maxime Coste
4cc187a54f Remove unneeded uses of NCurses WINDOW*
intrflush and meta have a WINDOW* parameter that is documented as
always ignored.
2019-09-05 00:25:27 +10:00
Maxime Coste
afd45c6755 Extract most ncurses calls into NCursesUI::Window methods
Try to isolate ncurses as much as possible to explore alternate
terminal UI implementation.
2019-09-05 00:25:27 +10:00
Maxime Coste
4c4eb61c18 Introduce FunctionRef to replace std::function when not storing
std::function is not necessary when we just want to pass a type
erased callback that does not need to own its target. FunctionRef
provides that functionality for a much lower compile time cost.
2019-09-01 13:04:47 +10:00
Maxime Coste
b24be99fa3 Limit the amounts of calls to get_extra_word_chars
This is a relatively expensive function as it needs to resolve
an option, which uses dynamic_cast.
2019-08-31 13:14:46 +10:00
Maxime Coste
eeec8ade51 Merge remote-tracking branch 'eraserhd/pr/master/fix-kak-list-sessions' 2019-08-28 21:27:30 +10:00
Frank LENORMAND
cb2647878b src: Send the stop signal to the entire process group
Whenever a tool spawns the editor (e.g. Git), suspending it with ^Z is not
enough to be sent back to the calling shell - another ^Z is necessary.

Fixes #3061
2019-08-21 10:32:35 +02:00
Jason Felice
8d76603df4 Fix kak -l when $XDG_RUNTIME_DIR is set 2019-08-20 16:13:21 -04:00
Maxime Coste
1f4b6c3f78 Merge remote-tracking branch 'lenormf/indented-docstrings' 2019-08-19 22:21:52 +10:00
Maxime Coste
2359df0f17 Make scrolling speed configurable
The UI now can send a 'Scroll' key, whose value is the scrolling
amount encoded as a signed integer. This replaces the MouseWheelUp
and MouseWheelDown keys.

The NCursesUI now has a ncurses_wheel_scroll_amount ui_option that
controls that amount, it can be negative to swap scrolling direction.

Fixes #3045
2019-08-19 22:16:39 +10:00
Maxime Coste
f1047181cb Fallback to wrapping in between 'word' when 'WORD' fails
First try to break at a whitespace, if that fails (likely because
that last WORD is too long for the wrapping width), then try to
wrap at a 'word' boundary (on a non alphanumeric character).

Fixes #3048
2019-08-12 18:40:56 +10:00
Jason Felice
0e4a4acf61 Use $XDG_RUNTIME_DIR
Falls back on old mechanism if `XDG_RUNTIME_DIR` is not set.

The ability to specify a session as "<user>/<name>" was removed, since
it isn't possible to compute the value of `XDG_RUNTIME_DIR` for another
user, we wouldn't have access to it if we could, and it would be awkward
to support this feature only when `XDG_RUNTIME_DIR` is unset.  Also,
`rename-session` did not work when another user's session was specified.

Closes #3019
2019-08-05 11:57:07 -04:00
Maxime Coste
1c6aa9baed Fix bug in WrapHighlighter::do_compute_display_setup
Additional lines were not pulled correctly when a line was removed
due to its wrapping hiding the cursor.

Fixes #2999
2019-08-05 20:16:59 +10:00
Frank LENORMAND
da2f6c296a src: De-indent docstrings passed to command/option/mapping definitions
This commit implements formatting behaviour when the first character of a
docstring is a newline. In that case, the exact indentation level of the
next line will be removed from that line and all subsequent non-empty lines.

An error will be returned if a subsequent non-empty line does not have the
same indentation level.

The docstrings are always trimmed (surrounding whitespaces) whether the
first character is a newline or not, as was the case prior to this commit.

Example: the following declaration

```
define-command test -docstring %{
    test: do something

    Nothing really.
        More
            indented
                lines.
} nop
```

would be rendered as

```
test: do something

Nothing really.
    More
        indented
            lines.
```

Related to #2405
2019-07-25 12:28:04 +03:00
Maxime Coste
e42c81c8eb Ensure current context switches away from buffer on delete-buffer
Fixes #3025
2019-07-22 20:26:39 +10:00
Maxime Coste
39445f9acb save command history in execute-keys by default
This should make #3014 unnecessary
2019-07-21 12:29:52 +10:00
Maxime Coste
1a16590960 Slight code cleanup in prompt history handling 2019-07-21 12:20:47 +10:00
Maxime Coste
b83c09509e Merge branch 'master' of http://github.com/jo-he/kakoune 2019-07-21 12:15:48 +10:00
Maxime Coste
b18ca12882 More functional style for '*' code 2019-07-21 12:14:25 +10:00
Maxime Coste
c54e0ec873 Merge remote-tracking branch 'lenormf/fix-2994' 2019-07-21 12:10:22 +10:00
Maxime Coste
be3d0f8b33 Filter non-extra_word_chars completion candidates using Codepoints
Fixes #3010
2019-07-09 19:36:57 +10:00
Maxime Coste
c2e43ee42c Use -O0 for debug builds
-Og is not nice enough to work with in gdb, control jumps around
in too unpredictible ways due to inlining.
2019-07-09 19:27:55 +10:00
Joachim Henke
556d58a073 allow for mapping the Insert key 2019-07-07 18:38:46 +02:00
Maxime Coste
3a7d0b67fa Merge remote-tracking branch 'lenormf/fix-history-size' 2019-07-07 09:14:25 +10:00
Maxime Coste
9e62d2c345 Merge branch 'master' of http://github.com/jo-he/kakoune 2019-07-07 09:13:11 +10:00
Joachim Henke
4c61f82fb2 fix a few typos 2019-07-06 17:37:30 +02:00
Tobias Kortkamp
16bb55edee
Fix build on FreeBSD
file.cc:390:21: error: use of undeclared identifier 'rename'; did you mean 'devname'?
    if (replace and rename(temp_filename, zfilename) != 0)
                    ^~~~~~
                    devname
/usr/include/stdlib.h:277:7: note: 'devname' declared here
char    *devname(__dev_t, __mode_t);
         ^
file.cc:390:28: error: cannot initialize a parameter of type '__dev_t' (aka 'unsigned long') with an lvalue of type 'char [1024]'
    if (replace and rename(temp_filename, zfilename) != 0)
                           ^~~~~~~~~~~~~
/usr/include/stdlib.h:277:22: note: passing argument to parameter here
char    *devname(__dev_t, __mode_t);
                        ^
2 errors generated.

---

highlighters.cc:1110:13: error: use of undeclared identifier 'snprintf'; did you mean 'vswprintf'?
            snprintf(buffer, 16, format, std::abs(line_to_format));
            ^~~~~~~~
            vswprintf
/usr/include/wchar.h:139:5: note: 'vswprintf' declared here
int     vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
highlighters.cc:1110:22: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [16]'
            snprintf(buffer, 16, format, std::abs(line_to_format));
                     ^~~~~~
/usr/include/wchar.h:139:35: note: passing argument to parameter here
int     vswprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                      ^
2 errors generated.

---

json_ui.cc:60:13: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
            sprintf(buf, "\\u%04x", *next);
            ^~~~~~~
            swprintf
/usr/include/wchar.h:133:5: note: 'swprintf' declared here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
json_ui.cc:60:21: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [7]'
            sprintf(buf, "\\u%04x", *next);
                    ^~~
/usr/include/wchar.h:133:34: note: passing argument to parameter here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                     ^
json_ui.cc:74:9: error: use of undeclared identifier 'sprintf'
        sprintf(buffer, R"("#%02x%02x%02x")", color.r, color.g, color.b);
        ^
3 errors generated.

---

regex_impl.cc:1039:9: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
        sprintf(buf, " %03d     ", count++);
        ^~~~~~~
        swprintf
/usr/include/wchar.h:133:5: note: 'swprintf' declared here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
regex_impl.cc:1039:17: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [20]'
        sprintf(buf, " %03d     ", count++);
                ^~~
/usr/include/wchar.h:133:34: note: passing argument to parameter here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                     ^
regex_impl.cc:1197:17: error: use of undeclared identifier 'puts'
    { if (dump) puts(dump_regex(*this).c_str()); }
                ^
regex_impl.cc:1208:18: note: in instantiation of member function 'Kakoune::(anonymous namespace)::TestVM<Kakoune::RegexMode::Forward>::TestVM' requested here
        TestVM<> vm{R"(a*b)"};
                 ^
regex_impl.cc:1197:17: error: use of undeclared identifier 'puts'
    { if (dump) puts(dump_regex(*this).c_str()); }
                ^
regex_impl.cc:1283:56: note: in instantiation of member function 'Kakoune::(anonymous namespace)::TestVM<5>::TestVM' requested here
        TestVM<RegexMode::Forward | RegexMode::Search> vm{R"(f.*a(.*o))"};
                                                       ^
regex_impl.cc:1197:17: error: use of undeclared identifier 'puts'
    { if (dump) puts(dump_regex(*this).c_str()); }
                ^
regex_impl.cc:1423:57: note: in instantiation of member function 'Kakoune::(anonymous namespace)::TestVM<6>::TestVM' requested here
        TestVM<RegexMode::Backward | RegexMode::Search> vm{R"(fo{1,})"};
                                                        ^
5 errors generated.

---

remote.cc:829:9: error: use of undeclared identifier 'rename'; did you mean 'devname'?
    if (rename(old_socket_file.c_str(), new_socket_file.c_str()) != 0)
        ^~~~~~
        devname
/usr/include/stdlib.h:277:7: note: 'devname' declared here
char    *devname(__dev_t, __mode_t);
         ^
remote.cc:829:16: error: cannot initialize a parameter of type '__dev_t' (aka 'unsigned long') with an rvalue of type 'const char *'
    if (rename(old_socket_file.c_str(), new_socket_file.c_str()) != 0)
               ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:277:22: note: passing argument to parameter here
char    *devname(__dev_t, __mode_t);
                        ^
2 errors generated.

---

string_utils.cc:126:20: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
    res.m_length = sprintf(res.m_data, "%i", val);
                   ^~~~~~~
                   swprintf
/usr/include/wchar.h:133:5: note: 'swprintf' declared here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
        ^
string_utils.cc:126:28: error: cannot initialize a parameter of type 'wchar_t *' with an lvalue of type 'char [15]'
    res.m_length = sprintf(res.m_data, "%i", val);
                           ^~~~~~~~~~
/usr/include/wchar.h:133:34: note: passing argument to parameter here
int     swprintf(wchar_t * __restrict, size_t n, const wchar_t * __restrict,
                                     ^
string_utils.cc:133:20: error: use of undeclared identifier 'sprintf'; did you mean 'swprintf'?
    res.m_length = sprintf(res.m_data, "%u", val);
                   ^~~~~~~
                   swprintf
[...]
2019-07-06 08:53:47 +02:00
Frank LENORMAND
78129150c9 src: Cap the maximum size of history registers
History registers (for prompt commands, pipe primitive commands etc) are
populated interactively by the users, and currently have no size limit.

This commits silently drops the oldest entries in the storage space to
allow at most 100 entries, to prevent long-running editing sessions from
hogging memory for data most likely never used.
2019-07-02 16:36:12 +03:00
Frank LENORMAND
b040bf8b81 src: Use all selections to generate a pattern upon hitting *
This commit makes the `*` and <a-*> primitives compose a search pattern
comprised of all the current selections, as opposed to only the main one.

All selections are OR'd into the default search register, which makes it
convenient to search for several identifiers already selected.

To retain the old behaviour, the following mappings can be used:

```
map global normal * ': exec -draft -save-regs "" %{<space>*}<ret>'
map global normal <a-*> ': exec -draft -save-regs "" %{<space><a-*>}<ret>'
```

Fixes #2994
2019-07-01 19:53:08 +03:00
Maxime Coste
2ff9fd8d92 Kakoune v2019.07.01 2019-07-01 22:07:29 +10:00
Maxime Coste
aff3e7d5b7 Merge remote-tracking branch 'lenormf/fix-2907-2' 2019-06-29 09:54:51 +10:00