bool InsetMathGrid::interpretString(Cursor & cur, docstring const & str)
{
if (str == "\\hline") {
- FuncRequest fr = FuncRequest(LFUN_INSET_MODIFY, "tabular add-hline-above");
+ FuncRequest fr = FuncRequest(LFUN_TABULAR_FEATURE, "add-hline-above");
FuncStatus status;
if (getStatus(cur, fr, status)) {
if (status.enabled()) {
colinfo_[col].offset_ =
colinfo_[col - 1].offset_ +
colinfo_[col - 1].width_ +
- colinfo_[col - 1].skip_ +
+ displayColSpace(col - 1) +
colsep() +
colinfo_[col].lines_ * vlinesep();
}
int const nextoffset =
colinfo_[first].offset_ +
wid +
- colinfo_[last].skip_ +
+ displayColSpace(last) +
colsep() +
colinfo_[last+1].lines_ * vlinesep();
int const dx = nextoffset - colinfo_[last+1].offset_;
colinfo_[col].offset_ =
colinfo_[col - 1].offset_ +
colinfo_[col - 1].width_ +
- colinfo_[col - 1].skip_ +
+ displayColSpace(col - 1) +
1 ; //colsep() +
//colinfo_[col].lines_ * vlinesep();
}
col_type c2 = c1 + ncellcols(idx);
return colinfo_[c2].offset_
- colinfo_[c1].offset_
- - colinfo_[c2].skip_
+ - displayColSpace(c2)
- colsep()
- colinfo_[c2].lines_ * vlinesep();
}
}
+int InsetMathGrid::displayColSpace(col_type col) const
+{
+ return colinfo_[col].skip_;
+}
+
void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
{
//lyxerr << "*** InsetMathGrid: request: " << cmd << endl;
case LFUN_CELL_BACKWARD:
// See below.
- cur.setSelection(false);
+ cur.selection(false);
if (!idxPrev(cur)) {
cmd = FuncRequest(LFUN_FINISHED_BACKWARD);
cur.undispatched();
case LFUN_CELL_FORWARD:
// Can't handle selection by additional 'shift' as this is
// hard bound to LFUN_CELL_BACKWARD
- cur.setSelection(false);
+ cur.selection(false);
if (!idxNext(cur)) {
cmd = FuncRequest(LFUN_FINISHED_FORWARD);
cur.undispatched();
break;
}
- case LFUN_INSET_MODIFY: {
+ case LFUN_TABULAR_FEATURE: {
cur.recordUndoInset();
//lyxerr << "handling tabular-feature " << to_utf8(cmd.argument()) << endl;
istringstream is(to_utf8(cmd.argument()));
string s;
is >> s;
- if (s != "tabular") {
- InsetMathNest::doDispatch(cur, cmd);
- return;
- }
- is >> s;
if (s == "valign-top")
setVerticalAlignment('t');
else if (s == "valign-middle")
}
bool hline_enabled = false;
- FuncRequest fr = FuncRequest(LFUN_INSET_MODIFY, "tabular add-hline-above");
+ FuncRequest fr = FuncRequest(LFUN_TABULAR_FEATURE, "add-hline-above");
FuncStatus status;
if (getStatus(cur, fr, status))
hline_enabled = status.enabled();
FuncStatus & status) const
{
switch (cmd.action()) {
- case LFUN_INSET_MODIFY: {
- istringstream is(to_utf8(cmd.argument()));
- string s;
- is >> s;
- if (s != "tabular") {
- // We only now about table actions here.
- break;
- }
+ case LFUN_TABULAR_FEATURE: {
+ string s = cmd.getArg(0);
if (&cur.inset() != this) {
// Table actions requires that the cursor is _inside_ the
// table.
status.message(from_utf8(N_("Cursor not in table")));
return true;
}
- is >> s;
if (nrows() <= 1 && (s == "delete-row" || s == "swap-row")) {
status.setEnabled(false);
status.message(from_utf8(N_("Only one row")));
} else {
status.setEnabled(false);
status.message(bformat(
- from_utf8(N_("Unknown tabular feature '%1$s'")), lyx::from_ascii(s)));
+ from_utf8(N_("Unknown tabular feature '%1$s'")),
+ from_utf8(s)));
}
#if 0
}
+// static
+char InsetMathGrid::colAlign(HullType type, col_type col)
+{
+ switch (type) {
+ case hullEqnArray:
+ return "rcl"[col % 3];
+
+ case hullMultline:
+ case hullGather:
+ return 'c';
+
+ case hullAlign:
+ case hullAlignAt:
+ case hullXAlignAt:
+ case hullXXAlignAt:
+ case hullFlAlign:
+ return "rl"[col & 1];
+
+ case hullUnknown:
+ case hullNone:
+ case hullSimple:
+ case hullEquation:
+ case hullRegexp:
+ return 'c';
+ }
+ // avoid warning
+ return 'c';
+}
+
+
+//static
+int InsetMathGrid::colSpace(HullType type, col_type col)
+{
+ int alignInterSpace = 0;
+ switch (type) {
+ case hullUnknown:
+ case hullNone:
+ case hullSimple:
+ case hullEquation:
+ case hullMultline:
+ case hullGather:
+ case hullRegexp:
+ return 0;
+
+ case hullEqnArray:
+ return 5;
+
+ case hullAlign:
+ alignInterSpace = 20;
+ break;
+ case hullAlignAt:
+ alignInterSpace = 0;
+ break;
+ case hullXAlignAt:
+ alignInterSpace = 40;
+ break;
+ case hullXXAlignAt:
+ case hullFlAlign:
+ alignInterSpace = 60;
+ break;
+ }
+ return (col % 2) ? alignInterSpace : 0;
+}
+
+
} // namespace lyx