示例#1
0
tree
xml_html_parser::finalize_space (tree t) {
  if (is_atomic (t) || (!is_tuple (t, "tag"))) return t;
  else {
    int i, n= N(t);
    tree r= tuple (t[0], t[1]);
    int first= -1, last= -1;
    for (i=2; i<n; i++)
      if (!is_tuple (t[i], "attr")) {
	first= i; break;
      }
    if (!is_tuple (t[n-1], "attr"))
      last= n-1;
    (void) first; (void) last;
    for (i=2; i<n; i++) {
      if (is_atomic (t[i])) {
	if (finalize_preserve_space (t[1]->label)) r << t[i];
	else {
	  string s= finalize_space (t[i]->label, i==2, i==(n-1));
	  if (s != "") r << s;
	}
      }
      else if (is_tuple (t[i], "tag")) r << finalize_space (t[i]);
      else r << t[i];
    }
    return r;
  }
}
示例#2
0
static array<tree>
get_springer_affiliation_datas (tree t, bool llncs=false) {
  int i, n=N(t);
  array<tree> r, author_datas, author_affiliation;
  tree tmp (CONCAT);
  for (i=0; i<n; i++) {
    while (i<n && !is_tuple (t[i], "\\at")) tmp << t[i++];
    author_datas= get_springer_author_datas (tmp, "name");
    tmp= concat ();
    if (is_tuple (t[i], "\\at")) {
      i++;
      while (i<n && !is_tuple (t[i], "\\and")) tmp << t[i++];
      author_affiliation= get_springer_author_datas (tmp, "affiliation");
      tmp= concat ();
      for (int j=0; j<N(author_datas); j++)
        for (int k=0; k<N(author_affiliation); k++)
          for (int l=1; l<N(author_affiliation[k]); l++)
            author_datas[j]= (author_datas[j] << author_affiliation[k][l]);
      r << author_datas;
      author_datas= array<tree>();
      author_affiliation= array<tree>();
    }
  }
  return r;
}
示例#3
0
bool
is_metadata_env (tree u) {
  return is_tuple (u, "\\begin-frontmatter")  ||
         is_tuple (u, "\\begin-IEEEkeywords") ||
         is_tuple (u, "\\begin-keywords")     ||
         is_tuple (u, "\\begin-abstract");
}
示例#4
0
void
xml_html_parser::build (tree& r) {
  while (i<n) {
    if (is_tuple (a[i], "begin")) {
      string name= a[i][1]->label;
      if (build_must_close (name)) return;
      tree sub= copy (a[i]); sub[0]= "tag";
      i++;
      if (html && html_empty_tag_table->contains (name))
	r << sub;
      else {
	stack= tuple (name, stack);
	build (sub);
	r << sub;
	stack= stack[1];
      }
    }
    else if (is_tuple (a[i], "end")) {
      if (stack[0]->label == a[i][1]->label) { i++; return; }
      if (build_can_close (a[i][1]->label)) return;
      i++;
    }
    else r << a[i++];
  }
}
示例#5
0
db_atoms
database_rep::query (tree ql, db_time t, int limit) {
    //cout << "query " << ql << ", " << t << ", " << limit << LF;
    ql= normalize_query (ql);
    //cout << "normalized query " << ql << ", " << t << ", " << limit << LF;
    db_atoms ids= ansatz (ql, t);
    //cout << "ansatz ids= " << ids << LF;
    bool sort_flag= false;
    if (is_tuple (ql))
        for (int i=0; i<N(ql); i++)
            sort_flag= sort_flag || is_tuple (ql[i], "order", 2);
    ids= filter (ids, ql, t, max (limit, sort_flag? 1000: 0));
    //cout << "filtered ids= " << ids << LF;
    for (int i=0; i<N(ql); i++) {
        if (is_tuple (ql[i], "modified", 2) &&
                is_atomic (ql[i][1]) && is_atomic (ql[i][2]) &&
                is_quoted (ql[i][1]->label) && is_quoted (ql[i][2]->label)) {
            string t1= scm_unquote (ql[i][1]->label);
            string t2= scm_unquote (ql[i][2]->label);
            if (is_int (t1) && is_int (t2))
                ids= filter_modified (ids, (db_time) as_long_int (t1),
                                      (db_time) as_long_int (t2));
        }
    }
    //cout << "filtered on modified ids= " << ids << LF;
    ids= sort_results (ids, ql, t);
    //cout << "sorted ids= " << ids << LF;
    if (N(ids) > limit) ids= range (ids, 0, limit);
    return ids;
}
示例#6
0
static void pd_check(ProcDict *pd) 
{
    unsigned int i;
    Uint num;
    if (pd == NULL)
	return;
    ASSERT(pd->size >= pd->used);
    ASSERT(HASH_RANGE(pd) <= MAX_HASH);
    for (i = 0, num = 0; i < pd->used; ++i) {
	Eterm t = pd->data[i];
	if (is_nil(t)) {
	    continue;
	} else if (is_tuple(t)) {
	    ++num;
	    ASSERT(arityval(*tuple_val(t)) == 2);
	    continue;
	} else if (is_list(t)) {
	    while (t != NIL) {
		++num;
		ASSERT(is_tuple(TCAR(t)));
		ASSERT(arityval(*(tuple_val(TCAR(t)))) == 2);
		t = TCDR(t);
	    }
	    continue;
	} else {
	    erl_exit(1, 
		     "Found tag 0x%08x in process dictionary at position %d",
		     (unsigned long) t, (int) i);
	}
    }
    ASSERT(num == pd->numElements);
    ASSERT(pd->splitPosition <= pd->homeSize);
}
示例#7
0
tree
evaluate_merge (tree t) {
  int i, n= N(t);
  if (n == 0) return "";
  tree acc= evaluate (t[0]);
  if (is_concat (acc)) acc= tree_as_string (acc);
  for (i=1; i<n; i++) {
    tree add= evaluate (t[i]);
    if (is_atomic (acc) && (is_atomic (add) || is_concat (add)))
      acc= acc->label * tree_as_string (add);
    else if (is_tuple (acc) && is_tuple (add))
      acc= acc * add;
    else if (is_func (acc, MACRO) && is_func (add, MACRO) &&
	     (N(acc) == N(add)) &&
	     (acc (0, N(acc)-1) == add (0, N(add)-1)))
      {
	tree r = copy (acc);
	tree u1= copy (acc[N(acc)-1]);
	tree u2= copy (add[N(add)-1]);
	tree u (CONCAT, u1, u2);
	if (u1 == "") u= u2;
	else if (u2 == "") u= u1;
	else if (is_atomic (u1) && is_atomic (u2))
	  u= u1->label * u2->label;
	r[N(r)-1]= u;
	acc= r;
      }
    else return evaluate_error ("bad merge");
  }
  return acc;
}
示例#8
0
string
connection_start (string name, string session, bool again) {
  // cout << "Start " << name << ", " << session << "\n";
  if (!connection_declared (name))
    return "Error: connection " * name * " has not been declared";

  connection con= connection (name * "-" * session);
  if (is_nil (con)) {
    if (DEBUG_VERBOSE)
      debug_io << "Starting session '" << session << "'\n";
    tree t= connection_info (name, session);
    if (is_tuple (t, "pipe", 1)) {
      tm_link ln= make_pipe_link (t[1]->label);
      con= tm_new<connection_rep> (name, session, ln);
    }
#ifndef QTTEXMACS
    else if (is_tuple (t, "socket", 2)) {
      tm_link ln= make_socket_link (t[1]->label, as_int (t[2]->label));
      con= tm_new<connection_rep> (name, session, ln);
    }
#endif
    else if (is_tuple (t, "dynlink", 3)) {
      tm_link ln=
	make_dynamic_link (t[1]->label, t[2]->label, t[3]->label, session);
      con= tm_new<connection_rep> (name, session, ln);
    }
  }

  return con->start (again);
}
示例#9
0
static void
make_entry (tree& D, tree t) {
  // cout << "Make entry " << t << "\n";
  int i, j, n= N(t);
  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 1)) {
      bool flag= true;
      for (j=0; j<n; j++)
	if (is_func (t[j], TUPLE, 2) && (t[i][0] == t[j][0]))
	  flag= false;
      if (flag) D << t[i][0];
    }

  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2) && is_tuple (t[i][1], "range", 2)) {
      bool flag= true;
      for (j=i+1; j<n; j++)
	if (is_func (t[j], TUPLE, 2) && is_tuple (t[j][1], "range", 2))
	  if ((t[i][0] == t[j][0]) && (t[i][1][1] == t[j][1][1])) {
	    t[i][1]= tree (CONCAT, t[i][1][2], "--", t[j][1][2]);
	    t[j]= "";
	    flag= false;
	    break;
	  }
      if (flag) t[i][1]= tree (CONCAT, t[i][1][2], "--?");
    }

  hashmap<tree,tree> h ("");
  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2)) {
      tree l= t[i][0], r= t[i][1];
      if (!h->contains (l)) h (l)= r;
      else {
	tree rr= h[l];
	if (rr == "") rr= r;
	else if (r != "") {
	  if (!is_concat (rr)) rr= tree (CONCAT, rr);
	  rr << ", " << r;
	}
	h (l)= rr;
      }
    }

  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2)) {
      tree l= t[i][0];
      if (h->contains (l)) {
	int k= N(l);
	tree e= compound ("index-" * as_string (k), copy (l[k-1]), h[l]);
	if (h[l] == "")
	  e= compound ("index-" * as_string (k) * "*", copy (l[k-1]));
	D << e;
	h->reset (l);
      }
    }
}
示例#10
0
void
edit_select_rep::selection_paste (string key) {
  tree t; string s;
  (void) ::get_selection (key, t, s, selection_import);
  if (inside_active_graphics ()) {
    if (is_tuple (t, "texmacs", 3))
      call ("graphics-paste", t[1]);
    return;
  }
  if (is_tuple (t, "extern", 1)) {
    string mode= get_env_string (MODE);
    string lan = get_env_string (MODE_LANGUAGE (mode));
    if ((selection_import == "latex") && (mode == "prog")) mode= "verbatim";
    if ((selection_import == "latex") && (mode == "math")) mode= "latex-math";
    if ((selection_import == "html") && (mode == "prog")) mode= "verbatim";
    string fm= selection_import * "-snippet";
    tree doc= generic_to_tree (selection_decode(lan, as_string(t[1])), fm);
    if (is_func (doc, DOCUMENT, 1)) doc= doc[0]; // temporary fix
    insert_tree (doc);
  }
  if (is_tuple (t, "texmacs", 3)) {
    string mode= get_env_string (MODE);
    string lan = get_env_string (MODE_LANGUAGE (mode));
    if (is_compound (t[1], "text", 1) && mode == "text")
      t= tuple ("texmacs", t[1][0], "text", lan);
    if (is_compound (t[1], "math", 1) && mode == "math")
      t= tuple ("texmacs", t[1][0], "math", lan);
    if (mode == "math" && t[2] == "text")
      set_message ("Error: invalid paste of text into a formula", "paste");
    else if (mode == "prog" && t[2] == "math") {
      tree in= tuple (lan, t[1]);
      tree r= stree_to_tree (call ("plugin-math-input", tree_to_stree (in)));
      insert_tree (r);
    }
    else {
      if ((t[2] != mode) && (t[2] != "src") && (mode != "src") &&
	  ((t[2] == "math") || (mode == "math"))) {
        if (t[2] == "math")
          insert_tree (compound ("math", ""), path (0, 0));
        else if (t[2] == "text")
          insert_tree (compound ("text", ""), path (0, 0));
        else
          insert_tree (tree (WITH, copy (MODE), copy (t[2]), ""), path (2, 0));
      }
      if (is_func (t[1], TFORMAT) || is_func (t[1], TABLE)) {
	int row, col;
	path fp= search_format (row, col);
	if (is_nil (fp)) insert_tree (compound (copy (TABULAR), t[1]));
	else table_write_subtable (fp, row, col, t[1]);
      }
      else insert_tree (t[1]);
    }
  }
}
示例#11
0
tree
collect_abstract_data (tree u) {
  if (!is_tuple (u) || N(u) < 1) return u;
  string s= as_string (u[0]);
  s= "\\abstract-" * s(3, N(s));
  tree r (APPLY, s);
  for (int i=1; i<N(u); i++)
    if (!is_tuple (u[i], "\\tmsep"))
      r << u[i];
  return r;
}
示例#12
0
void
concater_rep::typeset_anim_translate (tree t, path ip) {
  if (N(t) != 4) { typeset_error (t, ip); return; }
  player pl= get_player (env->get_animation_ip (ip));
  box  b  = typeset_as_concat (env, t[0], descend (ip, 0));
  int  len= env->as_length (env->exec (t[1]));
  tree t1 = env->exec (t[2]);
  tree t2 = env->exec (t[3]);
  SI x1= b->x1, y1= b->y1, x2= b->x1, y2= b->y1;
  if (is_tuple (t1) && N(t1)==2) effect_point (env, b, t1[0], t1[1], x1, y1);
  if (is_tuple (t2) && N(t2)==2) effect_point (env, b, t2[0], t2[1], x2, y2);
  print (anim_translate_box (ip, b, pl, len, x1, y1, x2, y2));
}
示例#13
0
static tree
clean_latex_title_markup (tree t) {
  if (is_atomic (t)) return t;
  if (is_latex_titlenote (t)      ||
      is_tuple (t, "\\tmmisc", 1) || is_tuple (t, "\\tmsubtitle", 1))
    return concat();
  if (is_tuple (t, "\\tmSep")) return concat ("\n");
  tree r (L(t));
  int i, n=N(t);
  for (i=0; i<n; i++)
      r << clean_latex_title_markup (t[i]);
  return r;
}
示例#14
0
static string
get_type (scheme_tree p, int i) {
  if (is_tuple (p[i]) && N(p[i])>1 &&
      is_atomic (p[i][1]) && is_quoted (p[i][1]->label))
    return scm_unquote (p[i][1]->label);
  return "string";
}
示例#15
0
void
dictionary_rep::load (url u) {
  if (is_none (u)) return;
  if (is_or (u)) {
    load (u[1]);
    load (u[2]);
    return;
  }

  string s;
  if (load_string (u, s, false)) return;
  tree t= block_to_scheme_tree (s);
  if (!is_tuple (t)) return;

  int i, n= N(t);
  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2) &&
        is_atomic (t[i][0]) && is_atomic (t[i][1]))
    {
      string l= t[i][0]->label; if (is_quoted (l)) l= scm_unquote (l);
      string r= t[i][1]->label; if (is_quoted (r)) r= scm_unquote (r);
      if (to == "chinese" ||  to == "japanese"  || to == "german" ||
          to == "korean"  ||  to == "taiwanese" ||
          to == "russian" ||  to == "ukrainian" || to == "bulgarian")
        r= utf8_to_cork (r);
      table (l)= r;
    }
}
示例#16
0
db_constraint
database_rep::encode_constraint (tree q) {
    db_constraint r;
    if (!is_tuple (q)) return db_constraint ();
    if (N(q) <= 1 || !is_atomic (q[0])) return db_constraint ();
    string attr= q[0]->label;
    if (attr == "any")
        r << -1;
    else if (attr == "keywords")
        return encode_keywords_constraint (q);
    else if (attr == "order") {
        r << -2;
        return r;
    }
    else if (attr == "modified") {
        r << -2;
        return r;
    }
    else if (!is_quoted (q[0]->label))
        return db_constraint ();
    else if (atom_encode->contains (scm_unquote (q[0]->label)))
        r << atom_encode [scm_unquote (q[0]->label)];
    else return db_constraint ();
    for (int i=1; i<N(q); i++)
        if (atom_encode->contains (scm_unquote (q[i]->label)))
            r << atom_encode [scm_unquote (q[i]->label)];
    return r;
}
示例#17
0
static tree
clean_acm_title_markup (tree t) {
  if (is_atomic (t)) return t;
  if (is_acm_titlenote (t) ||
      is_tuple (t, "\\tmacmmisc", 1) || is_tuple (t, "\\tmacmsubtitle", 1))
    return concat();
  if (is_tuple (t, "\\ttlit")) {
    t[0]= "\\it";
    return t;
  }
  tree r (L(t));
  int i, n=N(t);
  for (i=0; i<n; i++)
      r << clean_acm_title_markup (t[i]);
  return r;
}
示例#18
0
文件: erl_bif_op.c 项目: HansN/otp
BIF_RETTYPE is_tuple_1(BIF_ALIST_1)
{
    if (is_tuple(BIF_ARG_1)) {
	BIF_RET(am_true);
    }
    BIF_RET(am_false);
}
示例#19
0
apr_array_header_t *source_line_blocks(term_t info, apr_pool_t *pool)
{
	apr_array_header_t *refs = apr_array_make(pool, 64, sizeof(source_ref_t));
	term_t cons = info;
	while (is_cons(cons))
	{
		term_box_t *cb = peel(cons);
		term_t t = cb->cons.head;
		//{F,L,S,E}
		if (is_tuple(t))
		{
			term_box_t *tb = peel(t);
			if (tb->tuple.size == 4)
			{
				source_ref_t *ref = &APR_ARRAY_PUSH(refs, source_ref_t);
				ref->file_index = int_value(tb->tuple.elts[0]);
				ref->source_line = int_value(tb->tuple.elts[1]);
				ref->off_starts = int_value(tb->tuple.elts[2]);
				ref->off_ends = int_value(tb->tuple.elts[3]);
			}
		}
		cons = cb->cons.tail;
	}
	return refs;
}
示例#20
0
tree
filter_spaces (tree t, bool &spaced) {
  if (is_space (t) && spaced)  return concat();
  if (is_space (t) && !spaced) {
    spaced= true;
    return t;
  }
  spaced= false;
  if (is_atomic (t)) return t;
  tree r (L(t));
  int i, n=N(t);
  if (is_apply (t) || is_tuple (t)) {
    // then arity shouldn't vary
    for (i=0; i<n; i++)
      r << filter_spaces (t[i], spaced);
    return r;
  }
  for (i=0; i<n; i++) {
    if (t[i] == concat() || t[i] == "") continue;
    if (!is_space (t[i]) || !spaced) {
      r << filter_spaces (t[i], spaced);
      if (is_space (t[i])) spaced= true;
      else spaced= false;
    }
  }
  n= N(r);
  if (n>0 && is_space (r[n-1])) r[n-1]= concat();
  return r;
}
示例#21
0
static Eterm
pd_hash_get_all(Process *p, ProcDict *pd)
{
    Eterm* hp;
    Eterm res = NIL;
    Eterm tmp, tmp2;
    unsigned int i;
    unsigned int num;

    if (pd == NULL) {
	return res;
    }
    num = HASH_RANGE(pd);
    hp = HAlloc(p, pd->numElements * 2);
    
    for (i = 0; i < num; ++i) {
	tmp = ARRAY_GET(pd, i);
	if (is_boxed(tmp)) {
	    ASSERT(is_tuple(tmp));
	    res = CONS(hp, tmp, res);
	    hp += 2;
	} else if (is_list(tmp)) {
	    while (tmp != NIL) {
		tmp2 = TCAR(tmp);
		res = CONS(hp, tmp2, res);
		hp += 2;
		tmp = TCDR(tmp);
	    }
	}
    }
    return res;
}
示例#22
0
static Eterm pd_hash_get_keys(Process *p, Eterm value) 
{
    Eterm *hp;
    Eterm res = NIL;
    ProcDict *pd = p->dictionary;
    unsigned int i, num;
    Eterm tmp, tmp2;

    if (pd == NULL) {
	return res;
    }

    num = HASH_RANGE(pd);
    for (i = 0; i < num; ++i) {
	tmp = ARRAY_GET(pd, i);
	if (is_boxed(tmp)) {
	    ASSERT(is_tuple(tmp));
	    if (EQ(tuple_val(tmp)[2], value)) {
		hp = HAlloc(p, 2);
		res = CONS(hp, tuple_val(tmp)[1], res);
	    }
	} else if (is_list(tmp)) {
	    while (tmp != NIL) {
		tmp2 = TCAR(tmp);
		if (EQ(tuple_val(tmp2)[2], value)) {
		    hp = HAlloc(p, 2);
		    res = CONS(hp, tuple_val(tmp2)[1], res);
		}
		tmp = TCDR(tmp);
	    }
	}
    }
    return res;
}
示例#23
0
db_atoms
database_rep::ansatz (tree ql, db_time t) {
    if (!is_tuple (ql)) return db_atoms ();
    int a= ansatz_index (ql);
    //cout << "ansatz index: " << a << LF;
    if (a < 0) return ids_list;
    tree q= ql[a];
    db_atoms idsl;
    hashset<db_atom> idss;
    db_constraint c= encode_constraint (q);
    if (N(c) == 1 && c[0] == -2) return ids_list;
    if (N(c) <= 1) return db_atoms ();
    for (int i=1; i<N(c); i++) {
        db_atom val= c[i];
        db_line_nrs nrs= val_lines[val];
        //cout << "trying " << val << ", " << nrs << LF;
        for (int j=0; j<N(nrs); j++) {
            db_line& l= db[nrs[j]];
            //cout << "  line " << l->id << ", " << l->attr << ", " << l->val << LF;
            if ((t == 0) || (l->created <= t && t < l->expires))
                if (!idss->contains (l->id)) {
                    idss->insert (l->id);
                    idsl << l->id;
                }
        }
    }
    return idsl;
}
示例#24
0
/* 
 * Called from process_info/1,2.
 */
Eterm erts_dictionary_copy(Process *p, ProcDict *pd) 
{
    Eterm* hp;
    Eterm* heap_start;
    Eterm res = NIL;
    Eterm tmp, tmp2;
    unsigned int i, num;

    if (pd == NULL) {
	return res;
    }

    PD_CHECK(pd);
    num = HASH_RANGE(pd);
    heap_start = hp = (Eterm *) erts_alloc(ERTS_ALC_T_TMP,
					   sizeof(Eterm) * pd->numElements * 2);
    for (i = 0; i < num; ++i) {
	tmp = ARRAY_GET(pd, i);
	if (is_boxed(tmp)) {
	    ASSERT(is_tuple(tmp));
	    res = CONS(hp, tmp, res);
	    hp += 2;
	} else if (is_list(tmp)) {
	    while (tmp != NIL) {
		tmp2 = TCAR(tmp);
		res = CONS(hp, tmp2, res);
		hp += 2;
		tmp = TCDR(tmp);
	    }
	}
    }
    res = copy_object(res, p);
    erts_free(ERTS_ALC_T_TMP, (void *) heap_start);
    return res;
}
示例#25
0
Eterm erts_pd_hash_get(Process *p, Eterm id) 
{
    unsigned int hval;
    Eterm tmp;
    ProcDict *pd = p->dictionary;

    if (pd == NULL)
	return am_undefined;
    hval = pd_hash_value(pd, id);
    tmp = ARRAY_GET(pd, hval);
    if (is_boxed(tmp)) {	/* Tuple */
	ASSERT(is_tuple(tmp));
	if (EQ(tuple_val(tmp)[1], id)) {
	    return tuple_val(tmp)[2];
	}
    } else if (is_list(tmp)) {
	for (; tmp != NIL && !EQ(tuple_val(TCAR(tmp))[1], id); tmp = TCDR(tmp)) {
	    ;
	}
	if (tmp != NIL) {
	    return tuple_val(TCAR(tmp))[2];
	}
    } else if (is_not_nil(tmp)) {
#ifdef DEBUG
	erts_fprintf(stderr,
		     "Process dictionary for process %T is broken, trying to "
		     "display term found in line %d:\n"
		     "%T\n", p->common.id, __LINE__, tmp);
#endif
	erl_exit(1, "Damaged process dictionary found during get/1.");
    }
    return am_undefined;
}
示例#26
0
widget
texmacs_window_widget (widget wid, tree geom) {
    int W, H;
    int w= geometry_w, h= geometry_h;
    int x= geometry_x, y= geometry_y;
    bool custom= is_tuple (geom) && N (geom) >= 2;
#ifndef QTTEXMACS
    if (use_side_tools) {
        w += 200;
        h += 100;
    }
#endif
    if (custom) {
        w= as_int (geom[0]);
        h= as_int (geom[1]);
    }
    gui_root_extents (W, H);
    W /= PIXEL;
    H /= PIXEL;
    if (x < 0) x= W + x + 1 - w;
    if (y < 0) y= H + y + 1 - h;
    string name= "TeXmacs";
    name= unique_window_name (name);
    widget win= plain_window_widget (wid, name);
    SI xx= x * PIXEL, yy= -y * PIXEL;
    SI ww= w * PIXEL, hh=  h * PIXEL;
    if (!custom) {
        get_preferred_position (name, xx, yy);
        get_preferred_size (name, ww, hh);
    }
    set_size (win, ww, hh);
    set_position (win, xx, yy);
    return win;
}
示例#27
0
translator
load_virtual (string name) {
  if (translator::instances -> contains (name))
    return translator (name);
  translator trl= tm_new<translator_rep> (name);

  string s, r;
  name= name * ".vfn";
  if (DEBUG_STD) debug_fonts << "Loading " << name << "\n";
  url u ("$TEXMACS_HOME_PATH/fonts/virtual:$TEXMACS_PATH/fonts/virtual", name);
  load_string (u, s, true);
  tree t= string_to_scheme_tree (s);
  ASSERT (is_tuple (t, "virtual-font"), "bad virtual font format");

  int i, n= N(t);
  trl->virt_def= array<tree> (n);
  for (i=1; i<n; i++)
    if (is_func (t[i], TUPLE, 2) && is_atomic (t[i][0])) {
      string s= as_string (t[i][0]);
      if (N(s)>1) s= "<" * s * ">";
      trl->dict (s)= i;
      trl->virt_def[i]= t[i][1];
      // cout << s << "\t" << i << "\t" << t[i][1] << "\n";
    }
  return trl;
}
示例#28
0
box
pager_rep::pages_format (array<page_item> l, SI ht, SI tcor, SI bcor) {
  // cout << "Formatting insertion of height " << ht << LF;
  ht -= (tcor + bcor);
  int i, n= N(l);
  array<box>   bs;
  array<space> spc;
  for (i=0; i<n; i++) {
    page_item item= l[i];
    if (item->type == PAGE_CONTROL_ITEM) {
      if (is_tuple (item->t, "env_page")) {
	if (((item->t[1] == PAGE_THIS_HEADER) ||
	     (item->t[1] == PAGE_THIS_FOOTER)) &&
	    (item->t[2] == "")) style (item->t[1]->label)= " ";
	else if (item->t[1] == PAGE_NR)
	  page_offset= as_int (item->t[2]->label)- N(pages)- 1;
	else style (item->t[1]->label)= copy (item->t[2]);
      }
    }
    else {
      bs  << item->b;
      spc << item->spc;
    }
  }
  if (N(bs) == 0) {
    box b= empty_box (decorate_middle (ip), 0, -ht, 0, 0);
    return vcorrect_box (b->ip, b, tcor, bcor);
  }
  else {
    box b= format_stack (ip, bs, spc, ht, true);
    return vcorrect_box (b->ip, b, tcor, bcor);
  }
}
示例#29
0
bool
check_snap_mode (string type) {
  if (!is_tuple (snap_mode)) return true;
  for (int i=0; i<N(snap_mode); i++)
    if (snap_mode[i] == "all") return true;
    else if (snap_mode[i] == type) return true;
  return false;
}
示例#30
0
string
get_setting (string var, string def) {
  int i, n= N (texmacs_settings);
  for (i=0; i<n; i++)
    if (is_tuple (texmacs_settings[i], var, 1)) {
      return scm_unquote (as_string (texmacs_settings[i][1]));
    }
  return def;
}