src/Tools/jEdit/src/jedit/scala_console.scala
changeset 34845 6d64de27efa5
parent 34844 92ea2174ea78
child 34846 ca76b3978540
equal deleted inserted replaced
34844:92ea2174ea78 34845:6d64de27efa5
     7 package isabelle.jedit
     7 package isabelle.jedit
     8 
     8 
     9 
     9 
    10 import console.{Console, ConsolePane, Shell, Output}
    10 import console.{Console, ConsolePane, Shell, Output}
    11 
    11 
    12 import org.gjt.sp.jedit.jEdit
    12 import org.gjt.sp.jedit.{jEdit, JARClassLoader}
    13 import org.gjt.sp.jedit.MiscUtilities
    13 import org.gjt.sp.jedit.MiscUtilities
    14 
    14 
    15 import java.io.{Writer, PrintWriter}
    15 import java.io.{Writer, PrintWriter}
    16 
    16 
    17 import scala.tools.nsc.{Interpreter, GenericRunnerSettings, NewLinePrintWriter, ConsoleWriter}
    17 import scala.tools.nsc.{Interpreter, GenericRunnerSettings, NewLinePrintWriter, ConsoleWriter}
    62 
    62 
    63   override def openConsole(console: Console)
    63   override def openConsole(console: Console)
    64   {
    64   {
    65     val settings = new GenericRunnerSettings(report_error)
    65     val settings = new GenericRunnerSettings(report_error)
    66     val printer = new PrintWriter(new Console_Writer, true)
    66     val printer = new PrintWriter(new Console_Writer, true)
    67     interpreters += (console -> new Interpreter(settings, printer))
    67     val interp = new Interpreter(settings, printer)
       
    68     {
       
    69       override def parentClassLoader = new JARClassLoader
       
    70     }
       
    71     interp.setContextClassLoader
       
    72 
       
    73     val view = console.getView
       
    74     val edit_pane = view.getEditPane
       
    75     interp.bind("view", "org.gjt.sp.jedit.View", view)
       
    76     interp.bind("editPane", "org.gjt.sp.jedit.EditPane", edit_pane)
       
    77     interp.bind("buffer", "org.gjt.sp.jedit.Buffer", edit_pane.getBuffer)
       
    78     interp.bind("textArea", "org.gjt.sp.jedit.textarea.JEditTextArea", edit_pane.getTextArea)
       
    79     interp.bind("wm", "org.gjt.sp.jedit.gui.DockableWindowManager", view.getDockableWindowManager)
       
    80 
       
    81     interpreters += (console -> interp)
    68   }
    82   }
    69 
    83 
    70   override def closeConsole(console: Console)
    84   override def closeConsole(console: Console)
    71   {
    85   {
    72     interpreters -= console
    86     interpreters -= console
    73   }
    87   }
    74 
    88 
    75   override def printPrompt(console: Console, out: Output)
    89   override def printPrompt(console: Console, out: Output)
    76 	{
    90 	{
    77     out.writeAttrs(ConsolePane.colorAttributes(console.getInfoColor), "scala>")
    91     out.writeAttrs(ConsolePane.colorAttributes(console.getInfoColor), "scala>")
    78 		out.writeAttrs(null," ")
    92 		out.writeAttrs(ConsolePane.colorAttributes(console.getPlainColor), " ")
    79 	}
    93 	}
    80 
    94 
    81   override def execute(console: Console, input: String, out: Output, err: Output, command: String)
    95   override def execute(console: Console, input: String, out: Output, err: Output, command: String)
    82   {
    96   {
    83     with_console(console, out, err) {
    97     with_console(console, out, err) { interpreters(console).interpret(command) }
    84       interpreters(console).interpret(command)
       
    85     }
       
    86     if (err != null) err.commandDone()
    98     if (err != null) err.commandDone()
    87 		out.commandDone()
    99 		out.commandDone()
    88   }
   100   }
    89 }
   101 }