mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
*** empty log message ***
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2626 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
50391b2d7e
commit
3e7bc31d0c
@ -82,6 +82,8 @@ libmathed_la_SOURCES = \
|
||||
math_sizeinset.h \
|
||||
math_spaceinset.C \
|
||||
math_spaceinset.h \
|
||||
math_specialcharinset.C \
|
||||
math_specialcharinset.h \
|
||||
math_sqrtinset.C \
|
||||
math_sqrtinset.h \
|
||||
math_stackrelinset.C \
|
||||
|
@ -14,21 +14,14 @@
|
||||
|
||||
|
||||
MathCharInset::MathCharInset(char c)
|
||||
: char_(c), code_(nativeCode(c)), needbs_(false)
|
||||
: char_(c), code_(nativeCode(c))
|
||||
{
|
||||
//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
|
||||
}
|
||||
|
||||
|
||||
MathCharInset::MathCharInset(char c, MathTextCodes t)
|
||||
: char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t), needbs_(false)
|
||||
{
|
||||
//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
|
||||
}
|
||||
|
||||
|
||||
MathCharInset::MathCharInset(char c, MathTextCodes t, bool needbs)
|
||||
: char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t), needbs_(needbs)
|
||||
: char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
|
||||
{
|
||||
//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
|
||||
}
|
||||
@ -38,8 +31,6 @@ MathTextCodes MathCharInset::nativeCode(char c) const
|
||||
{
|
||||
if (isalpha(c))
|
||||
return LM_TC_VAR;
|
||||
if (strchr("#$%{|}", c))
|
||||
return LM_TC_SPECIAL;
|
||||
//if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
|
||||
return LM_TC_CONST;
|
||||
}
|
||||
@ -100,8 +91,6 @@ void MathCharInset::writeTrailer(std::ostream & os) const
|
||||
|
||||
void MathCharInset::writeRaw(std::ostream & os) const
|
||||
{
|
||||
if (needbs_)
|
||||
os << "\\";
|
||||
os << char_;
|
||||
}
|
||||
|
||||
@ -116,8 +105,6 @@ void MathCharInset::write(std::ostream & os, bool) const
|
||||
|
||||
void MathCharInset::writeNormal(std::ostream & os) const
|
||||
{
|
||||
if (needbs_)
|
||||
os << "\\";
|
||||
os << char_;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,6 @@ public:
|
||||
///
|
||||
MathCharInset(char c, MathTextCodes t);
|
||||
///
|
||||
MathCharInset(char c, MathTextCodes t, bool needbs);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
MathTextCodes nativeCode(char c) const;
|
||||
@ -60,7 +58,5 @@ private:
|
||||
char char_;
|
||||
/// the font to be used on screen
|
||||
MathTextCodes code_;
|
||||
/// do wee need a backslash when writing LaTeX?
|
||||
bool needbs_;
|
||||
};
|
||||
#endif
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "math_matrixinset.h"
|
||||
#include "math_scriptinset.h"
|
||||
#include "math_spaceinset.h"
|
||||
#include "math_specialcharinset.h"
|
||||
#include "math_parser.h"
|
||||
|
||||
using std::endl;
|
||||
@ -1281,6 +1282,11 @@ void MathCursor::interpret(string const & s)
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastcode_ != LM_TC_TEX && strchr("#$%{|}", c)) {
|
||||
insert(new MathSpecialCharInset(c));
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastcode_ == LM_TC_TEX) {
|
||||
if (macroName().empty()) {
|
||||
insert(c, LM_TC_TEX);
|
||||
@ -1299,11 +1305,6 @@ void MathCursor::interpret(string const & s)
|
||||
return;
|
||||
}
|
||||
|
||||
if (c == '{' || c == '}') {
|
||||
niceInsert(new MathCharInset(c, LM_TC_SPECIAL));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isalpha(c) && (lastcode_ == LM_TC_GREEK || lastcode_ == LM_TC_GREEK1)) {
|
||||
static char const greek[26] =
|
||||
{'A', 'B', 'X', 0 , 'E', 0 , 0 , 'H', 'I', 0 ,
|
||||
|
@ -75,8 +75,6 @@ enum MathTextCodes {
|
||||
LM_TC_TEXTRM,
|
||||
/// Math mode TeX characters ",;:{}"
|
||||
LM_TC_TEX,
|
||||
/// Special characters "{}&#_%"
|
||||
LM_TC_SPECIAL,
|
||||
/// Internal code when typing greek
|
||||
LM_TC_GREEK,
|
||||
/// Internal code when typing a single greek character
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "math_notinset.h"
|
||||
#include "math_rootinset.h"
|
||||
#include "math_spaceinset.h"
|
||||
#include "math_specialcharinset.h"
|
||||
#include "math_sqrtinset.h"
|
||||
#include "math_symbolinset.h"
|
||||
#include "math_stackrelinset.h"
|
||||
@ -30,6 +31,8 @@ MathInset * createMathInset(latexkeys const * l)
|
||||
return new MathBigopInset(l);
|
||||
case LM_TK_FUNCLIM:
|
||||
return new MathFuncLimInset(l);
|
||||
case LM_TK_SPECIAL:
|
||||
return new MathSpecialCharInset(l->id);
|
||||
case LM_TK_SYM:
|
||||
return new MathSymbolInset(l);
|
||||
case LM_TK_STACK:
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "math_rootinset.h"
|
||||
#include "math_sqrtinset.h"
|
||||
#include "math_scriptinset.h"
|
||||
#include "math_specialcharinset.h"
|
||||
#include "math_sqrtinset.h"
|
||||
#include "debug.h"
|
||||
#include "support.h"
|
||||
@ -682,18 +683,18 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
}
|
||||
|
||||
else if (t.cat() == catBegin) {
|
||||
array.push_back(new MathCharInset('{', LM_TC_SPECIAL));
|
||||
array.push_back(new MathCharInset('{', LM_TC_TEX));
|
||||
}
|
||||
|
||||
else if (t.cat() == catEnd) {
|
||||
if (flags & FLAG_BRACE_LAST)
|
||||
return;
|
||||
array.push_back(new MathCharInset('}', LM_TC_SPECIAL));
|
||||
array.push_back(new MathCharInset('}', LM_TC_TEX));
|
||||
}
|
||||
|
||||
else if (t.cat() == catAlign) {
|
||||
lyxerr << "found tab unexpectedly, array: '" << array << "'\n";
|
||||
array.push_back(new MathCharInset('&', LM_TC_SPECIAL));
|
||||
array.push_back(new MathCharInset('&', LM_TC_TEX));
|
||||
}
|
||||
|
||||
else if (t.cat() == catSuper)
|
||||
@ -796,7 +797,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
break;
|
||||
|
||||
else LM_TK_SPECIAL:
|
||||
array.push_back(new MathCharInset(ival_, LM_TC_SPECIAL));
|
||||
array.push_back(new MathCharInset(ival_, LM_TC_TEX));
|
||||
break;
|
||||
*/
|
||||
|
||||
@ -849,7 +850,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
int pos;
|
||||
for (pos = array.size() - 1; pos >= 0; --pos) {
|
||||
MathInset * q = array.nextInset(pos);
|
||||
if (q->getChar() == '{' && q->code() == LM_TC_SPECIAL)
|
||||
if (q->getChar() == '{')
|
||||
break;
|
||||
}
|
||||
if (pos >= 0) {
|
||||
|
62
src/mathed/math_specialcharinset.C
Normal file
62
src/mathed/math_specialcharinset.C
Normal file
@ -0,0 +1,62 @@
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "math_specialcharinset.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "support.h"
|
||||
|
||||
|
||||
MathSpecialCharInset::MathSpecialCharInset(char c)
|
||||
: char_(c)
|
||||
{}
|
||||
|
||||
|
||||
MathInset * MathSpecialCharInset::clone() const
|
||||
{
|
||||
return new MathSpecialCharInset(*this);
|
||||
}
|
||||
|
||||
|
||||
int MathSpecialCharInset::ascent() const
|
||||
{
|
||||
return mathed_char_ascent(LM_TC_CONST, size(), char_);
|
||||
}
|
||||
|
||||
|
||||
int MathSpecialCharInset::descent() const
|
||||
{
|
||||
return mathed_char_descent(LM_TC_CONST, size(), char_);
|
||||
}
|
||||
|
||||
|
||||
int MathSpecialCharInset::width() const
|
||||
{
|
||||
return mathed_char_width(LM_TC_CONST, size(), char_);
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::metrics(MathStyles st) const
|
||||
{
|
||||
size_ = st;
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
xo(x);
|
||||
yo(y);
|
||||
drawChar(pain, LM_TC_CONST, size_, x, y, char_);
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::write(std::ostream & os, bool) const
|
||||
{
|
||||
os << "\\" << char_;
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::writeNormal(std::ostream & os) const
|
||||
{
|
||||
os << "\\" << char_;
|
||||
}
|
41
src/mathed/math_specialcharinset.h
Normal file
41
src/mathed/math_specialcharinset.h
Normal file
@ -0,0 +1,41 @@
|
||||
// -*- C++ -*-
|
||||
#ifndef MATH_SPECIALCHARINSET_H
|
||||
#define MATH_SPECIALCHARINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
/** An inset for characters like {, #, and $ that need to be escaped
|
||||
when written out, but can be inserted by a single keystroke
|
||||
\author André Pönitz
|
||||
*/
|
||||
|
||||
class MathSpecialCharInset : public MathInset {
|
||||
public:
|
||||
///
|
||||
explicit MathSpecialCharInset(char c);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathStyles st) const;
|
||||
///
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
void write(std::ostream &, bool fragile) const;
|
||||
///
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
int ascent() const;
|
||||
///
|
||||
int descent() const;
|
||||
///
|
||||
int width() const;
|
||||
|
||||
private:
|
||||
/// the character
|
||||
char char_;
|
||||
};
|
||||
#endif
|
@ -165,7 +165,6 @@ LyXFont WhichFont(MathTextCodes type, MathStyles size)
|
||||
f = Math_Fonts[5];
|
||||
break;
|
||||
|
||||
case LM_TC_SPECIAL: //f = Math_Fonts[0]; break;
|
||||
case LM_TC_TEXTRM:
|
||||
case LM_TC_CONST:
|
||||
case LM_TC_TEX:
|
||||
|
Loading…
Reference in New Issue
Block a user