Back to index

texmacs  1.0.7.15
Functions
tree_select.hpp File Reference
#include "tree_cursor.hpp"
#include "tree_traverse.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void selection_correct (tree t, path i1, path i2, path &o1, path &o2)
tree selection_compute (tree t, path i1, path i2)

Function Documentation

tree selection_compute ( tree  t,
path  i1,
path  i2 
)

Definition at line 179 of file tree_select.cpp.

                                                 {
  int  i1= start->item;
  int  i2= end->item;
  path p1= start->next;
  path p2= end->next;

  if (is_nil (p1) || is_nil (p2)) {
    if (start == path (right_index (t))) return "";
    if (end == path (0)) return "";
    if (start == end) return "";
    if (is_nil (p1) && is_nil (p2)) {
      if (is_compound (t)) return copy (t);
      if (i1>=i2) return "";
      return t->label (i1, i2);
    }
    if (is_compound (t) && (!is_format (t))) return copy (t);
    if (is_nil (p1)) {
      i1= 0;
      p1= (start->item==0? 0: right_index (t[i1]));
    }
    if (is_nil (p2)) {
      i2= N(t)-1;
      p2= (end->item==0? 0: right_index (t[i2]));
    }
  }

  if (i1==i2) return selection_compute (t[i1], p1, p2);
  if (is_compound (t) && (!is_format (t))) return copy (t);

  int i;
  tree r (t, i2-i1+1);
  r[0]     = selection_compute (t[i1], p1, path (right_index (t[i1])));
  r[N(r)-1]= selection_compute (t[i2], path (0), p2);
  for (i=1; i<N(r)-1; i++) r[i]= copy (t[i+i1]);
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void selection_correct ( tree  t,
path  i1,
path  i2,
path o1,
path o2 
)

Definition at line 161 of file tree_select.cpp.

                                                                 {
  o1= i1; o2= i2;
  while (true) {
    i1= o1; i2= o2;
    selection_adjust_border (t, i1, i2, o1, o2);
    i1= o1; i2= o2;
    selection_adjust (t, i1, i2, o1, o2);
    i1= o1; i2= o2;
    selection_make_accessible (t, i1, i2, o1, o2);
    if (o1 == i1 && o2 == i2) break;
  }
}

Here is the call graph for this function: