+
+2002-08-07 André Pönitz <poenitz@gmx.net>
+
+ * commandtags.h: new LFUN_MOUSE_(PRESS|MOTION|RELEASE)
+
+ * funcrequest.h: extension to keep mouse (x,y) position
+
2002-08-12 Juergen Vigna <jug@sad.it>
* BufferView2.C (insertErrors): forbid undo when inserting error
LFUN_FORKS_SHOW, // Angus 16 Feb 2002
LFUN_FORKS_KILL, // Angus 16 Feb 2002
LFUN_TOOLTIPS_TOGGLE, // Angus 8 Mar 2002
+ LFUN_MOUSE_PRESS, // André 9 Aug 2002
+ LFUN_MOUSE_MOTION, // André 9 Aug 2002
+ LFUN_MOUSE_RELEASE, // André 9 Aug 2002
LFUN_LASTACTION /* this marks the end of the table */
};
: action(act), argument(arg)
{}
+ /// for mouse events
+ FuncRequest(kb_action act, int ax, int ay, int aextra)
+ : action(act), argument(), x(ax), y(ay), extra(aextra)
+ {}
+
/// the action
kb_action action;
/// the action's string argument
string argument;
+ /// the x coordinate of a mouse press
+ int x;
+ /// the y coordinate of a mouse press
+ int y;
+ /// some extra information (like button number)
+ int extra;
};
#endif // FUNCREQUEST_H
bool InsetFormulaBase::insetButtonRelease(BufferView * bv,
- int /*x*/, int /*y*/, mouse_button::state button)
+ int x, int y, mouse_button::state button)
{
if (!mathcursor)
return false;
if (button == mouse_button::button3) {
// try to dispatch to enclosed insets first
- if (mathcursor->dispatch("mouse-3-release"))
+ if (mathcursor->dispatch(FuncRequest(LFUN_MOUSE_RELEASE, x, y, 3)))
return true;
// launch math panel for right mouse button
if (button == mouse_button::button1) {
// try to dispatch to enclosed insets first
- if (mathcursor->dispatch("mouse-1-release"))
+ if (mathcursor->dispatch(FuncRequest(LFUN_MOUSE_RELEASE, x, y, 1)))
return true;
// try to set the cursor
//lyxerr << "insetButtonPress: "
// << x << " " << y << " but: " << button << "\n";
//lyxerr << "formula: ";
- par()->dump();
+ //par()->dump();
releaseMathCursor(bv);
mathcursor = new MathCursor(this, x == 0);
mathcursor->selClear();
mathcursor->setPos(x + xo_, y + yo_);
- if (mathcursor->dispatch("mouse-1-press")) {
+ if (mathcursor->dispatch(FuncRequest(LFUN_MOUSE_PRESS, x, y, 1))) {
//delete mathcursor;
return;
}
}
if (button == mouse_button::button3) {
- if (mathcursor->dispatch("mouse-3-press")) {
+ if (mathcursor->dispatch(FuncRequest(LFUN_MOUSE_PRESS, x, y, 3))) {
//delete mathcursor;
return;
}
return;
if (button == mouse_button::button1)
- if (mathcursor->dispatch("mouse-1-motion"))
+ if (mathcursor->dispatch(FuncRequest(LFUN_MOUSE_MOTION, x, y, 1)))
return;
if (button == mouse_button::button3)
- if (mathcursor->dispatch("mouse-3-motion"))
+ if (mathcursor->dispatch(FuncRequest(LFUN_MOUSE_MOTION, x, y, 3)))
return;
if (abs(x - first_x) < 2 && abs(y - first_y) < 2) {
}
-int MathCursor::dispatch(string const & cmd)
+int MathCursor::dispatch(FuncRequest const & cmd)
{
// try to dispatch to adajcent items if they are not editable
// actually, this should only happen for mouse clicks...
for (int i = Cursor_.size() - 1; i >= 0; --i) {
MathCursorPos & pos = Cursor_[i];
- if (int res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_))
+ int const res = pos.par_->dispatch(cmd, pos.idx_, pos.pos_);
+ if (res)
return res;
}
return 0;
unsigned depth() const;
/// local dispatcher
- int dispatch(string const & cmd);
+ int dispatch(FuncRequest const & cmd);
/// describe the situation
string info() const;
/// dump selection information for debugging
// special case of pre-defined macros
if (line.size() > 8 && line.substr(0, 5) == "\\def\\") {
- lyxerr << "defining: '" << line << "'\n";
+ //lyxerr << "defining: '" << line << "'\n";
istringstream is(line);
MathMacroTable::create(MathAtom(new MathMacroTemplate(is)));
continue;
setDefaults();
valign(v);
halign(h);
+ //lyxerr << "created grid with " << ncols() << " columns\n";
}
{
col_type col = 0;
for (string::const_iterator it = hh.begin(); it != hh.end(); ++it) {
+ if (col >= ncols())
+ break;
char c = *it;
if (c == '|') {
colinfo_[col].lines_++;
++col;
colinfo_[col].lines_ = 0;
} else {
- lyxerr << "unkown column separator: '" << c << "'\n";
+ lyxerr << "unknown column separator: '" << c << "'\n";
}
}
for (string::const_iterator it = hh.begin(); it != hh.end(); ++it)
if (*it == 'c' || *it == 'l' || *it == 'r')
++col;
+ // let's have at least one column, even if we did not recognize its
+ // alignment
+ if (col == 0)
+ col = 1;
return col;
}
}
-int MathInset::dispatch(string const &, idx_type, pos_type)
+int MathInset::dispatch(FuncRequest const &, idx_type, pos_type)
{
return 0; // undispatched
}
class MathMacroTemplate;
class MathPosFinder;
class Dimension;
+class FuncRequest;
class MathInset {
/// dump content to stderr for debugging
virtual void dump() const;
/// local dispatcher
- virtual int dispatch(string const & cmd, idx_type idx, pos_type pos);
+ virtual int dispatch(FuncRequest const & cmd, idx_type idx, pos_type pos);
/// LyXInset stuff
/// write labels into a list
FLAG_SIMPLE = 1 << 8, // next $ leaves the loop
FLAG_EQUATION = 1 << 9, // next \] leaves the loop
FLAG_SIMPLE2 = 1 << 10, // next \) leaves the loop
- FLAG_OPTION = 1 << 11 // read [...] style option
+ FLAG_OPTION = 1 << 11, // read [...] style option
+ FLAG_BRACED = 1 << 12 // read {...} style argument
};
///
void parse(MathArray & array, unsigned flags, mode_type mode);
///
+ MathArray parse(unsigned flags, mode_type mode);
+ ///
int lineno() const { return lineno_; }
///
void putback();
}
+MathArray Parser::parse(unsigned flags, mode_type mode)
+{
+ MathArray ar;
+ parse(ar, flags, mode);
+ return ar;
+}
+
+
void Parser::parse(MathArray & array, unsigned flags, mode_type mode)
{
MathGridInset grid(1, 1);
}
+ if (flags & FLAG_BRACED) {
+ if (t.cat() == catSpace)
+ continue;
+
+ if (t.cat() != catBegin) {
+ error("opening brace expected");
+ return;
+ }
+
+ // skip the brace and collect everything to the next matching
+ // closing brace
+ flags = FLAG_BRACE_LAST;
+ }
+
+
if (flags & FLAG_OPTION) {
if (t.cat() == catOther && t.character() == '[') {
MathArray ar;
else if (t.cs() == "begin") {
string const name = getArg('{', '}');
+
if (name == "array" || name == "subarray") {
- string const valign = getArg('[', ']') + 'c';
- string const halign = getArg('{', '}');
+ string const valign =
+ asString(parse(FLAG_OPTION, MathInset::VERBATIM_MODE)) + 'c';
+ string const halign =
+ asString(parse(FLAG_ITEM, MathInset::VERBATIM_MODE));
cell->push_back(MathAtom(new MathArrayInset(name, valign[0], halign)));
parse2(cell->back(), FLAG_END, mode, false);
}
}
else if (t.cs() == "label") {
- MathArray ar;
- parse(ar, FLAG_ITEM, MathInset::VERBATIM_MODE);
+ MathArray ar = parse(FLAG_ITEM, MathInset::VERBATIM_MODE);
if (grid.asHullInset()) {
grid.asHullInset()->label(cellrow, asString(ar));
} else {
// read optional positioning and width
MathArray pos, width;
parse(pos, FLAG_OPTION, MathInset::VERBATIM_MODE);
+
parse(width, FLAG_ITEM, MathInset::VERBATIM_MODE);
cell->push_back(createMathInset(t.cs()));
parse(cell->back().nucleus()->cell(0), FLAG_ITEM, MathInset::TEXT_MODE);
}
-int RefInset::dispatch(string const & cmd, idx_type, pos_type)
+int RefInset::dispatch(FuncRequest const & cmd, idx_type, pos_type)
{
- if (cmd == "mouse-3-release") {
- lyxerr << "trying to goto ref" << cell(0) << "\n";
- mathcursor->formula()->view()->owner()->getLyXFunc()->
- dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
- return 1; // dispatched
- }
-
- if (cmd == "mouse-1-release") {
- lyxerr << "trying to open ref" << cell(0) << "\n";
- // FuncRequestually trigger dialog with button 3 not 1
-// mathcursor->formula()->view()->owner()->getDialogs()
-// ->showRef(this);
- return 1; // dispatched
+ switch (cmd.action) {
+ case LFUN_MOUSE_RELEASE:
+ if (cmd.extra == 3) {
+ lyxerr << "trying to goto ref" << cell(0) << "\n";
+ mathcursor->formula()->view()->owner()->getLyXFunc()->
+ dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
+ return 1; // dispatched
+ }
+ if (cmd.extra == 1) {
+ lyxerr << "trying to open ref" << cell(0) << "\n";
+ // Eventually trigger dialog with button 3 not 1
+ // mathcursor->formula()->view()->owner()->getDialogs()
+ // ->showRef(this);
+ return 1; // dispatched
+ }
+ break;
+ case LFUN_MOUSE_PRESS:
+ case LFUN_MOUSE_MOTION:
+ // eat other mouse commands
+ return 1;
+ default:
+ break;
}
-
- // eat other mouse commands
- if (cmd.substr(0, 6) == "mouse-")
- return 1;
-
- return 0; // undispatched
+ // not our business
+ return 0;
}
///
void infoize(std::ostream & os) const;
///
- int dispatch(string const & cmd, idx_type idx, pos_type pos);
+ int dispatch(FuncRequest const & cmd, idx_type idx, pos_type pos);
///
string screenLabel() const;
///