author | wenzelm |
Sun, 18 Dec 2022 15:49:37 +0100 | |
changeset 76678 | f34b923ff2c9 |
parent 76609 | cc9ddf373bd2 |
child 76701 | 3543ecb4c97d |
permissions | -rw-r--r-- |
52971
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/PIDE/editor.scala |
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
3 |
|
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
4 |
General editor operations. |
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
6 |
|
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
8 |
|
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
9 |
|
75393 | 10 |
abstract class Editor[Context] { |
66082 | 11 |
/* session */ |
12 |
||
52971
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
13 |
def session: Session |
66084 | 14 |
def flush(): Unit |
54461 | 15 |
def invoke(): Unit |
66101
0f0f294e314f
maintain overlays within main state of document models;
wenzelm
parents:
66094
diff
changeset
|
16 |
|
0f0f294e314f
maintain overlays within main state of document models;
wenzelm
parents:
66094
diff
changeset
|
17 |
|
76609
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
18 |
/* document editor */ |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
19 |
|
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
20 |
protected val document_editor: Synchronized[Document_Editor.State] = |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
21 |
Synchronized(Document_Editor.State()) |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
22 |
|
76678 | 23 |
def document_editor_session: Option[Sessions.Background] = |
24 |
document_editor.value.session_background |
|
76609
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
25 |
def document_editor_active: Boolean = |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
26 |
document_editor.value.is_active |
76678 | 27 |
def document_editor_setup(background: Option[Sessions.Background]): Unit = |
28 |
document_editor.change(_.copy(session_background = background)) |
|
76609
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
29 |
def document_editor_init(id: AnyRef): Unit = |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
30 |
document_editor.change(_.register_view(id)) |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
31 |
def document_editor_exit(id: AnyRef): Unit = |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
32 |
document_editor.change(_.unregister_view(id)) |
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
33 |
|
cc9ddf373bd2
maintain global state of document editor views, notably for is_active operation;
wenzelm
parents:
75393
diff
changeset
|
34 |
|
66101
0f0f294e314f
maintain overlays within main state of document models;
wenzelm
parents:
66094
diff
changeset
|
35 |
/* current situation */ |
0f0f294e314f
maintain overlays within main state of document models;
wenzelm
parents:
66094
diff
changeset
|
36 |
|
52971
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
37 |
def current_node(context: Context): Option[Document.Node.Name] |
52978 | 38 |
def current_node_snapshot(context: Context): Option[Document.Snapshot] |
52974 | 39 |
def node_snapshot(name: Document.Node.Name): Document.Snapshot |
53844
71f103629327
skip ignored commands, similar to former proper_command_at (see d68ea01d5084) -- relevant to Output, Query_Operation etc.;
wenzelm
parents:
52980
diff
changeset
|
40 |
def current_command(context: Context, snapshot: Document.Snapshot): Option[Command] |
52977
15254e32d299
central management of Document.Overlays, independent of Document_Model;
wenzelm
parents:
52974
diff
changeset
|
41 |
|
66082 | 42 |
|
43 |
/* overlays */ |
|
44 |
||
66101
0f0f294e314f
maintain overlays within main state of document models;
wenzelm
parents:
66094
diff
changeset
|
45 |
def node_overlays(name: Document.Node.Name): Document.Node.Overlays |
73340 | 46 |
def insert_overlay(command: Command, fn: String, args: List[String]): Unit |
47 |
def remove_overlay(command: Command, fn: String, args: List[String]): Unit |
|
66082 | 48 |
|
49 |
||
50 |
/* hyperlinks */ |
|
52980 | 51 |
|
75393 | 52 |
abstract class Hyperlink { |
64663 | 53 |
def external: Boolean = false |
56494
1b74abf064e1
avoid confusion about pointless cursor movement with external links;
wenzelm
parents:
55884
diff
changeset
|
54 |
def follow(context: Context): Unit |
1b74abf064e1
avoid confusion about pointless cursor movement with external links;
wenzelm
parents:
55884
diff
changeset
|
55 |
} |
66084 | 56 |
|
52980 | 57 |
def hyperlink_command( |
64664 | 58 |
focus: Boolean, snapshot: Document.Snapshot, id: Document_ID.Generic, offset: Symbol.Offset = 0) |
60893 | 59 |
: Option[Hyperlink] |
66094 | 60 |
|
61 |
||
62 |
/* dispatcher thread */ |
|
63 |
||
64 |
def assert_dispatcher[A](body: => A): A |
|
65 |
def require_dispatcher[A](body: => A): A |
|
66 |
def send_dispatcher(body: => Unit): Unit |
|
67 |
def send_wait_dispatcher(body: => Unit): Unit |
|
52971
31926d2c04ee
tuned signature -- more abstract PIDE editor operations;
wenzelm
parents:
diff
changeset
|
68 |
} |