Revert "* compile fix"

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23234 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2008-02-25 22:02:48 +00:00
parent 1669c17c0f
commit f8d516c7af
10 changed files with 34 additions and 117 deletions

View File

@ -204,6 +204,9 @@ 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
@ -2665,4 +2668,16 @@ 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

View File

@ -50,6 +50,7 @@ class TeXErrors;
class TexRow;
class TocBackend;
class Undo;
class WordList;
namespace frontend {
class GuiBufferDelegate;
@ -452,6 +453,11 @@ 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,

View File

@ -39,9 +39,7 @@
#include "sgml.h"
#include "TextClass.h"
#include "TexRow.h"
#include "Text.h"
#include "VSpace.h"
#include "WordList.h"
#include "frontends/alert.h"
@ -198,10 +196,6 @@ public:
typedef docstring TextContainer;
///
TextContainer text_;
typedef std::set<docstring> Words;
///
Words words_;
};
@ -1063,7 +1057,6 @@ Paragraph & Paragraph::operator=(Paragraph const & par)
Paragraph::~Paragraph()
{
deregisterWords();
delete d;
}
@ -2685,63 +2678,4 @@ 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

View File

@ -31,7 +31,6 @@ class Buffer;
class BufferParams;
class Change;
class Counters;
class Cursor;
class Inset;
class InsetBibitem;
class LaTeXFeatures;
@ -369,15 +368,7 @@ 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;
///

View File

@ -581,8 +581,7 @@ void Text::charInserted(Cursor & cur)
&& !par.isLetter(cur.pos() - 1)) {
// get the word in front of cursor
BOOST_ASSERT(this == cur.text());
cur.paragraph().updateWords(cur);
/* CursorSlice focus = cur.top();
CursorSlice focus = cur.top();
focus.backwardPos();
CursorSlice from = focus;
CursorSlice to = focus;
@ -594,7 +593,7 @@ void Text::charInserted(Cursor & cur)
// register words longer than 5 characters
if (word.length() > 5)
cur.buffer().registerWord(word);*/
cur.buffer().registerWord(word);
}
}
@ -1130,7 +1129,7 @@ bool Text::dissolveInset(Cursor & cur) {
void Text::getWord(CursorSlice & from, CursorSlice & to,
word_location const loc) const
word_location const loc)
{
Paragraph const & from_par = pars_[from.pit()];
switch (loc) {
@ -1162,7 +1161,7 @@ void Text::getWord(CursorSlice & from, CursorSlice & to,
break;
}
to = from;
Paragraph const & to_par = pars_[to.pit()];
Paragraph & to_par = pars_[to.pit()];
while (to.pos() < to_par.size() && to_par.isLetter(to.pos()))
++to.pos();
}

View File

@ -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) const;
void getWord(CursorSlice & from, CursorSlice & to, word_location const);
/// just selects the word the cursor is in
void selectWord(Cursor & cur, word_location loc);

View File

@ -21,20 +21,12 @@
namespace lyx {
///
WordList theGlobalWordList;
WordList & theWordList()
{
return theGlobalWordList;
}
///
struct WordList::Impl {
///
size_t c_;
///
typedef stx::weighted_btree<docstring, size_t, int> Words;
typedef stx::weighted_btree<docstring, size_t> Words;
///
Words words_;
};
@ -75,22 +67,8 @@ size_t WordList::size() const
void WordList::insert(docstring const & w)
{
Impl::Words::iterator it = d->words_.find(w);
if (it == d->words_.end())
d->words_.insert(w, size_t(1), 1);
else
it.data()++;
d->words_.insert(w, size_t(1), stx::Void());
}
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

View File

@ -29,16 +29,12 @@ 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

View File

@ -80,14 +80,12 @@ public:
///
virtual size_t size() const
{
// return buf_.registeredWords().size();
return theWordList().size();
return buf_.registeredWords().size();
}
///
virtual docstring const & data(size_t idx) const
{
// return buf_.registeredWords().word(idx);
return theWordList().word(idx);
return buf_.registeredWords().word(idx);
}
private:

View File

@ -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];