GNU TeXmacsUser manualReferenceAboutEnglishยทDeutsch
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 for instance be useful for demo modes of computer algebra systems. All output which the application writes on its standard error is sent to a fourth channel error and displayed as error output in the session; this output may again be structured using DATA_BEGIN-DATA_END blocks. Blocks sent to other channels are ignored, unless a handler has been declared for the channel using the :handler configuration option (see the handler example plug-in).

Older plug-ins (such as mycas) use the equivalent syntax DATA_BEGINchannel:promptDATA_END, which redirects the remainder of the enclosing block to the prompt channel.

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;
cout.flush ();

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;
cout.flush ();
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".