mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-22 16:37:28 +00:00
* support/types.h: introduce the char_type type
* 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
This commit is contained in:
parent
cf4293824f
commit
618ca28af6
@ -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());
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
///
|
||||
|
@ -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();
|
||||
|
@ -20,6 +20,12 @@
|
||||
|
||||
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
|
||||
|
13
src/text.C
13
src/text.C
@ -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:
|
||||
|
@ -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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user