]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetlatexaccent.C
The speed patch: redraw only rows that have changed
[lyx.git] / src / insets / insetlatexaccent.C
index 95a3ffc3de8ebb5ad4bb5773c54125aa1aed69eb..f5a9fac5ec4205695b9827e983f3a935517f100f 100644 (file)
@@ -49,7 +49,7 @@ InsetLatexAccent::InsetLatexAccent(string const & str)
 }
 
 
-auto_ptr<InsetBase> InsetLatexAccent::clone() const
+auto_ptr<InsetBase> InsetLatexAccent::doClone() const
 {
        return auto_ptr<InsetBase>(new InsetLatexAccent(contents));
 }
@@ -65,44 +65,7 @@ void InsetLatexAccent::checkContents()
                return;
        }
 
-       // REMOVE IN 0.13
-       // Dirty Hack for backward compability. remove in 0.13 (Lgb)
        contents = trim(contents);
-       if (!contains(contents, '{') && !contains(contents, '}')) {
-               if (contents.length() == 2) {
-                       string tmp;
-                       tmp += contents[0];
-                       tmp += contents[1];
-                       tmp += "{}";
-                       contents = tmp;
-               } else if (contents.length() == 3) {
-                       string tmp;
-                       tmp += contents[0];
-                       tmp += contents[1];
-                       tmp += '{';
-                       tmp += contents[2];
-                       tmp += '}';
-                       contents = tmp;
-               } else if (contents.length() == 4 && contents[2] == ' ') {
-                       string tmp;
-                       tmp += contents[0];
-                       tmp += contents[1];
-                       tmp += '{';
-                       tmp += contents[3];
-                       tmp += '}';
-                       contents = tmp;
-               } else if  (contents.length() == 4 && contents[2] == '\\'
-                           && (contents[3] == 'i' || contents[3] == 'j')) {
-                       string tmp;
-                       tmp += contents[0];
-                       tmp += contents[1];
-                       tmp += '{';
-                       tmp += contents[2];
-                       tmp += contents[3];
-                       tmp += '}';
-                       contents = tmp;
-               }
-       }
        if (contents[0] != '\\') { // demand that first char is a '\\'
                lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl;
                return;
@@ -203,7 +166,7 @@ void InsetLatexAccent::checkContents()
                break;
        default:
                lyxerr[Debug::KEY] << "Default" << endl;
-               // unknow accent (or something else)
+               // unknown accent (or something else)
                return;
        }
 
@@ -327,33 +290,33 @@ bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const
        switch (modtype) {
 
        case CEDILLA: {
-               if (ic == 'c') tmpic = 0xe7;
-               if (ic == 'C') tmpic = 0xc7;
-               if (ic == 's') tmpic = 0xfe;
-               if (ic == 'S') tmpic = 0xde;
+               if (ic == 'c') tmpic = '\xe7';
+               if (ic == 'C') tmpic = '\xc7';
+               if (ic == 's') tmpic = '\xfe';
+               if (ic == 'S') tmpic = '\xde';
                break;
        }
 
        case BREVE: {
-               if (ic == 'g') tmpic = 0xf0;
-               if (ic == 'G') tmpic = 0xd0;
+               if (ic == 'g') tmpic = '\xf0';
+               if (ic == 'G') tmpic = '\xd0';
                break;
        }
 
        case UMLAUT: {
-               if (ic == 'o') tmpic = 0xf6;
-               if (ic == 'O') tmpic = 0xd6;
-               if (ic == 'u') tmpic = 0xfc;
-               if (ic == 'U') tmpic = 0xdc;
+               if (ic == 'o') tmpic = '\xf6';
+               if (ic == 'O') tmpic = '\xd6';
+               if (ic == 'u') tmpic = '\xfc';
+               if (ic == 'U') tmpic = '\xdc';
                break;
        }
 
        case DOT:
-               if (ic == 'I') tmpic = 0xdd;
+               if (ic == 'I') tmpic = '\xdd';
                break;
 
        case DOT_LESS_I:
-               tmpic = 0xfd;
+               tmpic = '\xfd';
                break;
 
        default:
@@ -444,30 +407,34 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
                // now the rest - draw within (x, y, x + wid, y + hg)
                switch (modtype) {
                case ACUTE:
-                       drawAccent(pi, x2, baseline, char(0xB4));
+                       drawAccent(pi, x2, baseline, '\xB4');
                        break;
 
                case GRAVE:
-                       drawAccent(pi, x2, baseline, char(0x60));
+                       drawAccent(pi, x2, baseline, '\x60');
                        break;
 
                case MACRON:
-                       drawAccent(pi, x2, baseline, char(0xAF));
+                       drawAccent(pi, x2, baseline, '\xAF');
                        break;
 
                case TILDE:
                        drawAccent(pi, x2, baseline, '~');
                        break;
 
-               case UNDERBAR:     // underbar 0x5F
-                       pi.pain.text(x2 - font_metrics::center(0x5F, font), baseline,
-                                 char(0x5F), font);
+               case UNDERBAR: {
+                       char const underbar('\x5F');
+                       pi.pain.text(x2 - font_metrics::center(underbar, font),
+                                    baseline, underbar, font);
                        break;
+               }
 
-               case CEDILLA:
-                       pi.pain.text(x2  - font_metrics::center(0xB8, font), baseline,
-                                 char(0xB8), font);
+               case CEDILLA: {
+                       char const cedilla('\xB8');
+                       pi.pain.text(x2  - font_metrics::center(cedilla, font),
+                                    baseline, cedilla, font);
                        break;
+               }
 
                case UNDERDOT:
                        pi.pain.text(x2  - font_metrics::center('.', font),
@@ -480,7 +447,7 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
                        break;
 
                case CIRCLE:
-                       drawAccent(pi, x2, baseline, char(0xB0));
+                       drawAccent(pi, x2, baseline, '\xB0');
                        break;
 
                case TIE:
@@ -531,7 +498,7 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
                        break;
 
                case CIRCUMFLEX:
-                       drawAccent(pi, x2, baseline, 0x5E);
+                       drawAccent(pi, x2, baseline, '\x5E');
                        break;
 
                case OGONEK: {
@@ -634,15 +601,22 @@ int InsetLatexAccent::docbook(Buffer const &, ostream & os,
 }
 
 
+int InsetLatexAccent::textString(Buffer const & buf, ostream & os,
+                      OutputParams const & op) const
+{
+       return plaintext(buf, os, op);
+}
+
+
 bool InsetLatexAccent::directWrite() const
 {
        return true;
 }
 
 
-InsetOld::Code InsetLatexAccent::lyxCode() const
+InsetBase::Code InsetLatexAccent::lyxCode() const
 {
-       return InsetOld::ACCENT_CODE;
+       return InsetBase::ACCENT_CODE;
 }