Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

JFace Text Editor

This is the text editor component that is used inside Eclipse.

Simple example on Linux-GTK
http://downloads.dsource.org/projects/dwt/screenshots/linux/jface/JFace.Text.SourceViewerTest.png

Simple example on WinXp?
http://downloads.dsource.org/projects/dwt/screenshots/win/jface/JFace.Text.SourceViewerTest.png

Source:

import dwt.std;
import dwtx.jface.text.Document;
import dwtx.jface.text.source.CompositeRuler;
import dwtx.jface.text.source.LineNumberRulerColumn;
import dwtx.jface.text.source.AnnotationRulerColumn;
import dwtx.jface.text.source.SourceViewer;
import dwtx.jface.window.ApplicationWindow;

version(JIVE) import jive.stacktrace;

const char[] startText = `void main()
{
    ApplicationWindow w = new SourceViewerTest();
    w.setBlockOnOpen( true );
    w.open();
    Display.getCurrent.dispose();
}
`;

class SourceViewerTest : ApplicationWindow {
    this() {
        super( null );
    }

    protected Control createContents( Composite parent ) {
        getShell.setText( "SourceViewerTest" );
        getShell.setSize( 350, 400 );
        Display disp = getShell.getDisplay();
        Composite container = new Composite( parent, DWT.NONE );
        container.setLayout( new FillLayout() );

        CompositeRuler ruler = new CompositeRuler();

        LineNumberRulerColumn lineCol = new LineNumberRulerColumn();
        lineCol.setBackground( disp.getSystemColor( DWT.COLOR_GRAY ) );
        lineCol.setForeground( disp.getSystemColor( DWT.COLOR_BLUE ) );
        ruler.addDecorator( 0, lineCol );

        Document doc = new Document( startText );

        SourceViewer sv = new SourceViewer( container, ruler, DWT.BORDER | DWT.H_SCROLL | DWT.V_SCROLL );
        sv.setDocument( doc );

        return container;
    }
}

void main() {
    ApplicationWindow w = new SourceViewerTest();
    w.setBlockOnOpen( true );
    w.open();
    Display.getCurrent.dispose();
}