]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Micro-optimization.
[lyx.git] / src / Text3.cpp
index 680494835dd8944618699dc2844b6716a57a2ed1..9eba7dbecb865bb0ad0e6c8d74ee865dcacf760e 100644 (file)
@@ -37,7 +37,7 @@
 #include "Language.h"
 #include "Layout.h"
 #include "LyXAction.h"
-#include "LyXFunc.h"
+#include "LyX.h"
 #include "Lexer.h"
 #include "LyXRC.h"
 #include "Paragraph.h"
@@ -485,7 +485,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                recUndo(cur, pit, pit + 1);
                cur.finishUndo();
                pars_.swap(pit, pit + 1);
-               cur.buffer()->updateLabels();
+               cur.buffer()->updateBuffer();
                needsUpdate = true;
                ++cur.pit();
                break;
@@ -496,7 +496,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                recUndo(cur, pit - 1, pit);
                cur.finishUndo();
                pars_.swap(pit, pit - 1);
-               cur.buffer()->updateLabels();
+               cur.buffer()->updateBuffer();
                --cur.pit();
                needsUpdate = true;
                break;
@@ -522,7 +522,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                par.params().startOfAppendix(start);
 
                // we can set the refreshing parameters now
-               cur.buffer()->updateLabels();
+               cur.buffer()->updateBuffer();
                break;
        }
 
@@ -1577,7 +1577,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                cur.posForward();
                // Some insets are numbered, others are shown in the outline pane so
                // let's update the labels and the toc backend.
-               bv->buffer().updateLabels();
+               bv->buffer().updateBuffer();
                break;
 
        case LFUN_TABULAR_INSERT:
@@ -1631,7 +1631,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                // date metrics.
                FuncRequest cmd_caption(LFUN_CAPTION_INSERT);
                doInsertInset(cur, cur.text(), cmd_caption, true, false);
-               bv->buffer().updateLabels();
+               bv->buffer().updateBuffer();
                cur.updateFlags(Update::Force);
                // FIXME: When leaving the Float (or Wrap) inset we should
                // delete any empty paragraph left above or below the
@@ -2000,8 +2000,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_SPELLING_ADD: {
                docstring word = from_utf8(cmd.getArg(0));
-               string code;
-               string variety;
+               Language * lang;
                if (word.empty()) {
                        word = cur.selectionAsString(false);
                        // FIXME
@@ -2010,19 +2009,17 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                selectWordWhenUnderCursor(cur, WHOLE_WORD);
                                word = cur.selectionAsString(false);
                        }
-                       code = cur.getFont().language()->code();
-                       variety = cur.getFont().language()->variety();
+                       lang = const_cast<Language *>(cur.getFont().language());
                } else
-                       variety = split(cmd.getArg(1), code, '-');
-               WordLangTuple wl(word, code, variety);
+                       lang = const_cast<Language *>(languages.getLanguage(cmd.getArg(1)));
+               WordLangTuple wl(word, lang);
                theSpellChecker()->insert(wl);
                break;
        }
 
        case LFUN_SPELLING_IGNORE: {
                docstring word = from_utf8(cmd.getArg(0));
-               string code;
-               string variety;
+               Language * lang;
                if (word.empty()) {
                        word = cur.selectionAsString(false);
                        // FIXME
@@ -2031,11 +2028,10 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                selectWordWhenUnderCursor(cur, WHOLE_WORD);
                                word = cur.selectionAsString(false);
                        }
-                       code = cur.getFont().language()->code();
-                       variety = cur.getFont().language()->variety();
+                       lang = const_cast<Language *>(cur.getFont().language());
                } else
-                       variety = split(cmd.getArg(1), code, '-');
-               WordLangTuple wl(word, code, variety);
+                       lang = const_cast<Language *>(languages.getLanguage(cmd.getArg(1)));
+               WordLangTuple wl(word, lang);
                theSpellChecker()->accept(wl);
                break;
        }
@@ -2076,26 +2072,26 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_OUTLINE_UP:
                outline(OutlineUp, cur);
                setCursor(cur, cur.pit(), 0);
-               cur.buffer()->updateLabels();
+               cur.buffer()->updateBuffer();
                needsUpdate = true;
                break;
 
        case LFUN_OUTLINE_DOWN:
                outline(OutlineDown, cur);
                setCursor(cur, cur.pit(), 0);
-               cur.buffer()->updateLabels();
+               cur.buffer()->updateBuffer();
                needsUpdate = true;
                break;
 
        case LFUN_OUTLINE_IN:
                outline(OutlineIn, cur);
-               cur.buffer()->updateLabels();
+               cur.buffer()->updateBuffer();
                needsUpdate = true;
                break;
 
        case LFUN_OUTLINE_OUT:
                outline(OutlineOut, cur);
-               cur.buffer()->updateLabels();
+               cur.buffer()->updateBuffer();
                needsUpdate = true;
                break;
 
@@ -2279,11 +2275,24 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                // not allowed in description items
                enable = !inDescriptionItem(cur);
                break;
-       case LFUN_FLOAT_LIST_INSERT:
+       case LFUN_FLOAT_LIST_INSERT: {
                code = FLOAT_LIST_CODE;
                // not allowed in description items
                enable = !inDescriptionItem(cur);
+               if (enable) {
+                       FloatList const & floats = cur.buffer()->params().documentClass().floats();
+                       FloatList::const_iterator cit = floats[to_ascii(cmd.argument())];
+                       // make sure we know about such floats
+                       if (cit == floats.end() ||
+                                       // and that we know how to generate a list of them
+                           (!cit->second.needsFloatPkg() && cit->second.listCommand().empty())) {
+                               flag.unknown(true);
+                               // probably not necessary, but...
+                               enable = false;
+                       }
+               }
                break;
+       }
        case LFUN_CAPTION_INSERT:
                code = CAPTION_CODE;
                // not allowed in description items