File: interface-commands.en.tm

package info (click to toggle)
texmacs 1%3A2.1.4%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 145,076 kB
  • sloc: cpp: 227,393; lisp: 197,386; ansic: 5,395; python: 1,939; makefile: 1,065; sh: 781; perl: 339; xml: 100; awk: 36
file content (121 lines) | stat: -rw-r--r-- 2,998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<TeXmacs|1.0.7.14>

<style|tmdoc>

<\body>
  <tmdoc-title|Sending commands to <TeXmacs>>

  The application may use <verbatim|command> as a very particular output
  format in order to send <scheme> commands to <TeXmacs>. In other words, the
  block

  <\quotation>
    <framed-fragment|<verbatim|<render-key|DATA_BEGIN>command:<em|cmd><render-key|DATA_END>>>
  </quotation>

  will send the command <verbatim|<em|cmd>> to <TeXmacs>. Such commands are
  executed immediately after reception of <render-key|DATA_END>. We also
  recall that such command blocks may be incorporated recursively in larger
  <render-key|DATA_BEGIN>-<render-key|DATA_END> blocks.

  <paragraph*|The <verbatim|menus> plug-in>

  The <verbatim|nested> plug-in shows how an application can modify the
  <TeXmacs> menus in an interactive way. The plug-in consists of the files

  <\verbatim>
    \ \ \ \ <example-plugin-link|menus/Makefile>

    \ \ \ \ <example-plugin-link|menus/progs/init-menus.scm>

    \ \ \ \ <example-plugin-link|menus/src/menus.cpp>
  </verbatim>

  The body of the main loop of <verbatim|menus.cpp> simply contains

  <\cpp-code>
    char buffer[100];

    cin.getline (buffer, 100, '\\n');

    cout \<less\>\<less\> DATA_BEGIN \<less\>\<less\> "verbatim:";

    cout \<less\>\<less\> DATA_BEGIN \<less\>\<less\> "command:(menus-add
    \\""

    \ \ \ \ \ \<less\>\<less\> buffer \<less\>\<less\> "\\")"
    \<less\>\<less\> DATA_END;

    cout \<less\>\<less\> "Added " \<less\>\<less\> buffer \<less\>\<less\> "
    to menu";

    cout \<less\>\<less\> DATA_END;

    cout.flush ();
  </cpp-code>

  The <scheme> macro <scm|menus-add> is defined in <verbatim|init-menus.scm>:

  <\scm-code>
    (define menu-items '("Hi"))

    \;

    (tm-menu (menus-menu)

    \ \ (for (entry menu-items)

    \ \ \ \ ((eval entry) (insert entry))))

    \;

    (tm-define (menus-add entry)

    \ \ (set! menu-items (cons entry menu-items)))

    \;

    (plugin-configure menus

    \ \ (:require (url-exists-in-path? "menus.bin"))

    \ \ (:launch "menus.bin")

    \ \ (:session "Menus"))

    \;

    (menu-bind plugin-menu

    \ \ (:require (in-menus?))

    \ \ (=\<gtr\> "Menus" (link menus-menu)))
  </scm-code>

  The configuration of <verbatim|menus> proceeds as usual:

  <\scm-code>
    (plugin-configure menus

    \ \ (:require (url-exists-in-path? "menus.bin"))

    \ \ (:launch "menus.bin")

    \ \ (:session "Menus"))
  </scm-code>

  <tmdoc-copyright|1998--2002|Joris van der Hoeven>

  <tmdoc-license|Permission is granted to copy, distribute and/or modify this
  document under the terms of the GNU Free Documentation License, Version 1.1
  or any later version published by the Free Software Foundation; with no
  Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  Texts. A copy of the license is included in the section entitled "GNU Free
  Documentation License".>
</body>

<\initial>
  <\collection>
    <associate|language|english>
  </collection>
</initial>