KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > kawa > GuiInPort


1 package kawa;
2
3 import java.io.Reader JavaDoc;
4 import gnu.mapping.*;
5
6 /** A TtyInPort that reads from a MessageArea.
7   */

8
9 class GuiInPort extends TtyInPort
10 {
11   MessageArea buffer;
12
13   public GuiInPort (Reader JavaDoc in, String JavaDoc name, OutPort tie, MessageArea buffer)
14   {
15     super (in, name, 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 JavaDoc
26   {
27     super.lineStart(revisited);
28     if (! revisited && buffer.outputMark < buffer.endMark)
29       {
30     buffer.enter();
31       }
32   }
33 }
34
Popular Tags