Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In addition the following methods are implemented:

MethodDescription
setTabSize(int)Sets the tab size (defaults to 4)
gotoLine(int [, col])Moves the caret to the specified 1-based line and column
select(line1, col1, line2, col2)Select the text from line1,col1 to line2,col2



Code completion

The editor supports code completion. To make this work you need to create a method which, depending on the text position and context, returns a list of AceEditor.Completion instances. The method will be called when the user presses CTRL+Spacebar in the editor, and the editor will allow the user to pick one of the values which will then be inserted.

...

You can use editor markers to highlight problems inside the editor. Press the "mark vars" button and the clear markers buttons to see, and look in the source code of that page how to use them.


Internals

The editor loads the Ace editor's javascript from a CDN (https://cdnjs.cloudflare.com/ajax/libs/ace/{version}/xxx). This allows easy caching and deployment. To add the required parts as HeaderContributors to a page there are two methods:

...

The setMode(String) method can be called to set the editor's mode (which language is being edited), like: editor.setMode("/ace/mode/javascript");

Available methods to play with the editor state

The following methods are implemented: