Back to index

texmacs  1.0.7.15
multiline.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : multiline.cpp
00004 * DESCRIPTION: A plugin which uses multiline input as long as
00005 *              the input is not terminated by ';'
00006 * COPYRIGHT  : (C) 2003  Joris van der Hoeven
00007 *******************************************************************************
00008 * This software falls under the GNU general public license version 3 or later.
00009 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00010 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00011 ******************************************************************************/
00012 
00013 #include <iostream>
00014 using namespace std;
00015 
00016 #define DATA_BEGIN   ((char) 2)
00017 #define DATA_END     ((char) 5)
00018 #define DATA_COMMAND ((char) 16)
00019 #define DATA_ESCAPE  ((char) 27)
00020 
00021 int
00022 main () {
00023   cout << DATA_BEGIN << "verbatim:";
00024   cout << "Terminate your input by ';'";
00025   cout << DATA_END;
00026   cout.flush ();
00027 
00028   while (true) {
00029     char buffer[100];
00030     cin.getline (buffer, 100, '\n');
00031     if (buffer[0] != DATA_COMMAND) {
00032       cout << DATA_BEGIN << "verbatim:";
00033       cout << buffer;
00034       cout << DATA_END;
00035     }
00036     else {
00037       int  n = strlen (buffer);
00038       cout << DATA_BEGIN << "scheme:";
00039       if (buffer[n-3] == ';') cout << "#t";
00040       else cout << "#f";
00041       cout << DATA_END;
00042     }
00043     cout.flush ();
00044   }
00045   return 0;
00046 }