X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fasm%2Feditor%2FAsmAutoEditStrategy.java;fp=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fasm%2Feditor%2FAsmAutoEditStrategy.java;h=7198a27aa70414250daccb5cfc69edd2e797f508;hb=f14ea37d69488dd51518a36413af7176916b8bd7;hp=0000000000000000000000000000000000000000;hpb=a84700145147c263ad6692c99117a7cf37832378;p=Mograsim.git diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/editor/AsmAutoEditStrategy.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/editor/AsmAutoEditStrategy.java new file mode 100644 index 00000000..7198a27a --- /dev/null +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/editor/AsmAutoEditStrategy.java @@ -0,0 +1,38 @@ +package net.mograsim.plugin.asm.editor; + +import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.DocumentCommand; +import org.eclipse.jface.text.IAutoEditStrategy; +import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IRegion; + +public class AsmAutoEditStrategy implements IAutoEditStrategy +{ + + @Override + public void customizeDocumentCommand(IDocument document, DocumentCommand command) + { + if (!">".equals(command.text)) + { // NON-NLS-1 + return; + } + try + { + IRegion region = document.getLineInformationOfOffset(command.offset); + String line = document.get(region.getOffset(), command.offset - region.getOffset()); + int index = line.lastIndexOf('<'); + if (index != -1 && (index != line.length() - 1) && line.charAt(index + 1) != '/') + { + String tag = line.substring(index + 1); + command.caretOffset = command.offset + 1; + command.text += "