Back to index

texmacs  1.0.7.15
Functions
evaluate_length.cpp File Reference
#include "evaluate_main.hpp"
#include "vars.hpp"
#include "analyze.hpp"
#include "font.hpp"
#include "gui.hpp"

Go to the source code of this file.

Functions

bool is_length (string s)
bool is_length (tree t)
bool is_anylen (tree t)
tree tmlen_plus (tree t1, tree t2)
tree tmlen_times (double sc, tree t)
tree tmlen_over (tree t1, tree t2)
tree as_tmlen (tree t)
SI as_length (string l)
SI as_length (tree t)
SI std_inch ()
int std_sfactor ()
int std_dpi ()
double std_magnification ()
int std_font_base_size ()
double std_font_size ()
int std_math_level ()
int std_mode ()
font std_fn ()
tree evaluate_cm_length ()
tree evaluate_mm_length ()
tree evaluate_in_length ()
tree evaluate_pt_length ()
tree evaluate_bp_length ()
tree evaluate_dd_length ()
tree evaluate_pc_length ()
tree evaluate_cc_length ()
tree evaluate_fs_length ()
tree evaluate_fbs_length ()
tree evaluate_em_length ()
tree evaluate_ln_length ()
tree evaluate_sep_length ()
tree evaluate_yfrac_length ()
tree evaluate_ex_length ()
tree evaluate_fn_length ()
tree evaluate_fns_length ()
static space as_vspace (tree t)
tree evaluate_bls_length ()
tree evaluate_fnbot_length ()
tree evaluate_fntop_length ()
tree evaluate_spc_length ()
tree evaluate_xspc_length ()
tree evaluate_par_length ()
tree evaluate_pag_length ()
tree evaluate_tmpt_length ()
tree evaluate_px_length ()
tree evaluate_gw_length ()
tree evaluate_gh_length ()
tree evaluate_msec_length ()
tree evaluate_sec_length ()
tree evaluate_min_length ()
tree evaluate_hr_length ()

Function Documentation

Definition at line 104 of file evaluate_length.cpp.

                     {
  tree r= as_tmlen (l);
  string s= r[N(r)==1? 0: 1]->label;
  return (SI) (as_double (s));
}

Here is the call graph for this function:

Here is the caller graph for this function:

SI as_length ( tree  t)

Definition at line 111 of file evaluate_length.cpp.

                   {
  tree r= as_tmlen (t);
  string s= r[N(r)==1? 0: 1]->label;
  return (SI) (as_double (s));
}

Here is the call graph for this function:

tree as_tmlen ( tree  t)

Definition at line 75 of file evaluate_length.cpp.

                  {
  if (is_func (t, TMLEN)) {
    if (is_double (t[0])) return t;
    if (N(t) < 3) return as_tmlen (t[0]);
    tree _min= as_tmlen (t[0]);
    tree _def= as_tmlen (t[1]);
    tree _max= as_tmlen (t[2]);
    _min= _min[N(_min) == 3? 1: 0];
    _def= _def[N(_def) == 3? 1: 0];
    _max= _max[N(_max) == 3? 1: 0];
    return tree (TMLEN, _min, _def, _max);
  }
  else if (is_atomic (t)) {
    string s= t->label;
    int start= 0, i, n=N(s);
    while ((start+1<n) && (s[start]=='-') && (s[start+1]=='-')) start += 2;
    for (i=start; (i<n) && ((s[i]<'a') || (s[i]>'z')); i++) {}
    string s1= s (start, i);
    string s2= s (i, n);
    if (!(is_double (s1) && is_locase_alpha (s2))) return tree (TMLEN, "0");
    return tmlen_times (as_double (s1),
                     as_tmlen (evaluate (compound (s2 * "-length"))));
  }
  else if (is_func (t, MACRO, 1))
    return as_tmlen (evaluate (t[0]));
  else return tree (TMLEN, "0");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static space as_vspace ( tree  t) [static]

Definition at line 239 of file evaluate_length.cpp.

                   {
  tree r= as_tmlen (t);
  if (N(r) == 1)
    return space ((SI) (as_double (r[0]->label)));
  else {
    SI _min= (SI) as_double (r[0]->label);
    SI _def= (SI) as_double (r[1]->label);
    SI _max= (SI) as_double (r[2]->label);
    double flexibility= as_double (std_env [PAGE_FLEXIBILITY]);
    return space (_def + ((SI) (flexibility * (_min - _def))),
                _def,
                _def + ((SI) (flexibility * (_max - _def))));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 255 of file evaluate_length.cpp.

                       {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tmlen_plus (tree (TMLEN, as_string (fs)),
                   tree (as_vspace (std_env [PAR_SEP])));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 186 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 72.0)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 192 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (4.531 * std_inch() / 25.4)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 178 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 2.54)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 188 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (0.376 * std_inch() / 25.4)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 213 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_fn()->wquad)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 221 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_fn()->yx)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 207 of file evaluate_length.cpp.

                       {
  double fbs= (std_font_base_size () * std_magnification () *
              std_inch ()) / 72.0;
  return tree (TMLEN, as_string (fbs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 225 of file evaluate_length.cpp.

                      {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tree (TMLEN, as_string (0.5*fs), as_string (fs), as_string (1.5*fs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 263 of file evaluate_length.cpp.

                         {
  return tree (TMLEN, as_string (std_fn()->y1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 232 of file evaluate_length.cpp.

                       {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tree (TMLEN, "0", "0", as_string (fs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 268 of file evaluate_length.cpp.

                         {
  return tree (TMLEN, as_string (std_fn()->y2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file evaluate_length.cpp.

                      {
  double fs= (std_font_base_size () * std_magnification () *
             std_inch () * std_font_size ()) / 72.0;
  return tree (TMLEN, as_string (fs));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 323 of file evaluate_length.cpp.

                      {
  //return tree (TMLEN, as_string (gh));
  return tree (TMLEN, as_string (6 * std_inch() / 2.54)); // 6cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 317 of file evaluate_length.cpp.

                      {
  //return tree (TMLEN, as_string (gw));
  return tree (TMLEN, as_string (10 * std_inch() / 2.54)); // 10cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 331 of file evaluate_length.cpp.

{ return tree (TMLEN, "3600000"); }

Here is the caller graph for this function:

Definition at line 182 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch())); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 215 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_fn()->wline)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 330 of file evaluate_length.cpp.

{ return tree (TMLEN, "60000"); }

Here is the caller graph for this function:

Definition at line 180 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 25.4)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 328 of file evaluate_length.cpp.

{ return tree (TMLEN, "1"); }

Here is the caller graph for this function:

Definition at line 302 of file evaluate_length.cpp.

                       {
  /*
  SI d1, height, d2, d3, d4, d5, d6, d7;
  get_page_pars (d1, height, d2, d3, d4, d5, d6, d7);
  return tree (TMLEN, as_string (height));
  */
  return tree (TMLEN, as_string (23 * std_inch() / 2.54)); // 23cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 291 of file evaluate_length.cpp.

                       {
  /*
  SI width, d1, d2, d3, d4, d5, d6, d7;
  get_page_pars (width, d1, d2, d3, d4, d5, d6, d7);
  width -= (get_length (PAR_LEFT) + get_length (PAR_RIGHT));
  return tree (TMLEN, as_string (width));
  */
  return tree (TMLEN, as_string (15 * std_inch() / 2.54)); // 15cm
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 190 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (12.0 * std_inch() / 72.27)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 184 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_inch() / 72.27)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 313 of file evaluate_length.cpp.

                           {
  return tree (TMLEN, as_string (std_sfactor () * PIXEL)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 329 of file evaluate_length.cpp.

{ return tree (TMLEN, "1000"); }

Here is the caller graph for this function:

Definition at line 217 of file evaluate_length.cpp.

                            {
  return tree (TMLEN, as_string (std_fn()->sep)); }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 273 of file evaluate_length.cpp.

                       {
  space spc= std_fn()->spc;
  return tree (TMLEN,
              as_string (spc->min),
              as_string (spc->def),
              as_string (spc->max));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 311 of file evaluate_length.cpp.

                             {
  return tree (TMLEN, "1"); }

Here is the caller graph for this function:

Definition at line 282 of file evaluate_length.cpp.

                        {
  space spc= std_fn()->extra;
  return tree (TMLEN,
              as_string (spc->min),
              as_string (spc->def),
              as_string (spc->max));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 219 of file evaluate_length.cpp.

                              {
  return tree (TMLEN, as_string (std_fn()->yfrac)); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_anylen ( tree  t)

Definition at line 35 of file evaluate_length.cpp.

                   {
  return
    (is_func (t, TMLEN) && ((N(t) == 1) || (N(t) == 3))) ||
    (is_atomic (t) && is_length (t->label)) ||
    is_func (t, MACRO, 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_length ( string  s)

Definition at line 23 of file evaluate_length.cpp.

                     {
  int i;
  for (i=0; (i<N(s)) && ((s[i]<'a') || (s[i]>'z')); i++) {}
  return is_double (s (0, i)) && is_locase_alpha (s (i, N(s)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool is_length ( tree  t)

Definition at line 30 of file evaluate_length.cpp.

                   {
  return is_atomic (t) && is_length (t->label);
}

Here is the call graph for this function:

int std_dpi ( ) [inline]

Definition at line 125 of file evaluate_length.cpp.

                      {
  return as_int (std_env [DPI]); }

Here is the call graph for this function:

Here is the caller graph for this function:

font std_fn ( )

Definition at line 144 of file evaluate_length.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int std_font_base_size ( ) [inline]

Definition at line 129 of file evaluate_length.cpp.

                                 {
  return as_int (std_env [FONT_BASE_SIZE]); }

Here is the call graph for this function:

Here is the caller graph for this function:

double std_font_size ( ) [inline]

Definition at line 131 of file evaluate_length.cpp.

                               {
  return as_double (std_env [FONT_SIZE]); }

Here is the call graph for this function:

Here is the caller graph for this function:

SI std_inch ( ) [inline]

Definition at line 121 of file evaluate_length.cpp.

                      {
  return (SI) ((double) as_int (std_env [DPI]) * PIXEL); }

Here is the call graph for this function:

Here is the caller graph for this function:

double std_magnification ( ) [inline]

Definition at line 127 of file evaluate_length.cpp.

                                   {
  return as_double (std_env [MAGNIFICATION]); }

Here is the call graph for this function:

Here is the caller graph for this function:

int std_math_level ( ) [inline]

Definition at line 133 of file evaluate_length.cpp.

                             {
  return as_int (std_env [MATH_LEVEL]); }

Here is the call graph for this function:

Here is the caller graph for this function:

int std_mode ( ) [inline]

Definition at line 136 of file evaluate_length.cpp.

                       {
  string s= as_string (std_env [MODE]);
  if (s == "text") return 1;
  else if (s == "math") return 2;
  else if (s == "prog") return 3;
  else return 0; }

Here is the call graph for this function:

Here is the caller graph for this function:

int std_sfactor ( ) [inline]

Definition at line 123 of file evaluate_length.cpp.

                          {
  return as_int (std_env [SFACTOR]); }

Here is the call graph for this function:

Here is the caller graph for this function:

tree tmlen_over ( tree  t1,
tree  t2 
)

Definition at line 64 of file evaluate_length.cpp.

                              {
  t1= t1[N(t1)==1? 0: 1];
  t2= t2[N(t2)==1? 0: 1];
  return as_string (as_double (t1) / as_double (t2));
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree tmlen_plus ( tree  t1,
tree  t2 
)

Definition at line 43 of file evaluate_length.cpp.

                              {
  if ((N(t1) == 1) && (N(t2) == 1))
    return tree (TMLEN, as_string (as_double (t1[0]) + as_double (t2[0])));
  if (N(t1) == 1) t1= tree (TMLEN, t1[0], t1[0], t1[0]);
  if (N(t2) == 1) t2= tree (TMLEN, t2[0], t2[0], t2[0]);
  tree _min= as_string (as_double (t1[0]) + as_double (t2[0]));
  tree _def= as_string (as_double (t1[1]) + as_double (t2[1]));
  tree _max= as_string (as_double (t1[2]) + as_double (t2[2]));
  return tree (TMLEN, _min, _def, _max);
}

Here is the call graph for this function:

Here is the caller graph for this function:

tree tmlen_times ( double  sc,
tree  t 
)

Definition at line 55 of file evaluate_length.cpp.

                                {
  if (N(t) == 1) return tree (TMLEN, as_string (sc * as_double (t[0])));
  tree _min= as_string (sc * as_double (t[0]));
  tree _def= as_string (sc * as_double (t[1]));
  tree _max= as_string (sc * as_double (t[2]));
  return tree (TMLEN, _min, _def, _max);
}

Here is the call graph for this function:

Here is the caller graph for this function: