Output channels, prompts and default input

Besides blocks of the form

DATA_BEGINformat:messageDATA_END

the TeXmacs meta-format also allows you to use blocks of the form

DATA_BEGINchannel#messageDATA_END

Here channel specifies an “output channel” to which the body message has to be sent. The default output channel is output, but we also provide channels prompt and input for specifying the prompt and a default input for the next input in a session. Default inputs may be useful for instance be useful for demo modes of computer algebra systems. In the future, we also plan to support error and status channels.

The prompt plug-in

The prompt plug-in shows how to use prompts. It consists of the files

    prompt/Makefile
    prompt/progs/init-prompt.scm
    prompt/src/prompt.cpp

The routine for displaying the next prompt is given by

void
next_input () {
  counter++;
  cout << DATA_BEGIN << "prompt#";
  cout << "Input " << counter << "] ";
  cout << DATA_END;
}

This routine is both used for displaying the startup banner

cout << DATA_BEGIN << "verbatim:";
cout << "A LaTeX -> TeXmacs converter";
next_input ();
cout << DATA_END;
fflush (stdout);

and in the body of the main loop

char buffer[100];
cin.getline (buffer, 100, '\n');
cout << DATA_BEGIN << "verbatim:";
cout << DATA_BEGIN;
cout << "latex:$" << buffer << "$";
cout << DATA_END;
next_input ();
cout << DATA_END;
fflush (stdout);

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".