diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-08-05 10:23:13 +0200 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-08-05 10:23:13 +0200 |
| commit | 9148b1ae92024ea4974299e87788a58d67635664 (patch) | |
| tree | 9f13c91922edf921fce148274c7003bdefd90aa6 /src/input_handler.cc | |
| parent | c05f9f31dda0e4cac5ac9a318aaf0eabed6734e8 (diff) | |
Add line completion
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index a2ed3cae..2c23af80 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -723,6 +723,23 @@ public: return {}; } + BufferCompletion complete_line(const Buffer& buffer, BufferCoord cursor_pos) + { + String prefix = buffer[cursor_pos.line].substr(0_byte, cursor_pos.column); + StringList res; + for (LineCount l = 0_line; l < buffer.line_count(); ++l) + { + if (l == cursor_pos.line) + continue; + ByteCount len = buffer[l].length(); + if (len > cursor_pos.column and std::equal(prefix.begin(), prefix.end(), buffer[l].begin())) + res.push_back(buffer[l].substr(0_byte, len-1)); + } + if (res.empty()) + return {}; + return { cursor_pos.line, cursor_pos, std::move(res), buffer.timestamp() }; + } + private: void on_option_changed(const Option& opt) override { @@ -807,6 +824,8 @@ public: m_completer.try_complete<&BufferCompleter::complete_word<true>>(); if (key.key == 'o') m_completer.try_complete<&BufferCompleter::complete_option>(); + if (key.key == 'l') + m_completer.try_complete<&BufferCompleter::complete_line>(); m_mode = Mode::Default; return; } |
