equal
deleted
inserted
replaced
|
1 /* Title: Pure/PIDE/document_editor.scala |
|
2 Author: Makarius |
|
3 |
|
4 Central resources for interactive document preparation. |
|
5 */ |
|
6 |
|
7 package isabelle |
|
8 |
|
9 |
|
10 object Document_Editor { |
|
11 /* document output */ |
|
12 |
|
13 def document_name: String = "document" |
|
14 def document_output_dir(): Path = Path.explode("$ISABELLE_HOME_USER/document_output") |
|
15 def document_output(): Path = document_output_dir() + Path.basic(document_name) |
|
16 |
|
17 def view_document(): Unit = { |
|
18 val path = document_output().pdf |
|
19 if (path.is_file) Isabelle_System.pdf_viewer(path) |
|
20 } |
|
21 |
|
22 |
|
23 /* progress */ |
|
24 |
|
25 class Log_Progress(session: Session) extends Progress { |
|
26 def show(text: String): Unit = {} |
|
27 |
|
28 private val syslog = session.make_syslog() |
|
29 |
|
30 private def update(text: String = syslog.content()): Unit = show(text) |
|
31 private val delay = |
|
32 Delay.first(session.session_options.seconds("editor_update_delay"), gui = true) { update() } |
|
33 |
|
34 override def echo(msg: String): Unit = { syslog += msg; delay.invoke() } |
|
35 |
|
36 def load(): Unit = GUI_Thread.require { |
|
37 val path = document_output().log |
|
38 val text = if (path.is_file) File.read(path) else "" |
|
39 GUI_Thread.later { delay.revoke(); update(text) } |
|
40 } |
|
41 |
|
42 GUI_Thread.later { update() } |
|
43 } |
|
44 } |