Back to index

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

Go to the source code of this file.

Classes

class  modification_rep
class  modification

Defines

#define MOD_ASSIGN   1
#define MOD_INSERT   2
#define MOD_REMOVE   3
#define MOD_SPLIT   4
#define MOD_JOIN   5
#define MOD_ASSIGN_NODE   6
#define MOD_INSERT_NODE   7
#define MOD_REMOVE_NODE   8
#define MOD_SET_CURSOR   9

Typedefs

typedef int modification_type

Functions

 CONCRETE_CODE (modification)
bool operator== (modification m1, modification m2)
bool operator!= (modification m1, modification m2)
tm_ostreamoperator<< (tm_ostream &out, modification mod)
modification mod_assign (path p, tree t)
modification mod_insert (path p, int pos, tree t)
modification mod_remove (path p, int pos, int nr)
modification mod_split (path p, int pos, int at)
modification mod_join (path p, int pos)
modification mod_assign_node (path p, tree_label lab)
modification mod_insert_node (path p, int pos, tree t)
modification mod_remove_node (path p, int pos)
modification mod_set_cursor (path p, int pos, tree data)
modification operator* (int i, modification mod)
modification operator* (path p, modification mod)
modification operator* (modification mod, int i)
modification operator/ (modification mod, path p)
modification copy (modification mod)
path root (modification mod)
int index (modification mod)
int argument (modification mod)
tree_label L (modification mod)
bool is_applicable (tree t, modification mod)
tree clean_apply (tree t, modification mod)
void raw_apply (tree &t, modification mod)
void apply (tree &t, modification mod)
void edit_announce (editor_rep *ed, modification mod)
void edit_done (editor_rep *ed, modification mod)
void edit_touch (editor_rep *ed, path p)
void archive_announce (archiver_rep *buf, modification mod)
void link_announce (observer obs, modification mod)

Define Documentation

#define MOD_ASSIGN   1

Definition at line 21 of file modification.hpp.

#define MOD_ASSIGN_NODE   6

Definition at line 26 of file modification.hpp.

#define MOD_INSERT   2

Definition at line 22 of file modification.hpp.

#define MOD_INSERT_NODE   7

Definition at line 27 of file modification.hpp.

#define MOD_JOIN   5

Definition at line 25 of file modification.hpp.

#define MOD_REMOVE   3

Definition at line 23 of file modification.hpp.

#define MOD_REMOVE_NODE   8

Definition at line 28 of file modification.hpp.

#define MOD_SET_CURSOR   9

Definition at line 29 of file modification.hpp.

#define MOD_SPLIT   4

Definition at line 24 of file modification.hpp.


Typedef Documentation

typedef int modification_type

Definition at line 35 of file modification.hpp.


Function Documentation

void apply ( tree t,
modification  mod 
)

Definition at line 389 of file observer.cpp.

                                    {
  if (!is_applicable (ref, mod)) {
    cout << "mod= " << mod << "\n";
    cout << "ref= " << ref << "\n";
    ASSERT (is_applicable (ref, mod), "invalid modification");
  }
  path ip= obtain_ip (ref);
  path rp= reverse (ip);
  path p = rp * root (mod);
  if (versioning_busy) raw_apply (ref, mod);
  else if (is_busy) {
    if (ip_attached (ip) && !busy_path (p)) {
      //cout << "Postpone " << (reverse (ip) * mod) << "\n";
      busy_paths= busy_paths * p;
      upcoming  = upcoming * (reverse (ip) * mod);
    }
  }
  else {
    if (!ip_attached (ip)) raw_apply (ref, mod);
    else {
      is_busy= true;
      busy_paths= list<path> (p);
      upcoming  = list<modification> (reverse (ip) * mod);
      while (!is_nil (upcoming)) {
       //cout << "Handle " << upcoming->item << "\n";
       raw_apply (the_et, upcoming->item);
       //cout << "Done " << upcoming->item << "\n";
       upcoming= upcoming->next;
      }
      busy_paths= list<path> ();
      is_busy= false;
      if (has_subtree (the_et, rp))
       ref= subtree (the_et, rp);
    }
  }
}

Here is the call graph for this function:

void archive_announce ( archiver_rep buf,
modification  mod 
)

Definition at line 73 of file archiver.cpp.

                                                        {
  //cout << "Archive " << mod << "\n";
  if (DEBUG_HISTORY) cout << "Archive " << mod << "\n";
  ASSERT (arch->rp <= mod->p, "invalid modification");
  if (!arch->versioning) {
    arch->add (mod);
    pending_archs->insert ((pointer) arch);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int argument ( modification  mod)

Definition at line 97 of file modification.cpp.

                            {
  switch (mod->k) {
  case MOD_REMOVE: return last_item (mod->p);
  case MOD_SPLIT: return last_item (mod->p);
  case MOD_INSERT_NODE: return last_item (mod->p);
  default: FAILED ("invalid modification type");
  }
}

Here is the call graph for this function:

tree clean_apply ( tree  t,
modification  mod 
)

Definition at line 394 of file modification.cpp.

                                       {
  switch (mod->k) {
  case MOD_ASSIGN:
    return clean_assign (t, mod->p, mod->t);
  case MOD_INSERT:
    return clean_insert (t, mod->p, mod->t);
  case MOD_REMOVE:
    return clean_remove (t, path_up (mod->p), last_item (mod->p));
  case MOD_SPLIT:
    return clean_split (t, mod->p);
  case MOD_JOIN:
    return clean_join (t, mod->p);
  case MOD_ASSIGN_NODE:
    return clean_assign_node (t, mod->p, L(mod));
  case MOD_INSERT_NODE:
    return clean_insert_node (t, mod->p, mod->t);
  case MOD_REMOVE_NODE:
    return clean_remove_node (t, mod->p);
  case MOD_SET_CURSOR:
    return clean_set_cursor (t, mod->p, mod->t);
  default:
    FAILED ("invalid modification type");
    return "";
  }
}

Here is the call graph for this function:

modification copy ( modification  mod) [inline]

Definition at line 96 of file modification.hpp.

                                            {
  return modification (mod->k, copy (mod->p), copy (mod->t)); }

Here is the call graph for this function:

void edit_announce ( editor_rep ed,
modification  mod 
)

Definition at line 212 of file edit_modify.cpp.

                                                 {
  switch (mod->k) {
  case MOD_ASSIGN:
    edit_assign (ed, mod->p, mod->t);
    break;
  case MOD_INSERT:
    edit_insert (ed, mod->p, mod->t);
    break;
  case MOD_REMOVE:
    edit_remove (ed, path_up (mod->p), last_item (mod->p));
    break;
  case MOD_SPLIT:
    edit_split (ed, mod->p);
    break;
  case MOD_JOIN:
    edit_join (ed, mod->p);
    break;
  case MOD_ASSIGN_NODE:
    edit_assign_node (ed, mod->p, L(mod));
    break;
  case MOD_INSERT_NODE:
    edit_insert_node (ed, mod->p, mod->t);
    break;
  case MOD_REMOVE_NODE:
    edit_remove_node (ed, mod->p);
    break;
  case MOD_SET_CURSOR:
    edit_set_cursor (ed, mod->p, mod->t);
    break;
  default: FAILED ("invalid modification type");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void edit_done ( editor_rep ed,
modification  mod 
)

Definition at line 246 of file edit_modify.cpp.

                                             {
  path p= copy (mod->p);
  ASSERT (ed->the_buffer_path() <= p, "invalid modification");
  if (mod->k != MOD_SET_CURSOR)
    ed->post_notify (p);
#ifdef EXPERIMENTAL
  copy_announce (subtree (ed->et, ed->rp), ed->cct, mod / ed->rp);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void edit_touch ( editor_rep ed,
path  p 
)

Definition at line 257 of file edit_modify.cpp.

                                    {
  //cout << "Touch " << p << "\n";
  ASSERT (ed->the_buffer_path() <= p, "invalid touch");
  ed -> typeset_invalidate (p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int index ( modification  mod)

Definition at line 84 of file modification.cpp.

                         {
  switch (mod->k) {
  case MOD_INSERT: return last_item (mod->p);
  case MOD_REMOVE: return last_item (path_up (mod->p));
  case MOD_SPLIT: return last_item (path_up (mod->p));
  case MOD_JOIN: return last_item (mod->p);
  case MOD_REMOVE_NODE: return last_item (mod->p);
  case MOD_SET_CURSOR: return last_item (mod->p);
  default: FAILED ("invalid modification type");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_applicable ( tree  t,
modification  mod 
)

Definition at line 180 of file modification.cpp.

                                         {
  switch (mod->k) {
  case MOD_ASSIGN:
    return can_assign (t, root (mod), mod->t);
  case MOD_INSERT:
    return can_insert (t, root (mod), index (mod), mod->t);
  case MOD_REMOVE:
    return can_remove (t, root (mod), index (mod), argument (mod));
  case MOD_SPLIT:
    return can_split (t, root (mod), index (mod), argument (mod));
  case MOD_JOIN:
    return can_join (t, root (mod), index (mod));
  case MOD_ASSIGN_NODE:
    return can_assign_node (t, root (mod), L (mod));
  case MOD_INSERT_NODE:
    return can_insert_node (t, root (mod), argument (mod), mod->t);
  case MOD_REMOVE_NODE:
    return can_remove_node (t, root (mod), index (mod));
  case MOD_SET_CURSOR:
    return can_set_cursor (t, root (mod), index (mod), mod->t);
  default:
    return false;
  }
}

Here is the call graph for this function:

Definition at line 107 of file modification.cpp.

                     {
  ASSERT (mod->k == MOD_ASSIGN_NODE, "assign_node modification expected");
  return L (mod->t);
}
void link_announce ( observer  obs,
modification  mod 
)

Definition at line 248 of file link.cpp.

                                               {
  //cout << "Link event " << mod << "\n";
  for (list<string> ids= pointer_resolve [obs];
       !is_nil (ids); ids= ids->next)
    for (list<tree> lns= get_links (compound ("id", ids->item));
        !is_nil (lns); lns= lns->next)
      link_announce (lns->item, ids->item, mod);
}

Here is the call graph for this function:

modification mod_assign ( path  p,
tree  t 
) [inline]

Definition at line 70 of file modification.hpp.

                                                {
  return modification (MOD_ASSIGN, p, t); }

Here is the caller graph for this function:

modification mod_assign_node ( path  p,
tree_label  lab 
) [inline]

Definition at line 80 of file modification.hpp.

                                                             {
  return modification (MOD_ASSIGN_NODE, p, tree (lab)); }

Here is the caller graph for this function:

modification mod_insert ( path  p,
int  pos,
tree  t 
) [inline]

Definition at line 72 of file modification.hpp.

                                                         {
  return modification (MOD_INSERT, p * pos, t); }

Here is the caller graph for this function:

modification mod_insert_node ( path  p,
int  pos,
tree  t 
) [inline]

Definition at line 82 of file modification.hpp.

                                                              {
  return modification (MOD_INSERT_NODE, p * pos, t); }

Here is the caller graph for this function:

modification mod_join ( path  p,
int  pos 
) [inline]

Definition at line 78 of file modification.hpp.

                                               {
  return modification (MOD_JOIN, p * pos); }

Here is the caller graph for this function:

modification mod_remove ( path  p,
int  pos,
int  nr 
) [inline]

Definition at line 74 of file modification.hpp.

                                                         {
  return modification (MOD_REMOVE, p * path (pos, nr)); }

Here is the caller graph for this function:

modification mod_remove_node ( path  p,
int  pos 
) [inline]

Definition at line 84 of file modification.hpp.

                                                      {
  return modification (MOD_REMOVE_NODE, p * pos); }

Here is the caller graph for this function:

modification mod_set_cursor ( path  p,
int  pos,
tree  data 
) [inline]

Definition at line 86 of file modification.hpp.

                                                                {
  return modification (MOD_SET_CURSOR, p * pos, data); }

Here is the caller graph for this function:

modification mod_split ( path  p,
int  pos,
int  at 
) [inline]

Definition at line 76 of file modification.hpp.

                                                        {
  return modification (MOD_SPLIT, p * path (pos, at)); }

Here is the caller graph for this function:

bool operator!= ( modification  m1,
modification  m2 
)

Definition at line 24 of file modification.cpp.

                                               {
  return m1->k != m2->k || m1->p != m2->p || m1->t != m2->t;
}
modification operator* ( int  i,
modification  mod 
) [inline]

Definition at line 88 of file modification.hpp.

                                                         {
  return modification (mod->k, path (i, mod->p), mod->t); }
modification operator* ( path  p,
modification  mod 
) [inline]

Definition at line 90 of file modification.hpp.

                                                          {
  return modification (mod->k, p * mod->p, mod->t); }
modification operator* ( modification  mod,
int  i 
) [inline]

Definition at line 92 of file modification.hpp.

                                                         {
  return modification (mod->k, mod->p * i, mod->t); }
modification operator/ ( modification  mod,
path  p 
) [inline]

Definition at line 94 of file modification.hpp.

                                                          {
  return modification (mod->k, mod->p / p, mod->t); }
tm_ostream& operator<< ( tm_ostream out,
modification  mod 
)

Definition at line 29 of file modification.cpp.

                                                {
  switch (mod->k) {
  case MOD_ASSIGN:
    return out << "assign (" << root (mod)
              << ", " << mod->t << ")";
  case MOD_INSERT:
    return out << "insert (" << root (mod)
              << ", " << index (mod) << ", " << mod->t << ")";
  case MOD_REMOVE:
    return out << "remove (" << root (mod)
              << ", " << index (mod) << ", " << argument (mod) << ")";
  case MOD_SPLIT:
    return out << "split (" << root (mod)
              << ", " << index (mod) << ", " << argument (mod) << ")";
  case MOD_JOIN:
    return out << "join (" << root (mod)
              << ", " << index (mod) << ")";
  case MOD_ASSIGN_NODE:
    return out << "assign_node (" << root (mod)
              << ", " << mod->t << ")";
  case MOD_INSERT_NODE:
    return out << "insert_node (" << root (mod)
              << ", " << argument (mod) << ", " << mod->t << ")";
  case MOD_REMOVE_NODE:
    return out << "remove_node (" << root (mod)
              << ", " << index (mod) << ")";
  case MOD_SET_CURSOR:
    return out << "set_cursor (" << root (mod)
              << ", " << index (mod) << ", " << mod->t << ")";
  default: FAILED ("invalid modification type");
    return out;
  }
}

Here is the call graph for this function:

bool operator== ( modification  m1,
modification  m2 
)

Definition at line 19 of file modification.cpp.

                                               {
  return m1->k == m2->k && m1->p == m2->p && m1->t == m2->t;
}
void raw_apply ( tree t,
modification  mod 
)

Definition at line 331 of file observer.cpp.

                                      {
  ASSERT (is_applicable (t, mod), "invalid modification");
  switch (mod->k) {
  case MOD_ASSIGN:
    raw_assign (subtree (t, root (mod)), mod->t);
    break;
  case MOD_INSERT:
    raw_insert (subtree (t, root (mod)), index (mod), mod->t);
    break;
  case MOD_REMOVE:
    raw_remove (subtree (t, root (mod)), index (mod), argument (mod));
    break;
  case MOD_SPLIT:
    raw_split (subtree (t, root (mod)), index (mod), argument (mod));
    break;
  case MOD_JOIN:
    raw_join (subtree (t, root (mod)), index (mod));
    break;
  case MOD_ASSIGN_NODE:
    raw_assign_node (subtree (t, root (mod)), L (mod));
    break;
  case MOD_INSERT_NODE:
    raw_insert_node (subtree (t, root (mod)), argument (mod), mod->t);
    break;
  case MOD_REMOVE_NODE:
    raw_remove_node (subtree (t, root (mod)), index (mod));
    break;
  case MOD_SET_CURSOR:
    raw_set_cursor (subtree (t, root (mod)), index (mod), mod->t);
    break;
  }
  packrat_invalid_colors= true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 68 of file modification.cpp.

                        {
  switch (mod->k) {
  case MOD_ASSIGN: return mod->p;
  case MOD_INSERT: return path_up (mod->p);
  case MOD_REMOVE: return path_up (path_up (mod->p));
  case MOD_SPLIT: return path_up (path_up (mod->p));
  case MOD_JOIN: return path_up (mod->p);
  case MOD_ASSIGN_NODE: return mod->p;
  case MOD_INSERT_NODE: return path_up (mod->p);
  case MOD_REMOVE_NODE: return path_up (mod->p);
  case MOD_SET_CURSOR: return path_up (mod->p);
  default: FAILED ("invalid modification type");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: