summaryrefslogtreecommitdiff
path: root/src/json_ui.cc
AgeCommit message (Collapse)Author
2024-08-14Fix json-ui scroll supportMaxime Coste
Add cursor coordinate parameters, and fix encoding to match the new one.
2024-08-14Merge remote-tracking branch 'arrufat/support-double-underline'Maxime Coste
2024-08-12Reduce headers dependency graphMaxime Coste
Move more code into the implementation files to reduce the amount of code pulled by headers.
2024-08-04Add support for double underlineAdrià Arrufat
2023-11-03Add support for 0-padding in format and replace uses of sprintfMaxime Coste
2023-03-11Implement bracketed pasteJohannes Altmanninger
Text pasted into Kakoune's normal mode is interpreted as command sequence, which is probably never what the user wants. Text pasted during insert mode will be inserted fine but may trigger auto-indentation hooks which is likely not what users want. Bracketed paste is pair of escape codes sent by terminals that allow applications to distinguish between pasted text and typed text. Let's use this feature to always insert pasted text verbatim, skipping keymap lookup and the InsertChar hook. In future, we could add a dedicated Paste hook. We need to make a decision on whether to paste before or after the selection. I chose "before" because that's what I'm used to. TerminalUI::set_on_key has EventManager::instance().force_signal(0); I'm not sure if we want the same for TerminalUI::set_on_paste? I assume it doesn't matter because they are always called in tandem. Closes #2465
2022-12-13Fix a couple bugs with underline highlightingMaxime Coste
Add missing curly_underline attribute to json-rpc Fix underline color not correct after attrbute only change
2021-09-07Add support for curly underline and separate underline colorMaxime Coste
Add support for a third color in face definition that controls the underline and a 'c' attribute for curly underline (that takes precedence over 'u' if both are specified) Allow empty colors to mean default, so that `,,red+u` means the same as `default,default,red+u` Fixes #4138
2021-07-12src: Support strikethrough facesJason Felice
2021-03-11Do not select on non-urgent fd when handling only urgent eventsMaxime Coste
This avoids 100% CPU usage when we have pending fifo input while running a shell process, as we will not end-up busy looping in pselect but not reading the available data due to being only processing urgent events.
2020-06-28Refactor mouse press/release handling to support 3 buttonsMaxime Coste
Change button to be an additional parameter instead of having separate events for left/right buttons. Fixes #3471
2019-12-10Fix build on FreeBSD againTobias Kortkamp
json_ui.cc:29:9: error: use of undeclared identifier 'sprintf' sprintf(buffer, R"("#%02x%02x%02x")", color.r, color.g, color.b); ^ 1 error generated. Regressed by 7cdbe1d3d24c1cc13bd7cbc3fe252f1e88747ffb
2019-12-03Merge remote-tracking branch 'lenormf/split-json'Maxime Coste
2019-11-22Add support for markup in info boxesMaxime Coste
Fixes #2552
2019-11-17src: Move JSON parsing code to its own fileFrank LENORMAND
The `json_ui.cc` file contained both data-parsing and UI-related code. This commit moves the JSON parsing code to its own `json.cc` file, to separate concerns, make compilation faster when changes are made to either UI or parsing code, and make the parsing code more accessible to fuzzers. The signature of the following function: ``` auto parse_json(StringView json); ``` was changed to: ``` JsonResult parse_json(StringView json); ``` to avoid `auto` deduction issues at compile-time.
2019-11-09Add static or const where usefulJason Felice
2019-10-23Only allow minus at the begining of json numbersMaxime Coste
2019-10-22Teach JSON parser negative numbersDan Rosén
2019-08-19Make scrolling speed configurableMaxime Coste
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-07-06Fix build on FreeBSDTobias Kortkamp
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-01-24Replace std::tie with structured bindingsMaxime Coste
2018-12-20src: Add support for right click eventsFrank LENORMAND
The current implementation treats left mouse button clicks as a generic "mouse press" modifier, this commit extends the list of modifiers by adding a "right mouse click" one. The proper way to implement this would be to ship the coordinates of mouse key press events in each `Key` object, and pass whichever button was clicked as a codepoint value (instead of coordinates currently), but this would require more work. This commit allows: * right clicks to set the cursor of the main selection * control-right clicks to merge all the selections, and then set its cursor Fixes #843
2018-09-23Replace the `Exclusive` face attribute with `Final`Maxime Coste
Final is more granular, it consists of FinalFg (f), FinalBg (g) and FinalAttr (a) which control if a face's fg, bg, or attributes fully overwrite the previous face (instead of merging) and if following faces apply on top of this face or not. Fixes #2388 if the Whitespace face has the FinalFg flag.
2018-08-18src: Improve error messages in RPC requests parsingFrank LENORMAND
Cast errors in RPC requests currently make the client quit with an error saying "uncaught exception", since `Kakoune::bad_value_cast` exceptions are not explicitely handled. This commit tries to catch ill-formatted requests and return a more human-friendly error message, without quitting the client.
2018-06-03Add MenuStyle::Search that prevents the menu from hiding buffer textMaxime Coste
Fixes #2042
2018-05-16Print a newline after errors in the JSON UI.Tim Allen
This makes them just a little easier to read.
2018-05-03Add support for explicit menu selection from the UIMaxime Coste
the JsonUI now supports a "menu_select(int)" RPC call that should trigger explicit selection of the provided item index. As discussed for issue #2019.
2018-05-03JsonUI: Add support for a "mouse" RPC calls from the UIMaxime Coste
As discussed on issue #2019
2018-04-29Fix tests after changes to json_ui outputMaxime Coste
2018-04-29Rework the way UI can trigger a client quittingMaxime Coste
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-29JsonUI: add support for set_ui_options RPC callMaxime Coste
As discussed on #2019
2018-04-06Make error messages more consistentDelapouite
2018-04-05Fix some trailing spaces and a tab that sneaked into the code baseMaxime Coste
2018-02-20Json: Fix buffer overflow when reading json finishing with { or [Maxime Coste
Fixes #1860
2017-10-10Move all non-core string code to string_utils.{hh,cc}Maxime Coste
2017-09-12Rename some string conversion function to the common 'to_string'Maxime Coste
2017-08-29Rename containers.hh to ranges.hh (and Container to Range)Maxime Coste
2017-04-12Place hardware terminal cursor at the current main cursor/prompt cursor positionMaxime Coste
Fixes #1318 Also fixes https://gitlab.com/gnachman/iterm2/issues/5408
2017-03-07Replace IdMap with HashMapMaxime Coste
2017-03-07Replace uses of UnorderedMap with HashMapMaxime Coste
2017-01-04Higher level implementation of attributes to json formattingMaxime Coste
2017-01-04Add `Modal` InfoStyle used for bufer reload info boxMaxime Coste
Modal info style wont be replaced by other info boxes. NCursesUI will center that info box. Fixes #1060
2016-12-01Make FDWatcher support Read, Write and Except events, instead of just ReadMaxime Coste
2016-11-29Simplify greatly UI input handlingMaxime Coste
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-28Cleanup include dependencies a bitMaxime Coste
2016-10-01Support codepoints of variable widthMaxime Coste
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-08-30Add a fd_readable(int fd) helper functionMaxime Coste
Use it instead of direct calls to select scatered around the code base.
2016-08-27Fix menu_select in the JSON uiEnrico Lumetti
2016-08-24JsonUi: try to handle all available requests, on input event, not just the ↵Maxime Coste
first one
2016-07-04Improve robustness of json parsing and executionMaxime Coste
Fixes #720