mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Add support for \mathbin and friends
All they do is change the class of the elements that they contain.
This commit is contained in:
parent
bf56e2c8e1
commit
0b5c2a8507
@ -403,6 +403,7 @@ SOURCEFILESMATHED = \
|
||||
mathed/InsetMathCancelto.cpp \
|
||||
mathed/InsetMathCases.cpp \
|
||||
mathed/InsetMathChar.cpp \
|
||||
mathed/InsetMathClass.cpp \
|
||||
mathed/InsetMathColor.cpp \
|
||||
mathed/InsetMathComment.cpp \
|
||||
mathed/InsetMathDecoration.cpp \
|
||||
@ -475,6 +476,7 @@ HEADERFILESMATHED = \
|
||||
mathed/InsetMathCancelto.h \
|
||||
mathed/InsetMathCases.h \
|
||||
mathed/InsetMathChar.h \
|
||||
mathed/InsetMathClass.h \
|
||||
mathed/InsetMathColor.h \
|
||||
mathed/InsetMathComment.h \
|
||||
mathed/InsetMathDelim.h \
|
||||
|
@ -235,6 +235,8 @@ enum InsetCode {
|
||||
///
|
||||
IPADECO_CODE,
|
||||
///
|
||||
MATH_CLASS_CODE,
|
||||
///
|
||||
INSET_CODE_SIZE
|
||||
};
|
||||
|
||||
|
57
src/mathed/InsetMathClass.cpp
Normal file
57
src/mathed/InsetMathClass.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* \file InsetMathClass.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author André Pönitz
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "InsetMathClass.h"
|
||||
|
||||
#include "support/docstream.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
InsetMathClass::InsetMathClass(Buffer * buf, MathClass mc)
|
||||
: InsetMathNest(buf, 1), math_class_(mc)
|
||||
{}
|
||||
|
||||
|
||||
Inset * InsetMathClass::clone() const
|
||||
{
|
||||
return new InsetMathClass(*this);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathClass::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
cell(0).metrics(mi, dim);
|
||||
metricsMarkers(dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathClass::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cell(0).draw(pi, x + 1, y);
|
||||
drawMarkers(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
docstring InsetMathClass::name() const
|
||||
{
|
||||
return class_to_string(math_class_);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathClass::infoize(odocstream & os) const
|
||||
{
|
||||
os << name() << " ";
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
50
src/mathed/InsetMathClass.h
Normal file
50
src/mathed/InsetMathClass.h
Normal file
@ -0,0 +1,50 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file InsetMathClass.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author André Pönitz
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef MATH_CLASSINSET_H
|
||||
#define MATH_CLASSINSET_H
|
||||
|
||||
#include "MathClass.h"
|
||||
|
||||
#include "InsetMathNest.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
/// Support for LaTeX's \\mathxxx class-changing commands
|
||||
|
||||
class InsetMathClass : public InsetMathNest {
|
||||
public:
|
||||
///
|
||||
InsetMathClass(Buffer * buf, MathClass);
|
||||
///
|
||||
docstring name() const;
|
||||
///
|
||||
MathClass mathClass() const { return math_class_; }
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void infoize(odocstream & os) const;
|
||||
///
|
||||
InsetCode lyxCode() const { return MATH_CLASS_CODE; }
|
||||
|
||||
private:
|
||||
virtual Inset * clone() const;
|
||||
///
|
||||
MathClass math_class_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
#endif
|
@ -19,6 +19,7 @@
|
||||
#include "InsetMathCancel.h"
|
||||
#include "InsetMathCancelto.h"
|
||||
#include "InsetMathCases.h"
|
||||
#include "InsetMathClass.h"
|
||||
#include "InsetMathColor.h"
|
||||
#include "InsetMathDecoration.h"
|
||||
#include "InsetMathDots.h"
|
||||
@ -662,10 +663,13 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
|
||||
return MathAtom(new InsetMathSpecialChar(s));
|
||||
if (s == " ")
|
||||
return MathAtom(new InsetMathSpace(" ", ""));
|
||||
|
||||
if (s == "regexp")
|
||||
return MathAtom(new InsetMathHull(buf, hullRegexp));
|
||||
|
||||
MathClass const mc = string_to_class(s);
|
||||
if (mc != MC_UNKNOWN)
|
||||
return MathAtom(new InsetMathClass(buf, mc));
|
||||
|
||||
return MathAtom(new MathMacro(buf, s));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user