Hello!
Right now, navigating macros with arguments is quite unintuitive, especially since they change their size on the screen when you enter and leave them. (Actually, I mean macro calls, not macro definitions.) So I've developed a small patch for Lyx (version 1.3.4 from Debian) that makes math macro arguments behave almost like arguments to other math functions (sqrt, frac, etc.).
However, please note that the patch is not complete yet: I did not address the issue that a macro argument does not actually have to appear in the macro body. If you like the patch, I will add support for this. But I'm not sure what the best solution would be.
Unfortunately, the patch is a bit of a hack: The macro argument class carries a pointer to a cell, and there is no way to ensure that this pointer will stay valid. However, the only case when the cell may be deleted is when the entire macro (call) is deleted. In that case, the macro argument is deleted as well, of course. I have used the patch for quite some time now, and I have not experienced any problems.
I hope you like the patch. If you do, please consider applying it to your sources, after the remaining issue is solved. Thank you very much.
-- Sebastian Reichelt
diff -ur lyx-1.3.4-old/src/mathed/math_macro.C lyx-1.3.4/src/mathed/math_macro.C --- lyx-1.3.4-old/src/mathed/math_macro.C 2003-01-07 12:24:43.000000000 +0100 +++ lyx-1.3.4/src/mathed/math_macro.C 2005-04-17 21:37:48.000000000 +0200 @@ -82,6 +82,7 @@ return; } +#if 0 if (editing()) { expand(); dim_ = expanded_.metrics(mi_); @@ -101,6 +102,7 @@ } return; } +#endif expand(); expanded_.substitute(*this); @@ -121,6 +123,7 @@ return; } +#if 0 if (editing()) { int h = y - ascent() + 2 + expanded_.ascent(); drawStr(pi, font_, x + 3, h, name()); @@ -143,6 +146,7 @@ } return; } +#endif expanded_.draw(pi, x, y); } @@ -160,6 +164,7 @@ } +#if 0 bool MathMacro::idxUpDown(idx_type & idx, pos_type &, bool up, int x) const { pos_type pos; @@ -187,6 +192,7 @@ { return false; } +#endif void MathMacro::validate(LaTeXFeatures & features) const diff -ur lyx-1.3.4-old/src/mathed/math_macro.h lyx-1.3.4/src/mathed/math_macro.h --- lyx-1.3.4-old/src/mathed/math_macro.h 2003-01-07 12:24:43.000000000 +0100 +++ lyx-1.3.4/src/mathed/math_macro.h 2005-04-17 14:49:56.000000000 +0200 @@ -50,12 +50,14 @@ /// void dump() const; +#if 0 /// bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const; /// bool idxLeft(idx_type & idx, pos_type & pos) const; /// bool idxRight(idx_type & idx, pos_type & pos) const; +#endif /// void validate(LaTeXFeatures &) const; diff -ur lyx-1.3.4-old/src/mathed/math_macroarg.C lyx-1.3.4/src/mathed/math_macroarg.C --- lyx-1.3.4-old/src/mathed/math_macroarg.C 2002-08-02 16:29:42.000000000 +0200 +++ lyx-1.3.4/src/mathed/math_macroarg.C 2005-04-17 21:41:00.000000000 +0200 @@ -13,7 +13,7 @@ MathMacroArgument::MathMacroArgument(int n) - : MathNestInset(1), number_(n), expanded_(false) + : MathDimInset(), number_(n), expanded_(false) { if (n < 1 || n > 9) { lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: " @@ -40,7 +40,7 @@ void MathMacroArgument::metrics(MathMetricsInfo & mi) const { if (expanded_) - dim_ = cell(0).metrics(mi); + dim_ = cell->metrics(mi); else mathed_string_dim(mi.base.font, str_, dim_); } @@ -49,7 +49,7 @@ void MathMacroArgument::draw(MathPainterInfo & pi, int x, int y) const { if (expanded_) - cell(0).draw(pi, x, y); + cell->draw(pi, x, y); else drawStrRed(pi, x, y, str_); } @@ -63,6 +63,6 @@ void MathMacroArgument::substitute(MathMacro const & m) { - cell(0) = m.cell(number_ - 1); + cell = &(m.cell(number_ - 1)); expanded_ = true; } diff -ur lyx-1.3.4-old/src/mathed/math_macroarg.h lyx-1.3.4/src/mathed/math_macroarg.h --- lyx-1.3.4-old/src/mathed/math_macroarg.h 2002-09-11 10:26:02.000000000 +0200 +++ lyx-1.3.4/src/mathed/math_macroarg.h 2005-04-17 21:41:06.000000000 +0200 @@ -13,7 +13,7 @@ * * Full author contact details are available in file CREDITS */ -class MathMacroArgument : public MathNestInset { +class MathMacroArgument : public MathDimInset { public: /// explicit MathMacroArgument(int); @@ -40,6 +40,8 @@ char str_[3]; /// bool expanded_; + /// + const MathArray * cell; }; #endif