From f8d874edd9fcf47a6eafd96a04474201242b8f88 Mon Sep 17 00:00:00 2001 From: quiver2k Date: Wed, 29 Jul 2009 21:25:25 +0900 Subject: [PATCH] added comment-region --- jp.sourceforge.moreemacs.updatesite/site.xml | 2 +- jp.sourceforge.moreemacs/plugin.xml | 17 ++++++++++++++ .../moreemacs/handlers/CommentRegionExecution.java | 27 ++++++++++++++++++++++ .../moreemacs/handlers/TextEditorExecution.java | 4 +++- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/CommentRegionExecution.java diff --git a/jp.sourceforge.moreemacs.updatesite/site.xml b/jp.sourceforge.moreemacs.updatesite/site.xml index 0c3886d..7757c71 100644 --- a/jp.sourceforge.moreemacs.updatesite/site.xml +++ b/jp.sourceforge.moreemacs.updatesite/site.xml @@ -3,7 +3,7 @@ More Emacs update site - + diff --git a/jp.sourceforge.moreemacs/plugin.xml b/jp.sourceforge.moreemacs/plugin.xml index 7c2821e..19312d1 100644 --- a/jp.sourceforge.moreemacs/plugin.xml +++ b/jp.sourceforge.moreemacs/plugin.xml @@ -87,6 +87,11 @@ id="jp.sourceforge.moreemacs.CapitalizeWord" name="capitalize-word"> + + + + + + @@ -355,6 +366,12 @@ schemeId="jp.sourceforge.moreemacs.moreEmacsAcceleratorConfiguration" sequence="M3+C"> + + diff --git a/jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/CommentRegionExecution.java b/jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/CommentRegionExecution.java new file mode 100644 index 0000000..c59115f --- /dev/null +++ b/jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/CommentRegionExecution.java @@ -0,0 +1,27 @@ +package jp.sourceforge.moreemacs.handlers; + +import org.eclipse.core.commands.Command; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.ui.handlers.IHandlerService; + + +public final class CommentRegionExecution extends TextEditorExecution { + @Override + public void execute() throws Exception { + ICommandService commandService = + (ICommandService)textEditor.getSite().getService(ICommandService.class); + for(Command command: commandService.getDefinedCommands()) { + if(!command.isEnabled()) { + continue; + } + if(!command.getId().endsWith(".toggle.comment")) { + continue; + } + getSelection(true); + IHandlerService handlerService = + (IHandlerService)textEditor.getSite().getService(IHandlerService.class); + handlerService.executeCommand(command.getId(), null); + break; + } + } +} diff --git a/jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/TextEditorExecution.java b/jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/TextEditorExecution.java index 56f01ae..8e3e355 100644 --- a/jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/TextEditorExecution.java +++ b/jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/TextEditorExecution.java @@ -72,7 +72,9 @@ abstract class TextEditorExecution implements Execution { int current = selection.getOffset(); int start = (mark < current) ? mark : current; - textEditor.selectAndReveal(start, Math.abs(mark - current)); + //textEditor.selectAndReveal(start, Math.abs(mark - current)); + textViewer.setSelectedRange(start, Math.abs(mark - current)); + return (ITextSelection) textEditor .getSelectionProvider().getSelection(); -- 2.11.0