Back to index

texmacs  1.0.7.15
Public Member Functions | Public Attributes | Protected Attributes
bridge_auto_rep Class Reference
Inheritance diagram for bridge_auto_rep:
Inheritance graph
[legend]
Collaboration diagram for bridge_auto_rep:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 bridge_auto_rep (typesetter ttt, tree st, path ip, tree f, bool border)
void initialize ()
void notify_assign (path p, tree u)
void notify_insert (path p, tree u)
void notify_remove (path p, int nr)
bool notify_macro (int type, string var, int level, path p, tree u)
void notify_change ()
void my_exec_until (path p)
void exec_until (path p, bool skip_flag)
bool my_typeset_will_be_complete ()
void my_typeset (int desired_status)
virtual void notify_split (path p)
virtual void notify_join (path p)
virtual void my_clean_links ()
void typeset (int desired_status)

Public Attributes

typesetter ttt
edit_envenv
tree st
path ip
int status
hashmap< string, treechanges
array< page_iteml
stack_border sb
link_repository link_env
int ref_count

Protected Attributes

tree f
bool border
bool valid
bridge body

Detailed Description

Definition at line 17 of file bridge_auto.cpp.


Constructor & Destructor Documentation

bridge_auto_rep::bridge_auto_rep ( typesetter  ttt,
tree  st,
path  ip,
tree  f,
bool  border 
)

Definition at line 40 of file bridge_auto.cpp.

                                                          :
    bridge_rep (ttt, st, ip)
{
  f     = f2;
  border= border2;
  valid = false;
}

Member Function Documentation

void bridge_auto_rep::exec_until ( path  p,
bool  skip_flag 
) [virtual]

Reimplemented from bridge_rep.

Definition at line 161 of file bridge_auto.cpp.

                                                   {
  // If we are executing until the start or the end of an automatic bridge,
  // some of the environment variables may be different from the usual
  // exec_until. For instance, for inactive* tags, we put ourselves
  // in source mode. The usual exec_until can only be used if we are
  // sure that are really executing until somewhere strictly after this bridge.

  if (skip_flag) bridge_rep::exec_until (p, skip_flag);
  else {
    if ((status & VALID_MASK) != PROCESSED) env->exec_until (st, p);
    else my_exec_until (p);
  }
}

Here is the call graph for this function:

Definition at line 50 of file bridge_auto.cpp.

                             {
  if ((!valid) || (body->st != f[1])) {
    valid= true;
    if (is_nil (body)) body= make_bridge (ttt, attach_right (f[1], ip));
    else replace_bridge (body, attach_right (f[1], ip));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bridge_rep::my_clean_links ( ) [virtual, inherited]

Reimplemented in bridge_surround_rep.

Definition at line 231 of file bridge.cpp.

                            {
  link_env= link_repository (true);
}

Here is the caller graph for this function:

void bridge_auto_rep::my_exec_until ( path  p) [virtual]

Reimplemented from bridge_rep.

Definition at line 148 of file bridge_auto.cpp.

                                      {
  env->macro_arg= list<hashmap<string,tree> >
    (hashmap<string,tree> (UNINIT), env->macro_arg);
  env->macro_src= list<hashmap<string,path> >
    (hashmap<string,path> (path (DECORATION)), env->macro_src);
  string var= f[0]->label;
  env->macro_arg->item (var)= st;
  (void) env->exec_until (f[1], p, var, 0);
  env->macro_arg= env->macro_arg->next;
  env->macro_src= env->macro_src->next;
}

Here is the caller graph for this function:

void bridge_auto_rep::my_typeset ( int  desired_status) [virtual]

Reimplemented from bridge_rep.

Definition at line 181 of file bridge_auto.cpp.

                                               {
  env->macro_arg= list<hashmap<string,tree> > (
    hashmap<string,tree> (UNINIT), env->macro_arg);
  env->macro_src= list<hashmap<string,path> > (
    hashmap<string,path> (path (DECORATION)), env->macro_src);
  string var= f[0]->label;
  env->macro_arg->item (var)= st;
  env->macro_src->item (var)= ip;
  tree oldv= env->read (PREAMBLE);
  env->write_update (PREAMBLE, "false");
  initialize ();
  if (border) ttt->insert_marker (st, ip);
  body->typeset (desired_status);
  env->write_update (PREAMBLE, oldv);
  env->macro_arg= env->macro_arg->next;
  env->macro_src= env->macro_src->next;
}

Here is the call graph for this function:

Reimplemented from bridge_rep.

Definition at line 176 of file bridge_auto.cpp.

                                              {
  return !valid;
}
void bridge_auto_rep::notify_assign ( path  p,
tree  u 
) [virtual]

Implements bridge_rep.

Definition at line 68 of file bridge_auto.cpp.

                                              {
  //cout << "Assign " << p << ", " << u << " in " << st << "\n";
  if (is_nil (body)) {
    st= substitute (st, p, u);
    valid= false;
  }
  else {
    // bool mp_flag= is_multi_paragraph (st);
    notify_macro (MACRO_ASSIGN, f[0]->label, -1, p->next, u);
    st= substitute (st, p, u);
    // if (mp_flag != is_multi_paragraph (st)) valid= false;
  }
  status= CORRUPTED;
}

Here is the call graph for this function:

void bridge_auto_rep::notify_change ( ) [virtual]

Implements bridge_rep.

Definition at line 138 of file bridge_auto.cpp.

                                {
  status= CORRUPTED;
  if (!is_nil (body)) body->notify_change ();
}

Here is the call graph for this function:

void bridge_auto_rep::notify_insert ( path  p,
tree  u 
) [virtual]

Reimplemented from bridge_rep.

Definition at line 84 of file bridge_auto.cpp.

                                              {
  //cout << "Insert " << p << ", " << u << " in " << st << "\n";
  if (is_nil (body)) bridge_rep::notify_insert (p, u);
  else {
    // bool mp_flag= is_multi_paragraph (st);
    notify_macro (MACRO_INSERT, f[0]->label, -1, p->next, u);
    st= insert_at (st, p, u);
    // if (mp_flag != is_multi_paragraph (st)) valid= false;
  }
  status= CORRUPTED;
}

Here is the call graph for this function:

void bridge_rep::notify_join ( path  p) [virtual, inherited]

Definition at line 208 of file bridge.cpp.

                               {
  // cout << "Join " << p << " in " << st << "\n";
  path q  = path_up (p);
  int  pos= last_item (p);
  tree t  = subtree (st, q);

  if (is_atomic (t[pos]) && is_atomic (t[pos+1])) {
    string j= t[pos]->label * t[pos+1]->label;
    notify_remove (q * pos, 1);
    notify_assign (q * pos, j);
  }
  else {
    tree j= t[pos] * t[pos+1];
    notify_remove (q * pos, 1);
    notify_assign (q * pos, j);
  }
}

Here is the call graph for this function:

bool bridge_auto_rep::notify_macro ( int  type,
string  var,
int  level,
path  p,
tree  u 
) [virtual]

Implements bridge_rep.

Definition at line 111 of file bridge_auto.cpp.

{
  /*
  cout << "Macro argument " << var << " [action=" << type
       << ", level=" << l << "] " << p << ", " << u << " in " << st << "\n";
  */

  bool flag;
  if (valid) {
    env->macro_arg= list<hashmap<string,tree> > (
      hashmap<string,tree> (UNINIT), env->macro_arg);
    env->macro_src= list<hashmap<string,path> > (
      hashmap<string,path> (path (DECORATION)), env->macro_src);
    string var= f[0]->label;
    env->macro_arg->item (var)= st;
    env->macro_src->item (var)= ip;
    flag= body->notify_macro (type, var, l+1, p, u);
    env->macro_arg= env->macro_arg->next;
    env->macro_src= env->macro_src->next;
  }
  else flag= env->depends (st, var, l);
  if (flag) status= CORRUPTED;
  return flag;
}

Here is the caller graph for this function:

void bridge_auto_rep::notify_remove ( path  p,
int  nr 
) [virtual]

Reimplemented from bridge_rep.

Definition at line 97 of file bridge_auto.cpp.

                                              {
  //cout << "Remove " << p << ", " << nr << " in " << st << "\n";
  if (is_nil (body)) bridge_rep::notify_remove (p, nr);
  else {
    // bool mp_flag= is_multi_paragraph (st);
    notify_macro (MACRO_REMOVE, f[0]->label, -1, p->next,
                tree (as_string (nr)));
    st= remove_at (st, p, nr);
    // if (mp_flag != is_multi_paragraph (st)) valid= false;
  }
  status= CORRUPTED;
}

Here is the call graph for this function:

void bridge_rep::notify_split ( path  p) [virtual, inherited]

Definition at line 188 of file bridge.cpp.

                                {
  // cout << "Split " << p << " in " << st << "\n";
  path q  = path_up (p, 2);
  int  pos= last_item (path_up (p));
  int  l  = last_item (p);
  tree t  = subtree (st, q);

  if (is_atomic (t[pos])) {
    string s1= t[pos]->label (0, l), s2= t[pos]->label (l, N (t[pos]->label));
    notify_insert (q * pos, tree (L(t), s1));
    notify_assign (q * (pos+1), s2);
  }
  else {
    tree t1= t[pos] (0, l), t2= t[pos] (l, N(t[pos]));
    notify_insert (q * pos, tree (L(t), t1));
    notify_assign (q * (pos+1), t2);
  }
}

Here is the call graph for this function:

void bridge_rep::typeset ( int  desired_status) [inherited]

Definition at line 279 of file bridge.cpp.

                                       {
  // FIXME: this dirty hack ensures a perfect coherence between
  // the bridge and the edit tree at the typesetting stage.
  // This should not be necessary, but we use because the ip_observers
  // may become wrong otherwise.
  if (is_accessible (ip))
    st= subtree (the_et, reverse (ip));
  if (!is_accessible (ip)) {
    path ip2= obtain_ip (st);
    if (ip2 != path (DETACHED))
      ip= ip2;
  }

  //cout << "Typesetting " << st << ", " << desired_status << LF << INDENT;
  if ((status==desired_status) && (N(ttt->old_patch)==0)) {
    //cout << "cached" << LF;
    env->monitored_patch_env (changes);
    // cout << "changes       = " << changes << LF;
  }
  else {
    // cout << "Typesetting " << st << ", " << desired_status << LF << INDENT;
    //cout << "recomputing" << LF;
    hashmap<string,tree> prev_back (UNINIT);
    my_clean_links ();
    link_repository old_link_env= env->link_env;
    env->link_env= link_env;
    ttt->local_start (l, sb);
    env->local_start (prev_back);
    if (env->hl_lan != 0) env->lan->highlight (st);
    my_typeset (desired_status);
    env->local_update (ttt->old_patch, changes);
    env->local_end (prev_back);
    ttt->local_end (l, sb);
    env->link_env= old_link_env;
    status= desired_status;
    // cout << "old_patch     = " << ttt->old_patch << LF;
    // cout << "changes       = " << changes << LF;
    // cout << UNINDENT << "Typesetted " << st << ", " << desired_status << LF;
  }
  //cout << UNINDENT << "Typesetted " << st << ", " << desired_status << LF;

  // ttt->insert_stack (l, sb);
  //if (N(l) == 0); else
  if (ttt->paper || (N(l) <= 1)) ttt->insert_stack (l, sb);
  else {
    bool flag= false;
    int i, n= N(l);
    for (i=0; i<n; i++)
      flag= flag || (N (l[i]->fl) != 0) || (l[i]->nr_cols > 1);
    if (flag) ttt->insert_stack (l, sb);
    else {
      int first=-1, last=-1;
      array<box> bs;
      array<SI>  spc;
      for (i=0; i<n; i++)
       if (l[i]->type != PAGE_CONTROL_ITEM) {
         if (first == -1 && l[i]->type == PAGE_LINE_ITEM) first= N(bs);
         bs  << l[i]->b;
         spc << l[i]->spc->def;
         last= i;
       }
      box lb= stack_box (path (ip), bs, spc);
      if (first != -1) lb= move_box (path (ip), lb, 0, bs[first]->y2);
      array<page_item> new_l (1);
      new_l[0]= page_item (lb);
      new_l[0]->spc= l[last]->spc;
      ttt->insert_stack (new_l, sb);
    }
  }

  //cout << "l   = " << l << LF;
  //cout << "sb  = " << sb << LF;
  //cout << "l   = " << ttt->l << LF;
  //cout << "a   = " << ttt->a << LF;
  //cout << "b   = " << ttt->b << LF;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 22 of file bridge_auto.cpp.

bool bridge_auto_rep::border [protected]

Definition at line 20 of file bridge_auto.cpp.

Definition at line 42 of file bridge.hpp.

edit_env& bridge_rep::env [inherited]

Definition at line 38 of file bridge.hpp.

tree bridge_auto_rep::f [protected]

Definition at line 19 of file bridge_auto.cpp.

path bridge_rep::ip [inherited]

Definition at line 40 of file bridge.hpp.

Definition at line 44 of file bridge.hpp.

Definition at line 46 of file bridge.hpp.

int abstract_struct::ref_count [inherited]

Definition at line 142 of file basic.hpp.

Definition at line 45 of file bridge.hpp.

tree bridge_rep::st [inherited]

Definition at line 39 of file bridge.hpp.

int bridge_rep::status [inherited]

Definition at line 41 of file bridge.hpp.

Definition at line 37 of file bridge.hpp.

bool bridge_auto_rep::valid [protected]

Definition at line 21 of file bridge_auto.cpp.


The documentation for this class was generated from the following file: