]> git.lyx.org Git - lyx.git/commitdiff
* support/types.h: introduce the char_type type
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 9 Apr 2006 02:30:40 +0000 (02:30 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 9 Apr 2006 02:30:40 +0000 (02:30 +0000)
* paragraph.h: make value_type point at char_type
* other files: change some bald 'char' to 'char_type'

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

13 files changed:
src/cursor.C
src/cursor.h
src/frontends/Painter.h
src/frontends/font_metrics.h
src/frontends/qt2/QLPainter.C
src/frontends/qt2/qfont_metrics.C
src/lyxtext.h
src/paragraph.C
src/paragraph.h
src/rowpainter.C
src/support/types.h
src/text.C
src/text3.C

index 6556fa25d4c97aa616b2f9d1e4cf1ef8284acd08..0ca25c2d20af868b2824c792038cd73367919867 100644 (file)
@@ -52,6 +52,7 @@
 #include <sstream>
 #include <limits>
 
+using lyx::char_type;
 using lyx::pit_type;
 
 using std::string;
@@ -637,7 +638,7 @@ void LCursor::plainErase()
 
 void LCursor::markInsert()
 {
-       insert(char(0));
+       insert(char_type(0));
 }
 
 
@@ -657,12 +658,12 @@ void LCursor::plainInsert(MathAtom const & t)
 void LCursor::insert(string const & str)
 {
        for_each(str.begin(), str.end(),
-                boost::bind(static_cast<void(LCursor::*)(char)>
+                boost::bind(static_cast<void(LCursor::*)(char_type)>
                             (&LCursor::insert), this, _1));
 }
 
 
-void LCursor::insert(char c)
+void LCursor::insert(char_type c)
 {
        //lyxerr << "LCursor::insert char '" << c << "'" << endl;
        BOOST_ASSERT(!empty());
index d02952f0af2c8cec78a886c812fc9a106c58b641..ae0dcf900bed44bb1bdd0f26bd1b1423ced8ee25 100644 (file)
@@ -112,7 +112,7 @@ public:
        /// insert an inset
        void insert(InsetBase *);
        /// insert a single char
-       void insert(char c);
+       void insert(lyx::char_type c);
        /// insert a string
        void insert(std::string const & str);
 
index c5eaa2d958617b1c323ba5ee55bed36578e71276..668ec4b9b89ab508dc822d0fec7eb26cf3fa6223 100644 (file)
@@ -15,6 +15,8 @@
 
 #include "LColor.h"
 
+#include "support/types.h"
+
 #include <string>
 
 
@@ -152,7 +154,7 @@ public:
 
        /// draw a char at position x, y (y is the baseline)
        virtual void text(int x, int y,
-               char c, LyXFont const & f) = 0;
+                         lyx::char_type c, LyXFont const & f) = 0;
 
        /**
         * Draw a string and enclose it inside a rectangle. If
index 6a83b25d03c23940d56b0049ac76a2e3c25a4b52..4d4a79b83a6d9104c191755cccea50d6c30ae568 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef FONT_METRICS_H
 #define FONT_METRICS_H
 
+#include "support/types.h"
+
 #include <string>
 
 
@@ -51,25 +53,25 @@ namespace font_metrics {
                return maxAscent(f) + maxDescent(f);
        }
        /// return the ascent of the char in the font
-       int ascent(char c, LyXFont const & f);
+       int ascent(lyx::char_type c, LyXFont const & f);
        /// return the descent of the char in the font
-       int descent(char c, LyXFont const & f);
+       int descent(lyx::char_type c, LyXFont const & f);
        /// return the descent of the char in the font
-       inline int height(char c, LyXFont const & f) {
+       inline int height(lyx::char_type c, LyXFont const & f) {
                return ascent(c, f) + descent(c, f);
        }
        /// return the left bearing of the char in the font
-       int lbearing(char c, LyXFont const & f);
+       int lbearing(lyx::char_type c, LyXFont const & f);
        /// return the right bearing of the char in the font
-       int rbearing(char c, LyXFont const & f);
+       int rbearing(lyx::char_type c, LyXFont const & f);
        /// return the inner width of the char in the font
-       inline int center(char c, LyXFont const & f) {
+       inline int center(lyx::char_type c, LyXFont const & f) {
                return (rbearing(c, f) - lbearing(c, f)) / 2;
        }
        /// return the width of the string in the font
        int width(char const * s, size_t n, LyXFont const & f);
        /// return the width of the char in the font
-       inline int width(char c, LyXFont const & f) {
+       inline int width(lyx::char_type c, LyXFont const & f) {
                return width(&c, 1, f);
        }
        /// return the width of the string in the font
index a2da9e221d64a4724df0dc502550b7bc8439b132..2b9f73dbea36f26391ac10c46cb7b59405b80c5e 100644 (file)
@@ -181,7 +181,7 @@ void QLPainter::text(int x, int y, string const & s, LyXFont const & f)
 }
 
 
-void QLPainter::text(int x, int y, char c, LyXFont const & f)
+void QLPainter::text(int x, int y, lyx::char_type c, LyXFont const & f)
 {
        char s[2] = { c, '\0' };
        return text(x, y, s, 1, f);
index ddf640b6fa1d2ddfe2c5adbbb2a3f2853e40721c..1091636c71152729eb9da2d7c16035ae0ba75418 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "language.h"
 
+using lyx::char_type;
 
 using std::string;
 
@@ -42,7 +43,7 @@ int maxDescent(LyXFont const & f)
 }
 
 
-int ascent(char c, LyXFont const & f)
+int ascent(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
@@ -58,7 +59,7 @@ int ascent(char c, LyXFont const & f)
 }
 
 
-int descent(char c, LyXFont const & f)
+int descent(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
@@ -74,7 +75,7 @@ int descent(char c, LyXFont const & f)
 }
 
 
-int lbearing(char c, LyXFont const & f)
+int lbearing(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
@@ -82,7 +83,7 @@ int lbearing(char c, LyXFont const & f)
 }
 
 
-int rbearing(char c, LyXFont const & f)
+int rbearing(char_type c, LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return 1;
index 14fa58b3cf43337cef25effbe7a17a68d707a92f..dbb957d7746445cfa41a572dd948fe70f14ce799 100644 (file)
@@ -108,7 +108,7 @@ public:
        std::string getStringToIndex(LCursor const & cur);
 
        /// insert a character at cursor position
-       void insertChar(LCursor & cur, char c);
+       void insertChar(LCursor & cur, lyx::char_type c);
        /// insert an inset at cursor position
        void insertInset(LCursor & cur, InsetBase * inset);
 
index 7b9ca795fce7b2dc7c50390c25450fccfe64af6b..47ced728e299f56cf12058cb4e98cb7ee75f25cb 100644 (file)
@@ -1816,11 +1816,11 @@ unsigned char Paragraph::transformChar(unsigned char c, pos_type pos) const
                else
                        return c;
 
-       unsigned char const prev_char = pos > 0 ? getChar(pos - 1) : ' ';
-       unsigned char next_char = ' ';
+       value_type const prev_char = pos > 0 ? getChar(pos - 1) : ' ';
+       value_type next_char = ' ';
 
        for (pos_type i = pos + 1, end = size(); i < end; ++i) {
-               unsigned char const par_char = getChar(i);
+               value_type const par_char = getChar(i);
                if (!Encodings::isComposeChar_arabic(par_char)) {
                        next_char = par_char;
                        break;
index f3c3700025dbd9abfca3ba99f5ace62cedcc1cfe..29d499a267768203dc94a496cb05fd4c7d8f545d 100644 (file)
@@ -70,9 +70,10 @@ public:
                /// try getInset() and crash. We should fix
                /// all these places.
                META_INSET = 1
+               //META_INSET = 0x200001  // above 0x10ffff, for ucs-4
        };
        ///
-       typedef char value_type;
+       typedef lyx::char_type value_type;
        ///
        typedef lyx::depth_type depth_type;
        ///
index c49721ef0873c6642dd5db167fe4971dc31884c2..5971b39d4603beb591bacfd7106137449e10d8fe 100644 (file)
@@ -42,6 +42,7 @@
 
 #include <boost/crc.hpp>
 
+using lyx::char_type;
 using lyx::pos_type;
 using lyx::pit_type;
 
@@ -186,7 +187,7 @@ void RowPainter::paintHebrewComposeChar(pos_type & vpos, LyXFont const & font)
        string str;
 
        // first char
-       char c = par_.getChar(pos);
+       char_type c = par_.getChar(pos);
        str += c;
        ++vpos;
 
@@ -219,7 +220,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos, LyXFont const & font)
        string str;
 
        // first char
-       char c = par_.getChar(pos);
+       char_type c = par_.getChar(pos);
        c = par_.transformChar(c, pos);
        str += c;
        ++vpos;
@@ -268,7 +269,7 @@ void RowPainter::paintChars(pos_type & vpos, LyXFont font,
                if (prev_change != par_.lookupChange(pos))
                        break;
 
-               char c = par_.getChar(pos);
+               char_type c = par_.getChar(pos);
 
                if (!isPrintableNonspace(c))
                        break;
@@ -327,7 +328,7 @@ void RowPainter::paintFromPos(pos_type & vpos)
        }
 
        // usual characters, no insets
-       char const c = par_.getChar(pos);
+       char_type const c = par_.getChar(pos);
 
        // special case languages
        std::string const & lang = orig_font.language()->lang();
index cb1de177ac3d12c29b1b85ee2b2d61ebb4619695..48fc219e8fa59d9e65aec4632a687eaacef8f896 100644 (file)
 
 namespace lyx {
 
+       // The type used to hold characters in paragraphs
+       //typedef uint32_t char_type; // Possibly the ucs-4 type we will use
+       //typedef wchar_t char_type;  // The wide char type CJK-LyX uses
+       typedef char char_type;       // Current narrow char type in use
+
+
        /// a type for positions used in paragraphs
        // needs to be signed for a while to hold the special value -1 that is
        // used there
index 937463fedd8f13f3b72b63f9f368a4b9d5c25137..82b09282884943399eca4a8698ec985dfb6eec1a 100644 (file)
@@ -75,6 +75,7 @@
 
 #include <sstream>
 
+using lyx::char_type;
 using lyx::pit_type;
 using lyx::pos_type;
 using lyx::word_location;
@@ -424,7 +425,7 @@ int LyXText::singleWidth(Paragraph const & par, pos_type pos) const
 
 
 int LyXText::singleWidth(Paragraph const & par,
-                        pos_type pos, char c, LyXFont const & font) const
+                        pos_type pos, char_type c, LyXFont const & font) const
 {
        // The most common case is handled first (Asger)
        if (isPrintable(c)) {
@@ -710,7 +711,7 @@ void LyXText::rowBreakPoint(pit_type const pit, Row & row) const
        pos_type point = end;
        pos_type i = pos;
        for ( ; i < end; ++i, ++fi) {
-               char const c = par.getChar(i);
+               char_type const c = par.getChar(i);
                int thiswidth = singleWidth(par, i, c, *fi);
 
                // add the auto-hfill from label end to the body
@@ -803,7 +804,7 @@ void LyXText::setRowWidth(pit_type const pit, Row & row) const
                                        w -= singleWidth(par, i - 1);
                                w = max(w, labelEnd(pit));
                        }
-                       char const c = par.getChar(i);
+                       char_type const c = par.getChar(i);
                        w += singleWidth(par, i, c, *fi);
                }
        }
@@ -1112,7 +1113,7 @@ void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
 
 // insert a character, moves all the following breaks in the
 // same Paragraph one to the right and make a rebreak
-void LyXText::insertChar(LCursor & cur, char c)
+void LyXText::insertChar(LCursor & cur, char_type c)
 {
        BOOST_ASSERT(this == cur.text());
        BOOST_ASSERT(c != Paragraph::META_INSET);
@@ -1145,7 +1146,7 @@ void LyXText::insertChar(LCursor & cur, char c)
                        number(cur); // Set current_font.number to ON
 
                        if (cur.pos() != 0) {
-                               char const c = par.getChar(cur.pos() - 1);
+                               char_type const c = par.getChar(cur.pos() - 1);
                                if (contains(number_unary_operators, c) &&
                                    (cur.pos() == 1
                                     || par.isSeparator(cur.pos() - 2)
@@ -1552,7 +1553,7 @@ void LyXText::changeCase(LCursor & cur, LyXText::TextCase action)
                        pos = 0;
                        continue;
                }
-               unsigned char c = pars_[pit].getChar(pos);
+               char_type c = pars_[pit].getChar(pos);
                if (c != Paragraph::META_INSET) {
                        switch (action) {
                        case text_lowercase:
index bf2b02d25bf2478fff572b7b70f92338dd3a3715..2c51c5153e705f3126d60df57413b03c08a4d5d1 100644 (file)
@@ -965,7 +965,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
                lyx::cap::replaceSelection(cur);
                Paragraph & par = cur.paragraph();
                lyx::pos_type pos = cur.pos();
-               char c;
+               lyx::char_type c;
                if (pos == 0)
                        c = ' ';
                else if (cur.prevInset() && cur.prevInset()->isSpace())