Back to index

texmacs  1.0.7.15
Functions
new_style.hpp File Reference
#include "drd_std.hpp"
#include "Scheme/object.hpp"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void style_invalidate_cache ()
void style_set_cache (tree style, hashmap< string, tree > H, tree t)
void style_get_cache (tree style, hashmap< string, tree > &H, tree &t, bool &f)
bool compute_env_and_drd (tree style)
hashmap< string, treeget_style_env (tree style)
drd_info get_style_drd (tree style)
tree get_document_preamble (tree t)
drd_info get_document_drd (tree doc)
object get_style_menu ()
object get_add_package_menu ()
object get_remove_package_menu ()

Function Documentation

bool compute_env_and_drd ( tree  style)

Definition at line 114 of file new_style.cpp.

                                 {
  init_style_data ();
  ASSERT (is_tuple (style), "style tuple expected");
  bool busy= false;
  for (int i=0; i<N(style); i++)
    busy= busy || sd->style_busy->contains (as_string (style[i]));
  hashmap<string,bool> old_busy= copy (sd->style_busy);
  for (int i=0; i<N(style); i++)
    sd->style_busy (as_string (style[i]))= true;

  //cout << "Get environment of " << style << INDENT << LF;
  hashmap<string,tree> H;
  drd_info drd ("none", std_drd);
  url none= url ("$PWD/none");
  hashmap<string,tree> lref;
  hashmap<string,tree> gref;
  hashmap<string,tree> laux;
  hashmap<string,tree> gaux;
  edit_env env (drd, none, lref, gref, laux, gaux);
  if (!busy) {
    tree t;
    bool ok;
    style_get_cache (style, H, t, ok);
    if (ok) {
      env->patch_env (H);
      ok= drd->set_locals (t);
      drd->set_environment (H);
    }
    if (!ok) {
      env->exec (tree (USE_PACKAGE, A (style)));
      env->read_env (H);
      drd->heuristic_init (H);
    }
    sd->style_cached (style)= H;
    sd->drd_cached (style)= drd;
  }
  //cout << UNINDENT << "Got environment of " << style << LF;

  sd->style_busy= old_busy;
  return !busy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 271 of file new_style.cpp.

                        {
  url pck_u= descendance ("$TEXMACS_PACKAGE_ROOT");
  string pck= compute_style_menu (pck_u, 1);
  return eval ("(menu-dynamic " * pck * ")");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 200 of file new_style.cpp.

                            {
  init_style_data ();
  tree style= extract (doc, "style");
  if (extract (doc, "TeXmacs") == "") {
    if (the_drd->get_syntax (make_tree_label ("theorem")) != tree (UNINIT))
      return the_drd;
    style= tree (TUPLE, "generic");
  }
  //cout << "style= " << style << "\n";
  drd_info drd= get_style_drd (style);
  tree p= get_document_preamble (doc);
  if (p != "") {
    drd= drd_info ("preamble", drd);
    url none= url ("$PWD/none");
    hashmap<string,tree> lref;
    hashmap<string,tree> gref;
    hashmap<string,tree> laux;
    hashmap<string,tree> gaux;
    edit_env env (drd, none, lref, gref, laux, gaux);
    hashmap<string,tree> H;
    env->exec (tree (USE_PACKAGE, A (style)));
    env->exec (p);
    env->read_env (H);
    drd->heuristic_init (H);
  }
  return drd;
}

Definition at line 184 of file new_style.cpp.

                               {
  init_style_data ();
  if (is_atomic (t)) return "";
  else if (is_compound (t, "hide-preamble", 1)) return t[0];
  else if (is_compound (t, "show-preamble", 1)) return t[0];
  else {
    int i, n= N(t);
    for (i=0; i<n; i++) {
      tree p= get_document_preamble (t[i]);
      if (p != "") return p;
    }
    return "";
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 278 of file new_style.cpp.

                           {
  url pck_u= descendance ("$TEXMACS_PACKAGE_ROOT");
  string pck= compute_style_menu (pck_u, 2);
  return eval ("(menu-dynamic " * pck * ")");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 170 of file new_style.cpp.

                           {
  init_style_data ();
  init_std_drd ();
  if (sd->drd_cached->contains (style))
    return sd->drd_cached [style];
  else if (compute_env_and_drd (style))
    return sd->drd_cached [style];
  else {
    //cout << "Busy drd: " << style << "\n";
    return std_drd;
  }
}

Definition at line 157 of file new_style.cpp.

                           {
  init_style_data ();
  if (sd->style_cached->contains (style))
    return sd->style_cached [style];
  else if (compute_env_and_drd (style))
    return sd->style_cached [style];
  else {
    //cout << "Busy style: " << style << "\n";
    return hashmap<string,tree> ();
  }
}

Here is the call graph for this function:

Definition at line 264 of file new_style.cpp.

                  {
  url sty_u= descendance ("$TEXMACS_STYLE_ROOT");
  string sty= compute_style_menu (sty_u, 0);
  return eval ("(menu-dynamic " * sty * ")");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void style_get_cache ( tree  style,
hashmap< string, tree > &  H,
tree t,
bool &  f 
)

Definition at line 85 of file new_style.cpp.

                                                                        {
  init_style_data ();
  //cout << "get cache " << style << LF;
  if ((style == "") || (style == tree (TUPLE))) { f= false; return; }
  f= sd->style_cache->contains (style);
  if (f) {
    H= sd->style_cache [style];
    t= sd->style_drd   [style];
  }
  else {
    string s;
    url name ("$TEXMACS_HOME_PATH/system/cache", cache_file_name (style));
    if (exists (name) && (!load_string (name, s, false))) {
      //cout << "loaded " << name << LF;
      tree p= scheme_to_tree (s);
      H= hashmap<string,tree> (UNINIT, p[0]);
      t= p[1];
      sd->style_cache (copy (style))= H;
      sd->style_drd   (copy (style))= t;
      f= true;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 64 of file new_style.cpp.

                          {
  init_style_data ();
  sd->style_cache=
    hashmap<tree,hashmap<string,tree> > (hashmap<string,tree> (UNINIT));
  remove ("$TEXMACS_HOME_PATH/system/cache" * url_wildcard ("__*"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void style_set_cache ( tree  style,
hashmap< string, tree H,
tree  t 
)

Definition at line 72 of file new_style.cpp.

                                                             {
  init_style_data ();
  // cout << "set cache " << style << LF;
  sd->style_cache (copy (style))= H;
  sd->style_drd   (copy (style))= t;
  url name ("$TEXMACS_HOME_PATH/system/cache", cache_file_name (style));
  if (!exists (name)) {
    save_string (name, tree_to_scheme (tuple ((tree) H, t)));
    // cout << "saved " << name << LF;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function: