01: package gnu.jemacs.buffer;
02:
03: import gnu.mapping.*;
04: import gnu.expr.Language;
05: import java.io.*;
06: import gnu.text.*;
07:
08: public class ReplMode extends ProcessMode {
09: BufferWriter processWriter;
10: InPort in;
11: OutPort out;
12: OutPort err;
13: Future thread;
14:
15: public ReplMode(Buffer buffer, Language language,
16: Environment environment) throws java.io.IOException {
17: lineMode = true;
18: this .buffer = buffer;
19: processMark = new Marker(buffer.pointMarker);
20: processWriter = new BufferWriter(processMark, true);
21: out = new OutPort(processWriter, true, true);
22: err = new OutPort(processWriter, true, true);
23: PipedReader preader = new PipedReader();
24: toInferior = new PipedWriter(preader);
25: in = new TtyInPort(preader, Path.valueOf("/dev/stdin"), out);
26: thread = new Future(new kawa.repl(language), environment, in,
27: out, err);
28: thread.setPriority(Thread.currentThread().getPriority() + 1);
29: thread.start();
30: }
31:
32: public static void make(Buffer buffer, Object language)
33: throws java.io.IOException {
34: Language lang = language instanceof Language ? (Language) language
35: : Language.getInstance(language.toString());
36: buffer.modes = new ReplMode(buffer, lang, Environment
37: .getGlobal());
38: }
39: }
|