Back to index

texmacs  1.0.7.15
mycas.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : mycas.cpp
00004 * DESCRIPTION: A simple computer algebra system with a link to TeXmacs
00005 * COPYRIGHT  : (C) 2001  Joris van der Hoeven
00006 *******************************************************************************
00007 * In order to test this program, you should first compile it using
00008 *    g++ mycas.cpp -o mycas
00009 * Next, move the binary to a location in your path.
00010 * After this, TeXmacs will automatically recognize the presence of mycas.
00011 *******************************************************************************
00012 * This software falls under the GNU general public license version 3 or later.
00013 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00014 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00015 ******************************************************************************/
00016 
00017 #include <stdio.h>
00018 #include <stdlib.h>
00019 #include <string.h>
00020 #include <iostream.h>
00021 
00022 #define DATA_BEGIN   ((char) 2)
00023 #define DATA_END     ((char) 5)
00024 #define DATA_ESCAPE  ((char) 27)
00025 
00026 static int counter= 0;
00027 
00028 void
00029 next_input () {
00030   counter++;
00031   cout << DATA_BEGIN << "channel:prompt" << DATA_END;
00032   cout << "Input " << counter << "] ";
00033 }
00034 
00035 int
00036 main () {
00037   cout << DATA_BEGIN << "verbatim:";
00038   cout << "------------------------------------------------------\n";
00039   cout << "Welcome to my test computer algebra system for TeXmacs\n";
00040   cout << "This software comes with no warranty whatsoever\n";
00041   cout << "(c) 2001  by Joris van der Hoeven\n";
00042   cout << "------------------------------------------------------\n";
00043   next_input ();
00044   cout << DATA_END;
00045   fflush (stdout);
00046 
00047   while (1) {
00048     char buffer[100];
00049     cin.getline (buffer, 100, '\n');
00050     if (strcmp (buffer, "quit") == 0) break;
00051     cout << DATA_BEGIN << "verbatim:";
00052     cout << "You typed " << buffer << "\n";
00053 
00054     cout << "And now a LaTeX formula: ";
00055     cout << DATA_BEGIN << "latex:" << "$x^2+y^2=z^2$" << DATA_END;
00056     cout << "\n";
00057 
00058     cout << "And finally a fraction ";
00059     cout << DATA_BEGIN << "scheme:" << "(frac \"a\" \"b\")" << DATA_END;
00060     cout << ".\n";
00061 
00062     next_input ();
00063     cout << DATA_END;
00064     fflush (stdout);
00065   }
00066   return 0;
00067 }