From 7e7a1070393277f5b298dcd5e2a42dc5ca4e23ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Mon, 20 Aug 2001 16:37:35 +0000 Subject: [PATCH] some *cough* support for \ll and \gg and potentially more... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2561 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/Makefile.am | 2 ++ src/mathed/math_cheatinset.C | 39 ++++++++++++++++++++++++++++++++++++ src/mathed/math_cheatinset.h | 31 ++++++++++++++++++++++++++++ src/mathed/math_hash.C | 2 -- src/mathed/math_macrotable.C | 14 +++++++++++++ 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/mathed/math_cheatinset.C create mode 100644 src/mathed/math_cheatinset.h diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 55e1e8d946..61e5df60f5 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -26,6 +26,8 @@ libmathed_la_SOURCES = \ math_bigopinset.h \ math_binominset.C \ math_binominset.h \ + math_cheatinset.C \ + math_cheatinset.h \ math_charinset.C \ math_charinset.h \ math_cursor.C \ diff --git a/src/mathed/math_cheatinset.C b/src/mathed/math_cheatinset.C new file mode 100644 index 0000000000..a62f321b40 --- /dev/null +++ b/src/mathed/math_cheatinset.C @@ -0,0 +1,39 @@ +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "math_cheatinset.h" +#include "support.h" +#include "support/LOstream.h" + + + +MathCheatInset::MathCheatInset(double w) + : wid_(w) +{} + + +MathInset * MathCheatInset::clone() const +{ + return new MathCheatInset(*this); +} + + +void MathCheatInset::draw(Painter & pain, int x, int y) const +{} + + +void MathCheatInset::write(std::ostream &, bool) const +{} + + +void MathCheatInset::writeNormal(std::ostream &) const +{} + + +void MathCheatInset::metrics(MathStyles st) const +{ + // mimic -.1em + mathed_char_dim(LM_TC_CONST, st, 'm', ascent_, descent_, width_); + width_ *= wid_; +} diff --git a/src/mathed/math_cheatinset.h b/src/mathed/math_cheatinset.h new file mode 100644 index 0000000000..5569c5a958 --- /dev/null +++ b/src/mathed/math_cheatinset.h @@ -0,0 +1,31 @@ +// -*- C++ -*- +#ifndef MATH_CHEATINSET_H +#define MATH_CHEATINSET_H + +#include "math_diminset.h" + +#ifdef __GNUG__ +#pragma interface +#endif + +/// Some cheating for displaying things like \ll etc + +class MathCheatInset : public MathDimInset { +public: + /// + explicit MathCheatInset(double wid); + /// + MathInset * clone() const; + /// + void draw(Painter &, int x, int y) const; + /// + void write(std::ostream &, bool fragile) const; + /// + void writeNormal(std::ostream &) const; + /// + void metrics(MathStyles st) const; +private: + /// width in em + double wid_; +}; +#endif diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 01ce7c409d..afba73cbdf 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -137,7 +137,6 @@ latexkeys wordlist[] = {"gamma", LM_TK_SYM, LM_gamma, LMB_NONE}, {"gcd", LM_TK_FUNCLIM, 0, LMB_NONE}, {"geq", LM_TK_SYM, LM_geq, LMB_RELATION}, - {"gg", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"grave", LM_TK_DECORATION, LM_grave, LMB_NONE}, {"hat", LM_TK_DECORATION, LM_hat, LMB_NONE}, {"hbar", LM_TK_NOGLYPH, 0, LMB_NONE}, @@ -171,7 +170,6 @@ latexkeys wordlist[] = {"liminf", LM_TK_FUNCLIM, 0, LMB_NONE}, {"limits", LM_TK_LIMIT, 1 , LMB_NONE}, {"limsup", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"ll", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"ln", LM_TK_FUNC, 0, LMB_NONE}, {"log", LM_TK_FUNC, 0, LMB_NONE}, {"longleftarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index 31c36c2c7e..c7cc1a4819 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -11,6 +11,8 @@ #include "math_macrotemplate.h" #include "math_parser.h" #include "math_fracinset.h" +#include "math_cheatinset.h" +#include "math_charinset.h" #include "debug.h" @@ -100,4 +102,16 @@ void MathMacroTable::builtinMacros() //createTemplate("lint", 4, "\\int_#1^#2#3 d#4"); //createTemplate("silentmult", 0, "\\cdot"); //createTemplate("binom", 2, "\\left(\\frac#1#2\\right)"); + + MathMacroTemplate ll("ll", 0); + ll.cell(0).push_back(new MathCharInset('<', LM_TC_CONST)); + ll.cell(0).push_back(new MathCheatInset(-0.9)); + ll.cell(0).push_back(new MathCharInset('<', LM_TC_CONST)); + insertTemplate(ll); + + MathMacroTemplate gg("gg", 0); + gg.cell(0).push_back(new MathCharInset('>', LM_TC_CONST)); + gg.cell(0).push_back(new MathCheatInset(-0.9)); + gg.cell(0).push_back(new MathCharInset('>', LM_TC_CONST)); + insertTemplate(gg); } -- 2.39.2