]> git.lyx.org Git - features.git/commitdiff
remove unneeded function Paragraph::checkInsertChar, fix small bug in boundary handling
authorAndré Pönitz <poenitz@gmx.net>
Sat, 16 Jul 2005 12:02:31 +0000 (12:02 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 16 Jul 2005 12:02:31 +0000 (12:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10240 a592a061-630c-0410-9148-cb99ea01b6c8

src/buffer.C
src/insets/ChangeLog
src/language.C
src/language.h
src/paragraph.C
src/paragraph_funcs.C
src/text.C

index d6c34394d0fac1fa1c032f6b4bc41a2cfd2a9228..76e9de907ab0623ee5621900897781554f6d971b 100644 (file)
@@ -498,7 +498,6 @@ void Buffer::insertStringAsLines(ParagraphList & pars,
 {
        LyXFont font = fn;
 
-       pars[pit].checkInsertChar(font);
        // insert the string, don't insert doublespace
        bool space_inserted = true;
        for (string::const_iterator cit = str.begin();
index c6da67c6d8b388c8e697a49872e005c3b852f2ad..7c52241d38ee55d6dad7470bbb28b803320b5bfb 100644 (file)
 
 2001-07-27  Juergen Vigna  <jug@sad.it>
 
-       * inset.h: remove not used font variable in parameter.
+       * inset.h: remove unused font variable in parameter.
        removed checkInsertChar in UpdatableInset as it was equal to
        the one in Inset and so not needed.
 
index c811aac9a9c5bfe41897eb6425d4f1ec54c4f079..d19ca03c5b85b0a29e17c08ab304a19a2a02708f 100644 (file)
@@ -31,6 +31,7 @@ Language const * ignore_language = &ignore_lang;
 Language latex_lang("latex", "latex", "Latex", false, 0, "latex", "");
 Language const * latex_language = &latex_lang;
 
+
 void Languages::read(string const & filename)
 {
        // We need to set the encoding of latex_lang
@@ -93,11 +94,9 @@ void Languages::read(string const & filename)
                english_language = default_language;
 }
 
+
 Language const * Languages::getLanguage(string const & language) const
 {
        const_iterator it = languagelist.find(language);
-       if (it != languagelist.end())
-               return &it->second;
-       else
-               return 0;
+       return it == languagelist.end() ? 0 : &it->second;
 }
index b0eeff259dd3c62a8ee9d2007b785d920051f2bd..5e75174820de5b1ee5f2600235d467bd80cc264c 100644 (file)
@@ -25,42 +25,28 @@ class Encoding;
 class Language {
 public:
        ///
-       Language() : RightToLeft_(false) {}
+       Language() : rightToLeft_(false) {}
        ///
        Language(std::string const & l, std::string const & b, std::string const & d,
                 bool rtl, Encoding const * e, std::string const & c,
                 std::string const & o)
-               : lang_(l), babel_(b), display_(d), RightToLeft_(rtl),
+               : lang_(l), babel_(b), display_(d), rightToLeft_(rtl),
                  encoding_(e), code_(c), latex_options_(o)
                {}
        ///
-       std::string const & lang() const {
-               return lang_;
-       }
+       std::string const & lang() const { return lang_; }
        ///
-       std::string const & babel() const {
-               return babel_;
-       }
+       std::string const & babel() const { return babel_; }
        ///
-       std::string const & display() const {
-               return display_;
-       }
+       std::string const & display() const { return display_; }
        ///
-       bool RightToLeft() const {
-               return RightToLeft_;
-       }
+       bool RightToLeft() const { return rightToLeft_; }
        ///
-       Encoding const * encoding() const {
-               return encoding_;
-       }
+       Encoding const * encoding() const { return encoding_; }
        ///
-       std::string const & code() const {
-               return code_;
-       }
+       std::string const & code() const { return code_; }
        ///
-       std::string const & latex_options() const {
-               return latex_options_;
-       }
+       std::string const & latex_options() const { return latex_options_; }
 private:
        ///
        std::string lang_;
@@ -69,7 +55,7 @@ private:
        ///
        std::string display_;
        ///
-       bool RightToLeft_;
+       bool rightToLeft_;
        ///
        Encoding const * encoding_;
        ///
@@ -92,17 +78,11 @@ public:
        ///
        Language const * getLanguage(std::string const & language) const;
        ///
-       size_type size() const {
-               return languagelist.size();
-       }
+       size_type size() const { return languagelist.size(); }
        ///
-       const_iterator begin() const {
-               return languagelist.begin();
-       }
+       const_iterator begin() const { return languagelist.begin(); }
        ///
-       const_iterator end() const {
-               return languagelist.end();
-       }
+       const_iterator end() const { return languagelist.end(); }
        ///
 
 private:
index 38d5763ec96963d04e6a6e679bae0bf188312899..bf272458c4a03ba8ce7488f9a5bb207da760fd13 100644 (file)
@@ -260,18 +260,11 @@ int Paragraph::erase(pos_type start, pos_type end)
 void Paragraph::insert(pos_type start, string const & str,
                       LyXFont const & font)
 {
-       int size = str.size();
-       for (int i = 0 ; i < size ; ++i)
+       for (size_t i = 0, n = str.size(); i != n ; ++i)
                insertChar(start + i, str[i], font);
 }
 
 
-bool Paragraph::checkInsertChar(LyXFont &)
-{
-       return true;
-}
-
-
 void Paragraph::insertChar(pos_type pos, Paragraph::value_type c,
                           Change change)
 {
index 2cb63eaa3825d355904e093bd8d80879a1be45d6..a43217cc055591222a2b62d954aecafec8812a6d 100644 (file)
@@ -83,8 +83,6 @@ bool moveItem(Paragraph & from, Paragraph & to,
                if (tmpinset)
                        to.insertInset(j, tmpinset, tmpfont, change);
        } else {
-               if (!to.checkInsertChar(tmpfont))
-                       return false;
                to.insertChar(j, tmpchar, tmpfont, change);
        }
        return true;
index 45ffe8dc6a5328b276a960d9d38b55a1078ce99d..33df190840e42069595c6e0d47cdf6797833153a 100644 (file)
@@ -424,14 +424,15 @@ int LyXText::singleWidth(Paragraph const & par,
 
        // The most common case is handled first (Asger)
        if (IsPrintable(c)) {
-               if (font.language()->RightToLeft()) {
+               Language const * language = font.language();
+               if (language->RightToLeft()) {
                        if ((lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
                             lyxrc.font_norm_type == LyXRC::ISO_10646_1)
-                           && font.language()->lang() == "arabic") {
+                           && language->lang() == "arabic") {
                                if (Encodings::IsComposeChar_arabic(c))
                                        return 0;
                                c = par.transformChar(c, pos);
-                       } else if (font.language()->lang() == "hebrew" &&
+                       } else if (language->lang() == "hebrew" &&
                                   Encodings::IsComposeChar_hebrew(c))
                                return 0;
                }
@@ -2066,8 +2067,9 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const
                return 0;
 
        pos_type ppos = sl.pos();
-       //// Correct position in front of big insets
-       if (ppos && boundary)
+       // Correct position in front of big insets
+       bool const boundary_correction = ppos != 0 && boundary;
+       if (boundary_correction)
                --ppos;
 
        Row const & row = par.getRow(ppos);
@@ -2108,22 +2110,16 @@ int LyXText::cursorX(CursorSlice const & sl, bool boundary) const
                                x -= singleWidth(par, body_pos - 1);
                }
 
-               if (hfillExpansion(par, row, pos)) {
-                       x += singleWidth(par, pos);
-                       if (pos >= body_pos)
-                               x += m.hfill;
-                       else
-                               x += m.label_hfill;
-               } else if (par.isSeparator(pos)) {
-                       x += singleWidth(par, pos);
-                       if (pos >= body_pos)
-                               x += m.separator;
-               } else
-                       x += singleWidth(par, pos);
+               x += singleWidth(par, pos);
+
+               if (hfillExpansion(par, row, pos))
+                       x += (pos >= body_pos) ? m.hfill : m.label_hfill;
+               else if (par.isSeparator(pos) && pos >= body_pos)
+                       x += m.separator;
        }
        
        // see correction above
-       if (ppos && boundary)
+       if (boundary_correction)
                x += singleWidth(par, ppos);
 
        return int(x);