public class AceEditor
extends com.google.gwt.user.client.ui.Composite
implements com.google.gwt.user.client.ui.RequiresResize, com.google.gwt.user.client.ui.HasText, com.google.gwt.user.client.TakesValue<java.lang.String>
Constructor and Description |
---|
AceEditor()
Preferred constructor.
|
AceEditor(boolean unused)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
addAnnotation(int row,
int column,
java.lang.String text,
AceAnnotationType type)
Add an annotation to a the local
annotations JsArray<AceAnnotation>, but does not set it on the editor |
void |
addCommand(AceCommandDescription description)
Add user defined command.
|
static void |
addCompletionProvider(AceCompletionProvider provider)
Add an
AceCompletionProvider to provide
custom code completions. |
int |
addFloatingMarker(AceRange range,
java.lang.String clazz,
AceMarkerType type)
Adds a floating marker into this editor (the marker follows lines changes as insertions, suppressions...).
|
int |
addMarker(AceRange range,
java.lang.String clazz,
AceMarkerType type,
boolean inFront)
Adds a static marker into this editor.
|
void |
addOnChangeHandler(AceEditorCallback callback)
Register a handler for change events generated by the editor.
|
void |
addOnCursorPositionChangeHandler(AceEditorCallback callback)
Register a handler for cursor position change events generated by the editor.
|
void |
clearAnnotations()
Clear any annotations from the editor and reset the local
annotations JsArray<AceAnnotation> |
void |
destroy()
Cleans up the entire editor.
|
void |
execCommand(AceCommand command)
Execute a command with no arguments.
|
void |
execCommand(AceCommand command,
AceCommandArgs args)
Execute a command with arguments (in case args is not null).
|
void |
execCommand(java.lang.String command)
Execute a command possibly containing string argument.
|
void |
execCommand(java.lang.String command,
AceCommandArgs args)
Execute a command with arguments (in case args is not null).
|
void |
execCommand(java.lang.String command,
java.lang.String arg)
Execute a command with arguments (in case args is not null).
|
void |
focus()
Causes the editor to gain input focus.
|
AceCommandDescription |
getCommandDescription(java.lang.String command)
Construct java wrapper for registered Ace command.
|
AceEditorCursorPosition |
getCursorPosition()
Get the current cursor position.
|
int |
getFontSize()
Give font size
|
int |
getIndexFromPosition(AceEditorCursorPosition position)
Gets the given document position as a zero-based index.
|
java.lang.String |
getLine(int row)
Get the line of text at the given row number.
|
int |
getLineCount()
Retrieves the number of lines in the editor.
|
java.util.HashMap<java.lang.Integer,AceRange> |
getMarkers()
Gets all the displayed markers.
|
AceEditorCursorPosition |
getPositionFromIndex(int index)
Gets a document position from a supplied zero-based index.
|
AceSelection |
getSelection()
Prepare a wrapper around Ace Selection object.
|
java.lang.String |
getText()
Get the complete text in the editor as a String.
|
java.lang.String |
getValue() |
void |
gotoLine(int line)
Go to given line.
|
void |
initializeCommandLine(AceCommandLine cmdLine)
Bind command line and editor.
|
void |
insertAtCursor(java.lang.String text)
Insert given text at the cursor.
|
java.util.List<java.lang.String> |
listCommands()
List names of all Ace commands.
|
void |
onResize() |
void |
redisplay()
Call this to force the editor contents to be redisplayed.
|
static void |
removeAllExistingCompleters()
Removes all existing completers from the langtools
This can be used to disable all completers including local completers, which can be very useful when completers are used on very large files (as the local completer tokenizes every word to put in the selected list). NOTE: This method may be removed, and replaced with another solution. |
void |
removeAllMarkers()
Remove all the displayed markers.
|
void |
removeCommand(AceCommand command)
Remove a command from the editor.
|
void |
removeCommandByName(java.lang.String command)
Remove commands, that may not be required, from the editor
|
void |
removeMarker(int markerId)
Removes the marker with the specified ID.
|
void |
setAnnotations()
Set any annotations which have been added via
addAnnotation on the editor |
void |
setAutocompleteEnabled(boolean b)
Set whether or not autocomplete is enabled.
|
void |
setFontSize(int fontSize)
Set integer font size.
|
void |
setFontSize(java.lang.String fontSize)
Set font size.
|
void |
setHighlightSelectedWord(boolean highlightSelectedWord)
Set or unset highlighting of currently selected word.
|
void |
setHScrollBarAlwaysVisible(boolean hScrollBarAlwaysVisible)
Set whether or not the horizontal scrollbar is always visible.
|
void |
setMode(AceEditorMode mode)
Set the mode.
|
void |
setModeByName(java.lang.String shortModeName)
Set the mode by name.
|
void |
setReadOnly(boolean readOnly)
Set or unset read-only mode.
|
void |
setShowGutter(boolean showGutter)
Set whether or not the gutter is shown.
|
void |
setShowPrintMargin(boolean showPrintMargin)
Set or unset the visibility of the print margin.
|
void |
setTabSize(int tabSize)
Set tab size.
|
void |
setText(java.lang.String text)
Set the complete text in the editor from a String.
|
void |
setTheme(AceEditorTheme theme)
Set the theme.
|
void |
setThemeByName(java.lang.String themeName)
Set the theme by name.
|
void |
setUseSoftTabs(boolean useSoftTabs)
Set whether or not soft tabs should be used.
|
void |
setUseWrapMode(boolean useWrapMode)
Set whether to use wrap mode or not
|
void |
setValue(java.lang.String value) |
void |
startEditor()
Call this method to start the editor.
|
claimElement, initializeClaimedElement, isAttached, onBrowserEvent, render, render
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, fireEvent, getLayoutData, getParent, removeFromParent, setLayoutData, sinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
public AceEditor()
@Deprecated public AceEditor(boolean unused)
unused
- this parameter is ignoredpublic void startEditor()
public void redisplay()
public void destroy()
public void setTheme(AceEditorTheme theme)
theme
- the theme (one of the values in the AceEditorTheme
enumeration)public void setThemeByName(java.lang.String themeName)
themeName
- the theme name (e.g., "twilight")public void setMode(AceEditorMode mode)
mode
- the mode (one of the values in the
AceEditorMode
enumeration)public void setModeByName(java.lang.String shortModeName)
shortModeName
- name of mode (e.g., "eclipse")public void addOnChangeHandler(AceEditorCallback callback)
callback
- the change event handlerpublic void addOnCursorPositionChangeHandler(AceEditorCallback callback)
callback
- the cursor position change event handlerpublic int getFontSize()
public void setFontSize(java.lang.String fontSize)
fontSize
- the font size to set, e.g., "16px"public void setFontSize(int fontSize)
fontSize
- the font size to set, e.g., 16public java.lang.String getText()
getText
in interface com.google.gwt.user.client.ui.HasText
public void focus()
public int getLineCount()
public void setText(java.lang.String text)
setText
in interface com.google.gwt.user.client.ui.HasText
text
- the text to set in the editorpublic java.lang.String getLine(int row)
row
- the row numberpublic void insertAtCursor(java.lang.String text)
text
- text to insert at the cursorpublic AceEditorCursorPosition getCursorPosition()
public int getIndexFromPosition(AceEditorCursorPosition position)
position
- the position to obtain the absolute index of (base zero)public AceEditorCursorPosition getPositionFromIndex(int index)
index
- (base zero)public void setUseSoftTabs(boolean useSoftTabs)
useSoftTabs
- true if soft tabs should be used, false otherwisepublic void setTabSize(int tabSize)
tabSize
- the tab size to setpublic void gotoLine(int line)
line
- the line to go topublic void setHScrollBarAlwaysVisible(boolean hScrollBarAlwaysVisible)
hScrollBarAlwaysVisible
- true if the horizontal scrollbar is always
visible, false if it is hidden when not neededpublic void setShowGutter(boolean showGutter)
showGutter
- true if the gutter should be shown, false if it should be hiddenpublic void setReadOnly(boolean readOnly)
readOnly
- true if editor should be set to readonly, false if the
editor should be set to read-writepublic void setHighlightSelectedWord(boolean highlightSelectedWord)
highlightSelectedWord
- true to highlight currently selected word, false otherwisepublic void setShowPrintMargin(boolean showPrintMargin)
showPrintMargin
- true if the print margin should be shown, false otherwisepublic void addAnnotation(int row, int column, java.lang.String text, AceAnnotationType type)
annotations
JsArray<AceAnnotation>, but does not set it on the editorrow
- to which the annotation should be addedcolumn
- to which the annotation appliestext
- to display as a tooltip with the annotationtype
- to be displayed (one of the values in the
AceAnnotationType
enumeration)public void setAnnotations()
addAnnotation
on the editorpublic void clearAnnotations()
annotations
JsArray<AceAnnotation>public void removeCommand(AceCommand command)
command
- the command (one of the values in the
AceCommand
enumeration)public void execCommand(AceCommand command)
AceCommand
values for example.command
- the command (one of the values in the
AceCommand
enumeration)public void execCommand(AceCommand command, AceCommandArgs args)
AceCommand
values for example.command
- the command (one of the values in the
AceCommand
enumeration)args
- command arguments (string or map)public void execCommand(java.lang.String command)
command
- the command which could be one or two words separated
by whitespacespublic void execCommand(java.lang.String command, java.lang.String arg)
command
- one word commandargs
- command argumentpublic void execCommand(java.lang.String command, AceCommandArgs args)
command
- one word commandargs
- command arguments of type AceCommandArgs
public void removeCommandByName(java.lang.String command)
command
- to be removed, one of
"gotoline", "findnext", "findprevious", "find", "replace", "replaceall"public AceCommandDescription getCommandDescription(java.lang.String command)
command
- name of commandpublic java.util.List<java.lang.String> listCommands()
public void addCommand(AceCommandDescription description)
description
- command descriptionpublic void setUseWrapMode(boolean useWrapMode)
useWrapMode
- true if word wrap should be used, false otherwisepublic void onResize()
onResize
in interface com.google.gwt.user.client.ui.RequiresResize
public void setValue(java.lang.String value)
setValue
in interface com.google.gwt.user.client.TakesValue<java.lang.String>
public java.lang.String getValue()
getValue
in interface com.google.gwt.user.client.TakesValue<java.lang.String>
public void setAutocompleteEnabled(boolean b)
b
- true if autocomplete should be enabled, false if notpublic static void removeAllExistingCompleters()
public static void addCompletionProvider(AceCompletionProvider provider)
AceCompletionProvider
to provide
custom code completions.
Warning: this is an experimental feature of AceGWT.
It is possible that the API will change in an incompatible way
in future releases.provider
- the AceCompletionProvider
public int addMarker(AceRange range, java.lang.String clazz, AceMarkerType type, boolean inFront)
range
- an AceRange
.clazz
- a CSS class that must be applied to the marker.type
- an AceMarkerType
.inFront
- set to 'true' if the marker must be in front of the text, 'false' otherwise.public int addFloatingMarker(AceRange range, java.lang.String clazz, AceMarkerType type)
range
- an AceRange
.clazz
- a CSS class that must be applied to the marker.type
- an AceMarkerType
.public void removeMarker(int markerId)
markerId
- the marker ID.public java.util.HashMap<java.lang.Integer,AceRange> getMarkers()
public void removeAllMarkers()
public AceSelection getSelection()
public void initializeCommandLine(AceCommandLine cmdLine)
AceCommandLine cmdLine = new AceDefaultCommandLine(textBox)
where textBox could be for instance standard GWT TextBox or TextArea.cmdLine
- implementation of command line