mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 11:52:25 +00:00
* compile fix
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23233 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b2475f6625
commit
1669c17c0f
@ -204,9 +204,6 @@ public:
|
||||
/// A cache for the bibfiles (including bibfiles of loaded child
|
||||
/// documents), needed for appropriate update of natbib labels.
|
||||
mutable EmbeddedFileList bibfilesCache_;
|
||||
|
||||
///
|
||||
WordList words_;
|
||||
};
|
||||
|
||||
/// Creates the per buffer temporary directory
|
||||
@ -2668,16 +2665,4 @@ void Buffer::bufferErrors(TeXErrors const & terr, ErrorList & errorList) const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Buffer::registerWord(docstring const & word)
|
||||
{
|
||||
d->words_.insert(word);
|
||||
}
|
||||
|
||||
|
||||
WordList const & Buffer::registeredWords() const
|
||||
{
|
||||
return d->words_;
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -50,7 +50,6 @@ class TeXErrors;
|
||||
class TexRow;
|
||||
class TocBackend;
|
||||
class Undo;
|
||||
class WordList;
|
||||
|
||||
namespace frontend {
|
||||
class GuiBufferDelegate;
|
||||
@ -453,11 +452,6 @@ public:
|
||||
///
|
||||
std::vector<Format const *> exportableFormats(bool only_viewable) const;
|
||||
|
||||
/// Register word for completion word list.
|
||||
void registerWord(docstring const & word);
|
||||
///
|
||||
WordList const & registeredWords() const;
|
||||
|
||||
private:
|
||||
/// search for macro in local (buffer) table or in children
|
||||
MacroData const * getBufferMacro(docstring const & name,
|
||||
|
@ -39,7 +39,9 @@
|
||||
#include "sgml.h"
|
||||
#include "TextClass.h"
|
||||
#include "TexRow.h"
|
||||
#include "Text.h"
|
||||
#include "VSpace.h"
|
||||
#include "WordList.h"
|
||||
|
||||
#include "frontends/alert.h"
|
||||
|
||||
@ -196,6 +198,10 @@ public:
|
||||
typedef docstring TextContainer;
|
||||
///
|
||||
TextContainer text_;
|
||||
|
||||
typedef std::set<docstring> Words;
|
||||
///
|
||||
Words words_;
|
||||
};
|
||||
|
||||
|
||||
@ -1057,6 +1063,7 @@ Paragraph & Paragraph::operator=(Paragraph const & par)
|
||||
|
||||
Paragraph::~Paragraph()
|
||||
{
|
||||
deregisterWords();
|
||||
delete d;
|
||||
}
|
||||
|
||||
@ -2678,4 +2685,63 @@ bool Paragraph::isSeparator(pos_type pos) const
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::deregisterWords()
|
||||
{
|
||||
// deregister words
|
||||
Private::Words::const_iterator it;
|
||||
WordList & wl = theWordList();
|
||||
for (it = d->words_.begin(); it != d->words_.end(); ++it)
|
||||
wl.remove(*it);
|
||||
d->words_.clear();
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::registerWords(Cursor const & cur)
|
||||
{
|
||||
// find new words
|
||||
bool inword = false;
|
||||
|
||||
lyxerr << "Words: ";
|
||||
pos_type n = size();
|
||||
for (pos_type pos = 0; pos != n; ++pos) {
|
||||
if (isDeleted(pos))
|
||||
continue;
|
||||
|
||||
if (!isLetter(pos)) {
|
||||
inword = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inword)
|
||||
continue;
|
||||
|
||||
inword = true;
|
||||
CursorSlice from = cur.top();
|
||||
CursorSlice to = cur.top();
|
||||
from.pos() = pos;
|
||||
to.pos() = pos;
|
||||
from.text()->getWord(from, to, NEXT_WORD);
|
||||
if (to.pos() - from.pos() < 6)
|
||||
continue;
|
||||
docstring word
|
||||
= asString(cur.buffer(), from.pos(), to.pos(), false);
|
||||
d->words_.insert(word);
|
||||
lyxerr << word << " ";
|
||||
}
|
||||
lyxerr << std::endl;
|
||||
|
||||
// register words
|
||||
Private::Words::const_iterator it;
|
||||
WordList & wl = theWordList();
|
||||
for (it = d->words_.begin(); it != d->words_.end(); ++it)
|
||||
wl.insert(*it);
|
||||
}
|
||||
|
||||
|
||||
void Paragraph::updateWords(Cursor const & cur)
|
||||
{
|
||||
deregisterWords();
|
||||
registerWords(cur);
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -31,6 +31,7 @@ class Buffer;
|
||||
class BufferParams;
|
||||
class Change;
|
||||
class Counters;
|
||||
class Cursor;
|
||||
class Inset;
|
||||
class InsetBibitem;
|
||||
class LaTeXFeatures;
|
||||
@ -368,7 +369,15 @@ public:
|
||||
pos_type pos, ///< start from here.
|
||||
bool del = true) const;
|
||||
|
||||
///
|
||||
void updateWords(Cursor const & cur);
|
||||
|
||||
private:
|
||||
///
|
||||
void deregisterWords();
|
||||
///
|
||||
void registerWords(Cursor const & cur);
|
||||
|
||||
/// Pimpl away stuff
|
||||
class Private;
|
||||
///
|
||||
|
@ -581,7 +581,8 @@ void Text::charInserted(Cursor & cur)
|
||||
&& !par.isLetter(cur.pos() - 1)) {
|
||||
// get the word in front of cursor
|
||||
BOOST_ASSERT(this == cur.text());
|
||||
CursorSlice focus = cur.top();
|
||||
cur.paragraph().updateWords(cur);
|
||||
/* CursorSlice focus = cur.top();
|
||||
focus.backwardPos();
|
||||
CursorSlice from = focus;
|
||||
CursorSlice to = focus;
|
||||
@ -593,7 +594,7 @@ void Text::charInserted(Cursor & cur)
|
||||
|
||||
// register words longer than 5 characters
|
||||
if (word.length() > 5)
|
||||
cur.buffer().registerWord(word);
|
||||
cur.buffer().registerWord(word);*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -1129,7 +1130,7 @@ bool Text::dissolveInset(Cursor & cur) {
|
||||
|
||||
|
||||
void Text::getWord(CursorSlice & from, CursorSlice & to,
|
||||
word_location const loc)
|
||||
word_location const loc) const
|
||||
{
|
||||
Paragraph const & from_par = pars_[from.pit()];
|
||||
switch (loc) {
|
||||
@ -1161,7 +1162,7 @@ void Text::getWord(CursorSlice & from, CursorSlice & to,
|
||||
break;
|
||||
}
|
||||
to = from;
|
||||
Paragraph & to_par = pars_[to.pit()];
|
||||
Paragraph const & to_par = pars_[to.pit()];
|
||||
while (to.pos() < to_par.size() && to_par.isLetter(to.pos()))
|
||||
++to.pos();
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
* @param from return here the start of the word
|
||||
* @param to return here the end of the word
|
||||
*/
|
||||
void getWord(CursorSlice & from, CursorSlice & to, word_location const);
|
||||
void getWord(CursorSlice & from, CursorSlice & to, word_location const) const;
|
||||
/// just selects the word the cursor is in
|
||||
void selectWord(Cursor & cur, word_location loc);
|
||||
|
||||
|
@ -21,12 +21,20 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
///
|
||||
WordList theGlobalWordList;
|
||||
|
||||
WordList & theWordList()
|
||||
{
|
||||
return theGlobalWordList;
|
||||
}
|
||||
|
||||
///
|
||||
struct WordList::Impl {
|
||||
///
|
||||
size_t c_;
|
||||
///
|
||||
typedef stx::weighted_btree<docstring, size_t> Words;
|
||||
typedef stx::weighted_btree<docstring, size_t, int> Words;
|
||||
///
|
||||
Words words_;
|
||||
};
|
||||
@ -67,8 +75,22 @@ size_t WordList::size() const
|
||||
|
||||
void WordList::insert(docstring const & w)
|
||||
{
|
||||
d->words_.insert(w, size_t(1), stx::Void());
|
||||
Impl::Words::iterator it = d->words_.find(w);
|
||||
if (it == d->words_.end())
|
||||
d->words_.insert(w, size_t(1), 1);
|
||||
else
|
||||
it.data()++;
|
||||
}
|
||||
|
||||
|
||||
void WordList::remove(docstring const & w)
|
||||
{
|
||||
Impl::Words::iterator it = d->words_.find(w);
|
||||
if (it != d->words_.end()) {
|
||||
it.data()--;
|
||||
if (it.data() == 0)
|
||||
d->words_.erase(w);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -29,12 +29,16 @@ public:
|
||||
size_t size() const;
|
||||
///
|
||||
void insert(docstring const & w);
|
||||
///
|
||||
void remove(docstring const & w);
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
Impl * d;
|
||||
};
|
||||
|
||||
WordList & theWordList();
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif // WORDLIST_H
|
||||
|
@ -80,12 +80,14 @@ public:
|
||||
///
|
||||
virtual size_t size() const
|
||||
{
|
||||
return buf_.registeredWords().size();
|
||||
// return buf_.registeredWords().size();
|
||||
return theWordList().size();
|
||||
}
|
||||
///
|
||||
virtual docstring const & data(size_t idx) const
|
||||
{
|
||||
return buf_.registeredWords().word(idx);
|
||||
// return buf_.registeredWords().word(idx);
|
||||
return theWordList().word(idx);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -2547,7 +2547,7 @@ private:
|
||||
left->weights[left->slotuse + i] = right->weights[i];
|
||||
}
|
||||
left->slotuse += right->slotuse;
|
||||
left->weight += right.weight;
|
||||
left->weight += right->weight;
|
||||
|
||||
left->nextleaf = right->nextleaf;
|
||||
if (left->nextleaf)
|
||||
@ -2600,7 +2600,7 @@ private:
|
||||
left->childid[left->slotuse + i] = right->childid[i];
|
||||
}
|
||||
left->slotuse += right->slotuse;
|
||||
left->weight += right.weight;
|
||||
left->weight += right->weight;
|
||||
|
||||
left->childid[left->slotuse] = right->childid[right->slotuse];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user