| 1 |
module test; |
|---|
| 2 |
|
|---|
| 3 |
import dwt.std; |
|---|
| 4 |
import dwtx.jface.text.Document; |
|---|
| 5 |
import dwtx.jface.text.source.CompositeRuler; |
|---|
| 6 |
import dwtx.jface.text.source.LineNumberRulerColumn; |
|---|
| 7 |
import dwtx.jface.text.source.AnnotationRulerColumn; |
|---|
| 8 |
import dwtx.jface.text.source.SourceViewer; |
|---|
| 9 |
import dwtx.jface.window.ApplicationWindow; |
|---|
| 10 |
|
|---|
| 11 |
version(JIVE) import jive.stacktrace; |
|---|
| 12 |
|
|---|
| 13 |
const char[] startText = `void main() |
|---|
| 14 |
{ |
|---|
| 15 |
ApplicationWindow w = new SourceViewerTest(); |
|---|
| 16 |
w.setBlockOnOpen( true ); |
|---|
| 17 |
w.open(); |
|---|
| 18 |
Display.getCurrent.dispose(); |
|---|
| 19 |
} |
|---|
| 20 |
`; |
|---|
| 21 |
|
|---|
| 22 |
class SourceViewerTest : ApplicationWindow { |
|---|
| 23 |
this() { |
|---|
| 24 |
super( null ); |
|---|
| 25 |
} |
|---|
| 26 |
|
|---|
| 27 |
protected Control createContents( Composite parent ) { |
|---|
| 28 |
getShell.setText( "SourceViewerTest" ); |
|---|
| 29 |
getShell.setSize( 350, 400 ); |
|---|
| 30 |
Display disp = getShell.getDisplay(); |
|---|
| 31 |
Composite container = new Composite( parent, DWT.NONE ); |
|---|
| 32 |
container.setLayout( new FillLayout() ); |
|---|
| 33 |
|
|---|
| 34 |
CompositeRuler ruler = new CompositeRuler(); |
|---|
| 35 |
|
|---|
| 36 |
LineNumberRulerColumn lineCol = new LineNumberRulerColumn(); |
|---|
| 37 |
lineCol.setBackground( disp.getSystemColor( DWT.COLOR_GRAY ) ); |
|---|
| 38 |
lineCol.setForeground( disp.getSystemColor( DWT.COLOR_BLUE ) ); |
|---|
| 39 |
ruler.addDecorator( 0, lineCol ); |
|---|
| 40 |
|
|---|
| 41 |
Document doc = new Document( startText ); |
|---|
| 42 |
|
|---|
| 43 |
SourceViewer sv = new SourceViewer( container, ruler, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL ); |
|---|
| 44 |
sv.setDocument( doc ); |
|---|
| 45 |
|
|---|
| 46 |
return container; |
|---|
| 47 |
} |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
void main() { |
|---|
| 51 |
ApplicationWindow w = new SourceViewerTest(); |
|---|
| 52 |
w.setBlockOnOpen( true ); |
|---|
| 53 |
w.open(); |
|---|
| 54 |
Display.getCurrent.dispose(); |
|---|
| 55 |
} |
|---|