nesctexteditor.java

来自「plugin for eclipse」· Java 代码 · 共 62 行

JAVA
62
字号
package isis.tinydt.editors.nesceditor;

import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.editors.text.TextEditor;

public class NesCTextEditor extends TextEditor
{
    private static final String CONTENTASSIST_PROPOSAL_ID = "isis.tinydt.editor.NesCEditor.ContentAssistProposal";

    public NesCTextEditor()
    {
        super();
        setDocumentProvider(new CompilationUnitDocumentProvider());
        setSourceViewerConfiguration(new NesCSourceViewerConfiguration(this));
    }

    public void setSelection(int line, int column, int len)
    {
        try
        {
            IRegion r = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(line);
            int offset = r.getOffset() + column;
            // FIXME: parser somtimes gives back bad offcet
            getSourceViewer().setSelectedRange(offset,len);
            //getSourceViewer().setSelectedRange(r.getOffset(), r.getLength());
            if(line < getSourceViewer().getTopIndex() || line > getSourceViewer().getBottomIndex())
                if(line > 5)
                    getSourceViewer().setTopIndex(line - 5);
                else
                    getSourceViewer().setTopIndex(0);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    protected void createActions()
    {
        super.createActions();

        // TODO: hogy ez fusson kell egy properties file valahova...

        // register ctrl+shift action for contetn assistant
        /*
         * IAction action = new TextOperationAction(
         * TinydtPlugin.getDefault().getResourceBundle(),
         * "ContentAssistProposal", this, SourceViewer.CONTENTASSIST_PROPOSALS);
         * action.setActionDefinitionId(CONTENTASSIST_PROPOSAL_ID);
         * setAction(CONTENTASSIST_PROPOSAL_ID, action);
         * setActionActivationCode(CONTENTASSIST_PROPOSAL_ID,' ', -1, SWT.CTRL);
         */
    }

    public void dispose()
    {
        //colorManager.dispose();
        super.dispose();
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?