01: package kawa;
02:
03: import java.io.Reader;
04: import gnu.mapping.*;
05: import gnu.text.Path;
06:
07: /** A TtyInPort that reads from a MessageArea.
08: */
09:
10: class GuiInPort extends TtyInPort {
11: MessageArea buffer;
12:
13: public GuiInPort(Reader in, Path path, OutPort tie,
14: MessageArea buffer) {
15: super (in, path, tie);
16: this .buffer = buffer;
17: }
18:
19: /** Overrides lineStart.
20: * Needed to handle when a multi-line selection is pasted in.
21: * We want the output (and prompt) to be "interpolated" in the right
22: * places, so we fake an <Enter> when we're ready to read the
23: * next line. This sends the next line to the reader.
24: */
25: public void lineStart(boolean revisited) throws java.io.IOException {
26: super.lineStart(revisited);
27: if (!revisited && buffer.outputMark < buffer.endMark) {
28: buffer.enter();
29: }
30: }
31: }
|