#include <sstream>
#include <limits>
+using lyx::char_type;
using lyx::pit_type;
using std::string;
void LCursor::markInsert()
{
- insert(char(0));
+ insert(char_type(0));
}
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());
/// 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);
#include "LColor.h"
+#include "support/types.h"
+
#include <string>
/// 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
#ifndef FONT_METRICS_H
#define FONT_METRICS_H
+#include "support/types.h"
+
#include <string>
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
}
-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);
#include "language.h"
+using lyx::char_type;
using std::string;
}
-int ascent(char c, LyXFont const & f)
+int ascent(char_type c, LyXFont const & f)
{
if (!lyx_gui::use_gui)
return 1;
}
-int descent(char c, LyXFont const & f)
+int descent(char_type c, LyXFont const & f)
{
if (!lyx_gui::use_gui)
return 1;
}
-int lbearing(char c, LyXFont const & f)
+int lbearing(char_type c, LyXFont const & f)
{
if (!lyx_gui::use_gui)
return 1;
}
-int rbearing(char c, LyXFont const & f)
+int rbearing(char_type c, LyXFont const & f)
{
if (!lyx_gui::use_gui)
return 1;
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);
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;
/// 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;
///
#include <boost/crc.hpp>
+using lyx::char_type;
using lyx::pos_type;
using lyx::pit_type;
string str;
// first char
- char c = par_.getChar(pos);
+ char_type c = par_.getChar(pos);
str += c;
++vpos;
string str;
// first char
- char c = par_.getChar(pos);
+ char_type c = par_.getChar(pos);
c = par_.transformChar(c, pos);
str += c;
++vpos;
if (prev_change != par_.lookupChange(pos))
break;
- char c = par_.getChar(pos);
+ char_type c = par_.getChar(pos);
if (!isPrintableNonspace(c))
break;
}
// 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();
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
#include <sstream>
+using lyx::char_type;
using lyx::pit_type;
using lyx::pos_type;
using lyx::word_location;
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)) {
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
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);
}
}
// 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);
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)
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:
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())