mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 05:40:59 +00:00
small bugfixes, new inset for comments and the main part is moving lfun
stuff from the FormulaBase and the cursor to those math insets that can handle the request... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4970 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3ce78466b5
commit
7cc71fc1e4
@ -35,6 +35,8 @@ libmathed_la_SOURCES = \
|
||||
math_casesinset.h \
|
||||
math_charinset.C \
|
||||
math_charinset.h \
|
||||
math_commentinset.C \
|
||||
math_commentinset.h \
|
||||
math_cursor.C \
|
||||
math_cursor.h \
|
||||
math_data.C \
|
||||
|
86
src/mathed/math_commentinset.C
Normal file
86
src/mathed/math_commentinset.C
Normal file
@ -0,0 +1,86 @@
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "math_commentinset.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "textpainter.h"
|
||||
|
||||
|
||||
|
||||
MathCommentInset::MathCommentInset()
|
||||
: MathNestInset(1)
|
||||
{}
|
||||
|
||||
|
||||
MathCommentInset::MathCommentInset(string const & str)
|
||||
: MathNestInset(1)
|
||||
{
|
||||
cell(0) = asArray(str);
|
||||
}
|
||||
|
||||
|
||||
MathInset * MathCommentInset::clone() const
|
||||
{
|
||||
return new MathCommentInset(*this);
|
||||
}
|
||||
|
||||
|
||||
void MathCommentInset::metrics(MathMetricsInfo & mi) const
|
||||
{
|
||||
dim_ = cell(0).metrics(mi);
|
||||
metricsMarkers();
|
||||
}
|
||||
|
||||
|
||||
void MathCommentInset::draw(MathPainterInfo & pi, int x, int y) const
|
||||
{
|
||||
cell(0).draw(pi, x + 1, y);
|
||||
drawMarkers(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
void MathCommentInset::metricsT(TextMetricsInfo const & mi) const
|
||||
{
|
||||
dim_ = cell(0).metricsT(mi);
|
||||
}
|
||||
|
||||
|
||||
void MathCommentInset::drawT(TextPainter & pain, int x, int y) const
|
||||
{
|
||||
cell(0).drawT(pain, x, y);
|
||||
}
|
||||
|
||||
|
||||
void MathCommentInset::write(WriteStream & os) const
|
||||
{
|
||||
os << '%' << cell(0) << "\n";
|
||||
}
|
||||
|
||||
|
||||
void MathCommentInset::maplize(MapleStream & os) const
|
||||
{}
|
||||
|
||||
|
||||
void MathCommentInset::mathematicize(MathematicaStream & os) const
|
||||
{}
|
||||
|
||||
|
||||
void MathCommentInset::octavize(OctaveStream & os) const
|
||||
{}
|
||||
|
||||
|
||||
void MathCommentInset::mathmlize(MathMLStream & os) const
|
||||
{
|
||||
os << MTag("comment") << cell(0) << cell(1) << ETag("comment");
|
||||
}
|
||||
|
||||
|
||||
void MathCommentInset::infoize(std::ostream & os) const
|
||||
{
|
||||
os << "Comment";
|
||||
}
|
47
src/mathed/math_commentinset.h
Normal file
47
src/mathed/math_commentinset.h
Normal file
@ -0,0 +1,47 @@
|
||||
// -*- C++ -*-
|
||||
#ifndef MATH_COMMENTINSET_H
|
||||
#define MATH_COMMENTINSET_H
|
||||
|
||||
#include "math_nestinset.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
/** Inset for end-of-line comments
|
||||
\author André Pönitz
|
||||
*/
|
||||
|
||||
class latexkeys;
|
||||
|
||||
class MathCommentInset : public MathNestInset {
|
||||
public:
|
||||
///
|
||||
MathCommentInset();
|
||||
///
|
||||
explicit MathCommentInset(string const &);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathMetricsInfo & mi) const;
|
||||
///
|
||||
void draw(MathPainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void metricsT(TextMetricsInfo const & mi) const;
|
||||
///
|
||||
void drawT(TextPainter & pi, int x, int y) const;
|
||||
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
///
|
||||
void maplize(MapleStream &) const;
|
||||
///
|
||||
void mathematicize(MathematicaStream &) const;
|
||||
///
|
||||
void octavize(OctaveStream &) const;
|
||||
///
|
||||
void mathmlize(MathMLStream &) const;
|
||||
///
|
||||
void infoize(std::ostream & os) const;
|
||||
};
|
||||
#endif
|
@ -33,7 +33,7 @@
|
||||
#include "math_autocorrect.h"
|
||||
#include "math_arrayinset.h"
|
||||
#include "math_braceinset.h"
|
||||
#include "math_casesinset.h"
|
||||
#include "math_commentinset.h"
|
||||
#include "math_charinset.h"
|
||||
#include "math_extern.h"
|
||||
#include "math_factory.h"
|
||||
@ -1151,15 +1151,6 @@ bool MathCursor::interpret(string const & s)
|
||||
//owner_->getIntl()->getTransManager().TranslateAndInsert(s[0], lt);
|
||||
//lyxerr << "trans: '" << s[0] << "' int: " << int(s[0]) << endl;
|
||||
|
||||
if (s.size() >= 5 && s.substr(0, 5) == "cases") {
|
||||
unsigned int n = 1;
|
||||
istringstream is(s.substr(5).c_str());
|
||||
is >> n;
|
||||
n = max(1u, n);
|
||||
niceInsert(MathAtom(new MathCasesInset(n)));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s.size() >= 6 && s.substr(0, 6) == "matrix") {
|
||||
unsigned int m = 1;
|
||||
unsigned int n = 1;
|
||||
@ -1384,7 +1375,7 @@ bool MathCursor::interpret(char c)
|
||||
}
|
||||
|
||||
if (c == '%') {
|
||||
insert(createMathInset("%"));
|
||||
niceInsert(MathAtom(new MathCommentInset));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -961,6 +961,42 @@ MathInset::result_type MathGridInset::dispatch
|
||||
return DISPATCHED_POP;
|
||||
}
|
||||
|
||||
case LFUN_MATH_HALIGN:
|
||||
halign((cmd.argument + "c")[0], col(idx));
|
||||
return DISPATCHED_POP;
|
||||
|
||||
case LFUN_MATH_VALIGN:
|
||||
valign((cmd.argument + "c")[0]);
|
||||
return DISPATCHED_POP;
|
||||
|
||||
case LFUN_MATH_ROW_INSERT:
|
||||
addRow(row(idx));
|
||||
return DISPATCHED_POP;
|
||||
|
||||
case LFUN_MATH_ROW_DELETE:
|
||||
delRow(row(idx));
|
||||
if (idx > nargs())
|
||||
idx -= ncols();
|
||||
return DISPATCHED_POP;
|
||||
|
||||
case LFUN_MATH_COLUMN_INSERT: {
|
||||
row_type r = row(idx);
|
||||
col_type c = col(idx);
|
||||
addFancyCol(c);
|
||||
idx = index(r, c);
|
||||
return DISPATCHED_POP;
|
||||
}
|
||||
|
||||
case LFUN_MATH_COLUMN_DELETE: {
|
||||
row_type r = row(idx);
|
||||
col_type c = col(idx);
|
||||
delFancyCol(col(idx));
|
||||
idx = index(r, c);
|
||||
if (idx > nargs())
|
||||
idx -= ncols();
|
||||
return DISPATCHED_POP;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -684,8 +684,14 @@ MathInset::result_type MathHullInset::dispatch
|
||||
}
|
||||
return DISPATCHED;
|
||||
|
||||
case LFUN_MATH_HALIGN:
|
||||
case LFUN_MATH_VALIGN:
|
||||
// we explicitly don't want the default behaviour here
|
||||
return UNDISPATCHED;
|
||||
|
||||
default:
|
||||
return UNDISPATCHED;
|
||||
return MathGridInset::dispatch(cmd, idx, pos);
|
||||
|
||||
}
|
||||
return UNDISPATCHED;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ following hack as starting point to write some macros:
|
||||
#include "math_braceinset.h"
|
||||
#include "math_boxinset.h"
|
||||
#include "math_charinset.h"
|
||||
#include "math_commentinset.h"
|
||||
#include "math_deliminset.h"
|
||||
#include "math_envinset.h"
|
||||
#include "math_extern.h"
|
||||
@ -434,12 +435,14 @@ void Parser::tokenize(string const & buffer)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
case catComment: {
|
||||
while (is.get(c) && catcode(c) != catNewline)
|
||||
;
|
||||
++lineno_;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case catEscape: {
|
||||
is.get(c);
|
||||
@ -563,7 +566,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
|
||||
|
||||
#ifdef FILEDEBUG
|
||||
lyxerr << "t: " << t << " flags: " << flags << "\n";
|
||||
//cell->dump();
|
||||
cell->dump();
|
||||
lyxerr << "\n";
|
||||
#endif
|
||||
|
||||
@ -724,6 +727,18 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
|
||||
else if (t.cat() == catOther)
|
||||
cell->push_back(MathAtom(new MathCharInset(t.character())));
|
||||
|
||||
else if (t.cat() == catComment) {
|
||||
string s;
|
||||
while (good()) {
|
||||
Token const & t = getToken();
|
||||
if (t.cat() == catNewline)
|
||||
break;
|
||||
s += t.asString();
|
||||
}
|
||||
cell->push_back(MathAtom(new MathCommentInset(s)));
|
||||
skipSpaces();
|
||||
}
|
||||
|
||||
//
|
||||
// control sequences
|
||||
//
|
||||
|
@ -292,12 +292,6 @@ bool MathScriptInset::has(bool up) const
|
||||
}
|
||||
|
||||
|
||||
bool MathScriptInset::empty() const
|
||||
{
|
||||
return !script_[0] && !script_[1] && cell(2).empty();
|
||||
}
|
||||
|
||||
|
||||
bool MathScriptInset::hasUp() const
|
||||
{
|
||||
return script_[1];
|
||||
|
@ -83,8 +83,6 @@ public:
|
||||
bool hasDown() const;
|
||||
/// do we have a script?
|
||||
bool has(bool up) const;
|
||||
/// do we have a anything?
|
||||
bool empty() const;
|
||||
/// remove script
|
||||
void removeScript(bool up);
|
||||
/// remove script
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
char const * latex_mathspace[] = {
|
||||
"!", ",", ";", ":", "quad", "qquad", "lyxnegspace", "lyxposspace"
|
||||
"!", ",", ":", ";", "quad", "qquad", "lyxnegspace", "lyxposspace"
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user