author | wenzelm |
Thu, 21 Mar 2013 16:35:53 +0100 | |
changeset 51469 | 18120e26f818 |
parent 51452 | 14e6d761ba1c |
child 51492 | eaa1c4cc1106 |
permissions | -rw-r--r-- |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Tools/jEdit/src/pretty_text_area.scala |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
3 |
|
50160 | 4 |
GUI component for pretty-printed text with markup, rendered like jEdit |
5 |
text area. |
|
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
6 |
*/ |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
7 |
|
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
8 |
package isabelle.jedit |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
9 |
|
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
10 |
|
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
11 |
import isabelle._ |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
12 |
|
50726
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
13 |
import java.awt.{Color, Font, FontMetrics, Toolkit, Window} |
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
14 |
import java.awt.event.{KeyEvent, KeyAdapter} |
49412 | 15 |
|
49422
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
16 |
import org.gjt.sp.jedit.{jEdit, View, Registers} |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
17 |
import org.gjt.sp.jedit.textarea.{AntiAlias, JEditEmbeddedTextArea} |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
18 |
import org.gjt.sp.jedit.syntax.SyntaxStyle |
50640 | 19 |
import org.gjt.sp.util.{SyntaxUtilities, Log} |
49412 | 20 |
|
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
21 |
|
49412 | 22 |
object Pretty_Text_Area |
23 |
{ |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
24 |
private def text_rendering(base_snapshot: Document.Snapshot, base_results: Command.Results, |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
25 |
formatted_body: XML.Body): (String, Rendering) = |
49471
97964515a676
text_rendering as managed task, with cancellation;
wenzelm
parents:
49446
diff
changeset
|
26 |
{ |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
27 |
val (text, state) = Pretty_Text_Area.document_state(base_snapshot, base_results, formatted_body) |
50205 | 28 |
val rendering = Rendering(state.snapshot(), PIDE.options.value) |
49471
97964515a676
text_rendering as managed task, with cancellation;
wenzelm
parents:
49446
diff
changeset
|
29 |
(text, rendering) |
97964515a676
text_rendering as managed task, with cancellation;
wenzelm
parents:
49446
diff
changeset
|
30 |
} |
97964515a676
text_rendering as managed task, with cancellation;
wenzelm
parents:
49446
diff
changeset
|
31 |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
32 |
private def document_state(base_snapshot: Document.Snapshot, base_results: Command.Results, |
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
33 |
formatted_body: XML.Body): (String, Document.State) = |
49412 | 34 |
{ |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
35 |
val command = Command.rich_text(Document.new_id(), base_results, formatted_body) |
49412 | 36 |
val node_name = command.node_name |
37 |
val edits: List[Document.Edit_Text] = |
|
49414 | 38 |
List(node_name -> Document.Node.Edits(List(Text.Edit.insert(0, command.source)))) |
49412 | 39 |
|
49419
e2726211f834
pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents:
49416
diff
changeset
|
40 |
val state0 = base_snapshot.state.define_command(command) |
e2726211f834
pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents:
49416
diff
changeset
|
41 |
val version0 = base_snapshot.version |
49412 | 42 |
val nodes0 = version0.nodes |
43 |
||
44 |
val nodes1 = nodes0 + (node_name -> nodes0(node_name).update_commands(Linear_Set(command))) |
|
45 |
val version1 = Document.Version.make(version0.syntax, nodes1) |
|
46 |
val state1 = |
|
47 |
state0.continue_history(Future.value(version0), edits, Future.value(version1))._2 |
|
48 |
.define_version(version1, state0.the_assignment(version0)) |
|
49414 | 49 |
.assign(version1.id, List(command.id -> Some(Document.new_id())))._2 |
49412 | 50 |
|
49416
1053a564dd25
some actual rich text markup via XML.content_markup;
wenzelm
parents:
49414
diff
changeset
|
51 |
(command.source, state1) |
49412 | 52 |
} |
53 |
} |
|
54 |
||
50538
48cb76b785da
init gutter according to view properties, which improves symmetry of windows and allows use of folds etc;
wenzelm
parents:
50507
diff
changeset
|
55 |
class Pretty_Text_Area( |
48cb76b785da
init gutter according to view properties, which improves symmetry of windows and allows use of folds etc;
wenzelm
parents:
50507
diff
changeset
|
56 |
view: View, |
50915
12de8ea66f54
close tooltip after Active.action, to make it look more interactive (notably due to lack of dynamic update);
wenzelm
parents:
50849
diff
changeset
|
57 |
close_action: () => Unit = () => (), |
50743
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
58 |
propagate_keys: Boolean = false) extends JEditEmbeddedTextArea |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
59 |
{ |
49446 | 60 |
text_area => |
61 |
||
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
62 |
Swing_Thread.require() |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
63 |
|
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
64 |
private var current_font_family = "Dialog" |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
65 |
private var current_font_size: Int = 12 |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
66 |
private var current_body: XML.Body = Nil |
49419
e2726211f834
pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents:
49416
diff
changeset
|
67 |
private var current_base_snapshot = Document.State.init.snapshot() |
50507 | 68 |
private var current_base_results = Command.Results.empty |
50199
6d04e2422769
quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents:
50195
diff
changeset
|
69 |
private var current_rendering: Rendering = |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
70 |
Pretty_Text_Area.text_rendering(current_base_snapshot, current_base_results, Nil)._2 |
49471
97964515a676
text_rendering as managed task, with cancellation;
wenzelm
parents:
49446
diff
changeset
|
71 |
private var future_rendering: Option[java.util.concurrent.Future[Unit]] = None |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
72 |
|
50306 | 73 |
private val rich_text_area = |
50915
12de8ea66f54
close tooltip after Active.action, to make it look more interactive (notably due to lack of dynamic update);
wenzelm
parents:
50849
diff
changeset
|
74 |
new Rich_Text_Area(view, text_area, () => current_rendering, close_action, |
50306 | 75 |
caret_visible = false, hovering = true) |
49416
1053a564dd25
some actual rich text markup via XML.content_markup;
wenzelm
parents:
49414
diff
changeset
|
76 |
|
51451
e4203ebfe750
recovered special background handling from 8d6e478934dc, particularly relevant for gutter border;
wenzelm
parents:
51449
diff
changeset
|
77 |
def get_background(): Option[Color] = None |
e4203ebfe750
recovered special background handling from 8d6e478934dc, particularly relevant for gutter border;
wenzelm
parents:
51449
diff
changeset
|
78 |
|
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
79 |
def refresh() |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
80 |
{ |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
81 |
Swing_Thread.require() |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
82 |
|
50168
4a575ef46466
always refresh font metrics, to help window size calculation (amending 2585c81d840a);
wenzelm
parents:
50166
diff
changeset
|
83 |
val font = new Font(current_font_family, Font.PLAIN, current_font_size) |
4a575ef46466
always refresh font metrics, to help window size calculation (amending 2585c81d840a);
wenzelm
parents:
50166
diff
changeset
|
84 |
getPainter.setFont(font) |
4a575ef46466
always refresh font metrics, to help window size calculation (amending 2585c81d840a);
wenzelm
parents:
50166
diff
changeset
|
85 |
getPainter.setAntiAlias(new AntiAlias(jEdit.getProperty("view.antiAlias"))) |
4a575ef46466
always refresh font metrics, to help window size calculation (amending 2585c81d840a);
wenzelm
parents:
50166
diff
changeset
|
86 |
getPainter.setStyles(SyntaxUtilities.loadStyles(current_font_family, current_font_size)) |
4a575ef46466
always refresh font metrics, to help window size calculation (amending 2585c81d840a);
wenzelm
parents:
50166
diff
changeset
|
87 |
|
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
88 |
val fold_line_style = new Array[SyntaxStyle](4) |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
89 |
for (i <- 0 to 3) { |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
90 |
fold_line_style(i) = |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
91 |
SyntaxUtilities.parseStyle( |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
92 |
jEdit.getProperty("view.style.foldLine." + i), |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
93 |
current_font_family, current_font_size, true) |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
94 |
} |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
95 |
getPainter.setFoldLineStyle(fold_line_style) |
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
96 |
|
51439
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
97 |
getGutter.setForeground(jEdit.getColorProperty("view.gutter.fgColor")) |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
98 |
getGutter.setBackground(jEdit.getColorProperty("view.gutter.bgColor")) |
51451
e4203ebfe750
recovered special background handling from 8d6e478934dc, particularly relevant for gutter border;
wenzelm
parents:
51449
diff
changeset
|
99 |
get_background().map(bg => { getPainter.setBackground(bg); getGutter.setBackground(bg) }) |
51439
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
100 |
getGutter.setHighlightedForeground(jEdit.getColorProperty("view.gutter.highlightColor")) |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
101 |
getGutter.setFoldColor(jEdit.getColorProperty("view.gutter.foldColor")) |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
102 |
getGutter.setFont(jEdit.getFontProperty("view.gutter.font")) |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
103 |
getGutter.setBorder(0, |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
104 |
jEdit.getColorProperty("view.gutter.focusBorderColor"), |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
105 |
jEdit.getColorProperty("view.gutter.noFocusBorderColor"), |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
106 |
getPainter.getBackground) |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
107 |
getGutter.setFoldPainter(getFoldPainter) |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
108 |
getGutter.setGutterEnabled(jEdit.getBooleanProperty("view.gutter.enabled")) |
b10b64679c5b
more precise tooltip window size (NB: dimensions are known after layout pack, before making content visible);
wenzelm
parents:
50915
diff
changeset
|
109 |
|
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
110 |
if (getWidth > 0) { |
50849 | 111 |
val fm = getPainter.getFontMetrics |
51469
18120e26f818
eliminated char_width_int to avoid unclear rounding;
wenzelm
parents:
51452
diff
changeset
|
112 |
val margin = (getPainter.getWidth / (Pretty.char_width(fm).ceil.toInt max 1)) max 20 |
49471
97964515a676
text_rendering as managed task, with cancellation;
wenzelm
parents:
49446
diff
changeset
|
113 |
|
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
114 |
val base_snapshot = current_base_snapshot |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
115 |
val base_results = current_base_results |
50849 | 116 |
val formatted_body = Pretty.formatted(current_body, margin, Pretty.font_metric(fm)) |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
117 |
|
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
118 |
future_rendering.map(_.cancel(true)) |
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
119 |
future_rendering = Some(default_thread_pool.submit(() => |
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
120 |
{ |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
121 |
val (text, rendering) = |
50640 | 122 |
try { Pretty_Text_Area.text_rendering(base_snapshot, base_results, formatted_body) } |
123 |
catch { case exn: Throwable => Log.log(Log.ERROR, this, exn); throw exn } |
|
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
124 |
Simple_Thread.interrupted_exception() |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
125 |
|
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
126 |
Swing_Thread.later { |
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
127 |
current_rendering = rendering |
50195
863b1dfc396c
prefer buffer_edit combinator over Java-style boilerplate;
wenzelm
parents:
50168
diff
changeset
|
128 |
JEdit_Lib.buffer_edit(getBuffer) { |
50216 | 129 |
rich_text_area.active_reset() |
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
130 |
getBuffer.setReadOnly(false) |
50542
58bd88159f8f
fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents:
50538
diff
changeset
|
131 |
getBuffer.setFoldHandler(new Fold_Handling.Document_Fold_Handler(rendering)) |
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
132 |
setText(text) |
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
133 |
setCaretPosition(0) |
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
134 |
getBuffer.setReadOnly(true) |
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
135 |
} |
49471
97964515a676
text_rendering as managed task, with cancellation;
wenzelm
parents:
49446
diff
changeset
|
136 |
} |
50166
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
137 |
})) |
2585c81d840a
take component width as indication if it is already visible/layed-out, to avoid multiple formatting with minimal margin;
wenzelm
parents:
50160
diff
changeset
|
138 |
} |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
139 |
} |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
140 |
|
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
141 |
def resize(font_family: String, font_size: Int) |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
142 |
{ |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
143 |
Swing_Thread.require() |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
144 |
|
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
145 |
current_font_family = font_family |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
146 |
current_font_size = font_size |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
147 |
refresh() |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
148 |
} |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
149 |
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
150 |
def update(base_snapshot: Document.Snapshot, base_results: Command.Results, body: XML.Body) |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
151 |
{ |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
152 |
Swing_Thread.require() |
49419
e2726211f834
pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents:
49416
diff
changeset
|
153 |
require(!base_snapshot.is_outdated) |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
154 |
|
49419
e2726211f834
pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents:
49416
diff
changeset
|
155 |
current_base_snapshot = base_snapshot |
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50306
diff
changeset
|
156 |
current_base_results = base_results |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
157 |
current_body = body |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
158 |
refresh() |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
159 |
} |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
160 |
|
49422
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
161 |
|
50726
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
162 |
/* key handling */ |
49422
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
163 |
|
50726
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
164 |
addKeyListener(new KeyAdapter { |
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
165 |
override def keyPressed(evt: KeyEvent) |
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
166 |
{ |
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
167 |
evt.getKeyCode match { |
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
168 |
case KeyEvent.VK_C |
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
169 |
if (evt.getModifiers & Toolkit.getDefaultToolkit.getMenuShortcutKeyMask) != 0 => |
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
170 |
Registers.copy(text_area, '$') |
50743
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
171 |
evt.consume |
50726
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
172 |
case KeyEvent.VK_ESCAPE => |
51452
14e6d761ba1c
extra tooltip_delay after window.dismiss operation, to avoid flickering of quick reactivation;
wenzelm
parents:
51451
diff
changeset
|
173 |
Pretty_Tooltip.windows().foreach(_.dismiss) |
50743
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
174 |
evt.consume |
49422
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
175 |
case _ => |
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
176 |
} |
50743
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
177 |
if (propagate_keys && !evt.isConsumed) |
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
178 |
view.getInputHandler.processKeyEvent(evt, View.ACTION_BAR, false) |
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
179 |
} |
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
180 |
|
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
181 |
override def keyTyped(evt: KeyEvent) |
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
182 |
{ |
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
183 |
if (propagate_keys && !evt.isConsumed) |
44571ac53fed
propagate keys to enclosing view like org.gjt.sp.jedit.gui.CompletionPopup, but without its KeyEventInterceptor;
wenzelm
parents:
50726
diff
changeset
|
184 |
view.getInputHandler.processKeyEvent(evt, View.ACTION_BAR, false) |
49422
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
185 |
} |
50726
27478c11f63c
more elementary key handling: listen to low-level KEY_PRESSED events (without consuming);
wenzelm
parents:
50640
diff
changeset
|
186 |
}) |
49422
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
187 |
|
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
188 |
|
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
189 |
/* init */ |
21f77309d93a
minimal clipboard support (similar to org.lobobrowser.html.gui.HtmlBlockPanel);
wenzelm
parents:
49421
diff
changeset
|
190 |
|
49472 | 191 |
getPainter.setStructureHighlightEnabled(false) |
49475 | 192 |
getPainter.setLineHighlightEnabled(false) |
193 |
||
49446 | 194 |
getBuffer.setTokenMarker(new Token_Markup.Marker(true, None)) |
195 |
getBuffer.setReadOnly(true) |
|
49475 | 196 |
|
49412 | 197 |
rich_text_area.activate() |
49398
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
198 |
} |
0fa4389c04f9
alternative output panel, based on Pretty_Text_Area, based on JEditEmbeddedTextArea;
wenzelm
parents:
diff
changeset
|
199 |