| org.armedbear.j.Mode
All known Subclasses: org.armedbear.j.VHDLMode, org.armedbear.j.AsmMode, org.armedbear.j.AutoconfMode, org.armedbear.j.DirectoryMode, org.armedbear.j.TclMode, org.armedbear.j.SchemeMode, org.armedbear.j.PythonMode, org.armedbear.j.PHPMode, org.armedbear.j.CMode, org.armedbear.j.ImageMode, org.armedbear.j.ListTagsMode, org.armedbear.j.ShellScriptMode, org.armedbear.j.CompilationMode, org.armedbear.j.VerilogMode, org.armedbear.j.ListRegistersMode, org.armedbear.j.PerlMode, org.armedbear.j.mail.MessageMode, org.armedbear.j.ShellMode, org.armedbear.j.jdb.JdbMode, org.armedbear.j.mail.MailboxMode, org.armedbear.j.WebMode, org.armedbear.j.mail.SendMailMode, org.armedbear.j.ListOccurrencesMode, org.armedbear.j.XmlMode, org.armedbear.j.mail.NewsGroupsMode, org.armedbear.j.JavaMode, org.armedbear.j.ArchiveMode, org.armedbear.j.MakefileMode, org.armedbear.j.RubyMode, org.armedbear.j.CppMode, org.armedbear.j.ObjCMode, org.armedbear.j.DiffMode, org.armedbear.j.LispShellMode, org.armedbear.j.PlainTextMode, org.armedbear.j.CSSMode, org.armedbear.j.HtmlMode, org.armedbear.j.LispMode, org.armedbear.j.PropertiesMode, org.armedbear.j.WordMode, org.armedbear.j.CheckinMode, org.armedbear.j.BinaryMode, org.armedbear.j.JavaScriptMode, org.armedbear.j.ManMode, org.armedbear.j.AbstractMode,
Mode | public interface Mode (Code) | | Mode is an interface for defining modes. A mode is a set of rules that
define how the editor behaves. Different behaviors are desireable when
editing different kinds of files. As an example, a user expects
different behavior/functionality when editing a C++ file than what she
expects when editing a Lisp file.
Users should not implement Mode directly, they should instead extend
AbstractMode AbstractMode .
See Also: AbstractMode |
Method Summary | |
public boolean | accepts(String filename) Returns whether or not this mode is willing to accept the given
file name.
Parameters: filename - the name of the file that is to be checked forvalidity for this mode. | public boolean | acceptsLinePaste(Editor editor) | public boolean | canIndent() Returns whether or not this mode will potentially perform context
sensitive indentation on a given Line in a given
Buffer . | public boolean | canIndentPaste() Returns whether or not this mode will potentially perform context
sensitive indentation for a paste operation. | public boolean | confirmClose(Editor editor, Buffer buffer) Allows this mode to confirm the closing of a Buffer , and
can cancel it by returning false . | public Buffer | createBuffer(File file) | public MenuBar | createMenuBar(Frame frame) Returns the MenuBar that is to be used for this mode. | public void | deleteKeyMap() | public Position | findIdentifierStart(Line line, int offset) Returns the position of the start of the identifier at the specified
line and offset. | public char | fixCase(Editor editor, char c) Examines c and returns the equivalent character but
possibly with a different case (upper or lower) as the rules of
this mode dictate. | public boolean | getBooleanProperty(Property property) Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. | public Color | getColorProperty(Property property) Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. | public String | getCommentEnd() Returns a string that signifies the end of a comment for the
given mode, or null if the concept of comments is
not applicable to this mode or the comment does not require an
end token. | public String | getCommentStart() Returns a string that signifies the start of a comment for the
given mode, or null if the concept of comments is
not applicable to this mode. | public JPopupMenu | getContextMenu(Editor editor) Returns a context menu populated with entries specific to the given
mode and the current location in the specified Editor . | public String | getContextString(Editor editor, boolean verbose) Returns a string that describes something about the current caret
position that is suitable to be displayed in the StatusBar .
Parameters: editor - the Editor for context. Parameters: verbose - whether or not to return more information. | public int | getCorrectIndentation(Line line, Buffer buffer) Returns the amount of indentation (in columns) needed to indent the
specified Line in the context of the given
Buffer . | public String | getDisplayName() Returns the display name of this mode. | public Expression | getExpressionAtDot(Editor editor, boolean exact) Returns the expression at the current location of the caret in the
specified editor. | public Formatter | getFormatter(Buffer buffer) Returns a Formatter for the given Buffer . | public int | getId() Returns the unique identifier of this mode. | public String | getIdentifier(Position pos) Returns the identifier at the specified position. | public String | getIdentifier(Line line, int offset) Returns the identifier at the specified line and offset. | public int | getIntegerProperty(Property property) Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. | public KeyMap | getKeyMap() Returns a non-null KeyMap that may define custom
KeyMapping s for this Mode. | public File | getKeyMapFile() Returns the file that defines a custom KeyMap for
this Mode, if any. | public String | getMenuName() Returns an identifier for the MenuBar that is to
be used for this mode. | public String | getMouseMovedContextString(Editor editor, Position pos) Returns a string that describes something about the current mouse
position that is suitable to be displayed in the StatusBar ,
or null if there is none.
Parameters: editor - the Editor for context. | public NavigationComponent | getSidebarComponent(Editor editor) Returns a navigation component for the specified Editor ,
or null if there is no navigation component for this mode. | public String | getStringProperty(Property property) Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. | public SyntaxIterator | getSyntaxIterator(Position pos) Returns a SyntaxIterator specific for this mode that
is situated at the given Position .
Parameters: pos - where to situate the SyntaxIterator . | public Tagger | getTagger(SystemBuffer buffer) Most useful for programming language modes, this method returns
either a Tagger for this mode, or null . | public ToolBar | getToolBar(Frame frame) Returns a ToolBar for the specified Frame . | public String | getToolTipText(Editor editor, MouseEvent e) Returns a string that describes something about the current mouse
position that is suitable to be displayed as a tool tip, or
null if there is none.
Parameters: editor - the Editor for context. | public boolean | hasQualifiedNames() Returns true if the mode's underlying programming language
supports qualified names. | public boolean | isCommentLine(Line line) Returns whether or not the given Line is a comment.
Parameters: line - the Line to check to see if it is acomment. | public boolean | isIdentifierPart(char c) Checks the given character against a list of characters that are
legal identifier parts (not the first character). | public boolean | isIdentifierStart(char c) Checks the given character against a list of characters that are
legal identifier starts. | public boolean | isInComment(Buffer buffer, Position pos) Returns true if the specified position is inside a comment. | public boolean | isInQuote(Buffer buffer, Position pos) Returns true if the specified position is inside a quoted
string. | public boolean | isKeyword(String s) Checks the given string against a list of keywords for this mode, and
returns true if the string is on that list.
Parameters: s - the keyword to test. | public boolean | isQualifiedName(String s) Returns true if the string in question is a qualified name
in the mode's underlying programming language. | public boolean | isTaggable() Returns whether or not this mode has a
Tagger Tagger associated with it. | public void | loadFile(Buffer buffer, File file) If this mode needs to do any special processing on a file in order to
load it into the buffer, e.g. | public void | populateMenu(Editor editor, Menu menu) Populates the given Menu with appropriate menu items. | public void | populateModeMenu(Editor editor, Menu menu) | public void | setProperty(Property property, String value) | public void | setProperty(Property property, boolean value) | public void | setProperty(Property property, int value) | public void | useDefaultKeyMap() |
accepts | public boolean accepts(String filename)(Code) | | Returns whether or not this mode is willing to accept the given
file name.
Parameters: filename - the name of the file that is to be checked forvalidity for this mode. true if the given filename can be handledby this mode. |
acceptsLinePaste | public boolean acceptsLinePaste(Editor editor)(Code) | | |
canIndent | public boolean canIndent()(Code) | | Returns whether or not this mode will potentially perform context
sensitive indentation on a given Line in a given
Buffer . This returns true if
Mode.getCorrectIndentation(Line,Buffer) getCorrectIndentation() might return something other than zero, false otherwise.
true if this mode supports context-sensitiveindentation. |
canIndentPaste | public boolean canIndentPaste()(Code) | | Returns whether or not this mode will potentially perform context
sensitive indentation for a paste operation. This returns
true if
Mode.getCorrectIndentation(Line,Buffer) getCorrectIndentation() might return something other than zero, false otherwise.
true if this mode supports context-sensitiveindentation of pasted text. |
confirmClose | public boolean confirmClose(Editor editor, Buffer buffer)(Code) | | Allows this mode to confirm the closing of a Buffer , and
can cancel it by returning false . confirmClose
allows for this mode to do things such as make sure the user wants to
close a Buffer even though it has been modified.
Parameters: editor - the Editor for context. Parameters: buffer - the Buffer that is to be closed. true to allow the Buffer toclose. |
createMenuBar | public MenuBar createMenuBar(Frame frame)(Code) | | Returns the MenuBar that is to be used for this mode.
Override to return a custom MenuBar for this mode.
If this method is overriden, then you must also override
Mode.getMenuName() getMenuName to return a unique identifier,
otherwise the default is fine.
Parameters: frame - the frame that the MenuBar will beattached to a MenuBar for the specified frame |
deleteKeyMap | public void deleteKeyMap()(Code) | | |
findIdentifierStart | public Position findIdentifierStart(Line line, int offset)(Code) | | Returns the position of the start of the identifier at the specified
line and offset.
Parameters: line - the line Parameters: offset - the offset the position of the start of the identifier at thespecified line and offset or null if noidentifier is found. since: 0.16.1 |
fixCase | public char fixCase(Editor editor, char c)(Code) | | Examines c and returns the equivalent character but
possibly with a different case (upper or lower) as the rules of
this mode dictate. This is primarily used in programming language
modes where the language is case-insensitive and the user wants
certain identifiers to have a certain casing style (all upper, all
lower).
Parameters: editor - the Editor for context. Parameters: c - the character in question. the character represented by c as theproper case given the context of editor and the case rules of this mode. |
getBooleanProperty | public boolean getBooleanProperty(Property property)(Code) | | Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. The property
and preferences lists are searched in an manner which gives precedence
in the following order: mode specific preferences, mode specific
properties, global preferences.
Parameters: property - the key to look for with the default value to returnif the key is not found. the value of the given property, or the default in thegiven Property if the property's key isnot found. |
getColorProperty | public Color getColorProperty(Property property)(Code) | | Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. The property
and preferences lists are searched in an manner which gives precedence
in the following order: mode specific preferences, mode specific
properties, global preferences.
Parameters: property - the key to look for with the default value to returnif the key is not found. the value of the given property, or the default in thegiven Property if the property's key isnot found. |
getCommentEnd | public String getCommentEnd()(Code) | | Returns a string that signifies the end of a comment for the
given mode, or null if the concept of comments is
not applicable to this mode or the comment does not require an
end token.
the token to end a comment, or null if notapplicable. |
getCommentStart | public String getCommentStart()(Code) | | Returns a string that signifies the start of a comment for the
given mode, or null if the concept of comments is
not applicable to this mode.
the token to start a comment, or null if notapplicable. |
getContextMenu | public JPopupMenu getContextMenu(Editor editor)(Code) | | Returns a context menu populated with entries specific to the given
mode and the current location in the specified Editor .
Parameters: editor - the current Editor a menu filled with context sensitive goodies. |
getContextString | public String getContextString(Editor editor, boolean verbose)(Code) | | Returns a string that describes something about the current caret
position that is suitable to be displayed in the StatusBar .
Parameters: editor - the Editor for context. Parameters: verbose - whether or not to return more information. information relevant to the current caret position. |
getCorrectIndentation | public int getCorrectIndentation(Line line, Buffer buffer)(Code) | | Returns the amount of indentation (in columns) needed to indent the
specified Line in the context of the given
Buffer .
If this mode does not support automatic context-sensitive indentation,
that is if
Mode.canIndent() canIndent() returns false ,
then this method returns zero.
Parameters: line - the line to be indented Parameters: buffer - the buffer which contains the line the amount of indentation required, in columns. |
getDisplayName | public String getDisplayName()(Code) | | Returns the display name of this mode. All display names should be
defined in Constants .
the display name of this mode See Also: Constants |
getExpressionAtDot | public Expression getExpressionAtDot(Editor editor, boolean exact)(Code) | | Returns the expression at the current location of the caret in the
specified editor.
Parameters: editor - the editor in question Parameters: exact - a hint to the implementation: if true, return theexpression at the exact location of the caret; iffalse, look for a suitable expression on the same line the expression, or null if no expressionis found. since: 0.16.1 |
getFormatter | public Formatter getFormatter(Buffer buffer)(Code) | | Returns a Formatter for the given Buffer .
Parameters: buffer - the Buffer that is to be formattedaccording to this mode a Formatter for the given mode. |
getId | public int getId()(Code) | | Returns the unique identifier of this mode. All identifiers should
be defined in Constants .
the unique identifier for this mode See Also: Constants |
getIdentifier | public String getIdentifier(Position pos)(Code) | | Returns the identifier at the specified position.
Parameters: pos - the position the identifier at the specified position, ornull if no identifier is found. since: 0.16.1 |
getIdentifier | public String getIdentifier(Line line, int offset)(Code) | | Returns the identifier at the specified line and offset.
Parameters: line - the line Parameters: offset - the offset the identifier at the specified line and offset, ornull if no identifier is found. since: 0.16.1 |
getIntegerProperty | public int getIntegerProperty(Property property)(Code) | | Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. The property
and preferences lists are searched in an manner which gives precedence
in the following order: mode specific preferences, mode specific
properties, global preferences.
Parameters: property - the key to look for with the default value to returnif the key is not found. the value of the given property, or the default in thegiven Property if the property's key isnot found. |
getKeyMap | public KeyMap getKeyMap()(Code) | | Returns a non-null KeyMap that may define custom
KeyMapping s for this Mode. If there are no custom
KeyMapping s for this Mode, then an empty
KeyMap is returned.
a non-null KeyMap See Also: KeyMapping |
getKeyMapFile | public File getKeyMapFile()(Code) | | Returns the file that defines a custom KeyMap for
this Mode, if any.
the KeyMap file, or null if there isnone. See Also: Mode.getKeyMap See Also: KeyMap See Also: KeyMapping |
getMenuName | public String getMenuName()(Code) | | Returns an identifier for the MenuBar that is to
be used for this mode.
Override this method to return a unique name if you override
Mode.createMenuBar(Frame) createMenuBar to have a
custom menu.
an identifier for the MenuBar that is returnedby calling createMenuBar . |
getMouseMovedContextString | public String getMouseMovedContextString(Editor editor, Position pos)(Code) | | Returns a string that describes something about the current mouse
position that is suitable to be displayed in the StatusBar ,
or null if there is none.
Parameters: editor - the Editor for context. information relevant to the current mouse position. |
getSidebarComponent | public NavigationComponent getSidebarComponent(Editor editor)(Code) | | Returns a navigation component for the specified Editor ,
or null if there is no navigation component for this mode.
The navigation component appears in the lower pane of the sidebar.
Parameters: editor - the Editor the navigation component, or null |
getStringProperty | public String getStringProperty(Property property)(Code) | | Looks in all mode and non-mode specific properties/preferences and
returns the value attached to the given key, or the default value
given in property if the key is not found. The property
and preferences lists are searched in an manner which gives precedence
in the following order: mode specific preferences, mode specific
properties, global preferences.
Parameters: property - the key to look for with the default value to returnif the key is not found. the value of the given property, or the default in thegiven Property if the property's key isnot found. |
getSyntaxIterator | public SyntaxIterator getSyntaxIterator(Position pos)(Code) | | Returns a SyntaxIterator specific for this mode that
is situated at the given Position .
Parameters: pos - where to situate the SyntaxIterator . a SyntaxIterator for this mode. |
getTagger | public Tagger getTagger(SystemBuffer buffer)(Code) | | Most useful for programming language modes, this method returns
either a Tagger for this mode, or null . If a
Tagger is returned, then
Mode.isTaggable() isTaggable() must return true .
Otherwise it should return false .
Parameters: buffer - the current buffer a Tagger specific for this mode ornull if a Tagger is notapplicable. |
getToolBar | public ToolBar getToolBar(Frame frame)(Code) | | Returns a ToolBar for the specified Frame .
Parameters: frame - the Frame the ToolBar |
getToolTipText | public String getToolTipText(Editor editor, MouseEvent e)(Code) | | Returns a string that describes something about the current mouse
position that is suitable to be displayed as a tool tip, or
null if there is none.
Parameters: editor - the Editor for context. information relevant to the current mouse position. |
hasQualifiedNames | public boolean hasQualifiedNames()(Code) | | Returns true if the mode's underlying programming language
supports qualified names. (For example, Java, C++ and Perl do; C does
not.)
true if the mode supports qualified names. since: 0.16.1 |
isCommentLine | public boolean isCommentLine(Line line)(Code) | | Returns whether or not the given Line is a comment.
Parameters: line - the Line to check to see if it is acomment. true if line qualifies asa comment for this mode. |
isIdentifierPart | public boolean isIdentifierPart(char c)(Code) | | Checks the given character against a list of characters that are
legal identifier parts (not the first character). Some languages
have different requirements for the beginning of an identifier than
the rest of that identifier. Such a case is Java which allows digits
in an identifier part, but does not allow a digit to be the first
character.
char the character to be checked for validity. true if c is one of thelegal identifier parts for this mode. |
isIdentifierStart | public boolean isIdentifierStart(char c)(Code) | | Checks the given character against a list of characters that are
legal identifier starts. Some languages have different requirements
for the beginning of an identifier than the rest of that identifier.
Such a case is Java which allows digits in an identifier name, but
does not allow them to be the first character.
char the character to be checked for validity. true if c is one of thelegal identifier start characters for this mode. |
isInComment | public boolean isInComment(Buffer buffer, Position pos)(Code) | | Returns true if the specified position is inside a comment.
Parameters: buffer - the Buffer containing the specifiedposition Parameters: pos - the position true if pos is inside acomment. |
isInQuote | public boolean isInQuote(Buffer buffer, Position pos)(Code) | | Returns true if the specified position is inside a quoted
string.
Parameters: buffer - the Buffer containing the specifiedposition Parameters: pos - the position true if pos is inside aquoted string. |
isKeyword | public boolean isKeyword(String s)(Code) | | Checks the given string against a list of keywords for this mode, and
returns true if the string is on that list.
Parameters: s - the keyword to test. true if s is a valid keywordfor this mode. |
isQualifiedName | public boolean isQualifiedName(String s)(Code) | | Returns true if the string in question is a qualified name
in the mode's underlying programming language.
true if the string is a qualified name. since: 0.16.1 |
isTaggable | public boolean isTaggable()(Code) | | Returns whether or not this mode has a
Tagger Tagger associated with it. This returns false if
Mode.getTagger(SystemBuffer) getTagger() returns null ,
and true otherwise.
Whether or not this mode is taggable. Which is the same aswhether or not getTagger returns null . |
loadFile | public void loadFile(Buffer buffer, File file)(Code) | | If this mode needs to do any special processing on a file in order to
load it into the buffer, e.g. the file is an archive, that
processing is to be done here. This method is called from the
protected
Buffer.loadFile(File) loadFile method in
Buffer when loading a file. It is also called from
the
Buffer.reload reload method in Buffer .
Parameters: buffer - the Buffer that the file is to be loadedinto. Parameters: file - the input source. |
populateMenu | public void populateMenu(Editor editor, Menu menu)(Code) | | Populates the given Menu with appropriate menu items.
Unless there is a compelling reason not to, classes that override
this method should call super.createMenuBar(editor, menu)
when they are done putting in their own entries.
Parameters: editor - the current Editor . Parameters: menu - the Menu that is to be populated withentries for this mode. |
setProperty | public void setProperty(Property property, boolean value)(Code) | | |
setProperty | public void setProperty(Property property, int value)(Code) | | |
useDefaultKeyMap | public void useDefaultKeyMap()(Code) | | |
|
|