]> git.lyx.org Git - features.git/commitdiff
activate the new InsetHFill,
authorAndré Pönitz <poenitz@gmx.net>
Tue, 11 Mar 2003 15:01:29 +0000 (15:01 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 11 Mar 2003 15:01:29 +0000 (15:01 +0000)
small ws

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6448 a592a061-630c-0410-9148-cb99ea01b6c8

14 files changed:
src/buffer.C
src/insets/insetert.C
src/insets/insethfill.h
src/insets/insetquotes.C
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/lyxlayout.C
src/paragraph.C
src/paragraph.h
src/paragraph_pimpl.C
src/sgml.C
src/support/textutils.h
src/text.C
src/text3.C

index 8b55fbeccadf59870e981b9c4b0668827d214e80..cc6ad28eaa1a791922f6294af4d0fda59d2df943 100644 (file)
@@ -49,6 +49,7 @@
 
 #include "insets/inset.h"
 #include "insets/inseterror.h"
+#include "insets/insethfill.h"
 #include "insets/insetlabel.h"
 #include "insets/insetref.h"
 #include "insets/inseturl.h"
@@ -966,7 +967,8 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
                par->insertInset(pos, inset, font, current_change);
                ++pos;
        } else if (token == "\\hfill") {
-               par->insertChar(pos, Paragraph::META_HFILL, font, current_change);
+               par->insertInset(pos, new InsetHFill(),
+                       LyXFont(LyXFont::ALL_INHERIT, params.language));
                ++pos;
        } else if (token == "\\change_unchanged") {
                // Hack ! Needed for empty paragraphs :/
@@ -1617,19 +1619,12 @@ string const Buffer::asciiParagraph(Paragraph const & par,
                        }
                        break;
 
-               case Paragraph::META_HFILL:
-                       buffer << word << "\t";
-                       currlinelen += word.length() + 1;
-                       word.erase();
-                       break;
-
                default:
                        if (c == ' ') {
                                if (linelen > 0 &&
                                    currlinelen + word.length() > linelen - 10) {
                                        buffer << "\n";
-                                       pair<int, string> p =
-                                               addDepth(depth, ltype_depth);
+                                       pair<int, string> p = addDepth(depth, ltype_depth);
                                        buffer << p.second;
                                        currlinelen = p.first;
                                }
index 78783ecde0b69d331963d515bb3fc7e8f81efa38..c4107c93a6ab1e2c0f5d3f3b56bf31bc0328c682 100644 (file)
@@ -208,7 +208,6 @@ void InsetERT::write(Buffer const * buf, ostream & os) const
                        Paragraph::value_type c = par->getChar(i);
                        switch (c) {
                        case Paragraph::META_INSET:
-                       case Paragraph::META_HFILL:
                                lyxerr << "Element is not allowed in insertERT"
                                       << endl;
                        case Paragraph::META_NEWLINE:
index 27df19a00447084e76cb7f12c8bb733dfc19465d..071761c4fee9b4babe5fcd93618a056deab4d3f4 100644 (file)
@@ -33,6 +33,8 @@ public:
        int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        void write(Buffer const * buf, ostream & os) const;
+       /// We don't need \begin_inset and \end_inset
+       bool directWrite() const { return true; }
 };
 
 #endif
index fe90f3e5639329cc1541e2e788149f5bd1a221a6..dfb1051a75c96be40dd84d9cea210aeaff148c4f 100644 (file)
@@ -86,7 +86,7 @@ InsetQuotes::InsetQuotes(char c, BufferParams const & params)
        // Decide whether left or right
        switch (c) {
        case ' ': case '(':
-       case Paragraph::META_HFILL:
+       //case Paragraph::META_HFILL:
        case Paragraph::META_NEWLINE:
                side_ = LeftQ;   // left quote
                break;
index dcf2f1a065db148b39ffd3120db6cae03192dc2c..510dee9f442fa4b82366fa213aa8865887aa92a5 100644 (file)
@@ -35,6 +35,7 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
        return kind_;
 }
 
+
 int InsetSpecialChar::ascent(BufferView *, LyXFont const & font) const
 {
        return font_metrics::maxAscent(font);
index 9b9956775b63785d8cde2301ac55f022233f9dce..79ced1f07db94350b24386bddae82a17fd937a8e 100644 (file)
@@ -71,15 +71,9 @@ public:
        ///
        virtual Inset * clone(Buffer const &, bool same_id = false) const;
        ///
-       Inset::Code lyxCode() const
-       {
-               return Inset::SPECIALCHAR_CODE;
-       }
+       Inset::Code lyxCode() const { return Inset::SPECIALCHAR_CODE; }
        /// We don't need \begin_inset and \end_inset
-       bool directWrite() const
-       {
-               return true;
-       };
+       bool directWrite() const { return true; }
        ///
        void validate(LaTeXFeatures &) const;
 
index 80e280b1577011124ebe46152a99a0d3602c5836..2f815aa162851979c017da2dc9d0b58d699e989b 100644 (file)
@@ -529,7 +529,7 @@ void LyXLayout::readLabelType(LyXLex & lexrc)
        keyword_item labelTypeTags[] = {
        { "bibliography",             LA_BIBLIO },
        { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
-       { "counter_chapter",          LA_COUNTER_CHAPTER },
+       { "counter_chapter",          LA_COUNTER_CHAPTER },
        { "counter_enumi",            LA_COUNTER_ENUMI },
        { "counter_enumii",           LA_COUNTER_ENUMII },
        { "counter_enumiii",          LA_COUNTER_ENUMIII },
@@ -544,7 +544,7 @@ void LyXLayout::readLabelType(LyXLex & lexrc)
        { "sensitive",                LA_SENSITIVE },
        { "static",                   LA_STATIC },
        { "top_environment",          LA_TOP_ENVIRONMENT }
-};
+       };
 
        pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
        int le = lexrc.lex();
index 730c68be39fd47f9d26319671be24dd26b4ba67c..7e8470af8f98420f7181ae931206b9f8d76666af 100644 (file)
@@ -265,10 +265,6 @@ void Paragraph::write(Buffer const * buf, ostream & os,
                        os << "\n\\newline \n";
                        column = 0;
                        break;
-               case META_HFILL:
-                       os << "\n\\hfill \n";
-                       column = 0;
-                       break;
                case '\\':
                        os << "\n\\backslash \n";
                        column = 0;
@@ -433,7 +429,6 @@ void Paragraph::insertInset(pos_type pos, Inset * inset, LyXFont const & font, C
 bool Paragraph::insetAllowed(Inset::Code code)
 {
        //lyxerr << "Paragraph::InsertInsetAllowed" << endl;
-
        if (pimpl_->inset_owner)
                return pimpl_->inset_owner->insetAllowed(code);
        return true;
@@ -443,7 +438,6 @@ bool Paragraph::insetAllowed(Inset::Code code)
 Inset * Paragraph::getInset(pos_type pos)
 {
        lyx::Assert(pos < size());
-
        return insetlist.get(pos);
 }
 
@@ -451,7 +445,6 @@ Inset * Paragraph::getInset(pos_type pos)
 Inset const * Paragraph::getInset(pos_type pos) const
 {
        lyx::Assert(pos < size());
-
        return insetlist.get(pos);
 }
 
@@ -470,11 +463,11 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
        }
 
        LyXFont retfont;
-       if (cit != end) {
+       if (cit != end)
                retfont = cit->font();
-       } else if (pos == size() && !empty()) {
+       else if (pos == size() && !empty())
                retfont = getFontSettings(bparams, pos - 1);
-       else
+       else
                retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
 
        return retfont;
@@ -1291,7 +1284,8 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
 
 bool Paragraph::isHfill(pos_type pos) const
 {
-       return IsHfillChar(getChar(pos));
+       return IsInsetChar(getChar(pos))
+                                       && getInset(pos)->lyxCode() == Inset::HFILL_CODE;
 }
 
 
@@ -1424,25 +1418,22 @@ string const Paragraph::asString(Buffer const * buffer, bool label) const
 string const Paragraph::asString(Buffer const * buffer,
                                 pos_type beg, pos_type end, bool label) const
 {
-       ostringstream ost;
+       ostringstream os;
 
        if (beg == 0 && label && !params().labelString().empty())
-               ost << params().labelString() << ' ';
+               os << params().labelString() << ' ';
 
        for (pos_type i = beg; i < end; ++i) {
                value_type const c = getUChar(buffer->params, i);
                if (IsPrintable(c))
-                       ost << c;
+                       os << c;
                else if (c == META_NEWLINE)
-                       ost << '\n';
-               else if (c == META_HFILL)
-                       ost << '\t';
-               else if (c == META_INSET) {
-                       getInset(i)->ascii(buffer, ost);
-               }
+                       os << '\n';
+               else if (c == META_INSET) 
+                       getInset(i)->ascii(buffer, os);
        }
 
-       return STRCONV(ost.str());
+       return STRCONV(os.str());
 }
 
 
@@ -1451,10 +1442,9 @@ void Paragraph::setInsetOwner(Inset * i)
        pimpl_->inset_owner = i;
        InsetList::iterator it = insetlist.begin();
        InsetList::iterator end = insetlist.end();
-       for (; it != end; ++it) {
+       for (; it != end; ++it) 
                if (it.getInset())
                        it.getInset()->setOwner(i);
-       }
 }
 
 
index dfbc8d226b430ca297517b18e15bc2074ff562da..7ffac04de6c137a66dfae74b1d1639f94f643b4d 100644 (file)
@@ -40,9 +40,7 @@ public:
        ///
        enum META_KIND {
                ///
-               META_HFILL = 1,
-               ///
-               META_NEWLINE,
+               META_NEWLINE = 2,
                ///
                META_INSET
        };
index 2e2098439908787eebe3025d7403fa716a30f440..0db77625212f0b4110dab3c7035318472726f262 100644 (file)
@@ -497,9 +497,11 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                                             value_type const c)
 {
        if (style.pass_thru) {
-               if (c != '\0') os << c;
+               if (c != '\0')
+                       os << c;
                return;
        }
+
        // Two major modes:  LaTeX or plain
        // Handle here those cases common to both modes
        // and then split to handle the two modes separately.
@@ -574,11 +576,6 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                running_font = basefont;
                break;
 
-       case Paragraph::META_HFILL:
-               os << "\\hfill{}";
-               column += 7;
-               break;
-
        default:
                // And now for the special cases within each mode
 
index 435d71cc13cf8a57a94337d87ef17c35307d1c36..e8b6f825f0144cba388a67c2a2b5bdc733eef0e7 100644 (file)
@@ -26,8 +26,6 @@ pair<bool, string> escapeChar(char c)
        string str;
 
        switch (c) {
-       case Paragraph::META_HFILL:
-               break;
        case Paragraph::META_NEWLINE:
                str = '\n';
                break;
index 3a239da1337bb6723ddcee61aa7ae978f1148ed6..fe07ee7c2c910930b191b415fa7932b09cb10309 100644 (file)
@@ -39,14 +39,6 @@ bool IsLineSeparatorChar(char c)
 }
 
 
-/// return true if the char is a meta-character for hfill
-inline
-bool IsHfillChar(char c)
-{
-       return (c == Paragraph::META_HFILL);
-}
-
-
 /// return true if the char is a meta-character for an inset
 inline
 bool IsInsetChar(char c)
@@ -119,7 +111,6 @@ bool IsWordChar(unsigned char c)
 {
        return !(IsSeparatorChar(c)
                  || IsKommaChar(c)
-                 || IsHfillChar(c)
                  || IsInsetChar(c));
 }
 
index f0e98d86fa4b4e4db234c2e3c61c7f8309793461..4515e9ff2c483bd7f54c0f2353b3ba3dde9a55ac 100644 (file)
@@ -221,23 +221,26 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
                if (font.language()->RightToLeft()) {
                        if (font.language()->lang() == "arabic" &&
                            (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
-                            lyxrc.font_norm_type == LyXRC::ISO_10646_1))
+                            lyxrc.font_norm_type == LyXRC::ISO_10646_1)) {
                                if (Encodings::IsComposeChar_arabic(c))
                                        return 0;
                                else
                                        c = transformChar(c, par, pos);
-                       else if (font.language()->lang() == "hebrew" &&
+                       else if (font.language()->lang() == "hebrew" &&
                                 Encodings::IsComposeChar_hebrew(c))
                                return 0;
                }
                return font_metrics::width(c, font);
 
-       } else if (IsHfillChar(c)) {
-               // Because of the representation as vertical lines
-               return 3;
-       } else if (c == Paragraph::META_INSET) {
+       }
+
+       if (c == Paragraph::META_INSET) {
                Inset * tmpinset = par->getInset(pos);
                if (tmpinset) {
+                       if (tmpinset->lyxCode() == Inset::HFILL_CODE) {
+                               // Because of the representation as vertical lines
+                               return 3;
+                       }
 #if 1
                        // this IS needed otherwise on initialitation we don't get the fill
                        // of the row right (ONLY on initialization if we read a file!)
@@ -245,10 +248,11 @@ int LyXText::singleWidth(BufferView * bview, Paragraph * par,
                        tmpinset->update(bview, font);
 #endif
                        return tmpinset->width(bview, font);
-               } else
-                       return 0;
+               }
+               return 0;
+       }
 
-       } else if (IsSeparatorChar(c))
+       if (IsSeparatorChar(c))
                c = ' ';
        else if (IsNewlineChar(c))
                c = 'n';
@@ -2311,7 +2315,7 @@ void LyXText::changeCase(BufferView & bview, LyXText::TextCase action)
                        continue;
                }
                unsigned char c = par->getChar(pos);
-               if (!IsInsetChar(c) && !IsHfillChar(c)) {
+               if (!IsInsetChar(c)) {
                        switch (action) {
                        case text_lowercase:
                                c = lowercase(c);
index 0ac114e8ba32b109fb809ab9c29da64454480cfe..e0a72562581c68cf4247e541192447155bced48d 100644 (file)
@@ -949,13 +949,6 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
                specialChar(this, bv, InsetSpecialChar::LDOTS);
                break;
 
-       case LFUN_HFILL:
-               bv->hideCursor();
-               update(bv, false);
-               insertChar(bv, Paragraph::META_HFILL);
-               update(bv);
-               break;
-
        case LFUN_END_OF_SENTENCE:
                specialChar(this, bv, InsetSpecialChar::END_OF_SENTENCE);
                break;
@@ -1617,6 +1610,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_INDEX_PRINT:
        case LFUN_PARENTINSERT:
        case LFUN_TOC_INSERT:
+       case LFUN_HFILL:
                // do nothing fancy
                doInsertInset(this, cmd, false, false);
                break;