Back to index

texmacs  1.0.7.15
Functions
concater.cpp File Reference
#include "concater.hpp"
#include "analyze.hpp"
#include "file.hpp"

Go to the source code of this file.

Functions

SI italic_correction (box left, box right)
array< line_itemtypeset_concat (edit_env env, tree t, path ip)
array< line_itemtypeset_marker (edit_env env, path ip)
box typeset_as_concat (edit_env env, tree t, path ip)
box typeset_as_box (edit_env env, tree t, path ip)
bool build_locus (edit_env env, tree t, list< string > &ids, string &col, string &ref, string &anchor)
bool build_locus (edit_env env, tree t, list< string > &ids, string &col)
box typeset_as_atomic (edit_env env, tree t, path ip)
tree box_info (edit_env env, tree t, string what)

Function Documentation

tree box_info ( edit_env  env,
tree  t,
string  what 
)

Definition at line 874 of file concater.cpp.

                                             {
  box b= typeset_as_atomic (env, attach_here (t, decorate ()));

  tree r= tuple();
  for (int i=0; i<N(what); i++) {
    switch (what[i]) {
    case 'l': r << as_string (b->x1); break;
    case 'b': r << as_string (b->y1); break;
    case 'r': r << as_string (b->x2); break;
    case 't': r << as_string (b->y2); break;
    case 'w': r << as_string (b->x2 - b->x1); break;
    case 'h': r << as_string (b->y2 - b->y1); break;
    case 'L': r << as_string (b->x3); break;
    case 'B': r << as_string (b->y3); break;
    case 'R': r << as_string (b->x4); break;
    case 'T': r << as_string (b->y4); break;
    case 'W': r << as_string (b->x4 - b->x3); break;
    case 'H': r << as_string (b->y4 - b->y3); break;
    case '.':
      if (N(r)==1) return as_string (r[0]) * "tmpt";
      else if (N(r)==0) return tree (ERROR, "No query for box-info");
      else return tree (ERROR, "More than one query for box-info");
    }
  }
  return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool build_locus ( edit_env  env,
tree  t,
list< string > &  ids,
string col,
string ref,
string anchor 
)

Definition at line 84 of file concat_active.cpp.

                                                                                                {
  //cout << "Typeset " << t << "\n";
  int last= N(t)-1;
  tree body= env->expand (t[last], true);
  //cout << "Typeset " << body << "\n";
  bool accessible= is_accessible (obtain_ip (body));
  bool visited= false;
  ref= "";
  anchor= "";

  if (!is_nil (env->link_env)) {
    int i, j;
    for (i=0; i<last; i++) {
      tree arg= env->exec (t[i]);
      if (is_compound (arg, "id", 1)) {
       string id= as_string (arg[0]);
       if (accessible) env->link_env->insert_locus (id, body);
       else if (N (obtain_ip (body)) > 1) {
         extern tree get_subtree (path p);
         path p= path_up (reverse (descend_decode (obtain_ip (body), 1)));
         env->link_env->insert_locus ("&" * id, get_subtree (p));
       }
       ids= list<string> (id, ids);
       visited= visited || has_been_visited ("id:" * id);
      }
      if (is_compound (arg, "link") && N(arg) >= 2) {
       if (is_func (arg[1], ATTR)) arg= copy (arg);
       else arg= arg (0, 1) * tree (LINK, tree (ATTR)) * arg (1, N(arg));
       arg[1] << tree ("secure")
              << (env->secure? tree ("true"): tree ("false"));
       env->link_env->insert_link (arg);
       for (j=2; j<N(arg); j++) {
         if (is_compound (arg[j], "id", 1) && is_atomic (arg[j][0])) {
           visited= visited || has_been_visited ("id:" * arg[j][0]->label);
           anchor = arg[j][0]->label;
         }
         if (is_compound (arg[j], "url", 1) && is_atomic (arg[j][0])) {
           visited= visited || has_been_visited ("url:" * arg[j][0]->label);
           ref = arg[j][0]->label;
         }
       }
      }
    }
  }

  bool on_paper= (env->get_string (PAGE_PRINTED) == "true");
  bool preserve= (get_locus_rendering ("locus-on-paper") == "preserve");
  string var= (visited? VISITED_COLOR: LOCUS_COLOR);
  string current_col= env->get_string (COLOR);
  string locus_col= env->get_string (var);
  if (locus_col == "preserve") col= current_col;
  else if (on_paper && preserve) col= current_col;
  else if (locus_col == "global") col= get_locus_rendering (var);
  else col= locus_col;

  return accessible;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool build_locus ( edit_env  env,
tree  t,
list< string > &  ids,
string col 
)

Definition at line 143 of file concat_active.cpp.

                                                                   {
  string ref;
  string anchor;
  return build_locus(env, t, ids, col, ref, anchor);
}

Here is the call graph for this function:

SI italic_correction ( box  left,
box  right 
)

Definition at line 27 of file math_boxes.cpp.

                                 {
  double slope_L= L->right_slope ();
  double slope_R= R->left_slope ();
  if (slope_L == slope_R) return 0;
  if (slope_L * slope_R == 0.0)
    return L->right_correction () + R->left_correction ();
  double M= (slope_L <= slope_R? slope_R: slope_L);
  if (M<0) M= (slope_L >= slope_R? slope_R: slope_L);
  double factor= (slope_R- slope_L) / M;
  if (factor < 0) factor= -factor;
  return (SI) (factor * (L->right_correction () + R->left_correction ()));
}

Here is the call graph for this function:

Here is the caller graph for this function:

box typeset_as_atomic ( edit_env  env,
tree  t,
path  ip 
)

Definition at line 808 of file concater.cpp.

                                                  {
  if (is_func (t, WITH)) {
    int i, n= N(t), k= (n-1)>>1; // is k=0 allowed ?
    if ((n&1) != 1) return empty_box (ip);

    STACK_NEW_ARRAY(vars,string,k);
    STACK_NEW_ARRAY(oldv,tree,k);
    STACK_NEW_ARRAY(newv,tree,k);
    for (i=0; i<k; i++) {
      tree var_t= env->exec (t[i<<1]);
      if (is_atomic (var_t)) {
       string var= var_t->label;
       vars[i]= var;
       oldv[i]= env->read (var);
       newv[i]= env->exec (t[(i<<1)+1]);
      }
      else {
       STACK_DELETE_ARRAY(vars);
       STACK_DELETE_ARRAY(oldv);
       STACK_DELETE_ARRAY(newv);
       return empty_box (ip);
      }
    }

    // for (i=0; i<k; i++) env->monitored_write_update (vars[i], newv[i]);
    for (i=0; i<k; i++) env->write_update (vars[i], newv[i]);
    box b= typeset_as_atomic (env, t[n-1], descend (ip, n-1));
    for (i=k-1; i>=0; i--) env->write_update (vars[i], oldv[i]);
    STACK_DELETE_ARRAY(vars);
    STACK_DELETE_ARRAY(oldv);
    STACK_DELETE_ARRAY(newv);
    return b;
  }
  else if (is_func (t, LOCUS) && N(t) != 0) {
    string ref;
    string anchor;
    int last= N(t)-1;
    list<string> ids;
    string col;
    (void) build_locus (env, t, ids, col, ref, anchor);
    tree old= env->local_begin (COLOR, col);
    box b= typeset_as_atomic (env, t[last], descend (ip, last));
    env->local_end (COLOR, old);
    return b;
  }
  else {
    array<line_item> a= typeset_concat (env, t, ip);
    if (N(a) == 1) return a[0]->b;

    int i, n=N(a);
    if (n == 0) return empty_box (ip); // FIXME: n=0 should never happen
    array<box> items (n);
    array<SI>  spc (n);
    if (n>0) {
      spc[0]=0;
      for (i=0; i<n-1; i++) {
       items[i]  = a[i]->b;
       spc  [i+1]= a[i]->spc->def;
      }
      items[i]= a[i]->b;
    }
    return concat_box (ip, items, spc);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

box typeset_as_box ( edit_env  env,
tree  t,
path  ip 
)

Definition at line 786 of file concater.cpp.

                                               {
  box b= typeset_as_concat (env, t, ip);

  SI ox= 0;
  int i, n=N(b);
  for (i=0; i<n; i++)
    if (b[i]->w() != 0)
      ox= b[i]->x1;

  array<box> bs (1);
  array<SI>  xs (1);
  array<SI>  ys (1);
  bs[0]= b;
  xs[0]= ox;
  ys[0]= 0;
  return composite_box (ip, bs, xs, ys);
}

Here is the call graph for this function:

Here is the caller graph for this function:

box typeset_as_concat ( edit_env  env,
tree  t,
path  ip 
)

Definition at line 761 of file concater.cpp.

                                                  {
  concater ccc= tm_new<concater_rep> (env, true);
  ccc->typeset (t, ip);
  ccc->finish ();
  array<line_item> a= ccc->a;

  int i, n=N(a);
  if (n == 0) return empty_box (ip); // FIXME: n=0 should never happen
  array<box> items (n);
  array<SI>  spc (n);
  if (n>0) {
    spc[0]=0;
    for (i=0; i<n-1; i++) {
      items[i]  = a[i]->b;
      spc  [i+1]= a[i]->spc->def;
    }
    items[i]= a[i]->b;
  }
  box b= concat_box (ip, items, spc);

  tm_delete (ccc);
  return b;
}

Here is the call graph for this function:

Here is the caller graph for this function:

array<line_item> typeset_concat ( edit_env  env,
tree  t,
path  ip 
)

Definition at line 742 of file concater.cpp.

                                               {
  concater ccc= tm_new<concater_rep> (env);
  ccc->typeset (t, ip);
  ccc->finish ();
  array<line_item> a= ccc->a;
  tm_delete (ccc);
  return a;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 752 of file concater.cpp.

                                       {
  concater ccc= tm_new<concater_rep> (env);
  ccc->marker (ip);
  array<line_item> a= ccc->a;
  tm_delete (ccc);
  return a;
}

Here is the call graph for this function:

Here is the caller graph for this function: