]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Revert 23154.
[lyx.git] / src / Text.cpp
index 50ac94aa08d1d212131a7bb606e7b2313cfa9f40..c29876d9a1efe030cd6e0403c79387c6679887c6 100644 (file)
@@ -125,12 +125,12 @@ void readParToken(Buffer const & buf, Paragraph & par, Lexer & lex,
                                        tclass.defaultLayoutName();
                }
 
-               par.layout(bp.getTextClass()[layoutname]);
+               par.setLayout(bp.getTextClass()[layoutname]);
 
                // Test whether the layout is obsolete.
                LayoutPtr const & layout = par.layout();
                if (!layout->obsoleted_by().empty())
-                       par.layout(bp.getTextClass()[layout->obsoleted_by()]);
+                       par.setLayout(bp.getTextClass()[layout->obsoleted_by()]);
 
                par.params().read(lex);
 
@@ -340,8 +340,7 @@ bool Text::empty() const
 }
 
 
-double Text::spacing(Buffer const & buffer,
-               Paragraph const & par) const
+double Text::spacing(Buffer const & buffer, Paragraph const & par) const
 {
        if (par.params().spacing().isDefault())
                return buffer.params().spacing().getValue();
@@ -564,6 +563,8 @@ void Text::insertChar(Cursor & cur, char_type c)
 
 void Text::charInserted(Cursor & cur)
 {
+       Paragraph & par = cur.paragraph();
+
        // Here we call finishUndo for every 20 characters inserted.
        // This is from my experience how emacs does it. (Lgb)
        static unsigned int counter;
@@ -573,6 +574,27 @@ void Text::charInserted(Cursor & cur)
                cur.finishUndo();
                counter = 0;
        }
+
+       // register word if a non-letter was entered
+       if (cur.pos() > 1
+           && par.isLetter(cur.pos() - 2)
+           && !par.isLetter(cur.pos() - 1)) {
+               // get the word in front of cursor
+               BOOST_ASSERT(this == cur.text());
+               CursorSlice focus = cur.top();
+               focus.backwardPos();
+               CursorSlice from = focus;
+               CursorSlice to = focus;
+               getWord(from, to, PREVIOUS_WORD);
+               if (focus == from || to == from)
+                       return;
+               docstring word
+               = par.asString(cur.buffer(), from.pos(), to.pos(), false);
+
+               // register words longer than 5 characters
+               if (word.length() > 5)
+                       cur.buffer().registerWord(word);
+       }
 }
 
 
@@ -906,9 +928,9 @@ bool Text::handleBibitems(Cursor & cur)
 
        // otherwise reset to default
        if (par.useEmptyLayout())
-               cur.paragraph().layout(bufparams.getTextClass().emptyLayout());
+               cur.paragraph().setLayout(bufparams.getTextClass().emptyLayout());
        else
-               cur.paragraph().layout(bufparams.getTextClass().defaultLayout());
+               cur.paragraph().setLayout(bufparams.getTextClass().defaultLayout());
        return true;
 }
 
@@ -1160,7 +1182,7 @@ void Text::write(Buffer const & buf, ostream & os) const
 
 
 bool Text::read(Buffer const & buf, Lexer & lex, 
-               ErrorList & errorList, Inset * insetPtr)
+               ErrorList & errorList, InsetText * insetPtr)
 {
        depth_type depth = 0;