Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/emmet.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ var SnippetManager = function() {
return;

var value = tokens.slice(i + 1, i1);
var isNested = value.some(function(t) {return typeof t === "object";});
var isNested = value.some(function(t) {return typeof t === "object";});
if (isNested && !ts.value) {
ts.value = value;
} else if (value.length && (!ts.value || typeof ts.value !== "string")) {
Expand Down
4 changes: 2 additions & 2 deletions ext/language_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ var SnippetManager = function() {
return;

var value = tokens.slice(i + 1, i1);
var isNested = value.some(function(t) {return typeof t === "object";});
var isNested = value.some(function(t) {return typeof t === "object";});
if (isNested && !ts.value) {
ts.value = value;
} else if (value.length && (!ts.value || typeof ts.value !== "string")) {
Expand Down Expand Up @@ -1638,7 +1638,7 @@ var Autocomplete = function() {
if (el.parentNode)
el.parentNode.removeChild(el);
};

this.onTooltipClick = function(e) {
var a = e.target;
while (a && a != this.tooltipNode) {
Expand Down
16 changes: 8 additions & 8 deletions ext/searchbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
var div = dom.createElement("div");
div.innerHTML = html;
this.element = div.firstChild;

this.setSession = this.setSession.bind(this);

this.$init();
Expand All @@ -203,7 +203,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
editor.renderer.scroller.appendChild(this.element);
this.editor = editor;
};

this.setSession = function(e) {
this.searchRange = null;
this.$syncOptions(true);
Expand Down Expand Up @@ -354,7 +354,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
sb.$syncOptions();
}
}]);

this.setSearchRange = function(range) {
this.searchRange = range;
if (range) {
Expand Down Expand Up @@ -406,11 +406,11 @@ var SearchBox = function(editor, range, showReplaceForm) {
var value = this.searchRange
? editor.session.getTextRange(this.searchRange)
: editor.getValue();

var offset = editor.session.doc.positionToIndex(editor.selection.anchor);
if (this.searchRange)
offset -= editor.session.doc.positionToIndex(this.searchRange.start);

var last = regex.lastIndex = 0;
var m;
while ((m = regex.exec(value))) {
Expand Down Expand Up @@ -466,7 +466,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.active = false;
this.setSearchRange(null);
this.editor.off("changeSession", this.setSession);

this.element.style.display = "none";
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
this.editor.focus();
Expand All @@ -476,15 +476,15 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.editor.on("changeSession", this.setSession);
this.element.style.display = "";
this.replaceOption.checked = isReplace;

if (value)
this.searchInput.value = value;

this.searchInput.focus();
this.searchInput.select();

this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);

this.$syncOptions(true);
};

Expand Down
159 changes: 122 additions & 37 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ declare namespace AceAjax {
export interface TokenInfo {

value: string;

index?: number;

start?: number;
}

export interface Position {
Expand Down Expand Up @@ -97,6 +101,29 @@ declare namespace AceAjax {
transformAction(state: any, action: any, editor: any, session: any, param: any): any;
}

export interface OptionProvider {

/**
* Sets a Configuration Option
**/
setOption(optionName: string, optionValue: any): void;

/**
* Sets Configuration Options
**/
setOptions(keyValueTuples: any): void;

/**
* Get a Configuration Option
**/
getOption(name: string):any;

/**
* Get Configuration Options
**/
getOptions():any;
}

////////////////
/// Ace
////////////////
Expand Down Expand Up @@ -345,18 +372,47 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
insert(position: Position, text: string): any;

/**
* Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
* @param row The index of the row to insert at
* @param lines An array of strings
**/
* @deprecated Use the insertFullLines method instead.
*/
insertLines(row: number, lines: string[]): any;

/**
* Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
* @param position The position to insert at
**/
* Inserts the elements in `lines` into the document as full lines (does not merge with existing line), starting at the row index given by `row`. This method also triggers the `"change"` event.
* @param {Number} row The index of the row to insert at
* @param {Array} lines An array of strings
* @returns {Object} Contains the final row and column, like this:
* ```
* {row: endRow, column: 0}
* ```
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
* ```
* {row: row, column: 0}
* ```
*
**/
insertFullLines(row: number, lines: string[]): any;

/**
* @deprecated Use insertMergedLines(position, ['', '']) instead.
*/
insertNewLine(position: Position): any;

/**
* Inserts the elements in `lines` into the document, starting at the position index given by `row`. This method also triggers the `"change"` event.
* @param {Number} row The index of the row to insert at
* @param {Array} lines An array of strings
* @returns {Object} Contains the final row and column, like this:
* ```
* {row: endRow, column: 0}
* ```
* If `lines` is empty, this function returns an object containing the current row, and column, like this:
* ```
* {row: row, column: 0}
* ```
*
**/
insertMergedLines(row: number, lines: string[]): any;

/**
* Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
* @param position The position to insert at
Expand All @@ -379,12 +435,19 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
removeInLine(row: number, startColumn: number, endColumn: number): any;

/**
* Removes a range of full lines. This method also triggers the `'change'` event.
* @param firstRow The first row to be removed
* @param lastRow The last row to be removed
**/
* @deprecated Use the removeFullLines method instead.
*/
removeLines(firstRow: number, lastRow: number): string[];

/**
* Removes a range of full lines. This method also triggers the `"change"` event.
* @param {Number} firstRow The first row to be removed
* @param {Number} lastRow The last row to be removed
* @returns {[String]} Returns all the removed lines.
*
**/
removeFullLines(firstRow: number, lastRow: number): string[];

/**
* Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
* @param row The row to check
Expand Down Expand Up @@ -455,7 +518,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state.
* `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s.
**/
export interface IEditSession {
export interface IEditSession extends OptionProvider {

selection: Selection;

Expand Down Expand Up @@ -486,6 +549,16 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
getFoldsInRange(range: Range): any;

highlight(text: string): void;


/**
* Highlight lines from `startRow` to `EndRow`.
* @param startRow Define the start line of the highlight
* @param endRow Define the end line of the highlight
* @param clazz Set the CSS class for the marker
* @param inFront Set to `true` to establish a front marker
**/
highlightLines(startRow:number, endRow: number, clazz: string, inFront: boolean): Range;

/**
* Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`.
Expand Down Expand Up @@ -539,7 +612,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* @param row The row number to retrieve from
* @param column The column number to retrieve from
**/
getTokenAt(row: number, column: number): TokenInfo;
getTokenAt(row: number, column: number): TokenInfo|null;

/**
* Sets the undo manager.
Expand Down Expand Up @@ -769,8 +842,9 @@ export function createEditSession(text: string, mode: TextMode): IEditSe

/**
* [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft}
* @param scrollLeft The new scroll left value
**/
setScrollLeft(): void;
setScrollLeft(scrollLeft: number): void;

/**
* [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft}
Expand Down Expand Up @@ -1034,7 +1108,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
* The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen.
* Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them.
**/
export interface Editor {
export interface Editor extends OptionProvider {

on(ev: string, callback: (e: any) => any): void;

Expand Down Expand Up @@ -1073,26 +1147,6 @@ export function createEditSession(text: string, mode: TextMode): IEditSe

execCommand(command:string, args?: any): void;

/**
* Sets a Configuration Option
**/
setOption(optionName: any, optionValue: any): void;

/**
* Sets Configuration Options
**/
setOptions(keyValueTuples: any): void;

/**
* Get a Configuration Option
**/
getOption(name: any):any;

/**
* Get Configuration Options
**/
getOptions():any;

/**
* Get rid of console warning by setting this to Infinity
**/
Expand Down Expand Up @@ -1179,7 +1233,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
/**
* Returns `true` if the current `textInput` is in focus.
**/
isFocused(): void;
isFocused(): boolean;

/**
* Blurs the current `textInput`.
Expand Down Expand Up @@ -2652,7 +2706,7 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
/**
* The class that is responsible for drawing everything you see on the screen!
**/
export interface VirtualRenderer {
export interface VirtualRenderer extends OptionProvider {

scroller: any;

Expand Down Expand Up @@ -2996,6 +3050,37 @@ export function createEditSession(text: string, mode: TextMode): IEditSe
**/
new(container: HTMLElement, theme?: string): VirtualRenderer;
}

export interface Completer {
/**
* Provides possible completion results asynchronously using the given callback.
* @param editor The editor to associate with
* @param session The `EditSession` to refer to
* @param pos An object containing the row and column
* @param prefix The prefixing string before the current position
* @param callback Function to provide the results or error
*/
getCompletions: (editor: Editor, session: IEditSession, pos: Position, prefix: string, callback: CompletionCallback) => void;

/**
* Provides tooltip information about a completion result.
* @param item The completion result
*/
getDocTooltip?: (item: Completion) => void;
}

export interface Completion {
value: string;
meta: string;
type?: string;
caption?: string;
snippet?: any;
score?: number;
exactMatch?: number;
docHTML?: string;
}

export type CompletionCallback = (error: Error, results: Completion[]) => void;
}

export = AceAjax;
Loading