ace.d.ts 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. /// <reference path="./ace-modules.d.ts" />
  2. export namespace Ace {
  3. export type NewLineMode = 'auto' | 'unix' | 'windows';
  4. export interface Anchor extends EventEmitter {
  5. getPosition(): Point;
  6. getDocument(): Document;
  7. setPosition(row: number, column: number, noClip?: boolean): void;
  8. detach(): void;
  9. attach(doc: Document): void;
  10. }
  11. export interface Document extends EventEmitter {
  12. setValue(text: string): void;
  13. getValue(): string;
  14. createAnchor(row: number, column: number): Anchor;
  15. getNewLineCharacter(): string;
  16. setNewLineMode(newLineMode: NewLineMode): void;
  17. getNewLineMode(): NewLineMode;
  18. isNewLine(text: string): boolean;
  19. getLine(row: number): string;
  20. getLines(firstRow: number, lastRow: number): string[];
  21. getAllLines(): string[];
  22. getTextRange(range: Range): string;
  23. getLinesForRange(range: Range): string[];
  24. insert(position: Point, text: string): Point;
  25. insertInLine(position: Point, text: string): Point;
  26. clippedPos(row: number, column: number): Point;
  27. clonePos(pos: Point): Point;
  28. pos(row: number, column: number): Point;
  29. insertFullLines(row: number, lines: string[]): void;
  30. insertMergedLines(position: Point, lines: string[]): Point;
  31. remove(range: Range): Point;
  32. removeInLine(row: number, startColumn: number, endColumn: number): Point;
  33. removeFullLines(firstRow: number, lastRow: number): string[];
  34. removeNewLine(row: number): void;
  35. replace(range: Range, text: string): Point;
  36. applyDeltas(deltas: Delta[]): void;
  37. revertDeltas(deltas: Delta[]): void;
  38. applyDelta(delta: Delta, doNotValidate?: boolean): void;
  39. revertDelta(delta: Delta): void;
  40. indexToPosition(index: number, startRow: number): Point;
  41. positionToIndex(pos: Point, startRow?: number): number;
  42. }
  43. export interface FoldLine {
  44. folds: Fold[];
  45. range: Range;
  46. start: Point;
  47. end: Point;
  48. shiftRow(shift: number): void;
  49. addFold(fold: Fold): void;
  50. containsRow(row: number): boolean;
  51. walk(callback: Function, endRow?: number, endColumn?: number): void;
  52. getNextFoldTo(row: number, column: number): null | { fold: Fold, kind: string };
  53. addRemoveChars(row: number, column: number, len: number): void;
  54. split(row: number, column: number): FoldLine;
  55. merge(foldLineNext: FoldLine): void;
  56. idxToPosition(idx: number): Point;
  57. }
  58. export interface Fold {
  59. range: Range;
  60. start: Point;
  61. end: Point;
  62. foldLine?: FoldLine;
  63. sameRow: boolean;
  64. subFolds: Fold[];
  65. setFoldLine(foldLine: FoldLine): void;
  66. clone(): Fold;
  67. addSubFold(fold: Fold): Fold;
  68. restoreRange(range: Range): void;
  69. }
  70. interface Folding {
  71. getFoldAt(row: number, column: number, side: number): Fold;
  72. getFoldsInRange(range: Range): Fold[];
  73. getFoldsInRangeList(ranges: Range[]): Fold[];
  74. getAllFolds(): Fold[];
  75. getFoldStringAt(row: number,
  76. column: number,
  77. trim?: number,
  78. foldLine?: FoldLine): string | null;
  79. getFoldLine(docRow: number, startFoldLine?: FoldLine): FoldLine | null;
  80. getNextFoldLine(docRow: number, startFoldLine?: FoldLine): FoldLine | null;
  81. getFoldedRowCount(first: number, last: number): number;
  82. addFold(placeholder: string | Fold, range?: Range): Fold;
  83. addFolds(folds: Fold[]): void;
  84. removeFold(fold: Fold): void;
  85. removeFolds(folds: Fold[]): void;
  86. expandFold(fold: Fold): void;
  87. expandFolds(folds: Fold[]): void;
  88. unfold(location: null | number | Point | Range,
  89. expandInner?: boolean): Fold[] | undefined;
  90. isRowFolded(docRow: number, startFoldRow?: FoldLine): boolean;
  91. getFoldRowEnd(docRow: number, startFoldRow?: FoldLine): number;
  92. getFoldRowStart(docRow: number, startFoldRow?: FoldLine): number;
  93. getFoldDisplayLine(foldLine: FoldLine,
  94. endRow: number | null,
  95. endColumn: number | null,
  96. startRow: number | null,
  97. startColumn: number | null): string;
  98. getDisplayLine(row: number,
  99. endColumn: number | null,
  100. startRow: number | null,
  101. startColumn: number | null): string;
  102. toggleFold(tryToUnfold?: boolean): void;
  103. getCommentFoldRange(row: number,
  104. column: number,
  105. dir: number): Range | undefined;
  106. foldAll(startRow?: number, endRow?: number, depth?: number): void;
  107. setFoldStyle(style: string): void;
  108. getParentFoldRangeData(row: number, ignoreCurrent?: boolean): {
  109. range?: Range,
  110. firstRange: Range
  111. };
  112. toggleFoldWidget(toggleParent?: boolean): void;
  113. updateFoldWidgets(delta: Delta): void;
  114. }
  115. export interface Range {
  116. start: Point;
  117. end: Point;
  118. isEqual(range: Range): boolean;
  119. toString(): string;
  120. contains(row: number, column: number): boolean;
  121. compareRange(range: Range): number;
  122. comparePoint(p: Point): number;
  123. containsRange(range: Range): boolean;
  124. intersects(range: Range): boolean;
  125. isEnd(row: number, column: number): boolean;
  126. isStart(row: number, column: number): boolean;
  127. setStart(row: number, column: number): void;
  128. setEnd(row: number, column: number): void;
  129. inside(row: number, column: number): boolean;
  130. insideStart(row: number, column: number): boolean;
  131. insideEnd(row: number, column: number): boolean;
  132. compare(row: number, column: number): number;
  133. compareStart(row: number, column: number): number;
  134. compareEnd(row: number, column: number): number;
  135. compareInside(row: number, column: number): number;
  136. clipRows(firstRow: number, lastRow: number): Range;
  137. extend(row: number, column: number): Range;
  138. isEmpty(): boolean;
  139. isMultiLine(): boolean;
  140. clone(): Range;
  141. collapseRows(): Range;
  142. toScreenRange(session: EditSession): Range;
  143. moveBy(row: number, column: number): void;
  144. }
  145. export interface EditSessionOptions {
  146. wrap: "off" | "free" | "printmargin" | boolean | number;
  147. wrapMethod: 'code' | 'text' | 'auto';
  148. indentedSoftWrap: boolean;
  149. firstLineNumber: number;
  150. useWorker: boolean;
  151. useSoftTabs: boolean;
  152. tabSize: number;
  153. navigateWithinSoftTabs: boolean;
  154. foldStyle: 'markbegin' | 'markbeginend' | 'manual';
  155. overwrite: boolean;
  156. newLineMode: NewLineMode;
  157. mode: string;
  158. }
  159. export interface VirtualRendererOptions {
  160. animatedScroll: boolean;
  161. showInvisibles: boolean;
  162. showPrintMargin: boolean;
  163. printMarginColumn: number;
  164. printMargin: boolean | number;
  165. showGutter: boolean;
  166. fadeFoldWidgets: boolean;
  167. showFoldWidgets: boolean;
  168. showLineNumbers: boolean;
  169. displayIndentGuides: boolean;
  170. highlightGutterLine: boolean;
  171. hScrollBarAlwaysVisible: boolean;
  172. vScrollBarAlwaysVisible: boolean;
  173. fontSize: number;
  174. fontFamily: string;
  175. maxLines: number;
  176. minLines: number;
  177. scrollPastEnd: boolean;
  178. fixedWidthGutter: boolean;
  179. theme: string;
  180. hasCssTransforms: boolean;
  181. maxPixelHeight: number;
  182. }
  183. export interface MouseHandlerOptions {
  184. scrollSpeed: number;
  185. dragDelay: number;
  186. dragEnabled: boolean;
  187. focusTimeout: number;
  188. tooltipFollowsMouse: boolean;
  189. }
  190. export interface EditorOptions extends EditSessionOptions,
  191. MouseHandlerOptions,
  192. VirtualRendererOptions {
  193. selectionStyle: string;
  194. highlightActiveLine: boolean;
  195. highlightSelectedWord: boolean;
  196. readOnly: boolean;
  197. copyWithEmptySelection: boolean;
  198. cursorStyle: 'ace' | 'slim' | 'smooth' | 'wide';
  199. mergeUndoDeltas: true | false | 'always';
  200. behavioursEnabled: boolean;
  201. wrapBehavioursEnabled: boolean;
  202. enableAutoIndent: boolean;
  203. autoScrollEditorIntoView: boolean;
  204. keyboardHandler: string;
  205. placeholder: string;
  206. value: string;
  207. session: EditSession;
  208. }
  209. export interface SearchOptions {
  210. needle: string | RegExp;
  211. preventScroll: boolean;
  212. backwards: boolean;
  213. start: Range;
  214. skipCurrent: boolean;
  215. range: Range;
  216. preserveCase: boolean;
  217. regExp: RegExp;
  218. wholeWord: string;
  219. caseSensitive: boolean;
  220. wrap: boolean;
  221. }
  222. export interface EventEmitter {
  223. once(name: string, callback: Function): void;
  224. setDefaultHandler(name: string, callback: Function): void;
  225. removeDefaultHandler(name: string, callback: Function): void;
  226. on(name: string, callback: Function, capturing?: boolean): void;
  227. addEventListener(name: string, callback: Function, capturing?: boolean): void;
  228. off(name: string, callback: Function): void;
  229. removeListener(name: string, callback: Function): void;
  230. removeEventListener(name: string, callback: Function): void;
  231. }
  232. export interface Point {
  233. row: number;
  234. column: number;
  235. }
  236. export interface Delta {
  237. action: 'insert' | 'remove';
  238. start: Point;
  239. end: Point;
  240. lines: string[];
  241. }
  242. export interface Annotation {
  243. row?: number;
  244. column?: number;
  245. text: string;
  246. type: string;
  247. }
  248. export interface Command {
  249. name?: string;
  250. bindKey?: string | { mac?: string, win?: string };
  251. readOnly?: boolean;
  252. exec: (editor: Editor, args?: any) => void;
  253. }
  254. export type CommandLike = Command | ((editor: Editor) => void);
  255. export interface KeyboardHandler {
  256. handleKeyboard: Function;
  257. }
  258. export interface MarkerLike {
  259. range: Range;
  260. type: string;
  261. renderer?: MarkerRenderer;
  262. clazz: string;
  263. inFront: boolean;
  264. id: number;
  265. update?: (html: string[],
  266. // TODO maybe define Marker class
  267. marker: any,
  268. session: EditSession,
  269. config: any) => void;
  270. }
  271. export type MarkerRenderer = (html: string[],
  272. range: Range,
  273. left: number,
  274. top: number,
  275. config: any) => void;
  276. export interface Token {
  277. type: string;
  278. value: string;
  279. index?: number;
  280. start?: number;
  281. }
  282. export interface Completion {
  283. value: string;
  284. score: number;
  285. meta?: string;
  286. name?: string;
  287. caption?: string;
  288. }
  289. export interface Tokenizer {
  290. removeCapturingGroups(src: string): string;
  291. createSplitterRegexp(src: string, flag?: string): RegExp;
  292. getLineTokens(line: string, startState: string | string[]): Token[];
  293. }
  294. interface TokenIterator {
  295. getCurrentToken(): Token;
  296. getCurrentTokenColumn(): number;
  297. getCurrentTokenRow(): number;
  298. getCurrentTokenPosition(): Point;
  299. getCurrentTokenRange(): Range;
  300. stepBackward(): Token;
  301. stepForward(): Token;
  302. }
  303. export interface SyntaxMode {
  304. getTokenizer(): Tokenizer;
  305. toggleCommentLines(state: any,
  306. session: EditSession,
  307. startRow: number,
  308. endRow: number): void;
  309. toggleBlockComment(state: any,
  310. session: EditSession,
  311. range: Range,
  312. cursor: Point): void;
  313. getNextLineIndent(state: any, line: string, tab: string): string;
  314. checkOutdent(state: any, line: string, input: string): boolean;
  315. autoOutdent(state: any, doc: Document, row: number): void;
  316. // TODO implement WorkerClient types
  317. createWorker(session: EditSession): any;
  318. createModeDelegates(mapping: { [key: string]: string }): void;
  319. transformAction(state: string,
  320. action: string,
  321. editor: Editor,
  322. session: EditSession,
  323. text: string): any;
  324. getKeywords(append?: boolean): Array<string | RegExp>;
  325. getCompletions(state: string,
  326. session: EditSession,
  327. pos: Point,
  328. prefix: string): Completion[];
  329. }
  330. export interface Config {
  331. get(key: string): any;
  332. set(key: string, value: any): void;
  333. all(): { [key: string]: any };
  334. moduleUrl(name: string, component?: string): string;
  335. setModuleUrl(name: string, subst: string): string;
  336. loadModule(moduleName: string | [string, string],
  337. onLoad: (module: any) => void): void;
  338. init(packaged: any): any;
  339. defineOptions(obj: any, path: string, options: { [key: string]: any }): Config;
  340. resetOptions(obj: any): void;
  341. setDefaultValue(path: string, name: string, value: any): void;
  342. setDefaultValues(path: string, optionHash: { [key: string]: any }): void;
  343. }
  344. export interface OptionsProvider {
  345. setOptions(optList: { [key: string]: any }): void;
  346. getOptions(optionNames?: string[] | { [key: string]: any }): { [key: string]: any };
  347. setOption(name: string, value: any): void;
  348. getOption(name: string): any;
  349. }
  350. export interface UndoManager {
  351. addSession(session: EditSession): void;
  352. add(delta: Delta, allowMerge: boolean, session: EditSession): void;
  353. addSelection(selection: string, rev?: number): void;
  354. startNewGroup(): void;
  355. markIgnored(from: number, to?: number): void;
  356. getSelection(rev: number, after?: boolean): { value: string, rev: number };
  357. getRevision(): number;
  358. getDeltas(from: number, to?: number): Delta[];
  359. undo(session: EditSession, dontSelect?: boolean): void;
  360. redo(session: EditSession, dontSelect?: boolean): void;
  361. reset(): void;
  362. canUndo(): boolean;
  363. canRedo(): boolean;
  364. bookmark(rev?: number): void;
  365. isAtBookmark(): boolean;
  366. }
  367. export interface EditSession extends EventEmitter, OptionsProvider, Folding {
  368. selection: Selection;
  369. on(name: 'changeFold',
  370. callback: (obj: { data: Fold, action: string }) => void): Function;
  371. on(name: 'changeScrollLeft', callback: (scrollLeft: number) => void): Function;
  372. on(name: 'changeScrollTop', callback: (scrollTop: number) => void): Function;
  373. on(name: 'tokenizerUpdate',
  374. callback: (obj: { data: { first: number, last: number } }) => void): Function;
  375. setOption<T extends keyof EditSessionOptions>(name: T, value: EditSessionOptions[T]): void;
  376. getOption<T extends keyof EditSessionOptions>(name: T): EditSessionOptions[T];
  377. setDocument(doc: Document): void;
  378. getDocument(): Document;
  379. resetCaches(): void;
  380. setValue(text: string): void;
  381. getValue(): string;
  382. getSelection(): Selection;
  383. getState(row: number): string;
  384. getTokens(row: number): Token[];
  385. getTokenAt(row: number, column: number): Token | null;
  386. setUndoManager(undoManager: UndoManager): void;
  387. markUndoGroup(): void;
  388. getUndoManager(): UndoManager;
  389. getTabString(): string;
  390. setUseSoftTabs(val: boolean): void;
  391. getUseSoftTabs(): boolean;
  392. setTabSize(tabSize: number): void;
  393. getTabSize(): number;
  394. isTabStop(position: Point): boolean;
  395. setNavigateWithinSoftTabs(navigateWithinSoftTabs: boolean): void;
  396. getNavigateWithinSoftTabs(): boolean;
  397. setOverwrite(overwrite: boolean): void;
  398. getOverwrite(): boolean;
  399. toggleOverwrite(): void;
  400. addGutterDecoration(row: number, className: string): void;
  401. removeGutterDecoration(row: number, className: string): void;
  402. getBreakpoints(): string[];
  403. setBreakpoints(rows: number[]): void;
  404. clearBreakpoints(): void;
  405. setBreakpoint(row: number, className: string): void;
  406. clearBreakpoint(row: number): void;
  407. addMarker(range: Range,
  408. className: string,
  409. type: "fullLine" | "screenLine" | "text" | MarkerRenderer,
  410. inFront?: boolean): number;
  411. addDynamicMarker(marker: MarkerLike, inFront: boolean): MarkerLike;
  412. removeMarker(markerId: number): void;
  413. getMarkers(inFront?: boolean): MarkerLike[];
  414. highlight(re: RegExp): void;
  415. highlightLines(startRow: number,
  416. endRow: number,
  417. className: string,
  418. inFront?: boolean): Range;
  419. setAnnotations(annotations: Annotation[]): void;
  420. getAnnotations(): Annotation[];
  421. clearAnnotations(): void;
  422. getWordRange(row: number, column: number): Range;
  423. getAWordRange(row: number, column: number): Range;
  424. setNewLineMode(newLineMode: NewLineMode): void;
  425. getNewLineMode(): NewLineMode;
  426. setUseWorker(useWorker: boolean): void;
  427. getUseWorker(): boolean;
  428. setMode(mode: string | SyntaxMode, callback?: () => void): void;
  429. getMode(): SyntaxMode;
  430. setScrollTop(scrollTop: number): void;
  431. getScrollTop(): number;
  432. setScrollLeft(scrollLeft: number): void;
  433. getScrollLeft(): number;
  434. getScreenWidth(): number;
  435. getLineWidgetMaxWidth(): number;
  436. getLine(row: number): string;
  437. getLines(firstRow: number, lastRow: number): string[];
  438. getLength(): number;
  439. getTextRange(range: Range): string;
  440. insert(position: Point, text: string): void;
  441. remove(range: Range): void;
  442. removeFullLines(firstRow: number, lastRow: number): void;
  443. undoChanges(deltas: Delta[], dontSelect?: boolean): void;
  444. redoChanges(deltas: Delta[], dontSelect?: boolean): void;
  445. setUndoSelect(enable: boolean): void;
  446. replace(range: Range, text: string): void;
  447. moveText(fromRange: Range, toPosition: Point, copy?: boolean): void;
  448. indentRows(startRow: number, endRow: number, indentString: string): void;
  449. outdentRows(range: Range): void;
  450. moveLinesUp(firstRow: number, lastRow: number): void;
  451. moveLinesDown(firstRow: number, lastRow: number): void;
  452. duplicateLines(firstRow: number, lastRow: number): void;
  453. setUseWrapMode(useWrapMode: boolean): void;
  454. getUseWrapMode(): boolean;
  455. setWrapLimitRange(min: number, max: number): void;
  456. adjustWrapLimit(desiredLimit: number): boolean;
  457. getWrapLimit(): number;
  458. setWrapLimit(limit: number): void;
  459. getWrapLimitRange(): { min: number, max: number };
  460. getRowLineCount(row: number): number;
  461. getRowWrapIndent(screenRow: number): number;
  462. getScreenLastRowColumn(screenRow: number): number;
  463. getDocumentLastRowColumn(docRow: number, docColumn: number): number;
  464. getdocumentLastRowColumnPosition(docRow: number, docColumn: number): Point;
  465. getRowSplitData(row: number): string | undefined;
  466. getScreenTabSize(screenColumn: number): number;
  467. screenToDocumentRow(screenRow: number, screenColumn: number): number;
  468. screenToDocumentColumn(screenRow: number, screenColumn: number): number;
  469. screenToDocumentPosition(screenRow: number,
  470. screenColumn: number,
  471. offsetX?: number): Point;
  472. documentToScreenPosition(docRow: number, docColumn: number): Point;
  473. documentToScreenPosition(position: Point): Point;
  474. documentToScreenColumn(row: number, docColumn: number): number;
  475. documentToScreenRow(docRow: number, docColumn: number): number;
  476. getScreenLength(): number;
  477. destroy(): void;
  478. }
  479. export interface KeyBinding {
  480. setDefaultHandler(handler: KeyboardHandler): void;
  481. setKeyboardHandler(handler: KeyboardHandler): void;
  482. addKeyboardHandler(handler: KeyboardHandler, pos: number): void;
  483. removeKeyboardHandler(handler: KeyboardHandler): boolean;
  484. getKeyboardHandler(): KeyboardHandler;
  485. getStatusText(): string;
  486. }
  487. interface CommandMap {
  488. [name: string]: Command;
  489. }
  490. type execEventHandler = (obj: {
  491. editor: Editor,
  492. command: Command,
  493. args: any[]
  494. }) => void;
  495. export interface CommandManager extends EventEmitter {
  496. byName: CommandMap,
  497. commands: CommandMap,
  498. on(name: 'exec', callback: execEventHandler): Function;
  499. on(name: 'afterExec', callback: execEventHandler): Function;
  500. once(name: string, callback: Function): void;
  501. setDefaultHandler(name: string, callback: Function): void;
  502. removeDefaultHandler(name: string, callback: Function): void;
  503. on(name: string, callback: Function, capturing?: boolean): Function;
  504. addEventListener(name: string, callback: Function, capturing?: boolean): void;
  505. off(name: string, callback: Function): void;
  506. removeListener(name: string, callback: Function): void;
  507. removeEventListener(name: string, callback: Function): void;
  508. exec(command: string, editor: Editor, args: any): boolean;
  509. toggleRecording(editor: Editor): void;
  510. replay(editor: Editor): void;
  511. addCommand(command: Command): void;
  512. removeCommand(command: Command | string, keepCommand?: boolean): void;
  513. bindKey(key: string | { mac?: string, win?: string },
  514. command: CommandLike,
  515. position?: number): void;
  516. }
  517. export interface VirtualRenderer extends OptionsProvider, EventEmitter {
  518. container: HTMLElement;
  519. setOption<T extends keyof VirtualRendererOptions>(name: T, value: VirtualRendererOptions[T]): void;
  520. getOption<T extends keyof VirtualRendererOptions>(name: T): VirtualRendererOptions[T];
  521. setSession(session: EditSession): void;
  522. updateLines(firstRow: number, lastRow: number, force?: boolean): void;
  523. updateText(): void;
  524. updateFull(force?: boolean): void;
  525. updateFontSize(): void;
  526. adjustWrapLimit(): boolean;
  527. setAnimatedScroll(shouldAnimate: boolean): void;
  528. getAnimatedScroll(): boolean;
  529. setShowInvisibles(showInvisibles: boolean): void;
  530. getShowInvisibles(): boolean;
  531. setDisplayIndentGuides(display: boolean): void;
  532. getDisplayIndentGuides(): boolean;
  533. setShowPrintMargin(showPrintMargin: boolean): void;
  534. getShowPrintMargin(): boolean;
  535. setPrintMarginColumn(showPrintMargin: boolean): void;
  536. getPrintMarginColumn(): boolean;
  537. setShowGutter(show: boolean): void;
  538. getShowGutter(): boolean;
  539. setFadeFoldWidgets(show: boolean): void;
  540. getFadeFoldWidgets(): boolean;
  541. setHighlightGutterLine(shouldHighlight: boolean): void;
  542. getHighlightGutterLine(): boolean;
  543. getContainerElement(): HTMLElement;
  544. getMouseEventTarget(): HTMLElement;
  545. getTextAreaContainer(): HTMLElement;
  546. getFirstVisibleRow(): number;
  547. getFirstFullyVisibleRow(): number;
  548. getLastFullyVisibleRow(): number;
  549. getLastVisibleRow(): number;
  550. setPadding(padding: number): void;
  551. setScrollMargin(top: number,
  552. bottom: number,
  553. left: number,
  554. right: number): void;
  555. setHScrollBarAlwaysVisible(alwaysVisible: boolean): void;
  556. getHScrollBarAlwaysVisible(): boolean;
  557. setVScrollBarAlwaysVisible(alwaysVisible: boolean): void;
  558. getVScrollBarAlwaysVisible(): boolean;
  559. freeze(): void;
  560. unfreeze(): void;
  561. updateFrontMarkers(): void;
  562. updateBackMarkers(): void;
  563. updateBreakpoints(): void;
  564. setAnnotations(annotations: Annotation[]): void;
  565. updateCursor(): void;
  566. hideCursor(): void;
  567. showCursor(): void;
  568. scrollSelectionIntoView(anchor: Point,
  569. lead: Point,
  570. offset?: number): void;
  571. scrollCursorIntoView(cursor: Point, offset?: number): void;
  572. getScrollTop(): number;
  573. getScrollLeft(): number;
  574. getScrollTopRow(): number;
  575. getScrollBottomRow(): number;
  576. scrollToRow(row: number): void;
  577. alignCursor(cursor: Point | number, alignment: number): number;
  578. scrollToLine(line: number,
  579. center: boolean,
  580. animate: boolean,
  581. callback: () => void): void;
  582. animateScrolling(fromValue: number, callback: () => void): void;
  583. scrollToY(scrollTop: number): void;
  584. scrollToX(scrollLeft: number): void;
  585. scrollTo(x: number, y: number): void;
  586. scrollBy(deltaX: number, deltaY: number): void;
  587. isScrollableBy(deltaX: number, deltaY: number): boolean;
  588. textToScreenCoordinates(row: number, column: number): { pageX: number, pageY: number };
  589. visualizeFocus(): void;
  590. visualizeBlur(): void;
  591. showComposition(position: number): void;
  592. setCompositionText(text: string): void;
  593. hideComposition(): void;
  594. setTheme(theme: string, callback?: () => void): void;
  595. getTheme(): string;
  596. setStyle(style: string, include?: boolean): void;
  597. unsetStyle(style: string): void;
  598. setCursorStyle(style: string): void;
  599. setMouseCursor(cursorStyle: string): void;
  600. attachToShadowRoot(): void;
  601. destroy(): void;
  602. }
  603. export interface Selection extends EventEmitter {
  604. moveCursorWordLeft(): void;
  605. moveCursorWordRight(): void;
  606. fromOrientedRange(range: Range): void;
  607. setSelectionRange(match: any): void;
  608. getAllRanges(): Range[];
  609. addRange(range: Range): void;
  610. isEmpty(): boolean;
  611. isMultiLine(): boolean;
  612. setCursor(row: number, column: number): void;
  613. setAnchor(row: number, column: number): void;
  614. getAnchor(): Point;
  615. getCursor(): Point;
  616. isBackwards(): boolean;
  617. getRange(): Range;
  618. clearSelection(): void;
  619. selectAll(): void;
  620. setRange(range: Range, reverse?: boolean): void;
  621. selectTo(row: number, column: number): void;
  622. selectToPosition(pos: any): void;
  623. selectUp(): void;
  624. selectDown(): void;
  625. selectRight(): void;
  626. selectLeft(): void;
  627. selectLineStart(): void;
  628. selectLineEnd(): void;
  629. selectFileEnd(): void;
  630. selectFileStart(): void;
  631. selectWordRight(): void;
  632. selectWordLeft(): void;
  633. getWordRange(): void;
  634. selectWord(): void;
  635. selectAWord(): void;
  636. selectLine(): void;
  637. moveCursorUp(): void;
  638. moveCursorDown(): void;
  639. moveCursorLeft(): void;
  640. moveCursorRight(): void;
  641. moveCursorLineStart(): void;
  642. moveCursorLineEnd(): void;
  643. moveCursorFileEnd(): void;
  644. moveCursorFileStart(): void;
  645. moveCursorLongWordRight(): void;
  646. moveCursorLongWordLeft(): void;
  647. moveCursorBy(rows: number, chars: number): void;
  648. moveCursorToPosition(position: any): void;
  649. moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean): void;
  650. moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean): void;
  651. toJSON(): SavedSelection | SavedSelection[];
  652. fromJSON(selection: SavedSelection | SavedSelection[]): void;
  653. }
  654. interface SavedSelection {
  655. start: Point;
  656. end: Point;
  657. isBackwards: boolean;
  658. }
  659. var Selection: {
  660. new(session: EditSession): Selection;
  661. }
  662. export interface Editor extends OptionsProvider, EventEmitter {
  663. container: HTMLElement;
  664. renderer: VirtualRenderer;
  665. id: string;
  666. commands: CommandManager;
  667. keyBinding: KeyBinding;
  668. session: EditSession;
  669. selection: Selection;
  670. on(name: 'blur', callback: (e: Event) => void): Function;
  671. on(name: 'input', callback: () => void): Function;
  672. on(name: 'change', callback: (delta: Delta) => void): Function;
  673. on(name: 'changeSelectionStyle', callback: (obj: { data: string }) => void): Function;
  674. on(name: 'changeSession',
  675. callback: (obj: { session: EditSession, oldSession: EditSession }) => void
  676. ): Function;
  677. on(name: 'copy', callback: (obj: { text: string }) => void): Function;
  678. on(name: 'focus', callback: (e: Event) => void): Function;
  679. on(name: 'paste', callback: (obj: { text: string }) => void): Function;
  680. setOption<T extends keyof EditorOptions>(name: T, value: EditorOptions[T]): void;
  681. getOption<T extends keyof EditorOptions>(name: T): EditorOptions[T];
  682. setKeyboardHandler(keyboardHandler: string, callback?: () => void): void;
  683. getKeyboardHandler(): string;
  684. setSession(session: EditSession): void;
  685. getSession(): EditSession;
  686. setValue(val: string, cursorPos?: number): string;
  687. getValue(): string;
  688. getSelection(): Selection;
  689. resize(force?: boolean): void;
  690. setTheme(theme: string, callback?: () => void): void;
  691. getTheme(): string;
  692. setStyle(style: string): void;
  693. unsetStyle(style: string): void;
  694. getFontSize(): string;
  695. setFontSize(size: string): void;
  696. focus(): void;
  697. isFocused(): boolean;
  698. blur(): void;
  699. getSelectedText(): string;
  700. getCopyText(): string;
  701. execCommand(command: string | string[], args?: any): boolean;
  702. insert(text: string, pasted?: boolean): void;
  703. setOverwrite(overwrite: boolean): void;
  704. getOverwrite(): boolean;
  705. toggleOverwrite(): void;
  706. setScrollSpeed(speed: number): void;
  707. getScrollSpeed(): number;
  708. setDragDelay(dragDelay: number): void;
  709. getDragDelay(): number;
  710. setSelectionStyle(val: string): void;
  711. getSelectionStyle(): string;
  712. setHighlightActiveLine(shouldHighlight: boolean): void;
  713. getHighlightActiveLine(): boolean;
  714. setHighlightGutterLine(shouldHighlight: boolean): void;
  715. getHighlightGutterLine(): boolean;
  716. setHighlightSelectedWord(shouldHighlight: boolean): void;
  717. getHighlightSelectedWord(): boolean;
  718. setAnimatedScroll(shouldAnimate: boolean): void;
  719. getAnimatedScroll(): boolean;
  720. setShowInvisibles(showInvisibles: boolean): void;
  721. getShowInvisibles(): boolean;
  722. setDisplayIndentGuides(display: boolean): void;
  723. getDisplayIndentGuides(): boolean;
  724. setShowPrintMargin(showPrintMargin: boolean): void;
  725. getShowPrintMargin(): boolean;
  726. setPrintMarginColumn(showPrintMargin: number): void;
  727. getPrintMarginColumn(): number;
  728. setReadOnly(readOnly: boolean): void;
  729. getReadOnly(): boolean;
  730. setBehavioursEnabled(enabled: boolean): void;
  731. getBehavioursEnabled(): boolean;
  732. setWrapBehavioursEnabled(enabled: boolean): void;
  733. getWrapBehavioursEnabled(): boolean;
  734. setShowFoldWidgets(show: boolean): void;
  735. getShowFoldWidgets(): boolean;
  736. setFadeFoldWidgets(fade: boolean): void;
  737. getFadeFoldWidgets(): boolean;
  738. remove(dir?: 'left' | 'right'): void;
  739. removeWordRight(): void;
  740. removeWordLeft(): void;
  741. removeLineToEnd(): void;
  742. splitLine(): void;
  743. transposeLetters(): void;
  744. toLowerCase(): void;
  745. toUpperCase(): void;
  746. indent(): void;
  747. blockIndent(): void;
  748. blockOutdent(): void;
  749. sortLines(): void;
  750. toggleCommentLines(): void;
  751. toggleBlockComment(): void;
  752. modifyNumber(amount: number): void;
  753. removeLines(): void;
  754. duplicateSelection(): void;
  755. moveLinesDown(): void;
  756. moveLinesUp(): void;
  757. moveText(range: Range, toPosition: Point, copy?: boolean): Range;
  758. copyLinesUp(): void;
  759. copyLinesDown(): void;
  760. getFirstVisibleRow(): number;
  761. getLastVisibleRow(): number;
  762. isRowVisible(row: number): boolean;
  763. isRowFullyVisible(row: number): boolean;
  764. selectPageDown(): void;
  765. selectPageUp(): void;
  766. gotoPageDown(): void;
  767. gotoPageUp(): void;
  768. scrollPageDown(): void;
  769. scrollPageUp(): void;
  770. scrollToRow(row: number): void;
  771. scrollToLine(line: number, center: boolean, animate: boolean, callback: () => void): void;
  772. centerSelection(): void;
  773. getCursorPosition(): Point;
  774. getCursorPositionScreen(): Point;
  775. getSelectionRange(): Range;
  776. selectAll(): void;
  777. clearSelection(): void;
  778. moveCursorTo(row: number, column: number): void;
  779. moveCursorToPosition(pos: Point): void;
  780. jumpToMatching(select: boolean, expand: boolean): void;
  781. gotoLine(lineNumber: number, column: number, animate: boolean): void;
  782. navigateTo(row: number, column: number): void;
  783. navigateUp(): void;
  784. navigateDown(): void;
  785. navigateLeft(): void;
  786. navigateRight(): void;
  787. navigateLineStart(): void;
  788. navigateLineEnd(): void;
  789. navigateFileEnd(): void;
  790. navigateFileStart(): void;
  791. navigateWordRight(): void;
  792. navigateWordLeft(): void;
  793. replace(replacement: string, options?: Partial<SearchOptions>): number;
  794. replaceAll(replacement: string, options?: Partial<SearchOptions>): number;
  795. getLastSearchOptions(): Partial<SearchOptions>;
  796. find(needle: string, options?: Partial<SearchOptions>, animate?: boolean): void;
  797. findNext(options?: Partial<SearchOptions>, animate?: boolean): void;
  798. findPrevious(options?: Partial<SearchOptions>, animate?: boolean): void;
  799. undo(): void;
  800. redo(): void;
  801. destroy(): void;
  802. setAutoScrollEditorIntoView(enable: boolean): void;
  803. completers: Completer[];
  804. }
  805. type CompleterCallback = (error: any, completions: Completion[]) => void;
  806. interface Completer {
  807. getCompletions(editor: Editor,
  808. session: EditSession,
  809. position: Point,
  810. prefix: string,
  811. callback: CompleterCallback): void;
  812. }
  813. }
  814. export const version: string;
  815. export const config: Ace.Config;
  816. export function require(name: string): any;
  817. export function edit(el: Element | string, options?: Partial<Ace.EditorOptions>): Ace.Editor;
  818. export function createEditSession(text: Ace.Document | string, mode: Ace.SyntaxMode): Ace.EditSession;
  819. export const VirtualRenderer: {
  820. new(container: HTMLElement, theme?: string): Ace.VirtualRenderer;
  821. };
  822. export const EditSession: {
  823. new(text: string | Document, mode?: Ace.SyntaxMode): Ace.EditSession;
  824. };
  825. export const UndoManager: {
  826. new(): Ace.UndoManager;
  827. };
  828. export const Range: {
  829. new(startRow: number, startColumn: number, endRow: number, endColumn: number): Ace.Range;
  830. fromPoints(start: Ace.Point, end: Ace.Point): Ace.Range;
  831. comparePoints(p1: Ace.Point, p2: Ace.Point): number;
  832. };