Various minor fixes
[texmacs.git] / src / TeXmacs / examples / plugins / complete / src / complete.cpp
blob4ad65f586bbbec9e3969dab804e7b66488bcb40a
2 /******************************************************************************
3 * MODULE : complete.cpp
4 * DESCRIPTION: Shows how to program tab-completion
5 * COPYRIGHT : (C) 2003 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 ******************************************************************************/
12 #include <stdio.h>
13 #include <iostream>
15 #define DATA_BEGIN ((char) 2)
16 #define DATA_END ((char) 5)
17 #define DATA_COMMAND ((char) 16)
18 #define DATA_ESCAPE ((char) 27)
20 void
21 format_plugin () {
22 // The configuration of a plugin can be completed at startup time.
23 // This is for instance interesting if you add tab-completion a posteriori.
24 cout << DATA_BEGIN << "command:";
25 cout << "(plugin-configure complete (:tab-completion #t))";
26 cout << DATA_END;
29 int
30 main () {
31 cout << DATA_BEGIN << "verbatim:";
32 format_plugin ();
33 cout << "We know how to complete 'h'";
34 cout << DATA_END;
35 fflush (stdout);
37 while (true) {
38 char buffer[100];
39 cin.getline (buffer, 100, '\n');
40 if (buffer[0] != DATA_COMMAND) {
41 cout << DATA_BEGIN << "verbatim:";
42 cout << "You typed " << buffer;
43 cout << DATA_END;
45 else {
46 cout << DATA_BEGIN << "scheme:";
47 cout << "(tuple \"h\" \"ello\" \"i there\" \"ola\" \"opsakee\")";
48 cout << DATA_END;
50 fflush (stdout);
52 return 0;