diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-01-24 00:56:33 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-01-27 19:51:58 +0000 |
| commit | ad818853a272a23cf9ea9e46b97a4e7ac818cfcc (patch) | |
| tree | 22a3f705ee27803c504c2f72814f2327dc5de4a7 /src/word_db.hh | |
| parent | a96b2d3cd2d84b410476293c9520e0f5dbc1fc39 (diff) | |
WordDB now uses a LineChangeWatcher based implementation
Diffstat (limited to 'src/word_db.hh')
| -rw-r--r-- | src/word_db.hh | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/word_db.hh b/src/word_db.hh index bbbfa04c..48ed2c4f 100644 --- a/src/word_db.hh +++ b/src/word_db.hh @@ -2,8 +2,9 @@ #define word_db_hh_INCLUDED #include "buffer.hh" +#include "line_change_watcher.hh" -#include <set> +#include <map> namespace Kakoune { @@ -11,26 +12,21 @@ namespace Kakoune class String; // maintain a database of words available in a buffer -class WordDB : public BufferChangeListener_AutoRegister +class WordDB { public: WordDB(const Buffer& buffer); - void on_insert(const Buffer& buffer, BufferCoord begin, BufferCoord end) override; - void on_erase(const Buffer& buffer, BufferCoord begin, BufferCoord end) override; - - std::vector<String> find_prefix(const String& prefix) const; + std::vector<String> find_prefix(const String& prefix); + using WordList = std::map<String, int>; private: - using WordToLines = std::map<String, std::vector<LineCount>>; - using LineToWords = std::map<LineCount, std::vector<String>>; + using LineToWords = std::vector<std::vector<String>>; - void add_words(LineCount line, const String& content); - LineToWords::iterator remove_line(LineToWords::iterator it); - void update_lines(LineToWords::iterator begin, LineToWords::iterator end, - LineCount num); + void update_db(); - WordToLines m_word_to_lines; + LineChangeWatcher m_change_watcher; + WordList m_words; LineToWords m_line_to_words; }; |
