📄 mysourceviewerconfig.java
字号:
package edit4.Myedit;import org.eclipse.jface.text.IDocument;import org.eclipse.jface.text.TextAttribute;import org.eclipse.jface.text.contentassist.ContentAssistant;import org.eclipse.jface.text.contentassist.IContentAssistant;import org.eclipse.jface.text.presentation.IPresentationReconciler;import org.eclipse.jface.text.presentation.PresentationReconciler;import org.eclipse.jface.text.rules.DefaultDamagerRepairer;import org.eclipse.jface.text.rules.Token;import org.eclipse.jface.text.source.ISourceViewer;import org.eclipse.jface.text.source.SourceViewerConfiguration;import org.eclipse.swt.graphics.Color;import org.eclipse.swt.graphics.RGB;import org.eclipse.swt.widgets.Display;public class MySourceViewerConfig extends SourceViewerConfiguration { private MyRuleScanner scanner; private static Color DEFAULT_TAG_COLOR = new Color(Display.getCurrent(), new RGB(0, 0, 255)); public MySourceViewerConfig() { } protected MyRuleScanner getTagScanner() { if (scanner == null) { scanner = new MyRuleScanner(); scanner.setDefaultReturnToken( new Token(new TextAttribute(DEFAULT_TAG_COLOR))); } return scanner; } /** * Define reconciler for MyEditor */ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { PresentationReconciler reconciler = new PresentationReconciler(); DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getTagScanner()); reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); return reconciler; } public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ContentAssistant assistant = new ContentAssistant(); assistant.setContentAssistProcessor( new MyCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE); assistant.enableAutoActivation(true); assistant.setAutoActivationDelay(500); assistant.setProposalPopupOrientation( IContentAssistant.PROPOSAL_OVERLAY); return assistant; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -