public abstract class EmacsAction extends BasicAction
EmacsAction
is an abstract class that all Emacs actions should extend from. This provides utility routines for supporting a kill-ring and for setting a mark in the editor.Modifier and Type | Class and Description |
---|---|
protected static class |
EmacsAction.Tracker
Protected class for tracking an editor and offset to determine whether to merge possibly consecutive kill actions, or for determining whether previous action was a yank or yank pop.
|
Constructor and Description |
---|
EmacsAction(java.lang.String actionName)
Constructs this object with the appropriate action name.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
actionPerformed(java.awt.event.ActionEvent event, BasicEditorPane editor, BasicDocument document)
The operation to perform when this action is triggered in a
BasicEditorPane . |
protected static void |
addKillRing(java.lang.String text)
Utility routine to add the given text as the last (top-most) entry in the kill ring.
|
protected static void |
appendKillRing(java.lang.String text)
Utility routine to append the given text to the last (top-most) entry in the kill ring.
|
protected static java.lang.String |
getClipboardText()
Utility routine to fetch the contents of the system clipboard as a String.
|
protected static int |
getMark(BasicEditorPane editor)
Utility routine to fetch the Emacs mark set for the given editor.
|
protected static java.awt.datatransfer.Clipboard |
getSystemClipboard()
Utility routine to fetch the system clipboard.
|
protected static java.lang.String |
popKillRing()
Utility routine to "pop" the last yank text from the kill ring, and retrieve the text before it from the kill ring.
|
protected static void |
prependKillRing(java.lang.String text)
Utility routine to prepend the given text to the last (top-most) entry in the kill ring.
|
protected static void |
removeMark(BasicEditorPane editor)
Utility routine to remove the Emacs mark from a given editor (i.e., when it is being closed.
|
protected static void |
setClipboardText(java.lang.String text)
Utility routine to set the contents of the system clipboard to the given String text.
|
protected static void |
setMark(BasicEditorPane editor, int offset)
Utility routine to set the Emacs mark for the given editor to the specified offset.
|
static void |
setSystemClipboard(java.awt.datatransfer.Clipboard clip)
Sets the clipboard used by EmacsAction.
|
protected static void |
showEndBufferMessage(BasicEditorPane editor)
Utility routine to show the message that we are at the end of the buffer
|
protected static void |
showMarkNotSetMessage(BasicEditorPane editor)
Utility routine to show the message that the mark has not yet been set.
|
protected static void |
showMarkSetMessage(BasicEditorPane editor)
Utility routine to show the message that the mark has been set.
|
protected static void |
showNextKillAppendMessage(BasicEditorPane editor)
Utility routine to show the message that if the next command is a kill, it will append
|
protected static void |
showPreviousNotYankMessage(BasicEditorPane editor)
Utility routine to show the message that the previous command was not a yank.
|
protected static void |
showReadOnlyMessage(BasicEditorPane editor)
Utility routine to show the message that the buffer is read-only.
|
protected static java.lang.String |
yankKillRing()
Utility routine to yank text from the last yank index of the kill ring, or from the clipboard if the text in the clipboard doesn't match the kill ring (which is generally the case if the user did a cut/copy elsewhere.)
|
actionPerformed, beep, buildIndent, getFontHeight, getIndentSizeProperty, getLastAction, getMagicCaretPosition, getName, getSmartIndentProvider, getSpaces, getTab, getTabs, getTabSizeProperty, getUseAutoIndentProperty, getUseTabsProperty, getVisibleRect, isEditable, lock, setMagicCaretPosition, showMessage, skipLeadingIndent, unlock
augmentList, getFocusedComponent, getTextComponent
public EmacsAction(java.lang.String actionName)
public abstract void actionPerformed(java.awt.event.ActionEvent event, BasicEditorPane editor, BasicDocument document)
BasicEditorPane
. Implementations should override this method. Implementations are guaranteed that the document read lock is held for the duration of this call.actionPerformed
in class BasicAction
event
- the action eventeditor
- the editor this action was invoked indocument
- the document associated with the editorprotected static void addKillRing(java.lang.String text)
text
- the text to add to the kill ringprotected static void appendKillRing(java.lang.String text)
text
- the text to append to the top-most entry of the clipboardprotected static void prependKillRing(java.lang.String text)
text
- the text to prepend to the top-most entry of the clipboardprotected static java.lang.String yankKillRing()
protected static java.lang.String popKillRing()
protected static java.lang.String getClipboardText()
protected static void setClipboardText(java.lang.String text)
text
- the STring text to put into the system clipboardprotected static java.awt.datatransfer.Clipboard getSystemClipboard()
public static void setSystemClipboard(java.awt.datatransfer.Clipboard clip)
clip
- clipboard that should be used.protected static int getMark(BasicEditorPane editor)
editor
- the editor to retrieve the mark forprotected static void setMark(BasicEditorPane editor, int offset)
editor
- the editor to set the mark foroffset
- the offset to set the mark toprotected static void removeMark(BasicEditorPane editor)
editor
- the editor to remove the mark for.protected static void showMarkSetMessage(BasicEditorPane editor)
editor
- the editor to show the message forprotected static void showMarkNotSetMessage(BasicEditorPane editor)
editor
- the editor to show the message forprotected static void showEndBufferMessage(BasicEditorPane editor)
editor
- the editor to show the message forprotected static void showReadOnlyMessage(BasicEditorPane editor)
editor
- the editor to show the message forprotected static void showNextKillAppendMessage(BasicEditorPane editor)
editor
- the editor to show the message forprotected static void showPreviousNotYankMessage(BasicEditorPane editor)
editor
- the editor to show the message for