2002-03-21 Lars Gullik Bjønnes <larsbj@birdstep.com>
+ * most files: ws cleanup
+
* Makefile.am: remove ld -r stuff
2002-03-20 Lars Gullik Bjønnes <larsbj@birdstep.com>
* math_inset.C (metrics): parameter "mi" is never referenced. Removed.
* math_hullinset.C (metrics): ditto.
-
+
2002-03-12 André Pönitz <poenitz@gmx.net>
2002-02-08 Otto Tronarp <otttr440@student.liu.se>
- * math_decorationinset.C:
+ * math_decorationinset.C:
- * math_support.C:
+ * math_support.C:
* math_hash.C: Added \underrightarrow and \underleftarrow
2002-02-08 Martin Vermeer <martin.vermeer@hut.fi>
* formulabase.C (localDispatch): fix umlaut handling
-
+
* formulabase.C: pop up math panel on right mouse click
2002-02-01 André Pönitz <poenitz@gmx.net>
2002-01-10 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* math_support.C: change latex_mathfontcmds to an array of
- kb_action.
+ kb_action.
2002-01-11 Angus Leeming <a.leeming@ic.ac.uk>
2002-01-09 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* math_hullinset.C (validate): rename feature "amsstyle" to
- "amsmath".
+ "amsmath".
2002-01-09 Martin Vermeer <martin.vermeer@hut.fi>
- * math_support.C: modified to support a mathed pop-up for math
+ * math_support.C: modified to support a mathed pop-up for math
size "styles" and font types.
2002-01-07 Angus Leeming <a.leeming@ic.ac.uk>
* math_parser.C: user std::fill to fill the catcodes. (please
check this one...), and some consts.
-
+
2001-12-11 André Pönitz <poenitz@gmx.net>
* math_cursor.C: allow cut&paste of rectangular regions of cells
* math_symbolinset.C:
* math_unknowninset.C: include math_streamstr.h and remove
unneeded c_str()
-
+
* math_symbolinset.[Ch]: add constructor taking string
-
+
* math_mathmlstream.C: move includes around
* math_streamstr.[Ch]: add operator<<(Stream, string) for
NormalStream, MapleStream, MathMLStream and OctaveStream
-
+
* math_gridinset.C: user LyXLength::zero
-
+
2001-11-19 Angus Leeming <a.leeming@ic.ac.uk>
* formula.C:
* math_arrayinset.C: add using std::getline directive.
2001-11-20 André Pönitz <poenitz@gmx.net>
-
+
* formulabase.C: fix mouse positioning using the cursor
2001-11-19 Dekel Tsur <dekelts@tau.ac.il>
2001-11-15 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
- * math_extern.C (extractNumber):
+ * math_extern.C (extractNumber):
(extractDiffExponent): add ugly .c_str()
2001-11-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
- * math_arrayinset.C (MathArrayInset):
- * formula.C (pipeThroughMaple):
+ * math_arrayinset.C (MathArrayInset):
+ * formula.C (pipeThroughMaple):
(pipeThroughOctave): add ugly .c_str() to help compile
with lyxstring
* math_*inset.[Ch]: remove MathStyles cache from insets that
don't need it
- * support.C:
+ * support.C:
formulabase.C: fix math font sizes in headings etc
* math_inset.[Ch]:
2001-09-27 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* math_cursor.C: fix type mismatches with what was declared in
- math_cursor.h.
+ math_cursor.h.
2001-09-28 Dekel Tsur <dekelts@tau.ac.il>
'xxalignt', 'gather' and 'multiline' environments
* math_cursor.C: fix handling of | and \|
-
+
2001-09-04 José Matos <jamatos@fep.up.pt>
* formulabase.C
2001-08-17 André Pönitz <poenitz@gmx.net>
* math_hash.C: Use std::map instead of faking it
-
+
* symbol_def.h: remove unneeded symbol definitions
* support.C: use the decorations' name for drawing
2001-08-31 Dekel Tsur <dekelts@tau.ac.il>
* math_hash.C: Read symbols information from external file
- many files: Add support for latex symbol fonts
+ many files: Add support for latex symbol fonts
2001-08-18 Dekel Tsur <dekelts@tau.ac.il>
* math_bigopinset.[Ch]: revival for things like \int, \sum
* math_funcliminset.[Ch]: dedicated new inset for \lim, \max, \min...
-
+
* math_diminset.h: make cache variables mutable, remove const_cast
* formulabase.[Ch]: remove unneeded convertFont()
the width_/ascent_/descent_ cache
2001-07-25 André Pönitz <poenitz@gmx.net>
-
+
* formulabase.C: re-enable 'space enlargement' feature
* math_scriptinset.C:
* formulabase.C: fix memory leak
* math_cursor.C: ^ now copies selection into new srriptinset
-
+
* xarray.C: less crude MathXArray::x2pos for preciser cursor positioning
using the mouse
* math_updowninset.[hC]: new base class for script and bigop insets
*.[hC]: subsequent changes to all Metric() functions
-
+
* math_parser.C: small changes (\sqrt0 is read properly now)
-
+
2001-07-10 André Pönitz <poenitz@gmx.net>
-
+
* math_accentinset.[hC]: rewrite
* math_parser.C:
2001-07-09 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* formulabase.C (mathDispatchInsertMath): remove bogus return
- statement.
+ statement.
2001-07-09 André Pönitz <poenitz@gmx.net>
- * math_*inset.C: Change order of arguments in MathInset constructor
+ * math_*inset.C: Change order of arguments in MathInset constructor
* math_cursor.C: Remove broken "increase space" feature for a while
* *.C: remove all "using namespace std" directives (not
good!!) and replaced it with relevant "using" directives.
-
+
* math_macrotemplate.C (Clone): change return type to MathInset*
2001-06-27 Lars Gullik Bjønnes <larsbj@birdstep.com>
* math_macrotemplate.C (Write): std:: qualify ostream
* math_bigopinset.C (Metrics): std:: qualify max, and include
- functional
+ functional
* math_matrixinset.h: include vector and std:: qualify it.
* math_cursor.C (Right): Fixes for cursor movement.
* formula.C (draw): New background color for math.
-
+
* math_cursor.C: Fixes for toggling labels on/off in math.
Fixes for infinity and other symbols that didn't appear in
LaTeX.
* math_cursor.C: Cursor improvements after a few dead-ends
in the evolution of cursor movement were tested and scrapped.
-
+
2001-06-24 The LyX Project <Asger>
* math_cursor.C: Renamed stack to path.
declared in std:: namespace.
* math_macrotemplate.h: do not use explicitely std::string, but
- string.
+ string.
* math_macroarg.C: avoid bringing the whole std:: namespace in
global-land. When you do that, there is an ambiguity between
* math_macro.[Ch]:
* math_macrotable.[Ch]:
* math_macroarg.[Ch]: restructuring of macro handling
- * several files:
+ * several files:
2001-04-25 Angus Leeming <a.leeming@ic.ac.uk>
2001-04-16 Allan Rae <rae@lyx.org>
- * formula.C (Latex, getLabelList, LocalDispatch):
- * math_parser.C (mathed_parse):
+ * formula.C (Latex, getLabelList, LocalDispatch):
+ * math_parser.C (mathed_parse):
* math_parinset.C (Write): #warning triggers an error on Sun CC 6.0 as
an unrecognised preprocessor directive. So ensure they're wrapped.
* math_matrixinset.h:
* math_parinset.[Ch]:
* math_rowst.[Ch]: move MathedRowContainer::row_ to the base
-
+
2001-03-13 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:
2001-03-08 André Pönitz <poenitz@gmx.net>
- * math_rowst.h: give MathedRowContainer an 'insert' method.
+ * math_rowst.h: give MathedRowContainer an 'insert' method.
* math_xiter.C: new 'container()' method to encapsulated access to
the MathParInset's MathedRowContainer
* math_matrixinset.[hC]: remove copy constructr and destructor. Those
automatically created by the compiler are ok now.
-
+
2001-03-06 André Pönitz <poenitz@gmx.net>
* array.[Ch]: factor out deep_copy,
- remove third argument from raw_pointer_insert
+ remove third argument from raw_pointer_insert
- * math_iter.[Ch]: remove unused function Clear()
+ * math_iter.[Ch]: remove unused function Clear()
* math_cursor.C: change signature of MathStackXIter:push()
whitespace changes
shared_ptr, let constructor take a shared_ptr
* math_macro.C (MathMacro): take shared_ptr as arg, remove double
- initialization.
+ initialization.
(draw): remove unneded update, remove removed update of x,y
(GetXY): call tmplates GetMacroXY directly
(SetFocus): call Metrics() instead of update()
* math_cursor.C: changes because of the above
* math_parser.C: changes because of the abobe
-
+
* formulamacro.h: change tmacro_ to be a shared_ptr, remove
default arg on constructor.
* formulamacro.C: changes because of the above
(~MathFuncInset): remove
* math_fracinset.h: make MathParInset den_ a real object and not a
- pointer.
+ pointer.
* math_fracinset.C (MathFracInset): clean up, move initalization
to initialization list
(Clone): remove leak
* math_draw.C: delete file
-
+
* math_dotsinset.[Ch]: add pragma
* math_bigopinset.h: make protected variables private add '_' to vars.
* math_macroarg.C (MathMacroArgument): delete
* math_macro.C (~MathMacro): delete
* math_macrotemplate.C (~MathMacroTemplate): delete
-
+
* math_decorationinset.[Ch]: add pragma
* math_deliminset.[Ch]: likewise
* math_fracinset.[Ch]: likewise
* math_macroarg.[Ch]: likewise
* math_macrotemplate.[Ch]: likewise
* math_matrixinset.[Ch]: likewise
-
+
* formulamacro.C (Read): set contents of tmacro_ to ar.
* formulamacro.h: add '_' to private variables.
* move MathIter::Copy(int, int) to MathArray::shrink(pos, pos)
* several files: subsequent changes
-
+
* math_cursor.C: make selarray a proper MathArray
* several files: Change "MathedArray *" to "MathedArray &"
2001-02-14 André Pönitz <poenitz@gmx.net>
* array.[Ch]: "deep" copy constructor and assignment operator for
- MathArray
+ MathArray
* math_iter.[Ch]: seperate Copy() from Copy(int, int)
2001-02-14 André Pönitz <poenitz@gmx.net>
* array.[Ch]: remove constructor and enums ARRAY_MIN_SIZE and
- ARRAY_STEP
+ ARRAY_STEP
* math_iter.C: default-construct and resize array
of private variables.
* changes to several files because of the above.
-
+
2001-02-14 André Pönitz <poenitz@gmx.net>
* math_iter.[Ch]: hide fcode_
* move funcs to more localized files, more general cleanup.
Constify several local vars. Doxygen changes. Formatting.
-
+
2001-02-15 Lars Gullik Bjønnes <larsbj@lyx.org>
* support.C: add some consts
2001-02-14 André Pönitz <poenitz@gmx.net>
- * formula.C: reformatting
+ * formula.C: reformatting
* math_cursor.[Ch]:
math_iter.[Ch]:
2001-02-14 Lars Gullik Bjønnes <larsbj@lyx.org>
- * math_parser.C:
- * math_panel.C:
+ * math_parser.C:
+ * math_panel.C:
* formula.C: remove cruft
* array.C (begin): new method
(end): ditto
2001-02-14 André Pönitz <poenitz@gmx.net>
-
+
* math_iter.[Ch]: remove 'insert', 'maxsize' and 'ARRAY_SIZE'
- * math_cursor.C: reformatting
+ * math_cursor.C: reformatting
2001-02-14 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
- * math_spaceinset.C:
- * math_root.C:
- * math_matrixinset.C:
- * math_macrotemplate.C:
- * math_funcinset.C:
- * math_fracinset.C:
- * math_dotsinset.C:
- * math_deliminset.C:
- * math_decorationinset.C:
- * math_bigopinset.C:
- * math_accentinset.C:
+ * math_spaceinset.C:
+ * math_root.C:
+ * math_matrixinset.C:
+ * math_macrotemplate.C:
+ * math_funcinset.C:
+ * math_fracinset.C:
+ * math_dotsinset.C:
+ * math_deliminset.C:
+ * math_decorationinset.C:
+ * math_bigopinset.C:
+ * math_accentinset.C:
* math_sqrtinset.C: include LOstream.h and add using directive.
2001-02-14 André Pönitz <poenitz@gmx.net>
- * math_iter.C: reformatting
+ * math_iter.C: reformatting
2001-02-13 Lars Gullik Bjønnes <larsbj@lyx.org>
* math_spaceinset.C (GetSpace): move here
* math_parinset.C: add debug.h, move several prev. inlined methods
- here.
+ here.
* math_macrotable.C math_xiter.C support.C: add debug.h
2001-02-13 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* Makefile.am (libmathed_la_SOURCES): remove duplicate
- math_sqrtinset.
+ math_sqrtinset.
- * support.C:
- * math_xiter.C:
+ * support.C:
+ * math_xiter.C:
* math_parinset.C: add a bunch of "using" directives.
- * math_funcinset.h:
- * math_decorationinset.h:
- * math_bigopinset.h:
+ * math_funcinset.h:
+ * math_decorationinset.h:
+ * math_bigopinset.h:
* math_spaceinset.h: remove more couples of inline.
2001-02-13 Lars Gullik Bjønnes <larsbj@lyx.org>
* math_xiter.h: remove a couple of "inline"
- * array.C (strange_copy): fix bug (hopefully)
+ * array.C (strange_copy): fix bug (hopefully)
* many files: add a lot of new files and move methods to the class
files they belong to. Only first attempt at cleanup more will
follow.
-
+
2001-02-12 André Pönitz <poenitz@gmx.net>
-
+
* math_macro.[hC]: replace MathMacroArgument[] with
std::vector<MathMacroArgument>
* math_defs.h:
* math_panel.h:
* math_symbols.C: replace FL_OBJECTP[] with
std::vector<FL_OBJECT*>
-
+
2001-02-12 Lars Gullik Bjønnes <larsbj@lyx.org>
* math_defs.h (struct MathedRowSt): make all private variables end
environment.
2001-02-12 André Pönitz <poenitz@gmx.net>
-
+
* array.[hC]: replace private variable maxsize_ with call to
bf_.size()
* math_defs.h: replace int[] by std::vector<int> for
changed name from LyxArrayBase to MathedArray.
changed name of some methods to start with lowerchar.
moved inline methods to array.C
-
+
* math_iter.C + several file: changes because of the above.
* array.C: new file with the prev inline methods.
-
+
2001-02-10 Dekel Tsur <dekelts@tau.ac.il>
* Many files: add support for the align environment from amsmath.
2001-02-09 André Pönitz <poenitz@gmx.net>
* array.h: replace array buffer 'byte bf[]' by 'std::vector<byte> bf'
- * several files: subsequent changes
+ * several files: subsequent changes
* math_iter.h: remove unused prototype
* array.h: ditto.
2001-02-02 Dekel Tsur <dekelts@tau.ac.il>
- * Many files: Add support for multline and alignat environments from
+ * Many files: Add support for multline and alignat environments from
amsmath.
2001-02-02 Dekel Tsur <dekelts@tau.ac.il>
2001-01-15 Dekel Tsur <dekelts@tau.ac.il>
* math_draw.C (Metrics): Use the correct GetString.
-
"eval(`latex/latex/*`)):\n";
// remove spurious \\noalign{\\medskip} in matrix output
- header +=
+ header +=
"`latex/latex/matrix`:= "
"subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
"eval(`latex/latex/matrix`)):\n";
//
// ... > echo "1A;" | mint -i 1 -S -s -q
// on line 1: 1A;
- // ^ syntax error -
+ // ^ syntax error -
// Probably missing an operator such as * p
//
lyxerr << "checking expr: '" << expr << "'\n";
mathed_parse_cell(res, out);
return res;
}
-
-
+
+
MathArray pipeThroughOctave(string const &, MathArray const & ar)
{
ostringstream os;
for (int i = 0; i < 100; ++i) { // at most 100 attempts
//
- // try to fix missing '*' the hard way
+ // try to fix missing '*' the hard way
// parse error:
// >>> ([[1 2 3 ];[2 3 1 ];[3 1 2 ]])([[1 2 3 ];[2 3 1 ];[3 1 2 ]])
// ^
//
lyxerr << "checking expr: '" << expr << "'\n";
- out = captureOutput("octave -q 2>&1", expr);
+ out = captureOutput("octave -q 2>&1", expr);
lyxerr << "checking out: '" << out << "'\n";
// leave loop if expression syntax is probably ok
lyxerr << "converter to '" << lang << "' not found\n";
return MathArray();
}
-
+
// run external sript
string out = captureOutput(file, data);
MathArray res;
{}
-InsetFormula::InsetFormula(string const & s)
+InsetFormula::InsetFormula(string const & s)
{
if (s.size()) {
bool res = mathed_parse_normal(par_, s);
switch (action) {
- case LFUN_BREAKLINE:
+ case LFUN_BREAKLINE:
bv->lockedInsetStoreUndo(Undo::INSERT);
mathcursor->breakLine();
mathcursor->normalize();
updateLocal(bv, true);
break;
}
-
+
case LFUN_PASTESELECTION:
{
string const clip = bv->getClipboard();
- if (!clip.empty())
+ if (!clip.empty())
mathed_parse_normal(par_, clip);
break;
}
{
// where are we?
if (!mathcursor)
- return;
+ return;
string lang;
string extra;
istringstream iss(arg.c_str());
iss >> lang >> extra;
if (extra.empty())
- extra = "noextra";
+ extra = "noextra";
bool selected = mathcursor->selection();
bool InsetFormula::insetAllowed(Inset::Code code) const
{
- return
+ return
(code == Inset::LABEL_CODE && display())
- || code == Inset::ERT_CODE;
+ || code == Inset::ERT_CODE;
}
/*
* File: formula.h
* Purpose: Declaration of formula inset
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
- * Description: Allows the edition of math paragraphs inside Lyx.
+ * Description: Allows the edition of math paragraphs inside Lyx.
*
* Copyright: 1996, Alejandro Aguilar Sierra
*
* the GNU General Public Licence version 2 or later.
*/
-#ifndef INSET_FORMULA_H
+#ifndef INSET_FORMULA_H
#define INSET_FORMULA_H
#ifdef __GNUG__
int hack_button;
-void handleFont(BufferView * bv, string const & arg, MathTextCodes t)
+void handleFont(BufferView * bv, string const & arg, MathTextCodes t)
{
if (mathcursor->selection())
bv->lockedInsetStoreUndo(Undo::EDIT);
{}
-void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
+void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
{
font_ = f;
metrics(bv);
}
-void InsetFormulaBase::metrics(BufferView * bv) const
+void InsetFormulaBase::metrics(BufferView * bv) const
{
if (bv)
view_ = bv;
bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
- int /*x*/, int /*y*/, int /*button*/)
+ int /*x*/, int /*y*/, int /*button*/)
{
if (!mathcursor)
return false;
bv->getLyXText()->selectionAsString(bv->buffer(), false);
mathed_parse_cell(ar, sel);
mathcursor->insert(ar);
- }
+ }
break;
*/
case 3:
first_x = x;
first_y = y;
- if (!mathcursor->selection())
+ if (!mathcursor->selection())
mathcursor->selStart();
-
+
//lyxerr << "insetMotionNotify: " << x + xo_ << ' ' << y + yo_
// << ' ' << button << "\n";
hideInsetCursor(bv);
//lyxerr << "InsetFormulaBase::localDispatch: act: " << action
// << " arg: '" << arg << "' cursor: " << mathcursor << "\n";
- if (!mathcursor)
+ if (!mathcursor)
return UNDISPATCHED;
if (mathcursor->asHyperActiveInset()) {
case LFUN_DEFAULT: handleFont(bv, arg, LM_TC_VAR); break;
case LFUN_FREE: handleFont(bv, arg, LM_TC_TEXTRM); break;
- case LFUN_GREEK:
+ case LFUN_GREEK:
handleFont(bv, arg, LM_TC_GREEK1);
if (arg.size())
mathcursor->interpret(arg);
updateLocal(bv, true);
break;
}
-
+
case LFUN_SUPERSCRIPT:
case LFUN_SUBSCRIPT:
{
updateLocal(bv, true);
break;
}
-
+
case LFUN_MATH_DELIM:
{
lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n";
//lyxerr << "reset lastformula to " << this << "\n";
lastformula = this;
laststr = str;
- current = ibegin(par().nucleus());
+ current = ibegin(par().nucleus());
ar.clear();
mathed_parse_cell(ar, str);
} else {
} else {
// create a macro if we see "\\newcommand" somewhere, and an ordinary
// formula otherwise
- if (sel.find("\\newcommand") == string::npos)
+ if (sel.find("\\newcommand") == string::npos)
f = new InsetFormula(sel);
else {
string name;
mathDispatchCreation(bv, arg, true);
}
-
+
void mathDispatchMathMode(BufferView * bv, string const & arg)
{
mathDispatchCreation(bv, arg, false);
void mathDispatchMathDelim(BufferView * bv, string const & arg)
{
- if (bv->available()) {
+ if (bv->available()) {
if (openNewInset(bv, new InsetFormula))
bv->theLockingInset()->localDispatch(bv, LFUN_MATH_DELIM, arg);
}
-}
+}
void mathDispatchInsertMatrix(BufferView * bv, string const & arg)
-{
- if (bv->available()) {
+{
+ if (bv->available()) {
if (openNewInset(bv, new InsetFormula))
bv->theLockingInset()->localDispatch(bv, LFUN_INSERT_MATRIX, arg);
}
-}
+}
void mathDispatchInsertMath(BufferView * bv, string const & arg)
void mathDispatchGreek(BufferView * bv, string const & arg)
-{
- if (bv->available()) {
+{
+ if (bv->available()) {
InsetFormula * f = new InsetFormula;
if (openNewInset(bv, f)) {
bv->theLockingInset()->localDispatch(bv, LFUN_GREEK, arg);
bv->unlockInset(f);
}
}
-}
+}
void mathDispatch(BufferView *, kb_action, string const &)
-{}
+{}
* Purpose: Common parts of the math LyX insets
* Author: André Pönitz
* Created: May 2001
- * Description: Allows the edition of math paragraphs inside Lyx.
+ * Description: Allows the edition of math paragraphs inside Lyx.
*
* Copyright: 2001, The LyX Project
*
* the GNU General Public Licence version 2 or later.
*/
-#ifndef INSET_FORMULABASE_H
+#ifndef INSET_FORMULABASE_H
#define INSET_FORMULABASE_H
#ifdef __GNUG__
virtual void insetMotionNotify(BufferView *, int x, int y, int state);
///
virtual void insetUnlock(BufferView *);
-
+
/// To allow transparent use of math editing functions
virtual RESULT localDispatch(BufferView *, kb_action, string const &);
-
+
///
virtual std::vector<string> const getLabelList() const;
///
///
virtual bool searchForward(BufferView *, string const &,
- bool = true, bool = false);
+ bool = true, bool = false);
///
virtual bool searchBackward(BufferView *, string const &,
- bool = true, bool = false);
+ bool = true, bool = false);
///
virtual bool isTextInset() const { return true; }
///
void handleAccent(BufferView * bv, string const & arg, string const & name);
///
- mutable BufferView * view_;
+ mutable BufferView * view_;
///
mutable LyXFont font_;
* Purpose: Implementation of the formula macro LyX inset
* Author: André Pönitz, based on ideas of Alejandro Aguilar Sierra
* Created: March 2001
- * Description: Allows the edition of math macros inside Lyx.
+ * Description: Allows the edition of math macros inside Lyx.
*
* Copyright: 2001 The LyX Project
*
}
-int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile,
+int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile,
bool /*free_spacing*/) const
{
WriteStream wi(os, fragile);
// label
font.setColor(LColor::math);
-
+
int const a = y - ascent(bv, font) + 1;
int const w = width(bv, font) - 2;
int const h = ascent(bv, font) + descent(bv, font) - 2;
yo_ = y;
par()->draw(pain, xo_, yo_);
}
-
/*
* File: formula.h
* Purpose: Declaration of formula inset
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
- * Description: Allows the edition of math paragraphs inside Lyx.
+ * Description: Allows the edition of math paragraphs inside Lyx.
*
* Copyright: 1996, Alejandro Aguilar Sierra
*
* the GNU General Public Licence version 2 or later.
*/
-#ifndef INSET_FORMULA_MACRO_H
+#ifndef INSET_FORMULA_MACRO_H
#define INSET_FORMULA_MACRO_H
#include "formulabase.h"
class MathMacroTemplate;
// InsetFormulaMacro's only knows its name and asks the global
-// MathMacroTable if it needs to know more.
+// MathMacroTable if it needs to know more.
///
class InsetFormulaMacro: public InsetFormulaBase {
void MathAMSArrayInset::draw(Painter & pain, int x, int y) const
-{
+{
MathGridInset::draw(pain, x + 6, y);
int yy = y - ascent_;
mathed_draw_deco(pain, x + 1, yy, 5, height(), name_left());
class MathAMSArrayInset : public MathGridInset {
-public:
+public:
///
MathAMSArrayInset(string const & name_, int m, int n);
///
os << "\\protect";
os << "\\begin{" << name_ << "}";
- if (v_align_ == 't' || v_align_ == 'b')
+ if (v_align_ == 't' || v_align_ == 'b')
os << '[' << char(v_align_) << ']';
os << '{' << halign() << "}\n";
class MathArrayInset : public MathGridInset {
-public:
+public:
///
MathArrayInset(string const &, int m, int n);
///
/*
* File: math_atom.C
- * Purpose: Wrapper for MathInset *
+ * Purpose: Wrapper for MathInset *
* Author: André Pönitz
* Created: July 2001
*
#pragma interface
#endif
-/**
+/**
The 'atom' is the major blob in math typesetting. And 'atom' consists
of a nucleus, an optional superscript, and an optional subscript.
Exactly where the subscript and superscript are drawn depends on the
-size, and type, of the nucleus they are attached to.
+size, and type, of the nucleus they are attached to.
Jules
class MathInset;
class MathAtom {
-public:
+public:
/// default constructor, object is useless, but we need it to put it into
// std::containers
MathAtom();
/// copy constructor, invokes nucleus_->clone()
MathAtom(MathAtom const &);
/// we really need to clean up
- ~MathAtom();
+ ~MathAtom();
/// assignment invokes nucleus_->clone()
void operator=(MathAtom const &);
/// change inset under the hood
MathInset * MathBigInset::clone() const
-{
+{
return new MathBigInset(*this);
}
void MathBigInset::draw(Painter & pain, int x, int y) const
-{
+{
mathed_draw_deco(pain, x + 1, y - ascent_, 4, height(), delim_);
}
size_type size() const;
///
double increase() const;
-
+
/// \bigl or what?
string const name_;
/// ( or [ or Vert...
MathInset * MathBinaryOpInset::clone() const
-{
+{
return new MathBinaryOpInset(*this);
}
void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
-{
- xcell(0).draw(pain, x, y);
+{
+ xcell(0).draw(pain, x, y);
drawChar(pain, LM_TC_CONST, mi_, x + xcell(0).width() , y, op_);
- xcell(1).draw(pain, x + width() - xcell(1).width(), y);
+ xcell(1).draw(pain, x + width() - xcell(1).width(), y);
}
MathInset * MathBinomInset::clone() const
-{
+{
return new MathBinomInset(*this);
}
xcell(0).metrics(mi);
xcell(1).metrics(mi);
ascent_ = xcell(0).height() + 4 + 5;
- descent_ = xcell(1).height() + 4 - 5;
- width_ = max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
+ descent_ = xcell(1).height() + 4 - 5;
+ width_ = max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
}
#endif
/** Binom like objects
- \author André Pönitz
+ \author André Pönitz
*/
class MathBinomInset : public MathFracbaseInset {
public:
MathInset * MathBraceInset::clone() const
-{
+{
return new MathBraceInset(*this);
}
void MathBraceInset::draw(Painter & pain, int x, int y) const
-{
+{
drawChar(pain, font_, x, y, '{');
xcell(0).draw(pain, x + wid_, y);
drawChar(pain, font_, x + width_ - wid_, y, '}');
{
os << "[block " << cell(0) << ']';
}
-
-
#pragma interface
#endif
-/** Extra nesting
+/** Extra nesting
\author André Pönitz
*/
void MathCasesInset::draw(Painter & pain, int x, int y) const
-{
+{
mathed_draw_deco(pain, x + 1, y - ascent(), 6, height(), "{");
MathGridInset::draw(pain, x + 8, y);
}
class MathCasesInset : public MathGridInset {
-public:
+public:
///
explicit MathCasesInset(row_type rows = 1u);
///
MathInset * MathCharInset::clone() const
-{
+{
return new MathCharInset(*this);
}
void MathCharInset::draw(Painter & pain, int x, int y) const
-{
+{
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
if (isBinaryOp(char_, code_))
x += lyxfont::width(' ', font_);
void MathCharInset::drawT(TextPainter & pain, int x, int y) const
-{
+{
//lyxerr << "drawing text '" << char_ << "' code: " << code_ << endl;
pain.draw(x, y, char_);
}
bool positionable(MathCursor::cursor_type const & cursor,
- MathCursor::cursor_type const & anchor)
+ MathCursor::cursor_type const & anchor)
{
// avoid deeper nested insets when selecting
if (cursor.size() > anchor.size())
}
#endif
- if (idx() >= par()->nargs()) {
+ if (idx() >= par()->nargs()) {
lyxerr << "this should not really happen - 1: "
<< idx() << " " << par()->nargs() << "\n";
dump("error 2");
}
- idx() = min(idx(), par()->nargs() - 1);
+ idx() = min(idx(), par()->nargs() - 1);
if (pos() > size()) {
lyxerr << "this should not really happen - 2: "
if (!popLeft()) {
// no such inset found, just take something "above"
///lyxerr << "updown: handled by strange case\n";
- return
+ return
bruteFind(xo, yo,
formula()->xlow(),
formula()->xhigh(),
}
// prevent entering of recursive macros
- if (formula()->lyxCode() == Inset::MATHMACRO_CODE
+ if (formula()->lyxCode() == Inset::MATHMACRO_CODE
&& formula()->getInsetName() == s.substr(1))
{
lyxerr << "can't enter recursive macro\n";
/*
* File: math_cursor.h
* Purpose: Declaration of interaction classes for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* Description: MathCursor control all user interaction
*
bool inMacroMode() const;
/// are we currently typing '#1' or '#2' or...?
bool inMacroArgMode() const;
-
+
// Local selection methods
///
bool selection() const;
void handleNest(MathInset * p);
/// splits cells and shifts right part to the next cell
void splitCell();
- /// splits line and insert new row of cell
+ /// splits line and insert new row of cell
void breakLine();
/// read contents of line into an array
void readLine(MathArray & ar) const;
/// make sure cursor position is valid
void normalize();
- /// mark current cursor trace for redraw
+ /// mark current cursor trace for redraw
void touch();
///
UpdatableInset * asHyperActiveInset() const;
- /// enter a MathInset
+ /// enter a MathInset
void push(MathAtom & par);
/// enter a MathInset from the front
void pushLeft(MathAtom & par);
void dump(char const * str) const;
///
void stripFromLastEqualSign();
- /// moves on
+ /// moves on
void setSelection(cursor_type const & where, size_type n);
///
void insert(char);
/// hack for reveal codes
void markInsert();
void markErase();
-
+
///
friend class Selection;
MathInset::difference_type macroNamePos() const;
///
void insert(char, MathTextCodes t);
- /// can we enter the inset?
+ /// can we enter the inset?
bool openable(MathAtom const &, bool selection) const;
/// write access to cursor cell position
pos_type & pos();
void MathArray::push_back(MathAtom const & t)
-{
+{
bf_.push_back(t);
}
void MathArray::swap(MathArray & ar)
{
- if (this != &ar)
+ if (this != &ar)
bf_.swap(ar.bf_);
}
void MathArray::pop_back()
-{
+{
if (!size()) {
lyxerr << "pop_back from empty array!\n";
return;
{
if (size() < ar.size() + pos)
return false;
- const_iterator it = begin() + pos;
+ const_iterator it = begin() + pos;
for (const_iterator jt = ar.begin(); jt != ar.end(); ++jt, ++it)
if (!jt->nucleus()->match(it->nucleus()))
return false;
for (const_iterator it = begin(); it != end(); ++it)
if (it->nucleus()->contains(ar))
return true;
-
+
return false;
}
// -*- C++ -*-
/*
- * Purpose: A general purpose resizable array.
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: A general purpose resizable array.
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
*
* Dependencies: None (almost)
/** \class MathArray
\brief Low level container for math insets
-
+
\author Alejandro Aguilar Sierra
\author André Pönitz
\author Lars Gullik Bjønnes
void clear();
///
void swap(MathArray &);
-
+
///
void insert(size_type pos, MathAtom const &);
///
///
void validate(LaTeXFeatures &) const;
///
- const_iterator begin() const;
+ const_iterator begin() const;
///
- const_iterator end() const;
+ const_iterator end() const;
///
iterator begin();
///
MathInset * MathDecorationInset::clone() const
-{
+{
return new MathDecorationInset(*this);
}
ascent_ = xcell(0).ascent();
descent_ = xcell(0).descent();
- dh_ = 6; //mathed_char_height(LM_TC_VAR, mi(), 'I', ascent_, descent_);
+ dh_ = 6; //mathed_char_height(LM_TC_VAR, mi(), 'I', ascent_, descent_);
dw_ = 6; //mathed_char_width(LM_TC_VAR, mi, 'x');
if (upper()) {
void MathDecorationInset::draw(Painter & pain, int x, int y) const
-{
+{
xcell(0).draw(pain, x, y);
- if (wide())
+ if (wide())
mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
else
mathed_draw_deco(pain, x + (width_ - dw_) / 2, y + dy_, dw_, dh_, name_);
// -*- C++ -*-
/*
* File: math_defs.h
- * Purpose: Math editor definitions
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Math editor definitions
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* Description: Math paragraph and objects for a WYSIWYG math editor.
*
*
* You are free to use and modify this code under the terms of
* the GNU General Public Licence version 2 or later.
- *
+ *
*/
#ifndef MATH_DEFS
///
enum MathTextCodes {
- ///
+ ///
LM_TC_MIN = 0,
/// internal code for variables
LM_TC_VAR,
LM_TC_IT,
///
LM_TC_TEXTRM,
- /// math mode TeX characters ",;:{}"
+ /// math mode TeX characters ",;:{}"
LM_TC_TEX,
/// internal code when typing greek
LM_TC_GREEK,
};
-/// Types of lyx-math insets
+/// Types of lyx-math insets
enum MathInsetTypes {
///
LM_OT_SIMPLE = 0,
///
LM_OT_EQUATION,
- ///
+ ///
LM_OT_EQNARRAY,
///
LM_OT_ALIGN,
MathInset * MathDelimInset::clone() const
-{
+{
return new MathDelimInset(*this);
}
void MathDelimInset::draw(Painter & pain, int x, int y) const
-{
+{
int const w = dw();
int const b = y - ascent_;
xcell(0).draw(pain, x + w + 4, y);
bool mat =
cell(0).size() == 1 && cell(0).begin()->nucleus()
&& cell(0).begin()->nucleus()->asMatrixInset();
- if (mat)
+ if (mat)
os << "linalg[det](" << cell(0) << ")";
else
os << "abs(" << cell(0) << ")";
void MathDiffInset::draw(Painter &, int, int) const
-{
+{
lyxerr << "should not happen\n";
}
{
lyxerr << "should not happen\n";
}
-
-
#include "math_diminset.h"
#include "Lsstream.h"
#include "textpainter.h"
public:
/// not sure whether the initialization is really necessary
MathDimInset() : width_(0), ascent_(0), descent_(0) {}
- /// read ascent value (should be inline according to gprof)
+ /// read ascent value (should be inline according to gprof)
int ascent() const { return ascent_; }
- /// read descent
+ /// read descent
int descent() const { return descent_; }
/// read width
int width() const { return width_; }
MathInset * MathDotsInset::clone() const
{
return new MathDotsInset(*this);
-}
+}
void MathDotsInset::metrics(MathMetricsInfo const & mi) const
case 'v': width_ /= 2;
case 'd': dh_ = ascent_; break;
}
-}
+}
void MathDotsInset::draw(Painter & pain, int x, int y) const
mutable int dh_;
///
string const name_;
-};
+};
#endif
void MathExFuncInset::draw(Painter & pain, int x, int y) const
-{
+{
drawStr(pain, font_, x, y, name_);
}
{
os << '\\' << name_ << '{' << cell(0) << '}';
}
-
-
void MathExIntInset::normalize(NormalStream & os) const
{
- os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
+ os << '[' << symbol_ << ' ' << cell(0) << ' ' << cell(1) << ' '
<< cell(2) << ' ' << cell(3) << ']';
}
void MathExIntInset::draw(Painter &, int, int) const
-{
+{
lyxerr << "should not happen" << endl;
}
os << symbol_ << '(';
if (cell(0).size())
os << cell(0);
- else
+ else
os << '1';
os << ',' << cell(1);
if (hasScripts())
boost::scoped_ptr<MathSymbolInset> sym(new MathSymbolInset(symbol_));
//if (hasScripts())
// mathmlize(sym, os);
- //else
+ //else
sym->mathmlize(os);
os << cell(0) << "<mo> ⁢ </mo>"
<< MTag("mrow") << "<mo> ⅆ </mo>"
{
lyxerr << "should not happen" << endl;
}
-
-
// This file contains most of the magic that extracts "context
// information" from the unstructered layout-oriented stuff in an
// MathArray.
ostream & operator<<(ostream & os, MathArray const & ar)
{
- NormalStream ns(os);
+ NormalStream ns(os);
ns << ar;
return os;
}
-// try to extract a super/subscript
+// try to extract a super/subscript
// modify iterator position to point behind the thing
bool extractScript(MathArray & ar,
MathArray::iterator & pos, MathArray::iterator last)
ar.erase(it + 1, jt + 1);
(*it).reset(p);
}
-}
+}
//
// split scripts into seperate super- and subscript insets. sub goes in
-// front of super...
+// front of super...
//
void splitScripts(MathArray & ar)
// create extra script inset and move superscript over
MathScriptInset * q = new MathScriptInset;
- q->ensure(true);
+ q->ensure(true);
q->up().data_.swap(p->up().data_);
p->removeScript(true);
// insert new inset behind
++i;
- ar.insert(i, MathAtom(q));
+ ar.insert(i, MathAtom(q));
}
//lyxerr << "\nScripts to: " << ar << "\n";
}
string name;
// is it a function?
- if ((*it)->asFuncInset()) {
+ if ((*it)->asFuncInset()) {
// it certainly is if it is well known...
name = (*it)->asFuncInset()->name();
- } else {
+ } else {
// is this a user defined function?
// it it probably not, if it doesn't have a name.
if (!extractString((*it).nucleus(), name))
// 'sin' '^2' 'x' -> 'sin(x)' '^2'
MathArray exp;
extractScript(exp, jt, ar.end());
-
+
// create a proper inset as replacement
MathExFuncInset * p = new MathExFuncInset(name);
// replace the function name by a real function inset
(*it).reset(p);
-
+
// remove the source of the argument from the array
ar.erase(it + 1, st);
ar.insert(i + 1, exp);
//lyxerr << "\nFunctions to: " << ar << "\n";
}
-}
+}
//
// collect subscript if any
MathArray::iterator st = it + 1;
if (st != ar.end())
- if (MathScriptInset * sub = (*st)->asScriptInset())
+ if (MathScriptInset * sub = (*st)->asScriptInset())
if (sub->hasDown()) {
p->cell(2) = sub->down().data_;
++st;
// collect superscript if any
if (st != ar.end())
- if (MathScriptInset * sup = (*st)->asScriptInset())
+ if (MathScriptInset * sup = (*st)->asScriptInset())
if (sup->hasUp()) {
p->cell(3) = sup->up().data_;
++st;
// use the "thing" behind the 'd' as differential
MathArray::iterator tt = extractArgument(p->cell(1), jt + 1, ar.end());
-
+
// remove used parts
ar.erase(it + 1, tt);
(*it).reset(p);
// is this a "differential fraction"?
if (!testDiffFrac(it->nucleus()))
continue;
-
+
MathFracInset * f = (*it)->asFracInset();
if (!f) {
lyxerr << "should not happen\n";
MathDiffInset * diff = new MathDiffInset;
// collect function, let jt point behind last used item
- MathArray::iterator jt = it + 1;
- //int n = 1;
+ MathArray::iterator jt = it + 1;
+ //int n = 1;
MathArray & numer = f->cell(0);
if (numer.size() > 1 && numer.at(1)->asScriptInset()) {
// this is something like d^n f(x) / d... or d^n / d...
// FIXME
- //n = 1;
- if (numer.size() > 2)
+ //n = 1;
+ if (numer.size() > 2)
diff->cell(0) = MathArray(numer.begin() + 2, numer.end());
else
jt = extractArgument(diff->cell(0), jt, ar.end());
} else {
// simply d f(x) / d... or d/d...
- if (numer.size() > 1)
+ if (numer.size() > 1)
diff->cell(0) = MathArray(numer.begin() + 1, numer.end());
else
jt = extractArgument(diff->cell(0), jt, ar.end());
q->write2(p, wi);
++it;
continue;
- }
+ }
}
p->write(wi);
}
if (it + 1 != ar.end()) {
if (MathScriptInset const * q = asScript(it)) {
q->octavize2(p, os);
- ++it;
+ ++it;
continue;
}
}
if (it + 1 != ar.end()) {
if (MathScriptInset const * q = asScript(it)) {
q->maplize2(p, os);
- ++it;
+ ++it;
continue;
}
}
if (it + 1 != ar.end()) {
if (MathScriptInset const * q = asScript(it)) {
q->mathmlize2(p, os);
- ++it;
+ ++it;
continue;
}
}
os << ETag("mrow");
}
}
-
return MathAtom(new MathStackrelInset);
case LM_TK_UNDERSET:
return MathAtom(new MathUndersetInset);
- case LM_TK_KERN:
+ case LM_TK_KERN:
return MathAtom(new MathKernInset);
case LM_TK_BINOM:
case LM_TK_CHOOSE:
return MathAtom(new MathArrayInset(s, 1, 1));
if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix" ||
- s == "matrix")
+ s == "matrix")
return MathAtom(new MathAMSArrayInset(s));
latexkeys const * l = in_word_set(s);
if (l)
return createMathInset(l);
- if (MathMacroTable::has(s))
+ if (MathMacroTable::has(s))
return MathAtom(new MathMacro(s));
//cerr << "creating inset 2 with name: '" << s << "'\n";
public:
///
MathFracbaseInset();
- ///
+ ///
bool idxUpDown(idx_type &, bool up) const;
///
bool idxLeft(idx_type &, pos_type &) const;
MathInset * MathFracInset::clone() const
-{
+{
return new MathFracInset(*this);
}
smallerStyleFrac(m);
xcell(0).metrics(m);
xcell(1).metrics(m);
- width_ = max(xcell(0).width(), xcell(1).width()) + 2;
+ width_ = max(xcell(0).width(), xcell(1).width()) + 2;
ascent_ = xcell(0).height() + 2 + 5;
- descent_ = xcell(1).height() + 2 - 5;
+ descent_ = xcell(1).height() + 2 - 5;
}
void MathFracInset::normalize(NormalStream & os) const
{
- if (atop_)
+ if (atop_)
os << "[atop ";
else
os << "[frac ";
}
-void MathFuncInset::metrics(MathMetricsInfo const & mi) const
+void MathFuncInset::metrics(MathMetricsInfo const & mi) const
{
whichFont(font_, LM_TC_TEXTRM, mi);
mathed_string_dim(font_, name_, ascent_, descent_, width_);
void MathFuncInset::draw(Painter & pain, int x, int y) const
-{
+{
drawStr(pain, font_, x, y, name_);
}
void MathFuncLimInset::draw(Painter & pain, int x, int y) const
-{
+{
drawStr(pain, font_, x, y, name_);
}
}
-//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
MathGridInset::RowInfo::RowInfo()
-//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
MathGridInset::ColInfo::ColInfo()
{}
-//////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////
MathGridInset::MathGridInset(char v, string const & h)
: MathNestInset(guessColumns(h)), rowinfo_(2), colinfo_(guessColumns(h) + 1)
{
setDefaults();
- valign(v);
+ valign(v);
halign(h);
}
: MathNestInset(m * n), rowinfo_(n + 1), colinfo_(m + 1), v_align_(v)
{
setDefaults();
- valign(v);
+ valign(v);
halign(h);
}
lyxerr << "unkown column separator: '" << c << "'\n";
}
}
-
+
/*
col_type n = hh.size();
if (n > ncols())
for (col_type col = 0; col < ncols(); ++col) {
res += string(colinfo_[col].lines_, '|');
res += colinfo_[col].align_;
- }
+ }
return res + string(colinfo_[ncols()].lines_, '|');
}
// compute vertical offsets
rowinfo_[0].offset_ = 0;
for (row_type row = 1; row <= nrows(); ++row) {
- rowinfo_[row].offset_ =
+ rowinfo_[row].offset_ =
rowinfo_[row - 1].offset_ +
rowinfo_[row - 1].descent_ +
rowinfo_[row - 1].skipPixels() +
}
for (row_type row = 0; row <= nrows(); ++row)
rowinfo_[row].offset_ -= h;
-
+
// compute absolute sizes of horizontal structure
for (col_type col = 0; col < ncols(); ++col) {
int wid = 0;
- for (row_type row = 0; row < nrows(); ++row)
+ for (row_type row = 0; row < nrows(); ++row)
wid = max(wid, xcell(index(row, col)).width());
colinfo_[col].width_ = wid;
}
for (col_type col = 1; col <= ncols(); ++col) {
colinfo_[col].offset_ =
colinfo_[col - 1].offset_ +
- colinfo_[col - 1].width_ +
+ colinfo_[col - 1].width_ +
colinfo_[col - 1].skip_ +
- colsep() +
+ colsep() +
colinfo_[col].lines_ * vlinesep();
}
- width_ = colinfo_[ncols() - 1].offset_
- + colinfo_[ncols() - 1].width_
- + vlinesep() * colinfo_[ncols()].lines_
- + border();
+ width_ = colinfo_[ncols() - 1].offset_
+ + colinfo_[ncols() - 1].width_
+ + vlinesep() * colinfo_[ncols()].lines_
+ + border();
- ascent_ = - rowinfo_[0].offset_
- + rowinfo_[0].ascent_
- + hlinesep() * rowinfo_[0].lines_
- + border();
+ ascent_ = - rowinfo_[0].offset_
+ + rowinfo_[0].ascent_
+ + hlinesep() * rowinfo_[0].lines_
+ + border();
descent_ = rowinfo_[nrows() - 1].offset_
- + rowinfo_[nrows() - 1].descent_
- + hlinesep() * rowinfo_[nrows()].lines_
- + border();
+ + rowinfo_[nrows() - 1].descent_
+ + hlinesep() * rowinfo_[nrows()].lines_
+ + border();
-/*
+/*
// Increase ws_[i] for 'R' columns (except the first one)
for (int i = 1; i < nc_; ++i)
if (align_[i] == 'R')
if (align_[0] == 'C')
if (ws_[0] < 7 * workwidth / 8)
ws_[0] = 7 * workwidth / 8;
-
+
// Adjust local tabs
width = colsep();
- for (cxrow = row_.begin(); cxrow; ++cxrow) {
+ for (cxrow = row_.begin(); cxrow; ++cxrow) {
int rg = COLSEP;
int lf = 0;
for (int i = 0; i < nc_; ++i) {
lf = 0;
break;
case 'c':
- lf = (ws_[i] - cxrow->getTab(i))/2;
+ lf = (ws_[i] - cxrow->getTab(i))/2;
break;
case 'r':
case 'R':
else if (cxrow.is_last())
lf = ws_[i] - cxrow->getTab(i);
else
- lf = (ws_[i] - cxrow->getTab(i))/2;
+ lf = (ws_[i] - cxrow->getTab(i))/2;
break;
}
int const ww = (isvoid) ? lf : lf + cxrow->getTab(i);
{
// let the cells adjust themselves
//MathNestInset::metrics(mi);
- for (idx_type i = 0; i < nargs(); ++i)
+ for (idx_type i = 0; i < nargs(); ++i)
xcell(i).metricsT(mi);
// compute absolute sizes of vertical structure
// compute vertical offsets
rowinfo_[0].offset_ = 0;
for (row_type row = 1; row <= nrows(); ++row) {
- rowinfo_[row].offset_ =
+ rowinfo_[row].offset_ =
rowinfo_[row - 1].offset_ +
rowinfo_[row - 1].descent_ +
//rowinfo_[row - 1].skipPixels() +
}
for (row_type row = 0; row <= nrows(); ++row)
rowinfo_[row].offset_ -= h;
-
+
// compute absolute sizes of horizontal structure
for (col_type col = 0; col < ncols(); ++col) {
int wid = 0;
- for (row_type row = 0; row < nrows(); ++row)
+ for (row_type row = 0; row < nrows(); ++row)
wid = max(wid, xcell(index(row, col)).width());
colinfo_[col].width_ = wid;
}
for (col_type col = 1; col <= ncols(); ++col) {
colinfo_[col].offset_ =
colinfo_[col - 1].offset_ +
- colinfo_[col - 1].width_ +
+ colinfo_[col - 1].width_ +
colinfo_[col - 1].skip_ +
- 1 ; //colsep() +
+ 1 ; //colsep() +
//colinfo_[col].lines_ * vlinesep();
}
- width_ = colinfo_[ncols() - 1].offset_
- + colinfo_[ncols() - 1].width_
- //+ vlinesep() * colinfo_[ncols()].lines_
- + 2;
+ width_ = colinfo_[ncols() - 1].offset_
+ + colinfo_[ncols() - 1].width_
+ //+ vlinesep() * colinfo_[ncols()].lines_
+ + 2;
- ascent_ = - rowinfo_[0].offset_
- + rowinfo_[0].ascent_
- //+ hlinesep() * rowinfo_[0].lines_
- + 1;
+ ascent_ = - rowinfo_[0].offset_
+ + rowinfo_[0].ascent_
+ //+ hlinesep() * rowinfo_[0].lines_
+ + 1;
descent_ = rowinfo_[nrows() - 1].offset_
- + rowinfo_[nrows() - 1].descent_
- //+ hlinesep() * rowinfo_[nrows()].lines_
- + 1;
+ + rowinfo_[nrows() - 1].descent_
+ //+ hlinesep() * rowinfo_[nrows()].lines_
+ + 1;
}
if (nrows() == 1)
return;
- cells_type::iterator it = cells_.begin() + row * ncols();
+ cells_type::iterator it = cells_.begin() + row * ncols();
cells_.erase(it, it + ncols());
rowinfo_.erase(rowinfo_.begin() + row);
const col_type nc = ncols();
const row_type nr = nrows();
cells_type new_cells((nc + 1) * nr);
-
+
for (row_type row = 0; row < nr; ++row)
for (col_type col = 0; col < nc; ++col)
new_cells[row * (nc + 1) + col + (col > newcol)]
return;
cells_type tmpcells;
- for (col_type i = 0; i < nargs(); ++i)
+ for (col_type i = 0; i < nargs(); ++i)
if (i % ncols() != col)
tmpcells.push_back(cells_[i]);
swap(cells_, tmpcells);
int x = colinfo_[c].offset_;
char align = colinfo_[c].align_;
if (align == 'r' || align == 'R')
- x += colinfo_[c].width_ - xcell(idx).width();
+ x += colinfo_[c].width_ - xcell(idx).width();
if (align == 'c' || align == 'C')
- x += (colinfo_[c].width_ - xcell(idx).width()) / 2;
+ x += (colinfo_[c].width_ - xcell(idx).width()) / 2;
return x;
}
}
}
-
+
bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
{
// leave matrix if on the left hand edge
pos = cell(idx).size();
return true;
}
-
-
+
+
bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
{
// leave matrix if on the right hand edge
case 'b':
idx = (nrows() - 1) * ncols();
break;
- default:
+ default:
idx = ((nrows() - 1) / 2) * ncols();
}
pos = 0;
// move cells if necessary
for (idx_type i = index(row(idx), 0); i < idx; ++i)
cell(i).swap(cell(i + ncols()));
-
+
delRow(row(idx));
if (idx >= nargs())
idx = nargs() - 1;
// undo effect of Ctrl-Tab (i.e. pull next cell)
- //if (idx + 1 != nargs())
+ //if (idx + 1 != nargs())
// cell(idx).swap(cell(idx + 1));
}
os << MTag("mtable");
for (row_type row = 0; row < nrows(); ++row) {
os << MTag("mtr");
- for (col_type col = 0; col < ncols(); ++col)
+ for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col));
os << ETag("mtr");
}
{
for (row_type row = 0; row < nrows(); ++row) {
os << verboseHLine(rowinfo_[row].lines_);
- for (col_type col = 0; col < ncols(); ++col)
+ for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col)) << eocString(col);
os << eolString(row);
}
// additional per-row information
struct ColInfo {
- ///
+ ///
ColInfo();
/// currently possible: 'l', 'c', 'r'
char align_;
mutable int width_;
/// cached offset
mutable int offset_;
- /// do we need a line to the left?
+ /// do we need a line to the left?
bool leftline_;
/// do we need a line to the right?
bool rightline_;
int skip_;
};
-public:
+public:
/// constructor from columns description, creates one row
MathGridInset(char valign, string const & halign);
/// Note: columns first!
bool idxEnd(idx_type &, pos_type &) const;
///
void idxDelete(idx_type &, bool &, bool &);
-
+
///
virtual void addRow(row_type);
///
std::vector<RowInfo> rowinfo_;
/// column info
std::vector<ColInfo> colinfo_;
- ///
+ ///
char v_align_; // add approp. type
};
};
-key_type wordlist_array[] =
+key_type wordlist_array[] =
{
{"!", LM_TK_SPACE, 0},
{"#", LM_TK_SPECIAL, '#'},
if (s == "multline") return LM_OT_MULTLINE;
if (s == "gather") return LM_OT_GATHER;
return LM_OT_SIMPLE;
- }
+ }
string normalName(MathInsetTypes t)
default: break;
}
return "unknown";
- }
+ }
} // end anon namespace
if (display()) {
ascent_ += 12;
descent_ += 12;
- }
+ }
if (numberedType()) {
whichFont(mi_.font, LM_TC_BF, mi_);
void MathHullInset::label(row_type row, string const & label)
{
- label_[row] = label;
+ label_[row] = label;
}
void MathHullInset::numbered(row_type row, bool num)
{
- nonum_[row] = !num;
+ nonum_[row] = !num;
}
{
return true;
/*
- return
+ return
objtype_ == LM_OT_ALIGN ||
objtype_ == LM_OT_MULTLINE ||
objtype_ == LM_OT_GATHER ||
case LM_OT_EQUATION:
if (n)
- os << "\\begin{equation" << star(n) << "}\n";
+ os << "\\begin{equation" << star(n) << "}\n";
else
- os << "\\[\n";
+ os << "\\[\n";
break;
case LM_OT_EQNARRAY:
break;
case LM_OT_XXALIGNAT:
- os << "\\begin{xxalignat}"
+ os << "\\begin{xxalignat}"
<< "{" << static_cast<unsigned int>(ncols()/2) << "}\n";
break;
case LM_OT_EQUATION:
if (n)
- os << "\\end{equation" << star(n) << "}\n";
+ os << "\\end{equation" << star(n) << "}\n";
else
- os << "\\]\n";
+ os << "\\]\n";
break;
case LM_OT_EQNARRAY:
}
-void MathHullInset::addRow(row_type row)
+void MathHullInset::addRow(row_type row)
{
nonum_.insert(nonum_.begin() + row + 1, !numberedType());
label_.insert(label_.begin() + row + 1, string());
}
-void MathHullInset::delRow(row_type row)
+void MathHullInset::delRow(row_type row)
{
MathGridInset::delRow(row);
nonum_.erase(nonum_.begin() + row);
setType(LM_OT_SIMPLE);
break;
- case LM_OT_ALIGN:
+ case LM_OT_ALIGN:
case LM_OT_ALIGNAT:
case LM_OT_XALIGNAT:
case LM_OT_XXALIGNAT: {
MathGridInset::addCol(1);
// split it "nicely"
- pos_type pos = firstRelOp(cell(0));
+ pos_type pos = firstRelOp(cell(0));
cell(1) = cell(0);
cell(0).erase(pos, cell(0).size());
cell(1).erase(0, pos);
MathGridInset::addCol(1);
// split it "nicely" on the firest relop
- pos_type pos = firstRelOp(cell(0));
+ pos_type pos = firstRelOp(cell(0));
cell(1) = MathArray(cell(0), pos, cell(0).size());
cell(0).erase(pos, cell(0).size());
setType(LM_OT_EQNARRAY);
mutate(newtype);
break;
-
+
case LM_OT_ALIGNAT:
case LM_OT_XALIGNAT:
case LM_OT_XXALIGNAT:
void MathHullInset::write(WriteStream & os) const
{
header_write(os);
-
+
bool n = numberedType();
-
+
for (row_type row = 0; row < nrows(); ++row) {
- for (col_type col = 0; col < ncols(); ++col)
+ for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col)) << eocString(col);
if (n) {
if (!label_[row].empty())
}
os << eolString(row);
}
-
+
footer_write(os);
}
lyx::Assert(nonum_.size() == nrows());
lyx::Assert(label_.size() == nrows());
}
-
-
class LaTeXFeatures;
class MathHullInset : public MathGridInset {
-public:
+public:
///
MathHullInset();
///
/*
* File: math_inset.C
* Purpose: Implementation of insets for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
- * Description:
+ * Description:
*
* Dependencies: Xlib, XForms
*
// -*- C++ -*-
/*
* File: math_inset.h
- * Purpose: Declaration of insets for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Declaration of insets for mathed
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* Description: Math paragraph and objects for a WYSIWYG math editor.
*
Abstract base class for all math objects. A math insets is for use of the
math editor only, it isn't a general LyX inset. It's used to represent all
-the math objects.
+the math objects.
Math insets do not know there parents, a cursor position or things
like that. The are dumb object that are contained in other math insets
class MathInset {
-public:
+public:
/// short of anything else reasonable
typedef MathArray::size_type size_type;
/// type for cursor positions differences within a cell
virtual MathXArray & xcell(idx_type);
/// return cell plus drawing cache given its number
virtual MathXArray const & xcell(idx_type) const;
-
+
/// the number of columns of this inset if it is grid-like
virtual col_type ncols() const { return 1; }
/// the number of rows of this inset if it is grid-like
-
#include <config.h>
#include "math_iterator.h"
// otherwise leave array, move on one position
// this might yield pos() == size(), but that's a ok.
- pop();
+ pop();
// it certainly invalidates top
++position().pos_;
}
//lyxerr << "==: " << it.cursor().size() << " " << jt.cursor().size() << endl;
if (it.cursor().size() != jt.cursor().size())
return false;
- return it.cursor() == jt.cursor();
+ return it.cursor() == jt.cursor();
}
//lyxerr << "!=: " << it.cursor().size() << " " << jt.cursor().size() << endl;
if (it.cursor().size() != jt.cursor().size())
return true;
- return it.cursor() != jt.cursor();
+ return it.cursor() != jt.cursor();
}
/// read access to top most item
MathArray const & cell() const;
-private:
+private:
/// own level down
void push(MathInset *);
/// own level up
{
os << "[kern " << wid_.asLatexString() << "]";
}
-
void MathLimitOpInset::draw(Painter &, int, int) const
-{
+{
lyxerr << "should not happen\n";
}
/*
* File: math_macro.C
- * Purpose: Implementation of macro class for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Implementation of macro class for mathed
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: November 1996
* Description: WYSIWYG math macros
*
descent_ += max(c.descent(), ldes) + 5;
}
return;
- }
+ }
expanded_ = tmplate_->xcell(0);
expanded_.data_.substitute(*this);
void MathMacro::normalize(NormalStream & os) const
{
os << "[macro " << name() << " ";
- for (idx_type i = 0; i < nargs(); ++i)
+ for (idx_type i = 0; i < nargs(); ++i)
os << cell(i) << ' ';
os << ']';
}
os << '\\' << name();
for (idx_type i = 0; i < nargs(); ++i)
os << '{' << cell(i) << '}';
- if (nargs() == 0)
+ if (nargs() == 0)
os << ' ';
}
// -*- C++ -*-
/*
* File: math_macro.h
- * Purpose: Declaration of macro class for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Declaration of macro class for mathed
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: November 1996
* Description: WYSIWYG math macros
*
it->nucleus()->handleFont(code_);
expanded_ = true;
}
-
MathAtom & MathMacroTable::provide(string const & name)
{
builtinMacros();
-
+
table_type::iterator pos = macro_table.find(name);
if (pos == macro_table.end()) {
lyxerr << "MathMacroTable::provideTemplate: no template with name '"
<< name << "' available.\n";
}
-
+
return pos->second;
}
void MathMacroTable::builtinMacros()
{
static bool built = false;
-
+
if (built)
- return;
+ return;
built = true;
//lyxerr[Debug::MATHED] << "Building macros\n";
/** This class contains the macro definition
\author Alejandro Aguilar Sierra
*/
-//class MathMacroTemplate : public MathInset, boost::noncopyable
+//class MathMacroTemplate : public MathInset, boost::noncopyable
class MathMacroTemplate : public MathNestInset {
public:
if (row)
os << ';';
os << '[';
- for (col_type col = 0; col < ncols(); ++col)
+ for (col_type col = 0; col < ncols(); ++col)
os << cell(index(row, col)) << ' ';
os << ']';
}
// "shortcut" for DelimInset("(",ArrayInset,")")
class MathMatrixInset : public MathArrayInset {
-public:
+public:
///
MathMatrixInset(MathArrayInset const &);
///
{
return mathcursor && mathcursor->isInside(this);
}
-
class LaTeXFeatures;
class MathNestInset : public MathDimInset {
-public:
+public:
/// nestinsets have a fixed size to start with
explicit MathNestInset(idx_type ncells);
/// the size is usuall some sort of convex hull of the cells
void metrics(MathMetricsInfo const & st) const;
/// appends itself with macro arguments substituted
- void substitute(MathMacro const & macro);
+ void substitute(MathMacro const & macro);
/// identifies NestInsets
MathNestInset * asNestInset() { return this; }
MathXArray & xcell(idx_type);
/// direct access to the cell including the drawing cache
MathXArray const & xcell(idx_type) const;
-
+
/// can we move into this cell (see macroarg.h)
bool isActive() const { return nargs() > 0; }
/// request "external features"
void MathNotInset::draw(Painter & pain, int x, int y) const
-{
+{
if (math_font_available(LM_TC_CMSY))
drawChar(pain, font_, x, y, 54);
else
/*
* File: math_parser.C
* Purpose: Parser for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* Description: Parse LaTeX2e math mode code.
*
* the GNU General Public Licence version 2 or later.
*/
-/*
+/*
If someone desperately needs partial "structures" (such as a few cells of
an array inset or similar) (s)he could uses the following hack as starting
// These are TeX's catcodes
enum CatCode {
- catEscape, // 0 backslash
+ catEscape, // 0 backslash
catBegin, // 1 {
catEnd, // 2 }
catMath, // 3 $
catParameter, // 6 #
catSuper, // 7 ^
catSub, // 8 _
- catIgnore, // 9
+ catIgnore, // 9
catSpace, // 10 space
catLetter, // 11 a-zA-Z
catOther, // 12 none of the above
catInvalid // 15 <delete>
};
-CatCode theCatcode[256];
+CatCode theCatcode[256];
inline CatCode catcode(unsigned char c)
fill(theCatcode + 'a', theCatcode + 'z' + 1, catLetter);
fill(theCatcode + 'A', theCatcode + 'Z' + 1, catLetter);
- theCatcode['\\'] = catEscape;
- theCatcode['{'] = catBegin;
- theCatcode['}'] = catEnd;
- theCatcode['$'] = catMath;
- theCatcode['&'] = catAlign;
- theCatcode['\n'] = catNewline;
- theCatcode['#'] = catParameter;
- theCatcode['^'] = catSuper;
- theCatcode['_'] = catSub;
- theCatcode['\7f'] = catIgnore;
- theCatcode[' '] = catSpace;
- theCatcode['\t'] = catSpace;
- theCatcode['\r'] = catSpace;
- theCatcode['~'] = catActive;
- theCatcode['%'] = catComment;
+ theCatcode['\\'] = catEscape;
+ theCatcode['{'] = catBegin;
+ theCatcode['}'] = catEnd;
+ theCatcode['$'] = catMath;
+ theCatcode['&'] = catAlign;
+ theCatcode['\n'] = catNewline;
+ theCatcode['#'] = catParameter;
+ theCatcode['^'] = catSuper;
+ theCatcode['_'] = catSub;
+ theCatcode['\7f'] = catIgnore;
+ theCatcode[' '] = catSpace;
+ theCatcode['\t'] = catSpace;
+ theCatcode['\r'] = catSpace;
+ theCatcode['~'] = catActive;
+ theCatcode['%'] = catComment;
}
///
bool isCR() const;
-private:
+private:
///
string cs_;
///
//bool operator==(Token const & s, Token const & t)
//{
// return s.character() == t.character()
-// && s.cat() == t.cat() && s.cs() == t.cs();
+// && s.cat() == t.cat() && s.cs() == t.cs();
//}
//
//bool operator!=(Token const & s, Token const & t)
string result;
char c = getChar();
- if (c != lf)
+ if (c != lf)
putback();
- else
+ else
while ((c = getChar()) != rg && good())
result += c;
void Parser::tokenize(string const & buffer)
{
static bool init_done = false;
-
+
if (!init_done) {
catInit();
init_done = true;
switch (catcode(c)) {
case catNewline: {
- ++lineno_;
+ ++lineno_;
is.get(c);
if (catcode(c) == catNewline)
; //push_back(Token("par"));
else {
push_back(Token(' ', catSpace));
- is.putback(c);
+ is.putback(c);
}
break;
}
case catComment: {
while (is.get(c) && catcode(c) != catNewline)
;
- ++lineno_;
+ ++lineno_;
break;
}
while (is.get(c) && catcode(c) == catLetter)
s += c;
skipSpaceTokens(is, c);
- }
+ }
push_back(Token(s));
}
break;
}
-void Parser::error(string const & msg)
+void Parser::error(string const & msg)
{
lyxerr << "Line ~" << lineno_ << ": Math parse error: " << msg << endl;
dump();
bool Parser::parse_lines(MathAtom & t, bool numbered, bool outmost)
-{
+{
MathGridInset * p = t->asGridInset();
if (!p) {
dump();
//lyxerr << "reading cell " << row << " " << col << " "
// << p->ncols() << "\n";
//lyxerr << "ncols: " << p->ncols() << "\n";
-
+
if (col >= p->ncols()) {
//lyxerr << "adding col " << col << "\n";
p->addCol(p->ncols());
// << row << " " << col << "\n";
break;
}
-
+
// skip the ampersand
getToken();
}
bool Parser::parse_lines2(MathAtom & t, bool braced)
-{
+{
MathGridInset * p = t->asGridInset();
if (!p) {
lyxerr << "error in Parser::parse_lines() 1\n";
// reading a row
for (MathInset::col_type col = 0; true; ++col) {
//lyxerr << "reading cell " << row << " " << col << " " << p->ncols() << "\n";
-
+
if (col >= p->ncols()) {
//lyxerr << "adding col " << col << "\n";
p->addCol(p->ncols());
//lyxerr << "less cells read than normal in row/col: " << row << " " << col << "\n";
break;
}
-
+
// skip the ampersand
getToken();
}
}
string arg = getArg('[', ']');
- int narg = arg.empty() ? 0 : atoi(arg.c_str());
+ int narg = arg.empty() ? 0 : atoi(arg.c_str());
if (getToken().cat() != catBegin) {
lyxerr << "'{' in \\newcommand expected (2)\n";
while (good()) {
Token const & t = getToken();
-
+
#ifdef FILEDEBUG
lyxerr << "t: " << t << " flags: " << flags << "\n";
//array.dump();
continue;
flags &= ~FLAG_ITEM;
- if (t.cat() == catBegin) {
+ if (t.cat() == catBegin) {
// skip the brace and collect everything to the next matching
// closing brace
flags |= FLAG_BRACE_LAST;
// ignore braces around simple items
if ((ar.size() == 1 && !ar.front()->needsBraces()
|| (ar.size() == 2 && !ar.front()->needsBraces()
- && ar.back()->asScriptInset()))
+ && ar.back()->asScriptInset()))
|| (ar.size() == 0 && array.size() == 0))
{
array.push_back(ar);
lyx::Assert(0);
add(array, '}', LM_TC_TEX);
}
-
+
else if (t.cat() == catAlign) {
lyxerr << "found tab unexpectedly, array: '" << array << "'\n";
//lyxerr << "found tab unexpectedly\n";
add(array, '&', LM_TC_TEX);
}
-
+
else if (t.cat() == catSuper || t.cat() == catSub) {
bool up = (t.cat() == catSuper);
- MathScriptInset * p = 0;
- if (array.size())
+ MathScriptInset * p = 0;
+ if (array.size())
p = array.back()->asScriptInset();
if (!p || p->has(up)) {
array.push_back(MathAtom(new MathScriptInset(up)));
else if (t.cat() == catOther)
add(array, t.character(), code);
-
+
//
// control sequences
- //
+ //
else if (t.cs() == "protect")
- // ignore \\protect, will be re-added during output
+ // ignore \\protect, will be re-added during output
;
else if (t.cs() == "end")
lyxerr << "found newline unexpectedly\n";
array.push_back(createMathInset("\\"));
}
-
+
else if (t.cs() == "limits")
limits = 1;
-
+
else if (t.cs() == "nolimits")
limits = -1;
-
+
else if (t.cs() == "nonumber")
curr_num_ = false;
parse_into(array.back()->cell(0), FLAG_ITEM);
}
}
-
+
else if (t.cs() == "left") {
string l = getToken().asString();
MathArray ar;
dl->cell(0) = ar;
array.push_back(dl);
}
-
+
else if (t.cs() == "right") {
if (!(flags & FLAG_RIGHT)) {
//lyxerr << "got so far: '" << array << "'\n";
}
else if (t.cs() == "begin") {
- string const name = getArg('{', '}');
+ string const name = getArg('{', '}');
if (name == "array" || name == "subarray") {
string const valign = getArg('[', ']') + 'c';
string const halign = getArg('{', '}');
array.push_back(MathAtom(new MathArrayInset(name, valign[0], halign)));
parse_lines(array.back(), false, false);
} else if (name == "split" || name == "cases" ||
- name == "gathered" || name == "aligned") {
+ name == "gathered" || name == "aligned") {
array.push_back(createMathInset(name));
parse_lines(array.back(), false, false);
} else if (name == "matrix" || name == "pmatrix" || name == "bmatrix" ||
- name == "vmatrix" || name == "Vmatrix") {
+ name == "vmatrix" || name == "Vmatrix") {
array.push_back(createMathInset(name));
parse_lines2(array.back(), false);
- } else
- lyxerr << "unknow math inset begin '" << name << "'\n";
+ } else
+ lyxerr << "unknow math inset begin '" << name << "'\n";
}
-
+
else if (t.cs() == "kern") {
#ifdef WITH_WARNINGS
#warning A hack...
while (1) {
Token const & t = getToken();
if (!good()) {
- putback();
+ putback();
break;
}
s += t.character();
//array.push_back(createMathInset(t.cs()));
array.push_back(MathAtom(new MathBoxInset(t.cs())));
// slurp in the argument of mbox
-
+
MathBoxInset * p = array.back()->asBoxInset();
//lyx::assert(p);
}
#endif
-
+
else if (t.cs().size()) {
latexkeys const * l = in_word_set(t.cs());
if (l) {
//lyxerr << "starting font\n";
//CatCode catSpaceSave = theCatcode[' '];
//if (l->id == LM_TC_TEXTRM) {
- // // temporarily change catcode
- // theCatcode[' '] = catLetter;
+ // // temporarily change catcode
+ // theCatcode[' '] = catLetter;
//}
MathArray ar;
else {
MathAtom p = createMathInset(t.cs());
- for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
+ for (MathInset::idx_type i = 0; i < p->nargs(); ++i)
parse_into(p->cell(i), FLAG_ITEM);
array.push_back(p);
}
if (panic) {
lyxerr << " Math Panic, expect problems!\n";
- // Search for the end command.
+ // Search for the end command.
Token t;
do {
t = getToken();
/*
* File: math_parser.h
* Purpose: Declaration of parsing utilities for mathed
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* Description: Parse LaTeX2e math mode code.
*
///
LM_TK_SPECIAL,
///
- LM_TK_ARGUMENT,
+ LM_TK_ARGUMENT,
///
LM_TK_NEWCOMMAND,
///
return p.idx_ < q.idx_;
return p.pos_ < q.pos_;
}
-
-
#include "math_xdata.h"
-/// Description of a position
+/// Description of a position
class MathCursorPos {
public:
- ///
+ ///
MathCursorPos();
- ///
+ ///
explicit MathCursorPos(MathInset *);
/// returns cell corresponding to this position
/*
* File: math_root.C
- * Purpose: Implementation of the root object
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Implementation of the root object
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1999
* Description: Root math object
*
// -*- C++ -*-
/*
* File: math_root.h
- * Purpose: Declaration of the root object
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
+ * Purpose: Declaration of the root object
+ * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1999
* Description: Root math object
*
int des = down().ascent();
if (hasLimits(nuc))
des += nd + 2;
- else
+ else
des = max(des, nd);
return des;
}
int asc = up().descent();
if (hasLimits(nuc))
asc += na + 2;
- else
+ else
asc = max(asc, na);
asc = max(asc, mathed_char_ascent(font_, 'I'));
return asc;
void MathScriptInset::metrics(MathMetricsInfo const & mi) const
-{
+{
metrics(0, mi);
}
void MathScriptInset::metrics(MathInset const * nuc,
MathMetricsInfo const & mi) const
-{
+{
MathMetricsInfo m = mi;
smallerStyleScript(m);
MathNestInset::metrics(m);
void MathScriptInset::draw(Painter & pain, int x, int y) const
-{
+{
//lyxerr << "unexpected call to MathScriptInset::draw()\n";
draw(0, pain, x, y);
}
void MathScriptInset::metricsT(TextMetricsInfo const & mi) const
-{
+{
metricsT(0, mi);
}
void MathScriptInset::metricsT(MathInset const * nuc,
TextMetricsInfo const & mi) const
-{
+{
if (hasUp())
up().metricsT(mi);
if (hasDown())
void MathScriptInset::draw(MathInset const * nuc, Painter & pain,
int x, int y) const
-{
+{
if (nuc)
nuc->draw(pain, x + dxx(nuc), y);
else // if (editing())
}
void MathScriptInset::drawT(TextPainter & pain, int x, int y) const
-{
+{
//lyxerr << "unexpected call to MathScriptInset::draw()\n";
drawT(0, pain, x, y);
}
void MathScriptInset::drawT(MathInset const * nuc, TextPainter & pain,
int x, int y) const
-{
+{
if (nuc)
nuc->drawT(pain, x + dxx(nuc), y);
if (hasUp())
if (limits_ == -1)
return false;
- // we can only display limits if the nucleus wants some
+ // we can only display limits if the nucleus wants some
if (!nuc)
return false;
if (!nuc->isScriptable())
return false;
-
+
// per default \int has limits beside the \int even in displayed formulas
if (nuc->asSymbolInset())
if (nuc->asSymbolInset()->name().find("int") != string::npos)
void MathScriptInset::write(WriteStream & os) const
-{
+{
//lyxerr << "unexpected call to MathScriptInset::write()\n";
write2(0, os);
}
void MathScriptInset::normalize(NormalStream & os) const
-{
+{
//lyxerr << "unexpected call to MathScriptInset::normalize()\n";
normalize2(0, os);
}
bool d = hasDown() && down().data_.size();
bool u = hasUp() && up().data_.size();
- if (u)
+ if (u)
os << "[sup ";
if (d)
os << "[sub ";
-
+
if (nuc)
os << nuc << ' ';
else
if (d)
os << down().data_ << ']';
- if (u)
+ if (u)
os << up().data_ << ']';
}
if (hasUp() && up().data_.size())
os << "^(" << up().data_ << ')';
}
-
-
bool hasLimits(MathInset const * nuc) const;
/// possible subscript (index 0) and superscript (index 1)
- bool script_[2];
+ bool script_[2];
/// 1 - "limits", -1 - "nolimits", 0 - "default"
int limits_;
/// cached font
};
#endif
-
void normalize(NormalStream &) const;
private:
- ///
+ ///
latexkeys const * key_;
};
void MathSpaceInset::draw(Painter & pain, int x, int y) const
-{
-
+{
+
// XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
-
+
// Sadly, HP-UX CC can't handle that kind of initialization.
-
+
int xp[4];
int yp[4];
-
+
xp[0] = ++x; yp[0] = y - 3;
xp[1] = x; yp[1] = y;
xp[2] = x + width_ - 2; yp[2] = y;
xp[3] = x + width_ - 2; yp[3] = y - 3;
-
+
pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
}
if (space_ >= 0 && space_ < 6)
os << '\\' << latex_mathspace[space_] << ' ';
}
-
-
MathInset * MathSpecialCharInset::clone() const
-{
+{
return new MathSpecialCharInset(*this);
}
void MathSpecialCharInset::draw(Painter & pain, int x, int y) const
-{
+{
drawChar(pain, font_, x, y, char_);
}
#pragma interface
#endif
-/** An inset for characters like {, #, and $ that need to be escaped
+/** 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
*/
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
- ///
+ ///
int ascent() const;
///
int descent() const;
class MathSplitInset : public MathGridInset {
-public:
+public:
///
explicit MathSplitInset(string const & name);
///
MathInset * MathSqrtInset::clone() const
-{
+{
return new MathSqrtInset(*this);
}
void MathSqrtInset::draw(Painter & pain, int x, int y) const
-{
- xcell(0).draw(pain, x + 10, y);
+{
+ xcell(0).draw(pain, x + 10, y);
int const a = ascent_;
int const d = descent_;
int xp[4];
void MathSqrtInset::drawT(TextPainter & pain, int x, int y) const
-{
- xcell(0).drawT(pain, x + 2, y);
+{
+ xcell(0).drawT(pain, x + 2, y);
pain.horizontalLine(x + 2, y - xcell(0).ascent(), xcell(0).width(), '_');
pain.verticalLine (x + 1, y - xcell(0).ascent() + 1, xcell(0).height());
pain.draw(x, y + xcell(0).descent(), '\\');
MathInset * MathStackrelInset::clone() const
-{
+{
return new MathStackrelInset(*this);
}
smallerStyleFrac(m);
xcell(0).metrics(m);
xcell(1).metrics(mi);
- width_ = max(xcell(0).width(), xcell(1).width()) + 4;
+ width_ = max(xcell(0).width(), xcell(1).width()) + 4;
ascent_ = xcell(1).ascent() + xcell(0).height() + 4;
descent_ = xcell(1).descent();
}
#pragma interface
#endif
-/** Stackrel objects
+/** Stackrel objects
\author André Pönitz
*/
class MathStackrelInset : public MathFracbaseInset {
MathInset * MathStringInset::clone() const
-{
+{
return new MathStringInset(*this);
}
void MathStringInset::draw(Painter & pain, int x, int y) const
-{
+{
//lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
drawStr(pain, font_, x, y, str_);
}
if (code_ != LM_TC_VAR || str_.size() <= 1) {
os << ' ' << str_ << ' ';
return;
- }
+ }
// insert '*' between adjacent chars if type is LM_TC_VAR
os << str_[0];
- for (string::size_type i = 1; i < str_.size(); ++i)
+ for (string::size_type i = 1; i < str_.size(); ++i)
os << '*' << str_[i];
}
if (code_ != LM_TC_VAR || str_.size() <= 1) {
os << ' ' << str_ << ' ';
return;
- }
+ }
// insert '*' between adjacent chars if type is LM_TC_VAR
os << str_[0];
- for (string::size_type i = 1; i < str_.size(); ++i)
+ for (string::size_type i = 1; i < str_.size(); ++i)
os << '*' << str_[i];
}
void MathStringInset::write(WriteStream & os) const
{
- if (math_font_name(code_))
+ if (math_font_name(code_))
os << '\\' << math_font_name(code_) << '{' << str_ << '}';
- else
+ else
os << str_;
}
-
-
void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter &, int x, int y) const;
- ///
+ ///
int ascent() const;
///
int descent() const;
class MathSubstackInset : public MathGridInset {
-public:
+public:
///
MathSubstackInset();
///
mathed_init_fonts();
switch (type) {
- case LM_TC_SYMB:
- case LM_TC_BOLDSYMB:
+ case LM_TC_SYMB:
+ case LM_TC_BOLDSYMB:
return MathFonts[FONT_SYMBOLI];
case LM_TC_VAR:
{"uparrow", arrow, 0 },
{"Uparrow", Arrow, 0 },
{"updownarrow", udarrow, 0 },
- {"Updownarrow", Udarrow, 0 },
-
+ {"Updownarrow", Udarrow, 0 },
+
// Accents
{"ddot", ddot, 0 },
{"dddot", dddot, 0 },
{"breve", parenth, 1 },
{"vec", arrow, 3 },
{"not", slash, 0 },
-
+
// Dots
{"ldots", hline3, 0 },
{"cdots", hline3, 0 },
pain.line(x + w/2, y, x + w/2, y + h,
LColor::mathcursor, Painter::line_onoffdash);
return;
- }
-
+ }
+
deco_struct const * mds = search_deco(name);
if (!mds) {
lyxerr << "Deco was not found. Programming error?\n";
lyxerr << "name: '" << name << "'\n";
return;
}
-
+
int const n = (w < h) ? w : h;
int const r = mds->angle;
double const * d = mds->data;
-
+
if (h > 70 && (name == "(" || name == ")"))
d = parenthHigh;
-
+
Matrix mt(r, w, h);
Matrix sqmt(r, n, n);
"textrm"
};
- if (code >= LM_TC_RM && code <= LM_TC_TEXTRM)
+ if (code >= LM_TC_RM && code <= LM_TC_TEXTRM)
return theFontNames[code - LM_TC_RM];
return 0;
}
return name;
return "\\" + name + " ";
}
-
-
void MathSymbolInset::draw(Painter & pain, int x, int y) const
-{
+{
if (isRelOp())
x += 3;
MathTextCodes Code = code();
bool MathSymbolInset::isRelOp() const
-{
+{
return sym_->type == "mathrel";
}
{
os << '\\' << name();
}
-
-
MathInset * MathUndersetInset::clone() const
-{
+{
return new MathUndersetInset(*this);
}
smallerStyleFrac(m);
xcell(0).metrics(m);
xcell(1).metrics(mi);
- width_ = max(xcell(0).width(), xcell(1).width()) + 4;
+ width_ = max(xcell(0).width(), xcell(1).width()) + 4;
ascent_ = xcell(1).ascent();
descent_ = xcell(1).descent() + xcell(0).height() + 4;
}
#pragma interface
#endif
-/** Underset objects
+/** Underset objects
\author André Pönitz
*/
class MathUndersetInset : public MathFracbaseInset {
}
-void MathUnknownInset::metrics(MathMetricsInfo const & mi) const
+void MathUnknownInset::metrics(MathMetricsInfo const & mi) const
{
whichFont(font_, LM_TC_TEX, mi);
mathed_string_dim(font_, name_, ascent_, descent_, width_);
void MathUnknownInset::draw(Painter & pain, int x, int y) const
-{
+{
drawStr(pain, font_, x, y, name_);
}
MathInset * MathXArrowInset::clone() const
-{
+{
return new MathXArrowInset(*this);
}
void MathXArrowInset::draw(Painter & pain, int x, int y) const
-{
+{
xcell(0).draw(pain, x + 5, y - 10);
mathed_draw_deco(pain, x + 1, y - 7, width_ - 2, 5, name_);
}
void MathXArray::touch() const
-{
+{
clean_ = false;
drawn_ = false;
}
q->metrics(p, mi);
ascent_ = max(ascent_, q->ascent2(p));
descent_ = max(descent_, q->descent2(p));
- width_ += q->width2(p);
+ width_ += q->width2(p);
++it;
} else {
p->metrics(mi);
ascent_ = max(ascent_, p->ascent());
descent_ = max(descent_, p->descent());
- width_ += p->width();
+ width_ += p->width();
}
}
- //lyxerr << "MathXArray::metrics(): '" << ascent_ << " "
+ //lyxerr << "MathXArray::metrics(): '" << ascent_ << " "
// << descent_ << " " << width_ << "'\n";
}
q->metricsT(p, mi);
ascent_ = max(ascent_, q->ascent2(p));
descent_ = max(descent_, q->descent2(p));
- width_ += q->width2(p);
+ width_ += q->width2(p);
++it;
} else {
p->metricsT(mi);
ascent_ = max(ascent_, p->ascent());
descent_ = max(descent_, p->descent());
- width_ += p->width();
+ width_ += p->width();
}
}
}
else if (y > yo_ + descent_)
yy = y - yo_ - descent_;
- return xx + yy;
+ return xx + yy;
}
void MathXArray::findPos(MathPosFinder & f) const
{
double x = xo_;
- double y = yo_;
+ double y = yo_;
for (const_iterator it = begin(); it < end(); ++it) {
// check this position in the cell first
f.visit(x, y);
const_iterator begin() const { return data_.begin(); }
/// end iterator of the underlying MathArray
const_iterator end() const { return data_.end(); }
-
+
public:
/// the underlying MathArray
MathArray data_;
MathXArray const & t = targetCell();
pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math);
xcell(1).draw(pain, (s.xm() + t.xm())/2, (s.ym() + t.ym())/2);
-
+
}
}
class MathXYMatrixInset;
class MathXYArrowInset : public MathNestInset {
-public:
+public:
///
MathXYArrowInset();
///
class MathXYMatrixInset : public MathGridInset {
-public:
+public:
///
MathXYMatrixInset();
///