PageRenderTime 34ms CodeModel.GetById 25ms app.highlight 8ms RepoModel.GetById 0ms app.codeStats 0ms

/TeXmacs-1.0.7.11-src/src/Data/Convert/Generic/generic.cpp

#
C++ | 69 lines | 48 code | 12 blank | 9 comment | 6 complexity | 1ee9312180a17b0a7397296d861ac50e MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception
 1
 2/******************************************************************************
 3* MODULE     : generic.cpp
 4* DESCRIPTION: routines for generic formats
 5* COPYRIGHT  : (C) 2000  Joris van der Hoeven
 6*******************************************************************************
 7* This software falls under the GNU general public license version 3 or later.
 8* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
 9* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10******************************************************************************/
11
12#include "convert.hpp"
13#include "file.hpp"
14#include "scheme.hpp"
15
16static url current_file_focus= url_none ();
17
18bool
19is_snippet (tree doc) {
20  if (!is_document (doc)) return true;
21  int i, n= N(doc);
22  for (i=0; i<n; i++)
23    if (is_compound (doc[i], "TeXmacs", 1))
24      return false;
25  return true;
26}
27
28string
29get_texmacs_path () {
30  string tmpath= get_env ("TEXMACS_PATH");
31  while ((N(tmpath)>0) && (tmpath [N(tmpath) - 1] == '/'))
32    tmpath= tmpath (0, N(tmpath)-1);
33  return tmpath;
34}
35
36url
37get_file_focus () {
38  return current_file_focus;
39}
40
41void
42set_file_focus (url u) {
43  current_file_focus= u;
44}
45
46string
47suffix_to_format (string suffix) {
48  return as_string (call ("format-from-suffix", suffix));
49}
50
51string
52format_to_suffix (string fm) {
53  return as_string (call ("format-default-suffix", fm));
54}
55
56string
57get_format (string s, string suffix) {
58  return as_string (call ("format-determine", s, suffix));
59}
60
61tree
62generic_to_tree (string s, string fm) {
63  return as_tree (call ("generic->texmacs", s, fm));
64}
65
66string
67tree_to_generic (tree doc, string fm) {
68  return as_string (call ("texmacs->generic", doc, fm));
69}