]> git.lyx.org Git - lyx.git/blob - src/PersonalWordList.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / PersonalWordList.h
1 // -*- C++ -*-
2 /**
3  * \file PersonalWordList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Stephan Witt
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef PERSONAL_WORD_LIST_H
13 #define PERSONAL_WORD_LIST_H
14
15 #include "support/strfwd.h"
16 #include "support/docstring_list.h"
17 #include "support/FileName.h"
18
19 #include <string>
20
21 namespace lyx {
22
23 /// A PersonalWordList holds a word list with persistent state
24 class PersonalWordList {
25 public:
26         /// the word list has an associated language
27         PersonalWordList(std::string const & lang) : lang_(lang), dirty_(false) {}
28         /// the location of the file to hold to word list
29         lyx::support::FileName dictfile() const;
30         /// (re)load the word list from file
31         void load();
32         /// save word list to file
33         void save();
34         /// check for presence of given word
35         bool exists(docstring const & word) const;
36         /// add given word to list
37         void insert(docstring const & word);
38         /// remove given word from list
39         void remove(docstring const & word);
40         /// is word list modified after load/save?
41         bool isDirty() const { return dirty_; }
42         /// first item in word list
43         docstring_list::const_iterator begin() const;
44         /// end of word list
45         docstring_list::const_iterator end() const;
46 private:
47         ///
48         docstring_list words_;
49         ///
50         std::string lang_;
51         ///
52         bool dirty_;
53         ///
54         bool equalwords(docstring const & w1, docstring const & w2) const;
55         ///
56         std::string header() const { return "# personal word list"; }
57         ///
58         void dirty(bool flag) { dirty_ = flag; }
59 };
60
61 } // namespace lyx
62
63 #endif // PERSONAL_WORD_LIST_H