diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-04-12 10:39:17 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-04-12 10:39:17 +0100 |
| commit | 91bfd714e4be3484e04eaadc5bbe630861fff652 (patch) | |
| tree | d8b2eb554c7feaf44545d650351480b468f4886d /src/input_handler.cc | |
| parent | 80dd9ec4cb68669df4688c621486a27dd9b33548 (diff) | |
Place hardware terminal cursor at the current main cursor/prompt cursor position
Fixes #1318
Also fixes https://gitlab.com/gnachman/iterm2/issues/5408
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 4edce81c..b378b871 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -37,6 +37,12 @@ public: virtual KeymapMode keymap_mode() const = 0; + virtual std::pair<CursorMode, DisplayCoord> get_cursor_info() const + { + DisplayCoord coord = context().window().display_position(context().selections().main().cursor()); + return {CursorMode::Buffer, coord}; + } + using Insertion = InputHandler::Insertion; Insertion& last_insert() { return m_input_handler.m_last_insert; } @@ -467,6 +473,11 @@ public: const String& line() const { return m_line; } CharCount cursor_pos() const { return m_cursor_pos; } + ColumnCount cursor_display_column() const + { + return m_line.substr(m_display_pos, m_cursor_pos).column_length(); + } + DisplayLine build_display_line(ColumnCount in_width) { auto cleanup = [](StringView str) { @@ -873,6 +884,12 @@ public: KeymapMode keymap_mode() const override { return KeymapMode::Prompt; } + std::pair<CursorMode, DisplayCoord> get_cursor_info() const override + { + DisplayCoord coord{0_line, m_prompt.column_length() + m_line_editor.cursor_display_column()}; + return { CursorMode::Prompt, coord }; + } + private: void refresh_completions(CompletionFlags flags) { @@ -1521,6 +1538,11 @@ DisplayLine InputHandler::mode_line() const return current_mode().mode_line(); } +std::pair<CursorMode, DisplayCoord> InputHandler::get_cursor_info() const +{ + return current_mode().get_cursor_info(); +} + bool show_auto_info_ifn(StringView title, StringView info, AutoInfo mask, const Context& context) { if (not (context.options()["autoinfo"].get<AutoInfo>() & mask) or |
