1 package gnu.jemacs.buffer; 2 import java.io.*; 3 4 5 6 public class InfProcessMode extends ProcessMode 7 { 8 Process proc; 9 10 InputStream out; 11 InputStream err; 12 OutputStream in; 13 14 public InfProcessMode (Buffer buffer, String command) 15 { 16 this.buffer = buffer; 17 processMark = new Marker(buffer.pointMarker); 18 19 try 20 { 21 proc = Runtime.getRuntime().exec(command); 22 } 23 catch (Exception ex) 24 { 25 throw new gnu.mapping.WrappedException("cannot run "+command, ex); 26 } 27 in = proc.getOutputStream(); 28 out = proc.getInputStream(); 29 err = proc.getErrorStream(); 30 toInferior = new OutputStreamWriter(in); 31 Thread outThread = new InputStreamHandler(out, this); 32 outThread.setPriority(Thread.currentThread().getPriority() + 1); 33 outThread.start(); 34 Thread errThread = new InputStreamHandler(err, this); 35 errThread.setPriority(Thread.currentThread().getPriority() + 1); 36 errThread.start(); 37 } 38 39 public static void shellMode (Buffer buffer, String command) 40 { 41 buffer.modes = new InfProcessMode(buffer, command); 42 } 43 } 44 | Popular Tags |