Back to index

texmacs  1.0.7.15
Classes | Defines | Typedefs | Functions | Variables
observer.hpp File Reference
#include "string.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  observer_rep
class  observer

Defines

#define OBSERVER_UNKNOWN   0
#define OBSERVER_LIST   1
#define OBSERVER_IP   2
#define OBSERVER_POINTER   3
#define OBSERVER_POSITION   4
#define OBSERVER_ADDENDUM   5
#define OBSERVER_EDIT   6
#define OBSERVER_UNDO   7
#define OBSERVER_HIGHLIGHT   8

Typedefs

typedef hard_link_rep * weak_link
typedef list< int > path

Functions

 ABSTRACT_NULL_CODE (observer)
tm_ostreamoperator<< (tm_ostream &out, observer o)
observer ip_observer (path ip)
observer list_observer (observer o1, observer o2)
observer tree_pointer (tree t, bool flag=false)
observer tree_position (tree t, int index)
observer edit_observer (editor_rep *ed)
observer undo_observer (archiver_rep *arch)
observer highlight_observer (int lan, array< int > cols)
bool busy_tree (tree &ref)
void assign (tree &ref, tree t)
void insert (tree &ref, int pos, tree t)
void remove (tree &ref, int pos, int nr)
void split (tree &ref, int pos, int at)
void join (tree &ref, int pos)
void assign_node (tree &ref, tree_label op)
void insert_node (tree &ref, int pos, tree t)
void remove_node (tree &ref, int pos)
void set_cursor (tree &ref, int pos, tree data)
void touch (tree &ref)
void assign (path p, tree t)
void insert (path p, tree ins)
void remove (path p, int nr)
void split (path p)
void join (path p)
void assign_node (path p, tree_label op)
void insert_node (path p, tree ins)
void remove_node (path p)
void set_cursor (path p, tree data)
void touch (path p)
void insert_observer (observer &o, observer what)
void remove_observer (observer &o, observer what)
void attach_observer (tree &ref, observer o)
void detach_observer (tree &ref, observer o)
void clean_observers (tree &ref)
path obtain_ip (tree &ref)
void attach_ip (tree &ref, path ip)
void detach_ip (tree &ref)
bool ip_attached (path ip)
tree obtain_tree (observer o)
observer tree_pointer_new (tree t)
void tree_pointer_delete (observer o)
path obtain_position (observer o)
observer tree_addendum_new (tree t, int kind, blackbox bb)
void tree_addendum_new (observer o)
observer search_observer (tree &ref, int type)
bool admits_edit_observer (tree t)
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)
void detach_highlight (tree &ref, int lan)
void stretched_print (tree t, bool ips=false, int indent=0)

Variables

int observer_count
observer nil_observer
bool versioning_busy

Define Documentation

#define OBSERVER_ADDENDUM   5

Definition at line 31 of file observer.hpp.

#define OBSERVER_EDIT   6

Definition at line 32 of file observer.hpp.

#define OBSERVER_HIGHLIGHT   8

Definition at line 34 of file observer.hpp.

#define OBSERVER_IP   2

Definition at line 28 of file observer.hpp.

#define OBSERVER_LIST   1

Definition at line 27 of file observer.hpp.

#define OBSERVER_POINTER   3

Definition at line 29 of file observer.hpp.

#define OBSERVER_POSITION   4

Definition at line 30 of file observer.hpp.

#define OBSERVER_UNDO   7

Definition at line 33 of file observer.hpp.

#define OBSERVER_UNKNOWN   0

Definition at line 26 of file observer.hpp.


Typedef Documentation

typedef list<int> path

Definition at line 24 of file observer.hpp.

typedef hard_link_rep* weak_link

Definition at line 22 of file observer.hpp.


Function Documentation

Definition at line 133 of file edit_observer.cpp.

                              {
  return !is_nil (search_observer (t, OBSERVER_EDIT));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void assign ( tree ref,
tree  t 
)

Definition at line 427 of file observer.cpp.

                           {
  apply (ref, mod_assign (path (), t));
}

Here is the call graph for this function:

void assign ( path  p,
tree  t 
)

Definition at line 483 of file observer.cpp.

                        {
  assign (subtree (the_et, p), t);
}

Here is the call graph for this function:

void assign_node ( tree ref,
tree_label  op 
)

Definition at line 452 of file observer.cpp.

                                       {
  apply (ref, mod_assign_node (path (), op));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void assign_node ( path  p,
tree_label  op 
)

Definition at line 511 of file observer.cpp.

                                    {
  assign_node (subtree (the_et, p), op);
}

Here is the call graph for this function:

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 attach_ip ( tree ref,
path  ip 
)

Definition at line 204 of file ip_observer.cpp.

                               {
  // cout << "Set ip of " << ref << " to " << ip << "\n";
  if (is_nil (ref->obs) || !ref->obs->set_ip (ip)) {
    // cout << "Create ip observer " << ip << " for " << ref << "\n";
    ref->obs= list_observer (ip_observer (ip), ref->obs);
  }
  if (is_compound (ref)) {
    int i, n= N(ref);
    for (i=0; i<n; i++) {
      path old_ip= obtain_ip (ref[i]);
      if ((old_ip->item != i) || (!strong_equal (old_ip->next, ip))) {
       attach_ip (ref[i], path (i, ip));
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void attach_observer ( tree ref,
observer  o 
)

Definition at line 269 of file list_observer.cpp.

                                        {
  insert_observer (ref->obs, o);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool busy_tree ( tree ref)

Definition at line 382 of file observer.cpp.

                      {
  path ip= obtain_ip (ref);
  if (ip_attached (ip)) return busy_path (reverse (ip));
  else return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void clean_observers ( tree ref)

Definition at line 279 of file list_observer.cpp.

                            {
  clean_observers (ref->obs);
}

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:

void detach_ip ( tree ref)

Definition at line 222 of file ip_observer.cpp.

                      {
  // cout << "Detach ip of " << ref << "\n";
  if (!is_nil (ref->obs))
    (void) ref->obs->set_ip (DETACHED);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void detach_observer ( tree ref,
observer  o 
)

Definition at line 274 of file list_observer.cpp.

                                        {
  remove_observer (ref->obs, o);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 110 of file edit_observer.cpp.

                               {
  return tm_new<edit_observer_rep> (ed);
}
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:

void insert ( tree ref,
int  pos,
tree  t 
)

Definition at line 432 of file observer.cpp.

                                    {
  apply (ref, mod_insert (path (), pos, t));
}

Here is the call graph for this function:

void insert ( path  p,
tree  ins 
)

Definition at line 488 of file observer.cpp.

                          {
  insert (subtree (the_et, path_up (p)), last_item (p), ins);
}

Here is the call graph for this function:

void insert_node ( tree ref,
int  pos,
tree  t 
)

Definition at line 457 of file observer.cpp.

                                         {
  apply (ref, mod_insert_node (path (), pos, t));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void insert_node ( path  p,
tree  ins 
)

Definition at line 516 of file observer.cpp.

                               {
  insert_node (subtree (the_et, path_up (p)), last_item (p), ins);
}

Here is the call graph for this function:

void insert_observer ( observer o,
observer  what 
)

Definition at line 241 of file list_observer.cpp.

                                             {
  o= list_observer (o, what);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool ip_attached ( path  ip)

Definition at line 237 of file ip_observer.cpp.

                      {
  return is_nil (ip) || last_item (ip) != DETACHED;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 246 of file ip_observer.cpp.

                      {
  return tm_new<ip_observer_rep> (ip);
}

Here is the caller graph for this function:

void join ( tree ref,
int  pos 
)

Definition at line 447 of file observer.cpp.

                          {
  apply (ref, mod_join (path (), pos));
}

Here is the call graph for this function:

void join ( path  p)

Definition at line 506 of file observer.cpp.

              {
  join (subtree (the_et, path_up (p)), last_item (p));
}

Here is the call graph for this function:

Definition at line 234 of file list_observer.cpp.

                                         {
  if (is_nil (o1)) return o2;
  if (is_nil (o2)) return o1;
  return tm_new<list_observer_rep> (o1, o2);
}

Here is the call graph for this function:

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:

path obtain_ip ( tree ref)

Definition at line 229 of file ip_observer.cpp.

                      {
  path ip;
  if (is_nil (ref->obs)) return DETACHED;
  if (!ref->obs->get_ip (ip)) return DETACHED;
  return ip;
}

Here is the call graph for this function:

Definition at line 191 of file tree_position.cpp.

                             {
  tree t;
  int  index;
  if (!o->get_position (t, index)) return path ();
  path ip= obtain_ip (t);
  if (ip == path (DETACHED)) return path ();
  return reverse (ip) * index;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file tree_pointer.cpp.

                           {
  tree t;
  (void) obs->get_tree (t);
  return t;
}

Here is the caller graph for this function:

tm_ostream& operator<< ( tm_ostream out,
observer  o 
)

Definition at line 68 of file observer.cpp.

                                          {
  out << "<observer";
  if (is_nil (o)) out << " null";
  else o->print (out);
  out << ">";
  return out;
}

Here is the call graph for this function:

void remove ( tree ref,
int  pos,
int  nr 
)

Definition at line 437 of file observer.cpp.

                                    {
  apply (ref, mod_remove (path (), pos, nr));
}

Here is the call graph for this function:

void remove ( path  p,
int  nr 
)

Definition at line 493 of file observer.cpp.

                        {
  remove (subtree (the_et, path_up (p)), last_item (p), nr);
}

Here is the call graph for this function:

void remove_node ( tree ref,
int  pos 
)

Definition at line 462 of file observer.cpp.

                                 {
  apply (ref, mod_remove_node (path (), pos));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_node ( path  p)

Definition at line 521 of file observer.cpp.

Here is the call graph for this function:

void remove_observer ( observer o,
observer  what 
)

Definition at line 246 of file list_observer.cpp.

                                             {
  if (is_nil (o)) return;
  else if (o == what) o= nil_observer;
  else {
    remove_observer (o->get_child (0), what);
    remove_observer (o->get_child (1), what);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

observer search_observer ( tree ref,
int  type 
)

Definition at line 128 of file edit_observer.cpp.

                                      {
  return search_type (ref->obs, type);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_cursor ( tree ref,
int  pos,
tree  data 
)

Definition at line 467 of file observer.cpp.

                                           {
  apply (ref, mod_set_cursor (path (), pos, data));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_cursor ( path  p,
tree  data 
)

Definition at line 526 of file observer.cpp.

                               {
  if (is_inside (the_et, p))
    set_cursor (subtree (the_et, path_up (p)), last_item (p), data);
  else
    cout << "TeXmacs] warning: invalid cursor position " << p << "\n";
}

Here is the call graph for this function:

void split ( tree ref,
int  pos,
int  at 
)

Definition at line 442 of file observer.cpp.

                                   {
  apply (ref, mod_split (path (), pos, at));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void split ( path  p)

Definition at line 498 of file observer.cpp.

               {
  tree& st= subtree (the_et, path_up (path_up (p)));
  int   l1= last_item (path_up (p));
  int   l2= last_item (p);
  split (st, l1, l2);  
}

Here is the call graph for this function:

void stretched_print ( tree  t,
bool  ips = false,
int  indent = 0 
)

Definition at line 50 of file observer.cpp.

                                               {
  int i;
  for (i=0; i<indent; i++) cout << "  ";
  if (is_atomic (t)) {
    cout << raw_quote (t->label);
    if (ips) cout << " -- " << obtain_ip (t);
    cout << "\n";
  }
  else {
    cout << as_string (L(t));
    if (ips) cout << " -- " << obtain_ip (t);
    cout << "\n";    
    for (i=0; i<N(t); i++)
      stretched_print (t[i], ips, indent+1);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void touch ( tree ref)

Definition at line 472 of file observer.cpp.

                  {
  //cout << "Touch " << ref << "\n";
  if (!is_nil (ref->obs))
    ref->obs->touched (ref, path ());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void touch ( path  p)

Definition at line 534 of file observer.cpp.

               {
  touch (subtree (the_et, p));
}

Here is the call graph for this function:

observer tree_addendum_new ( tree  t,
int  kind,
blackbox  bb 
)

Definition at line 173 of file tree_addendum.cpp.

                                                          {
  observer obs= tree_addendum (ref, kind, contents);
  attach_observer (ref, obs);
  return obs;
}

Here is the call graph for this function:

observer tree_pointer ( tree  t,
bool  flag = false 
)

Definition at line 168 of file tree_pointer.cpp.

                                   {
  return tm_new<tree_pointer_rep> (ref, flag);
}

Here is the caller graph for this function:

Definition at line 187 of file tree_pointer.cpp.

                                   {
  tree ref= obtain_tree (obs);
  detach_observer (ref, obs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 180 of file tree_pointer.cpp.

                            {
  observer obs= tree_pointer (ref);
  attach_observer (ref, obs);
  return obs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

observer tree_position ( tree  t,
int  index 
)

Definition at line 186 of file tree_position.cpp.

                                    {
  return tm_new<tree_position_rep> (ref, index);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 95 of file undo_observer.cpp.

                                   {
  return tm_new<undo_observer_rep> (arch);
}

Variable Documentation

Definition at line 19 of file observer.cpp.

Definition at line 369 of file observer.cpp.