privateval console_stream = new OutputStream { val buf = new StringBuilder(100)
overridedef flush(): Unit = { val s = buf.synchronized { val s = buf.toString; buf.clear(); s } val str = Bytes.raw(s).text
GUI_Thread.later { if (global_out == null) java.lang.System.out.print(str) else global_out.writeAttrs(null, str)
}
Time.seconds(0.01).sleep() // FIXME adhoc delay to avoid loosing output
}
overridedef close(): Unit = flush()
def write(byte: Int): Unit = { val c = byte.toChar
buf.synchronized { buf.append(c) } if (c == '\n') flush()
}
}
overridedef openConsole(console: Console): Unit = { val context =
Scala.Compiler.context(
jar_files = JEdit_Lib.directories,
class_loader = Some(new JARClassLoader))
val interpreter = new Scala_Console.Interpreter(context, console)
interpreter.execute((context, state) =>
context.compile(Scala_Console.init, state = state).state)
}
overridedef closeConsole(console: Console): Unit =
Scala_Console.console_interpreter(console).foreach(_.shutdown())
overridedef printInfoMessage(out: Output): Unit = {
out.print(null, "This shell evaluates Isabelle/Scala expressions.\n\n" + "The contents of package isabelle and isabelle.jedit are imported.\n" + "The following special toplevel bindings are provided:\n" + " view -- current jEdit/Swing view (e.g. view.getBuffer, view.getTextArea)\n" + " console -- jEdit Console plugin\n" + " PIDE -- Isabelle/PIDE plugin (e.g. PIDE.session, PIDE.snapshot, PIDE.rendering)\n")
}
overridedef execute(
console: Console,
input: String,
out: Output,
err: Output,
command: String
): Unit = {
Scala_Console.console_interpreter(console).foreach(interpreter =>
interpreter.execute { (context, state) => val result = with_console(console, out, err) { context.compile(command, state) }
GUI_Thread.later { val diag = if (err == null) out else err for (message <- result.messages) { val color = if (message.is_error) console.getErrorColor elsenull
diag.print(color, message.text + "\n")
}
Option(err).foreach(_.commandDone())
out.commandDone()
}
result.state
})
}
overridedef stop(console: Console): Unit =
Scala_Console.console_interpreter(console).foreach(_.shutdown())
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.1Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.