Back to index

texmacs  1.0.7.15
Classes | Functions
highlight_observer.cpp File Reference
#include "modification.hpp"

Go to the source code of this file.

Classes

class  highlight_observer_rep

Functions

observer highlight_observer (int lan, array< int > cols)
void remove_highlight (observer &obs, int lan)
void attach_highlight (tree &ref, int lan)
void attach_highlight (tree &ref, int lan, int col, int start, int end)
bool has_highlight (tree &ref, int lan)
array< int > obtain_highlight (tree &ref, int lan)
bool detach_highlight_sub (tree &ref, int lan)
void detach_highlight (tree &ref, int lan)

Function Documentation

void attach_highlight ( tree ref,
int  lan 
)

Definition at line 86 of file highlight_observer.cpp.

                                      {
  //cout << "Attach highlight " << ref << "\n";
  if (!has_highlight (ref, lan))
    attach_highlight (ref, lan, 0, 0, 0);
  if (is_compound (ref))
    for (int i=0; i<N(ref); i++)
      attach_highlight (ref[i], lan);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void attach_highlight ( tree ref,
int  lan,
int  col,
int  start,
int  end 
)

Definition at line 96 of file highlight_observer.cpp.

                                                                   {
  int n= (is_atomic (ref)? N(ref->label): 1);
  ASSERT (0 <= start && start <= end && end <= n, "out of range");
  if (is_nil (ref->obs) || !ref->obs->set_highlight (lan, col, start, end)) {
    array<int> cols (n);
    for (int i=0; n>i; i++) cols[i]= 0;
    for (int i=start; i<end; i++) cols[i]= col;
    attach_observer (ref, highlight_observer (lan, cols));
  }
}

Here is the call graph for this function:

void detach_highlight ( tree ref,
int  lan 
)

Definition at line 135 of file highlight_observer.cpp.

                                      {
  if (detach_highlight_sub (ref, lan))
    touch (ref);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool detach_highlight_sub ( tree ref,
int  lan 
)

Definition at line 123 of file highlight_observer.cpp.

                                          {
  //cout << "Detach highlight " << ref << "\n";
  array<int> cols;
  bool r= !is_nil (ref->obs) && ref->obs->get_highlight (lan, cols);
  remove_highlight (ref->obs, lan);
  if (is_compound (ref))
    for (int i=0; i<N(ref); i++)
      r= detach_highlight_sub (ref[i], lan) | r;
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool has_highlight ( tree ref,
int  lan 
)

Definition at line 108 of file highlight_observer.cpp.

                                   {
  if (lan == 0 || is_nil (ref->obs)) return false;
  array<int> cols;
  return ref->obs->get_highlight (lan, cols);
}

Here is the call graph for this function:

Here is the caller graph for this function:

observer highlight_observer ( int  lan,
array< int >  cols 
)

Definition at line 67 of file highlight_observer.cpp.

                                              {
  return tm_new<highlight_observer_rep> (lan, cols);
}

Here is the caller graph for this function:

array<int> obtain_highlight ( tree ref,
int  lan 
)

Definition at line 115 of file highlight_observer.cpp.

                                      {
  if (lan == 0 || is_nil (ref->obs)) return array<int> ();
  array<int> cols;
  if (ref->obs->get_highlight (lan, cols)) return cols;
  return array<int> ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_highlight ( observer obs,
int  lan 
)

Definition at line 72 of file highlight_observer.cpp.

                                          {
  if (is_nil (obs)) return;
  else if (obs->get_type () == OBSERVER_HIGHLIGHT) {
    array<int> r;
    if (obs->get_highlight (lan, r))
      obs= nil_observer;
  }
  else {
    remove_highlight (obs->get_child (0), lan);
    remove_highlight (obs->get_child (1), lan);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: