OSDN Git Service

change whitespace chars
[moreemacs/moreemacs.git] / jp.sourceforge.moreemacs / src / jp / sourceforge / moreemacs / handlers / KillWordExecution.java
1 package jp.sourceforge.moreemacs.handlers;
2
3 import org.eclipse.jface.text.BadLocationException;
4 import org.eclipse.swt.dnd.Clipboard;
5 import org.eclipse.swt.dnd.TextTransfer;
6 import org.eclipse.swt.dnd.Transfer;
7
8 public final class KillWordExecution extends TextEditorExecution {
9
10     @Override
11     public void execute() throws BadLocationException {
12         if (!textEditor.isEditable()) {
13             return;
14         }
15
16         int current = cursor.offset();
17         int next = ForwardWordExecution.getNextWordPosition(doc, current);
18         String word = doc.get(current, next - current);
19         Clipboard c = new Clipboard(window.getShell().getDisplay());
20         c.setContents(new String[] { word }, 
21                 new Transfer[] { TextTransfer.getInstance() });
22         doc.replace(current, next - current, "");
23     }
24 }