forked from danlucraft/java-mateview
-
Notifications
You must be signed in to change notification settings - Fork 2
/
projection_attempt.diff
61 lines (58 loc) · 2.69 KB
/
projection_attempt.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
diff --git a/src/com/redcareditor/mate/MateText.java b/src/com/redcareditor/mate/MateText.java
index 209fec9..7159d85 100644
--- a/src/com/redcareditor/mate/MateText.java
+++ b/src/com/redcareditor/mate/MateText.java
@@ -11,6 +11,9 @@ import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.OverviewRuler;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.jface.text.projection.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
@@ -28,6 +31,7 @@ import com.redcareditor.mate.document.swt.SwtMateDocument;
import com.redcareditor.mate.undo.MateTextUndoManager;
import com.redcareditor.mate.undo.swt.SwtMateTextUndoManager;
import com.redcareditor.mate.WhitespaceCharacterPainter;
+import com.redcareditor.mate.SharedTextColors;
import com.redcareditor.mate.LineNumberRulerColumn;
import com.redcareditor.onig.NullRx;
import com.redcareditor.onig.Rx;
@@ -55,6 +59,8 @@ public class MateText {
private CompositeRuler gutter;
private LineNumberRulerColumn lineNumbers;
private SwtMateDocument mateDocument;
+ private OverviewRuler overviewRuler;
+ private SharedTextColors sharedColors;
private MateTextUndoManager undoManager;
private List<IGrammarListener> grammarListeners;
@@ -69,16 +75,23 @@ public class MateText {
public MateText(Composite parent, boolean thisSingleLine) {
singleLine = thisSingleLine;
- document = new Document();
- gutter = constructRuler();
+ document = new Document();
if (singleLine) {
viewer = new SourceViewer(parent, null, SWT.FULL_SELECTION | SWT.HORIZONTAL | SWT.VERTICAL | SWT.SINGLE);
+ viewer.setDocument(document);
}
else {
- viewer = new SourceViewer(parent, gutter, SWT.FULL_SELECTION | SWT.HORIZONTAL | SWT.VERTICAL);
- }
- viewer.setDocument(document);
-
+ sharedColors = new SharedTextColors();
+ overviewRuler = new OverviewRuler(null, 20, sharedColors);
+ gutter = constructRuler();
+ viewer = new ProjectionViewer(parent, gutter, overviewRuler, true, SWT.FULL_SELECTION | SWT.HORIZONTAL | SWT.VERTICAL);
+ viewer.doOperation(ProjectionViewer.TOGGLE);
+
+ ProjectionDocumentManager manager = new ProjectionDocumentManager();
+ ProjectionDocument projectionDocument = (ProjectionDocument) manager.createSlaveDocument(document);
+ viewer.setDocument(projectionDocument);
+ }
+
whitespaceCharacterPainter = new WhitespaceCharacterPainter(viewer);
showingInvisibles = false;