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