]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetspecialchar.C
reformatting and remove using delc
[lyx.git] / src / insets / insetspecialchar.C
index f8705ec5120ac0511c7ac66e6007d040c5ce1c50..9f404779675684c96f7ab0c4604f0ef4ef56b5e5 100644 (file)
@@ -16,6 +16,7 @@
 #include "insetspecialchar.h"
 #include "debug.h"
 #include "LaTeXFeatures.h"
+#include "BufferView.h"
 #include "Painter.h"
 #include "font.h"
 
@@ -27,19 +28,19 @@ InsetSpecialChar::InsetSpecialChar(Kind k)
 {}
 
 
-int InsetSpecialChar::ascent(Painter &, LyXFont const & font) const
+int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxAscent(font);
 }
 
 
-int InsetSpecialChar::descent(Painter &, LyXFont const & font) const
+int InsetSpecialChar::descent(BufferView *, LyXFont const & font) const
 {
        return lyxfont::maxDescent(font);
 }
 
 
-int InsetSpecialChar::width(Painter &, LyXFont const & font) const
+int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
 {
        switch (kind) {
        case HYPHENATION:
@@ -71,30 +72,32 @@ int InsetSpecialChar::width(Painter &, LyXFont const & font) const
 }
 
 
-void InsetSpecialChar::draw(Painter & pain, LyXFont const & f,
-                           int baseline, float & x) const
+void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
+                           int baseline, float & x, bool) const
 {
+       Painter & pain = bv->painter();
        LyXFont font(f);
+
        switch (kind) {
        case HYPHENATION:
        {
                font.setColor(LColor::special);
                pain.text(int(x), baseline, "-", font);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case END_OF_SENTENCE:
        {
                font.setColor(LColor::special);
                pain.text(int(x), baseline, ".", font);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case LDOTS:
        {
                font.setColor(LColor::special);
                pain.text(int(x), baseline, ". . .", font);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case MENU_SEPARATOR:
@@ -111,12 +114,12 @@ void InsetSpecialChar::draw(Painter & pain, LyXFont const & f,
                xp[3] = ox;     yp[3] = baseline;
                
                pain.lines(xp, yp, 4, LColor::special);
-               x += width(pain, font);
+               x += width(bv, font);
                break;
        }
        case PROTECTED_SEPARATOR:
        {
-               float w = width(pain, font);
+               float w = width(bv, font);
                int h = lyxfont::ascent('x', font);
                int xp[4], yp[4];
                
@@ -141,7 +144,7 @@ void InsetSpecialChar::draw(Painter & pain, LyXFont const & f,
 
 
 // In lyxf3 this will be just LaTeX
-void InsetSpecialChar::Write(ostream & os) const
+void InsetSpecialChar::Write(Buffer const *, ostream & os) const
 {
        string command;
        switch (kind) {
@@ -150,14 +153,16 @@ void InsetSpecialChar::Write(ostream & os) const
        case LDOTS:             command = "\\ldots{}";  break;
        case MENU_SEPARATOR:    command = "\\menuseparator"; break;
        case PROTECTED_SEPARATOR:
-                               command = "\\protected_separator";          break;
+               //command = "\\protected_separator";
+               command = "~";
+               break;
        }
        os << "\\SpecialChar " << command << "\n";
 }
 
 
 // This function will not be necessary when lyx3
-void InsetSpecialChar::Read(LyXLex & lex)
+void InsetSpecialChar::Read(Buffer const *, LyXLex & lex)
 {    
        lex.nextToken();
        string command = lex.GetString();
@@ -170,14 +175,15 @@ void InsetSpecialChar::Read(LyXLex & lex)
                kind = LDOTS;
        else if (command == "\\menuseparator")
                kind = MENU_SEPARATOR;
-       else if (command == "\\protected_separator")
+       else if (command == "\\protected_separator"
+                || command == "~")
                kind = PROTECTED_SEPARATOR;
        else
                lex.printError("InsetSpecialChar: Unknown kind: `$$Token'");
 }
 
 
-int InsetSpecialChar::Latex(ostream & os, bool /*fragile*/,
+int InsetSpecialChar::Latex(Buffer const *, ostream & os, bool /*fragile*/,
                            bool free_space) const
 {
        switch (kind) {
@@ -190,12 +196,11 @@ int InsetSpecialChar::Latex(ostream & os, bool /*fragile*/,
        return 0;
 }
 
-
-int InsetSpecialChar::Linuxdoc(ostream & os) const
+int InsetSpecialChar::Ascii(Buffer const *, ostream & os, int) const
 {
        switch (kind) {
-       case HYPHENATION:         os << "";     break;
-       case END_OF_SENTENCE:     os << "";     break;
+       case HYPHENATION:                       break;
+       case END_OF_SENTENCE:     os << ".";    break;
        case LDOTS:               os << "...";  break;
        case MENU_SEPARATOR:      os << "->";   break;
        case PROTECTED_SEPARATOR: os << " ";   break;
@@ -204,20 +209,19 @@ int InsetSpecialChar::Linuxdoc(ostream & os) const
 }
 
 
-int InsetSpecialChar::DocBook(ostream & os) const
+int InsetSpecialChar::Linuxdoc(Buffer const * buf, ostream & os) const
 {
-       switch (kind) {
-       case HYPHENATION:         os << "";     break;
-       case END_OF_SENTENCE:     os << "";     break;
-       case LDOTS:               os << "...";  break;
-       case MENU_SEPARATOR:      os << "->";   break;
-       case PROTECTED_SEPARATOR: os << " ";   break;
-       }
-       return 0;
+       return Ascii(buf, os, 0);
+}
+
+
+int InsetSpecialChar::DocBook(Buffer const * buf, ostream & os) const
+{
+       return Ascii(buf, os, 0);
 }
 
 
-Inset * InsetSpecialChar::Clone() const
+Inset * InsetSpecialChar::Clone(Buffer const &) const
 {
        return new InsetSpecialChar(kind);
 }