"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Data/Tree/tree_cursor.cpp" between
TeXmacs-1.99.4-src.tar.gz and TeXmacs-1.99.5-src.tar.gz

About: GNU TeXmacs is a what-you-see-is-what-you-get scientific text editor, which was both inspired by TeX and GNU Emacs.

tree_cursor.cpp  (TeXmacs-1.99.4-src):tree_cursor.cpp  (TeXmacs-1.99.5-src)
skipping to change at line 87 skipping to change at line 87
return false; return false;
// Assuming that t is a concat, check whether p does not correspond // Assuming that t is a concat, check whether p does not correspond
// to an inaccessible border position // to an inaccessible border position
int i= p->item + 1; int i= p->item + 1;
if (i >= N(t)) return false; if (i >= N(t)) return false;
if (is_compound (t[i]) && the_drd->is_child_enforcing (t[i])) if (is_compound (t[i]) && the_drd->is_child_enforcing (t[i]))
return p->next == end (t[p->item]); return p->next == end (t[p->item]);
return false; return false;
} }
static int
lowest_accessible_child (tree t) {
for (int i=0; i<N(t); i++)
if (the_drd->is_accessible_child (t, i))
return i;
return 0;
}
static int
highest_accessible_child (tree t) {
for (int i=N(t)-1; i>=0; i--)
if (the_drd->is_accessible_child (t, i))
return i;
return N(t) - 1;
}
static bool
graphics_in_path (tree t, path p) {
// FIXME: when in the cursor is inside graphics,
// it cannot be at the start/end. There should be
// a more robust way to ensure this.
if (is_nil (p) || is_atom (p)) return false;
if (is_atomic (t) || p->item < 0 || p->item >= N(t)) return false;
if (is_func (t, GRAPHICS)) return true;
return graphics_in_path (t[p->item], p->next);
}
bool bool
is_accessible_cursor (tree t, path p) { is_accessible_cursor (tree t, path p) {
if (is_atomic (t) || is_atom (p)) { if (is_atomic (t) || is_atom (p)) {
if (get_writable_mode () == DRD_WRITABLE_INPUT && if (get_writable_mode () == DRD_WRITABLE_INPUT &&
get_access_mode () != DRD_ACCESS_SOURCE) get_access_mode () != DRD_ACCESS_SOURCE)
return false; return false;
else if (is_atomic (t)) else if (is_atomic (t))
return is_atom (p) && p->item >= 0 && p->item <= N(t->label); return is_atom (p) && p->item >= 0 && p->item <= N(t->label);
else return !the_drd->is_child_enforcing (t); else return !the_drd->is_child_enforcing (t);
} }
else if (0 > p->item || p->item >= N(t)) return false; else if (0 > p->item || p->item >= N(t)) return false;
else if (the_drd->is_parent_enforcing (t) && else if (the_drd->is_parent_enforcing (t) &&
((p->item == 0 && p->next == start (t[0])) || !graphics_in_path (t, p) &&
(p->item == N(t)-1 && p->next == end (t[p->item])))) ((p->item == lowest_accessible_child (t) &&
p->next == start (t[p->item])) ||
(p->item == highest_accessible_child (t) &&
p->next == end (t[p->item]))))
return false; return false;
else switch (L(t)) { else switch (L(t)) {
case CONCAT: case CONCAT:
if (!is_accessible_cursor (t[p->item], p->next)) return false; if (!is_accessible_cursor (t[p->item], p->next)) return false;
else return !next_without_border (t, p); else return !next_without_border (t, p);
case ACTIVE: case ACTIVE:
return is_modified_accessible (t, p, true, false); return is_modified_accessible (t, p, true, false);
case VAR_ACTIVE: case VAR_ACTIVE:
return is_modified_accessible (t, p, true, true); return is_modified_accessible (t, p, true, true);
case INACTIVE: case INACTIVE:
skipping to change at line 161 skipping to change at line 191
// FIXME: certain tags modify source accessability props // FIXME: certain tags modify source accessability props
// FIXME: cells with non-trivial span may lead to unaccessability // FIXME: cells with non-trivial span may lead to unaccessability
// FIXME: very dynamic markup should be treated after typesetting // FIXME: very dynamic markup should be treated after typesetting
if (is_atom (p) && is_atomic (t[j])) if (is_atom (p) && is_atomic (t[j]))
return path (j, p->item * (j < k? N (t[j]->label): 0)); return path (j, p->item * (j < k? N (t[j]->label): 0));
path sp= (is_atom (p)? (j < k? path (1): path (0)): p->next); path sp= (is_atom (p)? (j < k? path (1): path (0)): p->next);
path r= closest_accessible (t[j], sp); path r= closest_accessible (t[j], sp);
if (!is_nil (r)) { if (!is_nil (r)) {
r= path (j, r); r= path (j, r);
if (!is_concat (t) || !next_without_border (t, r)) { if (!is_concat (t) || !next_without_border (t, r)) {
if (the_drd->is_parent_enforcing (t)) { if (the_drd->is_parent_enforcing (t) &&
if (r->item == 0 && r->next == start (t[0])) !graphics_in_path (t, p)) {
if (r->item == lowest_accessible_child (t) &&
!is_accessible_cursor (t, p))
return path (0); return path (0);
if (r->item == N(t)-1 && r->next == end (t[r->item])) if (r->item == highest_accessible_child (t) &&
!is_accessible_cursor (t, p))
return path (1); return path (1);
} }
return r; return r;
} }
} }
} }
} }
return path (); return path ();
} }
} }
skipping to change at line 234 skipping to change at line 267
failed_error << "Testing valid cursor " << p << " in " << t << "\n"; failed_error << "Testing valid cursor " << p << " in " << t << "\n";
FAILED ("bad path"); FAILED ("bad path");
} }
if (is_nil (p)) return false; if (is_nil (p)) return false;
if (is_atom (p)) { if (is_atom (p)) {
if (the_drd->is_child_enforcing (t)) return false; if (the_drd->is_child_enforcing (t)) return false;
if (start_flag) return (p->item!=0); if (start_flag) return (p->item!=0);
return true; return true;
} }
if (the_drd->is_parent_enforcing (t)) if (the_drd->is_parent_enforcing (t) &&
if ((p->item == 0 && p->next == start (t[0])) || !graphics_in_path (t, p) &&
(p->item == N(t)-1 && p->next == end (t[p->item]))) ((p->item == lowest_accessible_child (t) &&
return false; p->next == start (t[p->item])) ||
(p->item == highest_accessible_child (t) &&
p->next == end (t[p->item]))))
return false;
if (is_concat (t)) { if (is_concat (t)) {
if (next_without_border (t, p)) return false; if (next_without_border (t, p)) return false;
return valid_cursor (t[p->item], p->next, start_flag || (p->item!=0)); return valid_cursor (t[p->item], p->next, start_flag || (p->item!=0));
} }
if (is_mod_active_once (t)) if (is_mod_active_once (t))
return is_atomic (t[0]) || (!is_atom (p->next)); return is_atomic (t[0]) || (!is_atom (p->next));
if (is_prime (t)) return false; if (is_prime (t)) return false;
// FIXME: hack for treating VAR_EXPAND "math" // FIXME: hack for treating VAR_EXPAND "math"
if (is_compound (t, "input", 2) && (N(p) == 2) && if (is_compound (t, "input", 2) && (N(p) == 2) &&
is_compound (t[1], "math", 1) && (p->item == 1)) is_compound (t[1], "math", 1) && (p->item == 1))
skipping to change at line 303 skipping to change at line 339
else return path (1); else return path (1);
} }
// FIXME: hack for treating VAR_EXPAND "math" // FIXME: hack for treating VAR_EXPAND "math"
if (is_compound (t, "input", 2) && (N(p) == 2) && if (is_compound (t, "input", 2) && (N(p) == 2) &&
is_compound (t[1], "math", 1) && (p->item == 1)) is_compound (t[1], "math", 1) && (p->item == 1))
{ {
int i= (p->next->item == 0? 0: right_index (t[1][0])); int i= (p->next->item == 0? 0: right_index (t[1][0]));
return path (1, 0, pre_correct (t[1][0], path (i))); return path (1, 0, pre_correct (t[1][0], path (i)));
} }
path r (p->item, pre_correct (t[p->item], p->next)); path r (p->item, pre_correct (t[p->item], p->next));
if (the_drd->is_parent_enforcing (t)) { if (the_drd->is_parent_enforcing (t) &&
if (r->item == 0 && r->next == start (t[0])) return path (0); !graphics_in_path (t, p)) {
if (r->item == N(t)-1 && r->next == end (t[r->item])) return path (1); if (r->item == lowest_accessible_child (t) &&
!valid_cursor (t, p, false))
return path (0);
if (r->item == highest_accessible_child (t) &&
!valid_cursor (t, p, false))
return path (1);
} }
return r; return r;
} }
static bool static bool
left_most (tree t, path p) { left_most (tree t, path p) {
if (is_nil (p)) FAILED ("invalid nil path"); if (is_nil (p)) FAILED ("invalid nil path");
if ((!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) { if ((!is_atom (p)) && ((p->item < 0) || (p->item >= arity (t)))) {
failed_error << "Left most " << p << " in " << t << "\n"; failed_error << "Left most " << p << " in " << t << "\n";
FAILED ("bad path"); FAILED ("bad path");
 End of changes. 6 change blocks. 
12 lines changed or deleted 53 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS