ace.d.ts 95 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984
  1. // Type definitions for Ace Ajax.org Cloud9 Editor
  2. // Project: http://ace.ajax.org/
  3. // Definitions by: Diullei Gomes <https://github.com/Diullei>
  4. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  5. declare module AceAjax {
  6. export interface Delta {
  7. action: string;
  8. range: Range;
  9. text: string;
  10. lines: string[];
  11. }
  12. export interface EditorCommand {
  13. name:string;
  14. bindKey:any;
  15. exec: Function;
  16. readOnly?: boolean;
  17. }
  18. export interface CommandManager {
  19. byName: any;
  20. commands: any;
  21. platform: string;
  22. addCommands(commands:EditorCommand[]): void;
  23. addCommand(command:EditorCommand): void;
  24. exec(name: string, editor: Editor, args: any): void;
  25. }
  26. export interface Annotation {
  27. row: number;
  28. column: number;
  29. text: string;
  30. type: string;
  31. }
  32. export interface TokenInfo {
  33. value: string;
  34. }
  35. export interface Position {
  36. row: number;
  37. column: number;
  38. }
  39. export interface KeyBinding {
  40. setDefaultHandler(kb: any): void;
  41. setKeyboardHandler(kb: any): void;
  42. addKeyboardHandler(kb: any, pos: any): void;
  43. removeKeyboardHandler(kb: any): boolean;
  44. getKeyboardHandler(): any;
  45. onCommandKey(e: any, hashId: any, keyCode: any): void;
  46. onTextInput(text: any): void;
  47. }
  48. var KeyBinding: {
  49. new(editor: Editor): KeyBinding;
  50. };
  51. export interface TextMode {
  52. getTokenizer(): any;
  53. toggleCommentLines(state: any, doc: any, startRow: any, endRow: any): void;
  54. getNextLineIndent (state: any, line: any, tab: any): string;
  55. checkOutdent(state: any, line: any, input: any): boolean;
  56. autoOutdent(state: any, doc: any, row: any): void;
  57. createWorker(session: any): any;
  58. createModeDelegates (mapping: any): void;
  59. transformAction(state: any, action: any, editor: any, session: any, param: any): any;
  60. }
  61. ////////////////
  62. /// Ace
  63. ////////////////
  64. /**
  65. * The main class required to set up an Ace instance in the browser.
  66. **/
  67. export interface Ace {
  68. /**
  69. * Provides access to require in packed noconflict mode
  70. * @param moduleName
  71. **/
  72. require(moduleName: string): any;
  73. /**
  74. * Embeds the Ace editor into the DOM, at the element provided by `el`.
  75. * @param el Either the id of an element, or the element itself
  76. **/
  77. edit(el: string): Editor;
  78. /**
  79. * Embeds the Ace editor into the DOM, at the element provided by `el`.
  80. * @param el Either the id of an element, or the element itself
  81. **/
  82. edit(el: HTMLElement): Editor;
  83. /**
  84. * Creates a new [[EditSession]], and returns the associated [[Document]].
  85. * @param text {:textParam}
  86. * @param mode {:modeParam}
  87. **/
  88. createEditSession(text: Document, mode: TextMode): IEditSession;
  89. /**
  90. * Creates a new [[EditSession]], and returns the associated [[Document]].
  91. * @param text {:textParam}
  92. * @param mode {:modeParam}
  93. **/
  94. createEditSession(text: string, mode: TextMode): IEditSession;
  95. }
  96. ////////////////
  97. /// Anchor
  98. ////////////////
  99. /**
  100. * Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated.
  101. **/
  102. export interface Anchor {
  103. on(event: string, fn: (e: any) => any): void;
  104. /**
  105. * Returns an object identifying the `row` and `column` position of the current anchor.
  106. **/
  107. getPosition(): Position;
  108. /**
  109. * Returns the current document.
  110. **/
  111. getDocument(): Document;
  112. /**
  113. * Fires whenever the anchor position changes.
  114. * Both of these objects have a `row` and `column` property corresponding to the position.
  115. * Events that can trigger this function include [[Anchor.setPosition `setPosition()`]].
  116. * @param e An object containing information about the anchor position. It has two properties:
  117. * - `old`: An object describing the old Anchor position
  118. * - `value`: An object describing the new Anchor position
  119. **/
  120. onChange(e: any): void;
  121. /**
  122. * Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped.
  123. * @param row The row index to move the anchor to
  124. * @param column The column index to move the anchor to
  125. * @param noClip Identifies if you want the position to be clipped
  126. **/
  127. setPosition(row: number, column: number, noClip: boolean): void;
  128. /**
  129. * When called, the `'change'` event listener is removed.
  130. **/
  131. detach(): void;
  132. }
  133. var Anchor: {
  134. /**
  135. * Creates a new `Anchor` and associates it with a document.
  136. * @param doc The document to associate with the anchor
  137. * @param row The starting row position
  138. * @param column The starting column position
  139. **/
  140. new(doc: Document, row: number, column: number): Anchor;
  141. };
  142. ////////////////////////////////
  143. /// BackgroundTokenizer
  144. ////////////////////////////////
  145. /**
  146. * Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use.
  147. * If a certain row is changed, everything below that row is re-tokenized.
  148. **/
  149. export interface BackgroundTokenizer {
  150. states: any[];
  151. /**
  152. * Sets a new tokenizer for this object.
  153. * @param tokenizer The new tokenizer to use
  154. **/
  155. setTokenizer(tokenizer: Tokenizer): void;
  156. /**
  157. * Sets a new document to associate with this object.
  158. * @param doc The new document to associate with
  159. **/
  160. setDocument(doc: Document): void;
  161. /**
  162. * Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated.
  163. * @param firstRow The starting row region
  164. * @param lastRow The final row region
  165. **/
  166. fireUpdateEvent(firstRow: number, lastRow: number): void;
  167. /**
  168. * Starts tokenizing at the row indicated.
  169. * @param startRow The row to start at
  170. **/
  171. start(startRow: number): void;
  172. /**
  173. * Stops tokenizing.
  174. **/
  175. stop(): void;
  176. /**
  177. * Gives list of tokens of the row. (tokens are cached)
  178. * @param row The row to get tokens at
  179. **/
  180. getTokens(row: number): TokenInfo[];
  181. /**
  182. * [Returns the state of tokenization at the end of a row.]{: #BackgroundTokenizer.getState}
  183. * @param row The row to get state at
  184. **/
  185. getState(row: number): string;
  186. }
  187. var BackgroundTokenizer: {
  188. /**
  189. * Creates a new `BackgroundTokenizer` object.
  190. * @param tokenizer The tokenizer to use
  191. * @param editor The editor to associate with
  192. **/
  193. new(tokenizer: Tokenizer, editor: Editor): BackgroundTokenizer;
  194. };
  195. ////////////////
  196. /// Document
  197. ////////////////
  198. /**
  199. * Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s.
  200. * At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index.
  201. **/
  202. export interface Document {
  203. on(event: string, fn: (e: any) => any): void;
  204. /**
  205. * Replaces all the lines in the current `Document` with the value of `text`.
  206. * @param text The text to use
  207. **/
  208. setValue(text: string): void;
  209. /**
  210. * Returns all the lines in the document as a single string, split by the new line character.
  211. **/
  212. getValue(): string;
  213. /**
  214. * Creates a new `Anchor` to define a floating point in the document.
  215. * @param row The row number to use
  216. * @param column The column number to use
  217. **/
  218. createAnchor(row: number, column: number): void;
  219. /**
  220. * Returns the newline character that's being used, depending on the value of `newLineMode`.
  221. **/
  222. getNewLineCharacter(): string;
  223. /**
  224. * [Sets the new line mode.]{: #Document.setNewLineMode.desc}
  225. * @param newLineMode [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param}
  226. **/
  227. setNewLineMode(newLineMode: string): void;
  228. /**
  229. * [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode}
  230. **/
  231. getNewLineMode(): string;
  232. /**
  233. * Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`).
  234. * @param text The text to check
  235. **/
  236. isNewLine(text: string): boolean;
  237. /**
  238. * Returns a verbatim copy of the given line as it is in the document
  239. * @param row The row index to retrieve
  240. **/
  241. getLine(row: number): string;
  242. /**
  243. * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
  244. * @param firstRow The first row index to retrieve
  245. * @param lastRow The final row index to retrieve
  246. **/
  247. getLines(firstRow: number, lastRow: number): string[];
  248. /**
  249. * Returns all lines in the document as string array. Warning: The caller should not modify this array!
  250. **/
  251. getAllLines(): string[];
  252. /**
  253. * Returns the number of rows in the document.
  254. **/
  255. getLength(): number;
  256. /**
  257. * [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc}
  258. * @param range The range to work with
  259. **/
  260. getTextRange(range: Range): string;
  261. /**
  262. * Inserts a block of `text` and the indicated `position`.
  263. * @param position The position to start inserting at
  264. * @param text A chunk of text to insert
  265. **/
  266. insert(position: Position, text: string): any;
  267. /**
  268. * Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event.
  269. * @param row The index of the row to insert at
  270. * @param lines An array of strings
  271. **/
  272. insertLines(row: number, lines: string[]): any;
  273. /**
  274. * Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event.
  275. * @param position The position to insert at
  276. **/
  277. insertNewLine(position: Position): any;
  278. /**
  279. * Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event.
  280. * @param position The position to insert at
  281. * @param text A chunk of text
  282. **/
  283. insertInLine(position: any, text: string): any;
  284. /**
  285. * Removes the `range` from the document.
  286. * @param range A specified Range to remove
  287. **/
  288. remove(range: Range): any;
  289. /**
  290. * Removes the specified columns from the `row`. This method also triggers the `'change'` event.
  291. * @param row The row to remove from
  292. * @param startColumn The column to start removing at
  293. * @param endColumn The column to stop removing at
  294. **/
  295. removeInLine(row: number, startColumn: number, endColumn: number): any;
  296. /**
  297. * Removes a range of full lines. This method also triggers the `'change'` event.
  298. * @param firstRow The first row to be removed
  299. * @param lastRow The last row to be removed
  300. **/
  301. removeLines(firstRow: number, lastRow: number): string[];
  302. /**
  303. * Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event.
  304. * @param row The row to check
  305. **/
  306. removeNewLine(row: number): void;
  307. /**
  308. * Replaces a range in the document with the new `text`.
  309. * @param range A specified Range to replace
  310. * @param text The new text to use as a replacement
  311. **/
  312. replace(range: Range, text: string): any;
  313. /**
  314. * Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
  315. **/
  316. applyDeltas(deltas: Delta[]): void;
  317. /**
  318. * Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`.
  319. **/
  320. revertDeltas(deltas: Delta[]): void;
  321. /**
  322. * Converts an index position in a document to a `{row, column}` object.
  323. * Index refers to the "absolute position" of a character in the document. For example:
  324. * ```javascript
  325. * var x = 0; // 10 characters, plus one for newline
  326. * var y = -1;
  327. * ```
  328. * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second.
  329. * @param index An index to convert
  330. * @param startRow=0 The row from which to start the conversion
  331. **/
  332. indexToPosition(index: number, startRow: number): Position;
  333. /**
  334. * Converts the `{row, column}` position in a document to the character's index.
  335. * Index refers to the "absolute position" of a character in the document. For example:
  336. * ```javascript
  337. * var x = 0; // 10 characters, plus one for newline
  338. * var y = -1;
  339. * ```
  340. * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second.
  341. * @param pos The `{row, column}` to convert
  342. * @param startRow=0 The row from which to start the conversion
  343. **/
  344. positionToIndex(pos: Position, startRow: number): number;
  345. }
  346. var Document: {
  347. /**
  348. * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
  349. * @param text The starting text
  350. **/
  351. new(text?: string): Document;
  352. /**
  353. * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
  354. * @param text The starting text
  355. **/
  356. new(text?: string[]): Document;
  357. };
  358. ////////////////////////////////
  359. /// EditSession
  360. ////////////////////////////////
  361. /**
  362. * Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state.
  363. * `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s.
  364. **/
  365. export interface IEditSession {
  366. selection: Selection;
  367. bgTokenizer: BackgroundTokenizer;
  368. doc: Document;
  369. on(event: string, fn: (e: any) => any): void;
  370. findMatchingBracket(position: Position): void;
  371. addFold(text: string, range: Range): void;
  372. getFoldAt(row: number, column: number): any;
  373. removeFold(arg: any): void;
  374. expandFold(arg: any): void;
  375. unfold(arg1: any, arg2: boolean): void;
  376. screenToDocumentColumn(row: number, column: number): void;
  377. getFoldDisplayLine(foldLine: any, docRow: number, docColumn: number): any;
  378. getFoldsInRange(range: Range): any;
  379. highlight(text: string): void;
  380. /**
  381. * Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`.
  382. * @param doc The new `Document` to use
  383. **/
  384. setDocument(doc: Document): void;
  385. /**
  386. * Returns the `Document` associated with this session.
  387. **/
  388. getDocument(): Document;
  389. /**
  390. * undefined
  391. * @param row The row to work with
  392. **/
  393. $resetRowCache(row: number): void;
  394. /**
  395. * Sets the session text.
  396. * @param text The new text to place
  397. **/
  398. setValue(text: string): void;
  399. setMode(mode: string): void;
  400. /**
  401. * Returns the current [[Document `Document`]] as a string.
  402. **/
  403. getValue(): string;
  404. /**
  405. * Returns the string of the current selection.
  406. **/
  407. getSelection(): Selection;
  408. /**
  409. * {:BackgroundTokenizer.getState}
  410. * @param row The row to start at
  411. **/
  412. getState(row: number): string;
  413. /**
  414. * Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.
  415. * @param row The row to start at
  416. **/
  417. getTokens(row: number): TokenInfo[];
  418. /**
  419. * Returns an object indicating the token at the current row. The object has two properties: `index` and `start`.
  420. * @param row The row number to retrieve from
  421. * @param column The column number to retrieve from
  422. **/
  423. getTokenAt(row: number, column: number): TokenInfo;
  424. /**
  425. * Sets the undo manager.
  426. * @param undoManager The new undo manager
  427. **/
  428. setUndoManager(undoManager: UndoManager): void;
  429. /**
  430. * Returns the current undo manager.
  431. **/
  432. getUndoManager(): UndoManager;
  433. /**
  434. * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]): void; otherwise it's simply `'\t'`.
  435. **/
  436. getTabString(): string;
  437. /**
  438. * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`).
  439. * @param useSoftTabs Value indicating whether or not to use soft tabs
  440. **/
  441. setUseSoftTabs(useSoftTabs: boolean): void;
  442. /**
  443. * Returns `true` if soft tabs are being used, `false` otherwise.
  444. **/
  445. getUseSoftTabs(): boolean;
  446. /**
  447. * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event.
  448. * @param tabSize The new tab size
  449. **/
  450. setTabSize(tabSize: number): void;
  451. /**
  452. * Returns the current tab size.
  453. **/
  454. getTabSize(): number;
  455. /**
  456. * Returns `true` if the character at the position is a soft tab.
  457. * @param position The position to check
  458. **/
  459. isTabStop(position: any): boolean;
  460. /**
  461. * Pass in `true` to enable overwrites in your session, or `false` to disable.
  462. * If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event.
  463. * @param overwrite Defines wheter or not to set overwrites
  464. **/
  465. setOverwrite(overwrite: boolean): void;
  466. /**
  467. * Returns `true` if overwrites are enabled; `false` otherwise.
  468. **/
  469. getOverwrite(): boolean;
  470. /**
  471. * Sets the value of overwrite to the opposite of whatever it currently is.
  472. **/
  473. toggleOverwrite(): void;
  474. /**
  475. * Adds `className` to the `row`, to be used for CSS stylings and whatnot.
  476. * @param row The row number
  477. * @param className The class to add
  478. **/
  479. addGutterDecoration(row: number, className: string): void;
  480. /**
  481. * Removes `className` from the `row`.
  482. * @param row The row number
  483. * @param className The class to add
  484. **/
  485. removeGutterDecoration(row: number, className: string): void;
  486. /**
  487. * Returns an array of numbers, indicating which rows have breakpoints.
  488. **/
  489. getBreakpoints(): number[];
  490. /**
  491. * Sets a breakpoint on every row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
  492. * @param rows An array of row indices
  493. **/
  494. setBreakpoints(rows: any[]): void;
  495. /**
  496. * Removes all breakpoints on the rows. This function also emites the `'changeBreakpoint'` event.
  497. **/
  498. clearBreakpoints(): void;
  499. /**
  500. * Sets a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
  501. * @param row A row index
  502. * @param className Class of the breakpoint
  503. **/
  504. setBreakpoint(row: number, className: string): void;
  505. /**
  506. * Removes a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event.
  507. * @param row A row index
  508. **/
  509. clearBreakpoint(row: number): void;
  510. /**
  511. * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires.
  512. * @param range Define the range of the marker
  513. * @param clazz Set the CSS class for the marker
  514. * @param type Identify the type of the marker
  515. * @param inFront Set to `true` to establish a front marker
  516. **/
  517. addMarker(range: Range, clazz: string, type: Function, inFront: boolean): void;
  518. /**
  519. * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires.
  520. * @param range Define the range of the marker
  521. * @param clazz Set the CSS class for the marker
  522. * @param type Identify the type of the marker
  523. * @param inFront Set to `true` to establish a front marker
  524. **/
  525. addMarker(range: Range, clazz: string, type: string, inFront: boolean): void;
  526. /**
  527. * Adds a dynamic marker to the session.
  528. * @param marker object with update method
  529. * @param inFront Set to `true` to establish a front marker
  530. **/
  531. addDynamicMarker(marker: any, inFront: boolean): void;
  532. /**
  533. * Removes the marker with the specified ID. If this marker was in front, the `'changeFrontMarker'` event is emitted. If the marker was in the back, the `'changeBackMarker'` event is emitted.
  534. * @param markerId A number representing a marker
  535. **/
  536. removeMarker(markerId: number): void;
  537. /**
  538. * Returns an array containing the IDs of all the markers, either front or back.
  539. * @param inFront If `true`, indicates you only want front markers; `false` indicates only back markers
  540. **/
  541. getMarkers(inFront: boolean): any[];
  542. /**
  543. * Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event.
  544. * @param annotations A list of annotations
  545. **/
  546. setAnnotations(annotations: Annotation[]): void;
  547. /**
  548. * Returns the annotations for the `EditSession`.
  549. **/
  550. getAnnotations(): any;
  551. /**
  552. * Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event.
  553. **/
  554. clearAnnotations(): void;
  555. /**
  556. * If `text` contains either the newline (`\n`) or carriage-return ('\r') characters, `$autoNewLine` stores that value.
  557. * @param text A block of text
  558. **/
  559. $detectNewLine(text: string): void;
  560. /**
  561. * Given a starting row and column, this method returns the `Range` of the first word boundary it finds.
  562. * @param row The row to start at
  563. * @param column The column to start at
  564. **/
  565. getWordRange(row: number, column: number): Range;
  566. /**
  567. * Gets the range of a word, including its right whitespace.
  568. * @param row The row number to start from
  569. * @param column The column number to start from
  570. **/
  571. getAWordRange(row: number, column: number): any;
  572. /**
  573. * {:Document.setNewLineMode.desc}
  574. * @param newLineMode {:Document.setNewLineMode.param}
  575. **/
  576. setNewLineMode(newLineMode: string): void;
  577. /**
  578. * Returns the current new line mode.
  579. **/
  580. getNewLineMode(): string;
  581. /**
  582. * Identifies if you want to use a worker for the `EditSession`.
  583. * @param useWorker Set to `true` to use a worker
  584. **/
  585. setUseWorker(useWorker: boolean): void;
  586. /**
  587. * Returns `true` if workers are being used.
  588. **/
  589. getUseWorker(): boolean;
  590. /**
  591. * Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event.
  592. **/
  593. onReloadTokenizer(): void;
  594. /**
  595. * Sets a new text mode for the `EditSession`. This method also emits the `'changeMode'` event. If a [[BackgroundTokenizer `BackgroundTokenizer`]] is set, the `'tokenizerUpdate'` event is also emitted.
  596. * @param mode Set a new text mode
  597. **/
  598. $mode(mode: TextMode): void;
  599. /**
  600. * Returns the current text mode.
  601. **/
  602. getMode(): TextMode;
  603. /**
  604. * This function sets the scroll top value. It also emits the `'changeScrollTop'` event.
  605. * @param scrollTop The new scroll top value
  606. **/
  607. setScrollTop(scrollTop: number): void;
  608. /**
  609. * [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop}
  610. **/
  611. getScrollTop(): number;
  612. /**
  613. * [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft}
  614. **/
  615. setScrollLeft(): void;
  616. /**
  617. * [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft}
  618. **/
  619. getScrollLeft(): number;
  620. /**
  621. * Returns the width of the screen.
  622. **/
  623. getScreenWidth(): number;
  624. /**
  625. * Returns a verbatim copy of the given line as it is in the document
  626. * @param row The row to retrieve from
  627. **/
  628. getLine(row: number): string;
  629. /**
  630. * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`.
  631. * @param firstRow The first row index to retrieve
  632. * @param lastRow The final row index to retrieve
  633. **/
  634. getLines(firstRow: number, lastRow: number): string[];
  635. /**
  636. * Returns the number of rows in the document.
  637. **/
  638. getLength(): number;
  639. /**
  640. * {:Document.getTextRange.desc}
  641. * @param range The range to work with
  642. **/
  643. getTextRange(range: Range): string;
  644. /**
  645. * Inserts a block of `text` and the indicated `position`.
  646. * @param position The position {row, column} to start inserting at
  647. * @param text A chunk of text to insert
  648. **/
  649. insert(position: Position, text: string): any;
  650. /**
  651. * Removes the `range` from the document.
  652. * @param range A specified Range to remove
  653. **/
  654. remove(range: Range): any;
  655. /**
  656. * Reverts previous changes to your document.
  657. * @param deltas An array of previous changes
  658. * @param dontSelect [If `true`, doesn't select the range of where the change occured]{: #dontSelect}
  659. **/
  660. undoChanges(deltas: any[], dontSelect: boolean): Range;
  661. /**
  662. * Re-implements a previously undone change to your document.
  663. * @param deltas An array of previous changes
  664. * @param dontSelect {:dontSelect}
  665. **/
  666. redoChanges(deltas: any[], dontSelect: boolean): Range;
  667. /**
  668. * Enables or disables highlighting of the range where an undo occured.
  669. * @param enable If `true`, selects the range of the reinserted change
  670. **/
  671. setUndoSelect(enable: boolean): void;
  672. /**
  673. * Replaces a range in the document with the new `text`.
  674. * @param range A specified Range to replace
  675. * @param text The new text to use as a replacement
  676. **/
  677. replace(range: Range, text: string): any;
  678. /**
  679. * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this:
  680. * ```json
  681. * { row: newRowLocation, column: newColumnLocation }
  682. * ```
  683. * @param fromRange The range of text you want moved within the document
  684. * @param toPosition The location (row and column) where you want to move the text to
  685. **/
  686. moveText(fromRange: Range, toPosition: any): Range;
  687. /**
  688. * Indents all the rows, from `startRow` to `endRow` (inclusive), by prefixing each row with the token in `indentString`.
  689. * If `indentString` contains the `'\t'` character, it's replaced by whatever is defined by [[EditSession.getTabString `getTabString()`]].
  690. * @param startRow Starting row
  691. * @param endRow Ending row
  692. * @param indentString The indent token
  693. **/
  694. indentRows(startRow: number, endRow: number, indentString: string): void;
  695. /**
  696. * Outdents all the rows defined by the `start` and `end` properties of `range`.
  697. * @param range A range of rows
  698. **/
  699. outdentRows(range: Range): void;
  700. /**
  701. * Shifts all the lines in the document up one, starting from `firstRow` and ending at `lastRow`.
  702. * @param firstRow The starting row to move up
  703. * @param lastRow The final row to move up
  704. **/
  705. moveLinesUp(firstRow: number, lastRow: number): number;
  706. /**
  707. * Shifts all the lines in the document down one, starting from `firstRow` and ending at `lastRow`.
  708. * @param firstRow The starting row to move down
  709. * @param lastRow The final row to move down
  710. **/
  711. moveLinesDown(firstRow: number, lastRow: number): number;
  712. /**
  713. * Duplicates all the text between `firstRow` and `lastRow`.
  714. * @param firstRow The starting row to duplicate
  715. * @param lastRow The final row to duplicate
  716. **/
  717. duplicateLines(firstRow: number, lastRow: number): number;
  718. /**
  719. * Sets whether or not line wrapping is enabled. If `useWrapMode` is different than the current value, the `'changeWrapMode'` event is emitted.
  720. * @param useWrapMode Enable (or disable) wrap mode
  721. **/
  722. setUseWrapMode(useWrapMode: boolean): void;
  723. /**
  724. * Returns `true` if wrap mode is being used; `false` otherwise.
  725. **/
  726. getUseWrapMode(): boolean;
  727. /**
  728. * Sets the boundaries of wrap. Either value can be `null` to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for `min` or `max` are different, this method also emits the `'changeWrapMode'` event.
  729. * @param min The minimum wrap value (the left side wrap)
  730. * @param max The maximum wrap value (the right side wrap)
  731. **/
  732. setWrapLimitRange(min: number, max: number): void;
  733. /**
  734. * This should generally only be called by the renderer when a resize is detected.
  735. * @param desiredLimit The new wrap limit
  736. **/
  737. adjustWrapLimit(desiredLimit: number): boolean;
  738. /**
  739. * Returns the value of wrap limit.
  740. **/
  741. getWrapLimit(): number;
  742. /**
  743. * Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this:
  744. * { min: wrapLimitRange_min, max: wrapLimitRange_max }
  745. **/
  746. getWrapLimitRange(): any;
  747. /**
  748. * Given a string, returns an array of the display characters, including tabs and spaces.
  749. * @param str The string to check
  750. * @param offset The value to start at
  751. **/
  752. $getDisplayTokens(str: string, offset: number): void;
  753. /**
  754. * Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen.
  755. * @param str The string to calculate the screen width of
  756. * @param maxScreenColumn
  757. * @param screenColumn
  758. **/
  759. $getStringScreenWidth(str: string, maxScreenColumn: number, screenColumn: number): number[];
  760. /**
  761. * Returns number of screenrows in a wrapped line.
  762. * @param row The row number to check
  763. **/
  764. getRowLength(row: number): number;
  765. /**
  766. * Returns the position (on screen) for the last character in the provided screen row.
  767. * @param screenRow The screen row to check
  768. **/
  769. getScreenLastRowColumn(screenRow: number): number;
  770. /**
  771. * For the given document row and column, this returns the column position of the last screen row.
  772. * @param docRow
  773. * @param docColumn
  774. **/
  775. getDocumentLastRowColumn(docRow: number, docColumn: number): number;
  776. /**
  777. * For the given document row and column, this returns the document position of the last row.
  778. * @param docRow
  779. * @param docColumn
  780. **/
  781. getDocumentLastRowColumnPosition(docRow: number, docColumn: number): number;
  782. /**
  783. * For the given row, this returns the split data.
  784. **/
  785. getRowSplitData(): string;
  786. /**
  787. * The distance to the next tab stop at the specified screen column.
  788. * @param screenColumn The screen column to check
  789. **/
  790. getScreenTabSize(screenColumn: number): number;
  791. /**
  792. * Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations}
  793. * @param screenRow The screen row to check
  794. * @param screenColumn The screen column to check
  795. **/
  796. screenToDocumentPosition(screenRow: number, screenColumn: number): any;
  797. /**
  798. * Converts document coordinates to screen coordinates. {:conversionConsiderations}
  799. * @param docRow The document row to check
  800. * @param docColumn The document column to check
  801. **/
  802. documentToScreenPosition(docRow: number, docColumn: number): any;
  803. /**
  804. * For the given document row and column, returns the screen column.
  805. * @param row
  806. * @param docColumn
  807. **/
  808. documentToScreenColumn(row: number, docColumn: number): number;
  809. /**
  810. * For the given document row and column, returns the screen row.
  811. * @param docRow
  812. * @param docColumn
  813. **/
  814. documentToScreenRow(docRow: number, docColumn: number): void;
  815. /**
  816. * Returns the length of the screen.
  817. **/
  818. getScreenLength(): number;
  819. }
  820. var EditSession: {
  821. /**
  822. * Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`.
  823. * @param text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam}
  824. * @param mode [The inital language mode to use for the document]{: #modeParam}
  825. **/
  826. new(text: string, mode?: TextMode): IEditSession;
  827. new(content: string, mode?: string): IEditSession;
  828. new (text: string[], mode?: string): IEditSession;
  829. };
  830. ////////////////////////////////
  831. /// Editor
  832. ////////////////////////////////
  833. /**
  834. * The main entry point into the Ace functionality.
  835. * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen.
  836. * Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them.
  837. **/
  838. export interface Editor {
  839. addEventListener(ev: "change", callback: (ev: EditorChangeEvent) => any): void;
  840. addEventListener(ev: string, callback: Function): void;
  841. inMultiSelectMode: boolean;
  842. selectMoreLines(n: number): void;
  843. onTextInput(text: string): void;
  844. onCommandKey(e: any, hashId: any, keyCode: any): void;
  845. commands: CommandManager;
  846. session: IEditSession;
  847. selection: Selection;
  848. renderer: VirtualRenderer;
  849. keyBinding: KeyBinding;
  850. container: HTMLElement;
  851. onSelectionChange(e: any): void;
  852. onChangeMode(e?: any): void;
  853. execCommand(command:string, args?: any): void;
  854. /**
  855. * Sets a Configuration Option
  856. **/
  857. setOption(optionName: any, optionValue: any): void;
  858. /**
  859. * Sets Configuration Options
  860. **/
  861. setOptions(keyValueTuples: any): void;
  862. /**
  863. * Get a Configuration Option
  864. **/
  865. getOption(name: any):any;
  866. /**
  867. * Get Configuration Options
  868. **/
  869. getOptions():any;
  870. /**
  871. * Get rid of console warning by setting this to Infinity
  872. **/
  873. $blockScrolling:number;
  874. /**
  875. * Sets a new key handler, such as "vim" or "windows".
  876. * @param keyboardHandler The new key handler
  877. **/
  878. setKeyboardHandler(keyboardHandler: string): void;
  879. /**
  880. * Returns the keyboard handler, such as "vim" or "windows".
  881. **/
  882. getKeyboardHandler(): string;
  883. /**
  884. * Sets a new editsession to use. This method also emits the `'changeSession'` event.
  885. * @param session The new session to use
  886. **/
  887. setSession(session: IEditSession): void;
  888. /**
  889. * Returns the current session being used.
  890. **/
  891. getSession(): IEditSession;
  892. /**
  893. * Sets the current document to `val`.
  894. * @param val The new value to set for the document
  895. * @param cursorPos Where to set the new value. `undefined` or 0 is selectAll, -1 is at the document start, and 1 is at the end
  896. **/
  897. setValue(val: string, cursorPos?: number): string;
  898. /**
  899. * Returns the current session's content.
  900. **/
  901. getValue(): string;
  902. /**
  903. * Returns the currently highlighted selection.
  904. **/
  905. getSelection(): Selection;
  906. /**
  907. * {:VirtualRenderer.onResize}
  908. * @param force If `true`, recomputes the size, even if the height and width haven't changed
  909. **/
  910. resize(force?: boolean): void;
  911. /**
  912. * {:VirtualRenderer.setTheme}
  913. * @param theme The path to a theme
  914. **/
  915. setTheme(theme: string): void;
  916. /**
  917. * {:VirtualRenderer.getTheme}
  918. **/
  919. getTheme(): string;
  920. /**
  921. * {:VirtualRenderer.setStyle}
  922. * @param style A class name
  923. **/
  924. setStyle(style: string): void;
  925. /**
  926. * {:VirtualRenderer.unsetStyle}
  927. **/
  928. unsetStyle(): void;
  929. /**
  930. * Set a new font size (in pixels) for the editor text.
  931. * @param size A font size ( _e.g._ "12px")
  932. **/
  933. setFontSize(size: string): void;
  934. /**
  935. * Brings the current `textInput` into focus.
  936. **/
  937. focus(): void;
  938. /**
  939. * Returns `true` if the current `textInput` is in focus.
  940. **/
  941. isFocused(): void;
  942. /**
  943. * Blurs the current `textInput`.
  944. **/
  945. blur(): void;
  946. /**
  947. * Emitted once the editor comes into focus.
  948. **/
  949. onFocus(): void;
  950. /**
  951. * Emitted once the editor has been blurred.
  952. **/
  953. onBlur(): void;
  954. /**
  955. * Emitted whenever the document is changed.
  956. * @param e Contains a single property, `data`, which has the delta of changes
  957. **/
  958. onDocumentChange(e: any): void;
  959. /**
  960. * Emitted when the selection changes.
  961. **/
  962. onCursorChange(): void;
  963. /**
  964. * Returns the string of text currently highlighted.
  965. **/
  966. getCopyText(): string;
  967. /**
  968. * Called whenever a text "copy" happens.
  969. **/
  970. onCopy(): void;
  971. /**
  972. * Called whenever a text "cut" happens.
  973. **/
  974. onCut(): void;
  975. /**
  976. * Called whenever a text "paste" happens.
  977. * @param text The pasted text
  978. **/
  979. onPaste(text: string): void;
  980. /**
  981. * Inserts `text` into wherever the cursor is pointing.
  982. * @param text The new text to add
  983. **/
  984. insert(text: string): void;
  985. /**
  986. * Pass in `true` to enable overwrites in your session, or `false` to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event.
  987. * @param overwrite Defines wheter or not to set overwrites
  988. **/
  989. setOverwrite(overwrite: boolean): void;
  990. /**
  991. * Returns `true` if overwrites are enabled; `false` otherwise.
  992. **/
  993. getOverwrite(): boolean;
  994. /**
  995. * Sets the value of overwrite to the opposite of whatever it currently is.
  996. **/
  997. toggleOverwrite(): void;
  998. /**
  999. * Sets how fast the mouse scrolling should do.
  1000. * @param speed A value indicating the new speed (in milliseconds)
  1001. **/
  1002. setScrollSpeed(speed: number): void;
  1003. /**
  1004. * Returns the value indicating how fast the mouse scroll speed is (in milliseconds).
  1005. **/
  1006. getScrollSpeed(): number;
  1007. /**
  1008. * Sets the delay (in milliseconds) of the mouse drag.
  1009. * @param dragDelay A value indicating the new delay
  1010. **/
  1011. setDragDelay(dragDelay: number): void;
  1012. /**
  1013. * Returns the current mouse drag delay.
  1014. **/
  1015. getDragDelay(): number;
  1016. /**
  1017. * Indicates how selections should occur.
  1018. * By default, selections are set to "line". There are no other styles at the moment,
  1019. * although this code change in the future.
  1020. * This function also emits the `'changeSelectionStyle'` event.
  1021. * @param style The new selection style
  1022. **/
  1023. setSelectionStyle(style: string): void;
  1024. /**
  1025. * Returns the current selection style.
  1026. **/
  1027. getSelectionStyle(): string;
  1028. /**
  1029. * Determines whether or not the current line should be highlighted.
  1030. * @param shouldHighlight Set to `true` to highlight the current line
  1031. **/
  1032. setHighlightActiveLine(shouldHighlight: boolean): void;
  1033. /**
  1034. * Returns `true` if current lines are always highlighted.
  1035. **/
  1036. getHighlightActiveLine(): void;
  1037. /**
  1038. * Determines if the currently selected word should be highlighted.
  1039. * @param shouldHighlight Set to `true` to highlight the currently selected word
  1040. **/
  1041. setHighlightSelectedWord(shouldHighlight: boolean): void;
  1042. /**
  1043. * Returns `true` if currently highlighted words are to be highlighted.
  1044. **/
  1045. getHighlightSelectedWord(): boolean;
  1046. /**
  1047. * If `showInvisibiles` is set to `true`, invisible characters&mdash;like spaces or new lines&mdash;are show in the editor.
  1048. * @param showInvisibles Specifies whether or not to show invisible characters
  1049. **/
  1050. setShowInvisibles(showInvisibles: boolean): void;
  1051. /**
  1052. * Returns `true` if invisible characters are being shown.
  1053. **/
  1054. getShowInvisibles(): boolean;
  1055. /**
  1056. * If `showPrintMargin` is set to `true`, the print margin is shown in the editor.
  1057. * @param showPrintMargin Specifies whether or not to show the print margin
  1058. **/
  1059. setShowPrintMargin(showPrintMargin: boolean): void;
  1060. /**
  1061. * Returns `true` if the print margin is being shown.
  1062. **/
  1063. getShowPrintMargin(): boolean;
  1064. /**
  1065. * Sets the column defining where the print margin should be.
  1066. * @param showPrintMargin Specifies the new print margin
  1067. **/
  1068. setPrintMarginColumn(showPrintMargin: number): void;
  1069. /**
  1070. * Returns the column number of where the print margin is.
  1071. **/
  1072. getPrintMarginColumn(): number;
  1073. /**
  1074. * If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change.
  1075. * @param readOnly Specifies whether the editor can be modified or not
  1076. **/
  1077. setReadOnly(readOnly: boolean): void;
  1078. /**
  1079. * Returns `true` if the editor is set to read-only mode.
  1080. **/
  1081. getReadOnly(): boolean;
  1082. /**
  1083. * Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef}
  1084. * @param enabled Enables or disables behaviors
  1085. **/
  1086. setBehavioursEnabled(enabled: boolean): void;
  1087. /**
  1088. * Returns `true` if the behaviors are currently enabled. {:BehaviorsDef}
  1089. **/
  1090. getBehavioursEnabled(): boolean;
  1091. /**
  1092. * Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets
  1093. * when such a character is typed in.
  1094. * @param enabled Enables or disables wrapping behaviors
  1095. **/
  1096. setWrapBehavioursEnabled(enabled: boolean): void;
  1097. /**
  1098. * Returns `true` if the wrapping behaviors are currently enabled.
  1099. **/
  1100. getWrapBehavioursEnabled(): void;
  1101. /**
  1102. * Indicates whether the fold widgets are shown or not.
  1103. * @param show Specifies whether the fold widgets are shown
  1104. **/
  1105. setShowFoldWidgets(show: boolean): void;
  1106. /**
  1107. * Returns `true` if the fold widgets are shown.
  1108. **/
  1109. getShowFoldWidgets(): void;
  1110. /**
  1111. * Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace.
  1112. * @param dir The direction of the deletion to occur, either "left" or "right"
  1113. **/
  1114. remove(dir: string): void;
  1115. /**
  1116. * Removes the word directly to the right of the current selection.
  1117. **/
  1118. removeWordRight(): void;
  1119. /**
  1120. * Removes the word directly to the left of the current selection.
  1121. **/
  1122. removeWordLeft(): void;
  1123. /**
  1124. * Removes all the words to the left of the current selection, until the start of the line.
  1125. **/
  1126. removeToLineStart(): void;
  1127. /**
  1128. * Removes all the words to the right of the current selection, until the end of the line.
  1129. **/
  1130. removeToLineEnd(): void;
  1131. /**
  1132. * Splits the line at the current selection (by inserting an `'\n'`).
  1133. **/
  1134. splitLine(): void;
  1135. /**
  1136. * Transposes current line.
  1137. **/
  1138. transposeLetters(): void;
  1139. /**
  1140. * Converts the current selection entirely into lowercase.
  1141. **/
  1142. toLowerCase(): void;
  1143. /**
  1144. * Converts the current selection entirely into uppercase.
  1145. **/
  1146. toUpperCase(): void;
  1147. /**
  1148. * Inserts an indentation into the current cursor position or indents the selected lines.
  1149. **/
  1150. indent(): void;
  1151. /**
  1152. * Indents the current line.
  1153. **/
  1154. blockIndent(): void;
  1155. /**
  1156. * Outdents the current line.
  1157. **/
  1158. blockOutdent(arg?: string): void;
  1159. /**
  1160. * Given the currently selected range, this function either comments all the lines, or uncomments all of them.
  1161. **/
  1162. toggleCommentLines(): void;
  1163. /**
  1164. * Works like [[EditSession.getTokenAt]], except it returns a number.
  1165. **/
  1166. getNumberAt(): number;
  1167. /**
  1168. * If the character before the cursor is a number, this functions changes its value by `amount`.
  1169. * @param amount The value to change the numeral by (can be negative to decrease value)
  1170. **/
  1171. modifyNumber(amount: number): void;
  1172. /**
  1173. * Removes all the lines in the current selection
  1174. **/
  1175. removeLines(): void;
  1176. /**
  1177. * Shifts all the selected lines down one row.
  1178. **/
  1179. moveLinesDown(): number;
  1180. /**
  1181. * Shifts all the selected lines up one row.
  1182. **/
  1183. moveLinesUp(): number;
  1184. /**
  1185. * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this:
  1186. * ```json
  1187. * { row: newRowLocation, column: newColumnLocation }
  1188. * ```
  1189. * @param fromRange The range of text you want moved within the document
  1190. * @param toPosition The location (row and column) where you want to move the text to
  1191. **/
  1192. moveText(fromRange: Range, toPosition: any): Range;
  1193. /**
  1194. * Copies all the selected lines up one row.
  1195. **/
  1196. copyLinesUp(): number;
  1197. /**
  1198. * Copies all the selected lines down one row.
  1199. **/
  1200. copyLinesDown(): number;
  1201. /**
  1202. * {:VirtualRenderer.getFirstVisibleRow}
  1203. **/
  1204. getFirstVisibleRow(): number;
  1205. /**
  1206. * {:VirtualRenderer.getLastVisibleRow}
  1207. **/
  1208. getLastVisibleRow(): number;
  1209. /**
  1210. * Indicates if the row is currently visible on the screen.
  1211. * @param row The row to check
  1212. **/
  1213. isRowVisible(row: number): boolean;
  1214. /**
  1215. * Indicates if the entire row is currently visible on the screen.
  1216. * @param row The row to check
  1217. **/
  1218. isRowFullyVisible(row: number): boolean;
  1219. /**
  1220. * Selects the text from the current position of the document until where a "page down" finishes.
  1221. **/
  1222. selectPageDown(): void;
  1223. /**
  1224. * Selects the text from the current position of the document until where a "page up" finishes.
  1225. **/
  1226. selectPageUp(): void;
  1227. /**
  1228. * Shifts the document to wherever "page down" is, as well as moving the cursor position.
  1229. **/
  1230. gotoPageDown(): void;
  1231. /**
  1232. * Shifts the document to wherever "page up" is, as well as moving the cursor position.
  1233. **/
  1234. gotoPageUp(): void;
  1235. /**
  1236. * Scrolls the document to wherever "page down" is, without changing the cursor position.
  1237. **/
  1238. scrollPageDown(): void;
  1239. /**
  1240. * Scrolls the document to wherever "page up" is, without changing the cursor position.
  1241. **/
  1242. scrollPageUp(): void;
  1243. /**
  1244. * Moves the editor to the specified row.
  1245. **/
  1246. scrollToRow(): void;
  1247. /**
  1248. * Scrolls to a line. If `center` is `true`, it puts the line in middle of screen (or attempts to).
  1249. * @param line The line to scroll to
  1250. * @param center If `true`
  1251. * @param animate If `true` animates scrolling
  1252. * @param callback Function to be called when the animation has finished
  1253. **/
  1254. scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
  1255. /**
  1256. * Attempts to center the current selection on the screen.
  1257. **/
  1258. centerSelection(): void;
  1259. /**
  1260. * Gets the current position of the cursor.
  1261. **/
  1262. getCursorPosition(): Position;
  1263. /**
  1264. * Returns the screen position of the cursor.
  1265. **/
  1266. getCursorPositionScreen(): number;
  1267. /**
  1268. * {:Selection.getRange}
  1269. **/
  1270. getSelectionRange(): Range;
  1271. /**
  1272. * Selects all the text in editor.
  1273. **/
  1274. selectAll(): void;
  1275. /**
  1276. * {:Selection.clearSelection}
  1277. **/
  1278. clearSelection(): void;
  1279. /**
  1280. * Moves the cursor to the specified row and column. Note that this does not de-select the current selection.
  1281. * @param row The new row number
  1282. * @param column The new column number
  1283. **/
  1284. moveCursorTo(row: number, column?: number, animate?:boolean): void;
  1285. /**
  1286. * Moves the cursor to the position indicated by `pos.row` and `pos.column`.
  1287. * @param position An object with two properties, row and column
  1288. **/
  1289. moveCursorToPosition(position: Position): void;
  1290. /**
  1291. * Moves the cursor's row and column to the next matching bracket.
  1292. **/
  1293. jumpToMatching(): void;
  1294. /**
  1295. * Moves the cursor to the specified line number, and also into the indiciated column.
  1296. * @param lineNumber The line number to go to
  1297. * @param column A column number to go to
  1298. * @param animate If `true` animates scolling
  1299. **/
  1300. gotoLine(lineNumber: number, column?: number, animate?: boolean): void;
  1301. /**
  1302. * Moves the cursor to the specified row and column. Note that this does de-select the current selection.
  1303. * @param row The new row number
  1304. * @param column The new column number
  1305. **/
  1306. navigateTo(row: number, column: number): void;
  1307. /**
  1308. * Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.
  1309. * @param times The number of times to change navigation
  1310. **/
  1311. navigateUp(times?: number): void;
  1312. /**
  1313. * Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.
  1314. * @param times The number of times to change navigation
  1315. **/
  1316. navigateDown(times?: number): void;
  1317. /**
  1318. * Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.
  1319. * @param times The number of times to change navigation
  1320. **/
  1321. navigateLeft(times?: number): void;
  1322. /**
  1323. * Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.
  1324. * @param times The number of times to change navigation
  1325. **/
  1326. navigateRight(times: number): void;
  1327. /**
  1328. * Moves the cursor to the start of the current line. Note that this does de-select the current selection.
  1329. **/
  1330. navigateLineStart(): void;
  1331. /**
  1332. * Moves the cursor to the end of the current line. Note that this does de-select the current selection.
  1333. **/
  1334. navigateLineEnd(): void;
  1335. /**
  1336. * Moves the cursor to the end of the current file. Note that this does de-select the current selection.
  1337. **/
  1338. navigateFileEnd(): void;
  1339. /**
  1340. * Moves the cursor to the start of the current file. Note that this does de-select the current selection.
  1341. **/
  1342. navigateFileStart(): void;
  1343. /**
  1344. * Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection.
  1345. **/
  1346. navigateWordRight(): void;
  1347. /**
  1348. * Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection.
  1349. **/
  1350. navigateWordLeft(): void;
  1351. /**
  1352. * Replaces the first occurance of `options.needle` with the value in `replacement`.
  1353. * @param replacement The text to replace with
  1354. * @param options The [[Search `Search`]] options to use
  1355. **/
  1356. replace(replacement: string, options?: any): void;
  1357. /**
  1358. * Replaces all occurances of `options.needle` with the value in `replacement`.
  1359. * @param replacement The text to replace with
  1360. * @param options The [[Search `Search`]] options to use
  1361. **/
  1362. replaceAll(replacement: string, options?: any): void;
  1363. /**
  1364. * {:Search.getOptions} For more information on `options`, see [[Search `Search`]].
  1365. **/
  1366. getLastSearchOptions(): any;
  1367. /**
  1368. * Attempts to find `needle` within the document. For more information on `options`, see [[Search `Search`]].
  1369. * @param needle The text to search for (optional)
  1370. * @param options An object defining various search properties
  1371. * @param animate If `true` animate scrolling
  1372. **/
  1373. find(needle: string, options?: any, animate?: boolean): void;
  1374. /**
  1375. * Performs another search for `needle` in the document. For more information on `options`, see [[Search `Search`]].
  1376. * @param options search options
  1377. * @param animate If `true` animate scrolling
  1378. **/
  1379. findNext(options?: any, animate?: boolean): void;
  1380. /**
  1381. * Performs a search for `needle` backwards. For more information on `options`, see [[Search `Search`]].
  1382. * @param options search options
  1383. * @param animate If `true` animate scrolling
  1384. **/
  1385. findPrevious(options?: any, animate?: boolean): void;
  1386. /**
  1387. * {:UndoManager.undo}
  1388. **/
  1389. undo(): void;
  1390. /**
  1391. * {:UndoManager.redo}
  1392. **/
  1393. redo(): void;
  1394. /**
  1395. * Cleans up the entire editor.
  1396. **/
  1397. destroy(): void;
  1398. }
  1399. var Editor: {
  1400. /**
  1401. * Creates a new `Editor` object.
  1402. * @param renderer Associated `VirtualRenderer` that draws everything
  1403. * @param session The `EditSession` to refer to
  1404. **/
  1405. new(renderer: VirtualRenderer, session?: IEditSession): Editor;
  1406. };
  1407. interface EditorChangeEvent {
  1408. start: Position;
  1409. end: Position;
  1410. action: string; // insert, remove
  1411. lines: any[];
  1412. }
  1413. ////////////////////////////////
  1414. /// PlaceHolder
  1415. ////////////////////////////////
  1416. export interface PlaceHolder {
  1417. on(event: string, fn: (e: any) => any): void;
  1418. /**
  1419. * PlaceHolder.setup()
  1420. * TODO
  1421. **/
  1422. setup(): void;
  1423. /**
  1424. * PlaceHolder.showOtherMarkers()
  1425. * TODO
  1426. **/
  1427. showOtherMarkers(): void;
  1428. /**
  1429. * PlaceHolder.hideOtherMarkers()
  1430. * Hides all over markers in the [[EditSession `EditSession`]] that are not the currently selected one.
  1431. **/
  1432. hideOtherMarkers(): void;
  1433. /**
  1434. * PlaceHolder@onUpdate(e)
  1435. * Emitted when the place holder updates.
  1436. **/
  1437. onUpdate(): void;
  1438. /**
  1439. * PlaceHolder@onCursorChange(e)
  1440. * Emitted when the cursor changes.
  1441. **/
  1442. onCursorChange(): void;
  1443. /**
  1444. * PlaceHolder.detach()
  1445. * TODO
  1446. **/
  1447. detach(): void;
  1448. /**
  1449. * PlaceHolder.cancel()
  1450. * TODO
  1451. **/
  1452. cancel(): void;
  1453. }
  1454. var PlaceHolder: {
  1455. /**
  1456. * - @param session (Document): The document to associate with the anchor
  1457. * - @param length (Number): The starting row position
  1458. * - @param pos (Number): The starting column position
  1459. * - @param others (String):
  1460. * - @param mainClass (String):
  1461. * - @param othersClass (String):
  1462. **/
  1463. new (session: Document, length: number, pos: number, others: string, mainClass: string, othersClass: string): PlaceHolder;
  1464. new (session: IEditSession, length: number, pos: Position, positions: Position[]): PlaceHolder;
  1465. };
  1466. ////////////////
  1467. /// RangeList
  1468. ////////////////
  1469. export interface IRangeList {
  1470. ranges: Range[];
  1471. pointIndex(pos: Position, startIndex?: number): void;
  1472. addList(ranges: Range[]): void;
  1473. add(ranges: Range): void;
  1474. merge(): Range[];
  1475. substractPoint(pos: Position): void;
  1476. }
  1477. export var RangeList: {
  1478. new (): IRangeList;
  1479. };
  1480. ////////////////
  1481. /// Range
  1482. ////////////////
  1483. /**
  1484. * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column.
  1485. **/
  1486. export interface Range {
  1487. startRow:number;
  1488. startColumn:number;
  1489. endRow:number;
  1490. endColumn:number;
  1491. start: Position;
  1492. end: Position;
  1493. isEmpty(): boolean;
  1494. /**
  1495. * Returns `true` if and only if the starting row and column, and ending row and column, are equivalent to those given by `range`.
  1496. * @param range A range to check against
  1497. **/
  1498. isEqual(range: Range): void;
  1499. /**
  1500. * Returns a string containing the range's row and column information, given like this:
  1501. * ```
  1502. * [start.row/start.column] -> [end.row/end.column]
  1503. * ```
  1504. **/
  1505. toString(): void;
  1506. /**
  1507. * Returns `true` if the `row` and `column` provided are within the given range. This can better be expressed as returning `true` if:
  1508. * ```javascript
  1509. * this.start.row <= row <= this.end.row &&
  1510. * this.start.column <= column <= this.end.column
  1511. * ```
  1512. * @param row A row to check for
  1513. * @param column A column to check for
  1514. **/
  1515. contains(row: number, column: number): boolean;
  1516. /**
  1517. * Compares `this` range (A) with another range (B).
  1518. * @param range A range to compare with
  1519. **/
  1520. compareRange(range: Range): number;
  1521. /**
  1522. * Checks the row and column points of `p` with the row and column points of the calling range.
  1523. * @param p A point to compare with
  1524. **/
  1525. comparePoint(p: Range): number;
  1526. /**
  1527. * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range.
  1528. * @param range A range to compare with
  1529. **/
  1530. containsRange(range: Range): boolean;
  1531. /**
  1532. * Returns `true` if passed in `range` intersects with the one calling this method.
  1533. * @param range A range to compare with
  1534. **/
  1535. intersects(range: Range): boolean;
  1536. /**
  1537. * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`.
  1538. * @param row A row point to compare with
  1539. * @param column A column point to compare with
  1540. **/
  1541. isEnd(row: number, column: number): boolean;
  1542. /**
  1543. * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`.
  1544. * @param row A row point to compare with
  1545. * @param column A column point to compare with
  1546. **/
  1547. isStart(row: number, column: number): boolean;
  1548. /**
  1549. * Sets the starting row and column for the range.
  1550. * @param row A row point to set
  1551. * @param column A column point to set
  1552. **/
  1553. setStart(row: number, column: number): void;
  1554. /**
  1555. * Sets the starting row and column for the range.
  1556. * @param row A row point to set
  1557. * @param column A column point to set
  1558. **/
  1559. setEnd(row: number, column: number): void;
  1560. /**
  1561. * Returns `true` if the `row` and `column` are within the given range.
  1562. * @param row A row point to compare with
  1563. * @param column A column point to compare with
  1564. **/
  1565. inside(row: number, column: number): boolean;
  1566. /**
  1567. * Returns `true` if the `row` and `column` are within the given range's starting points.
  1568. * @param row A row point to compare with
  1569. * @param column A column point to compare with
  1570. **/
  1571. insideStart(row: number, column: number): boolean;
  1572. /**
  1573. * Returns `true` if the `row` and `column` are within the given range's ending points.
  1574. * @param row A row point to compare with
  1575. * @param column A column point to compare with
  1576. **/
  1577. insideEnd(row: number, column: number): boolean;
  1578. /**
  1579. * Checks the row and column points with the row and column points of the calling range.
  1580. * @param row A row point to compare with
  1581. * @param column A column point to compare with
  1582. **/
  1583. compare(row: number, column: number): number;
  1584. /**
  1585. * Checks the row and column points with the row and column points of the calling range.
  1586. * @param row A row point to compare with
  1587. * @param column A column point to compare with
  1588. **/
  1589. compareStart(row: number, column: number): number;
  1590. /**
  1591. * Checks the row and column points with the row and column points of the calling range.
  1592. * @param row A row point to compare with
  1593. * @param column A column point to compare with
  1594. **/
  1595. compareEnd(row: number, column: number): number;
  1596. /**
  1597. * Checks the row and column points with the row and column points of the calling range.
  1598. * @param row A row point to compare with
  1599. * @param column A column point to compare with
  1600. **/
  1601. compareInside(row: number, column: number): number;
  1602. /**
  1603. * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object.
  1604. * @param firstRow The starting row
  1605. * @param lastRow The ending row
  1606. **/
  1607. clipRows(firstRow: number, lastRow: number): Range;
  1608. /**
  1609. * Changes the row and column points for the calling range for both the starting and ending points.
  1610. * @param row A new row to extend to
  1611. * @param column A new column to extend to
  1612. **/
  1613. extend(row: number, column: number): Range;
  1614. /**
  1615. * Returns `true` if the range spans across multiple lines.
  1616. **/
  1617. isMultiLine(): boolean;
  1618. /**
  1619. * Returns a duplicate of the calling range.
  1620. **/
  1621. clone(): Range;
  1622. /**
  1623. * Returns a range containing the starting and ending rows of the original range, but with a column value of `0`.
  1624. **/
  1625. collapseRows(): Range;
  1626. /**
  1627. * Given the current `Range`, this function converts those starting and ending points into screen positions, and then returns a new `Range` object.
  1628. * @param session The `EditSession` to retrieve coordinates from
  1629. **/
  1630. toScreenRange(session: IEditSession): Range;
  1631. /**
  1632. * Creates and returns a new `Range` based on the row and column of the given parameters.
  1633. * @param start A starting point to use
  1634. * @param end An ending point to use
  1635. **/
  1636. fromPoints(start: Range, end: Range): Range;
  1637. }
  1638. /**
  1639. * Creates a new `Range` object with the given starting and ending row and column points.
  1640. * @param startRow The starting row
  1641. * @param startColumn The starting column
  1642. * @param endRow The ending row
  1643. * @param endColumn The ending column
  1644. **/
  1645. var Range: {
  1646. fromPoints(pos1: Position, pos2: Position): Range;
  1647. new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
  1648. };
  1649. ////////////////
  1650. /// RenderLoop
  1651. ////////////////
  1652. export interface RenderLoop { }
  1653. var RenderLoop: {
  1654. new(): RenderLoop;
  1655. };
  1656. ////////////////
  1657. /// ScrollBar
  1658. ////////////////
  1659. /**
  1660. * A set of methods for setting and retrieving the editor's scrollbar.
  1661. **/
  1662. export interface ScrollBar {
  1663. /**
  1664. * Emitted when the scroll bar, well, scrolls.
  1665. * @param e Contains one property, `"data"`, which indicates the current scroll top position
  1666. **/
  1667. onScroll(e: any): void;
  1668. /**
  1669. * Returns the width of the scroll bar.
  1670. **/
  1671. getWidth(): number;
  1672. /**
  1673. * Sets the height of the scroll bar, in pixels.
  1674. * @param height The new height
  1675. **/
  1676. setHeight(height: number): void;
  1677. /**
  1678. * Sets the inner height of the scroll bar, in pixels.
  1679. * @param height The new inner height
  1680. **/
  1681. setInnerHeight(height: number): void;
  1682. /**
  1683. * Sets the scroll top of the scroll bar.
  1684. * @param scrollTop The new scroll top
  1685. **/
  1686. setScrollTop(scrollTop: number): void;
  1687. }
  1688. var ScrollBar: {
  1689. /**
  1690. * Creates a new `ScrollBar`. `parent` is the owner of the scroll bar.
  1691. * @param parent A DOM element
  1692. **/
  1693. new(parent: HTMLElement): ScrollBar;
  1694. };
  1695. ////////////////
  1696. /// Search
  1697. ////////////////
  1698. /**
  1699. * A class designed to handle all sorts of text searches within a [[Document `Document`]].
  1700. **/
  1701. export interface Search {
  1702. /**
  1703. * Sets the search options via the `options` parameter.
  1704. * @param options An object containing all the new search properties
  1705. **/
  1706. set(options: any): Search;
  1707. /**
  1708. * [Returns an object containing all the search options.]{: #Search.getOptions}
  1709. **/
  1710. getOptions(): any;
  1711. /**
  1712. * Sets the search options via the `options` parameter.
  1713. * @param An object containing all the search propertie
  1714. **/
  1715. setOptions(An: any): void;
  1716. /**
  1717. * Searches for `options.needle`. If found, this method returns the [[Range `Range`]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
  1718. * @param session The session to search with
  1719. **/
  1720. find(session: IEditSession): Range;
  1721. /**
  1722. * Searches for all occurances `options.needle`. If found, this method returns an array of [[Range `Range`s]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session.
  1723. * @param session The session to search with
  1724. **/
  1725. findAll(session: IEditSession): Range[];
  1726. /**
  1727. * Searches for `options.needle` in `input`, and, if found, replaces it with `replacement`.
  1728. * @param input The text to search in
  1729. * @param replacement The replacing text
  1730. * + (String): If `options.regExp` is `true`, this function returns `input` with the replacement already made. Otherwise, this function just returns `replacement`.<br/>
  1731. * If `options.needle` was not found, this function returns `null`.
  1732. **/
  1733. replace(input: string, replacement: string): string;
  1734. }
  1735. var Search: {
  1736. /**
  1737. * Creates a new `Search` object. The following search options are avaliable:
  1738. * - `needle`: The string or regular expression you're looking for
  1739. * - `backwards`: Whether to search backwards from where cursor currently is. Defaults to `false`.
  1740. * - `wrap`: Whether to wrap the search back to the beginning when it hits the end. Defaults to `false`.
  1741. * - `caseSensitive`: Whether the search ought to be case-sensitive. Defaults to `false`.
  1742. * - `wholeWord`: Whether the search matches only on whole words. Defaults to `false`.
  1743. * - `range`: The [[Range]] to search within. Set this to `null` for the whole document
  1744. * - `regExp`: Whether the search is a regular expression or not. Defaults to `false`.
  1745. * - `start`: The starting [[Range]] or cursor position to begin the search
  1746. * - `skipCurrent`: Whether or not to include the current line in the search. Default to `false`.
  1747. **/
  1748. new(): Search;
  1749. };
  1750. ////////////////
  1751. /// Search
  1752. ////////////////
  1753. /**
  1754. * Contains the cursor position and the text selection of an edit session.
  1755. * The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding.
  1756. **/
  1757. export interface Selection {
  1758. addEventListener(ev: string, callback: Function): void;
  1759. moveCursorWordLeft(): void;
  1760. moveCursorWordRight(): void;
  1761. fromOrientedRange(range: Range): void;
  1762. setSelectionRange(match: any): void;
  1763. getAllRanges(): Range[];
  1764. on(event: string, fn: (e: any) => any): void;
  1765. addRange(range: Range): void;
  1766. /**
  1767. * Returns `true` if the selection is empty.
  1768. **/
  1769. isEmpty(): boolean;
  1770. /**
  1771. * Returns `true` if the selection is a multi-line.
  1772. **/
  1773. isMultiLine(): boolean;
  1774. /**
  1775. * Gets the current position of the cursor.
  1776. **/
  1777. getCursor(): Position;
  1778. /**
  1779. * Sets the row and column position of the anchor. This function also emits the `'changeSelection'` event.
  1780. * @param row The new row
  1781. * @param column The new column
  1782. **/
  1783. setSelectionAnchor(row: number, column: number): void;
  1784. /**
  1785. * Returns an object containing the `row` and `column` of the calling selection anchor.
  1786. **/
  1787. getSelectionAnchor(): any;
  1788. /**
  1789. * Returns an object containing the `row` and `column` of the calling selection lead.
  1790. **/
  1791. getSelectionLead(): any;
  1792. /**
  1793. * Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns.
  1794. * @param columns The number of columns to shift by
  1795. **/
  1796. shiftSelection(columns: number): void;
  1797. /**
  1798. * Returns `true` if the selection is going backwards in the document.
  1799. **/
  1800. isBackwards(): boolean;
  1801. /**
  1802. * [Returns the [[Range]] for the selected text.]{: #Selection.getRange}
  1803. **/
  1804. getRange(): Range;
  1805. /**
  1806. * [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection}
  1807. **/
  1808. clearSelection(): void;
  1809. /**
  1810. * Selects all the text in the document.
  1811. **/
  1812. selectAll(): void;
  1813. /**
  1814. * Sets the selection to the provided range.
  1815. * @param range The range of text to select
  1816. * @param reverse Indicates if the range should go backwards (`true`) or not
  1817. **/
  1818. setRange(range: Range, reverse: boolean): void;
  1819. /**
  1820. * Moves the selection cursor to the indicated row and column.
  1821. * @param row The row to select to
  1822. * @param column The column to select to
  1823. **/
  1824. selectTo(row: number, column: number): void;
  1825. /**
  1826. * Moves the selection cursor to the row and column indicated by `pos`.
  1827. * @param pos An object containing the row and column
  1828. **/
  1829. selectToPosition(pos: any): void;
  1830. /**
  1831. * Moves the selection up one row.
  1832. **/
  1833. selectUp(): void;
  1834. /**
  1835. * Moves the selection down one row.
  1836. **/
  1837. selectDown(): void;
  1838. /**
  1839. * Moves the selection right one column.
  1840. **/
  1841. selectRight(): void;
  1842. /**
  1843. * Moves the selection left one column.
  1844. **/
  1845. selectLeft(): void;
  1846. /**
  1847. * Moves the selection to the beginning of the current line.
  1848. **/
  1849. selectLineStart(): void;
  1850. /**
  1851. * Moves the selection to the end of the current line.
  1852. **/
  1853. selectLineEnd(): void;
  1854. /**
  1855. * Moves the selection to the end of the file.
  1856. **/
  1857. selectFileEnd(): void;
  1858. /**
  1859. * Moves the selection to the start of the file.
  1860. **/
  1861. selectFileStart(): void;
  1862. /**
  1863. * Moves the selection to the first word on the right.
  1864. **/
  1865. selectWordRight(): void;
  1866. /**
  1867. * Moves the selection to the first word on the left.
  1868. **/
  1869. selectWordLeft(): void;
  1870. /**
  1871. * Moves the selection to highlight the entire word.
  1872. **/
  1873. getWordRange(): void;
  1874. /**
  1875. * Selects an entire word boundary.
  1876. **/
  1877. selectWord(): void;
  1878. /**
  1879. * Selects a word, including its right whitespace.
  1880. **/
  1881. selectAWord(): void;
  1882. /**
  1883. * Selects the entire line.
  1884. **/
  1885. selectLine(): void;
  1886. /**
  1887. * Moves the cursor up one row.
  1888. **/
  1889. moveCursorUp(): void;
  1890. /**
  1891. * Moves the cursor down one row.
  1892. **/
  1893. moveCursorDown(): void;
  1894. /**
  1895. * Moves the cursor left one column.
  1896. **/
  1897. moveCursorLeft(): void;
  1898. /**
  1899. * Moves the cursor right one column.
  1900. **/
  1901. moveCursorRight(): void;
  1902. /**
  1903. * Moves the cursor to the start of the line.
  1904. **/
  1905. moveCursorLineStart(): void;
  1906. /**
  1907. * Moves the cursor to the end of the line.
  1908. **/
  1909. moveCursorLineEnd(): void;
  1910. /**
  1911. * Moves the cursor to the end of the file.
  1912. **/
  1913. moveCursorFileEnd(): void;
  1914. /**
  1915. * Moves the cursor to the start of the file.
  1916. **/
  1917. moveCursorFileStart(): void;
  1918. /**
  1919. * Moves the cursor to the word on the right.
  1920. **/
  1921. moveCursorLongWordRight(): void;
  1922. /**
  1923. * Moves the cursor to the word on the left.
  1924. **/
  1925. moveCursorLongWordLeft(): void;
  1926. /**
  1927. * Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document.
  1928. * @param rows The number of rows to move by
  1929. * @param chars The number of characters to move by
  1930. **/
  1931. moveCursorBy(rows: number, chars: number): void;
  1932. /**
  1933. * Moves the selection to the position indicated by its `row` and `column`.
  1934. * @param position The position to move to
  1935. **/
  1936. moveCursorToPosition(position: any): void;
  1937. /**
  1938. * Moves the cursor to the row and column provided. [If `preventUpdateDesiredColumn` is `true`, then the cursor stays in the same column position as its original point.]{: #preventUpdateBoolDesc}
  1939. * @param row The row to move to
  1940. * @param column The column to move to
  1941. * @param keepDesiredColumn [If `true`, the cursor move does not respect the previous column]{: #preventUpdateBool}
  1942. **/
  1943. moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean): void;
  1944. /**
  1945. * Moves the cursor to the screen position indicated by row and column. {:preventUpdateBoolDesc}
  1946. * @param row The row to move to
  1947. * @param column The column to move to
  1948. * @param keepDesiredColumn {:preventUpdateBool}
  1949. **/
  1950. moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean): void;
  1951. }
  1952. var Selection: {
  1953. /**
  1954. * Creates a new `Selection` object.
  1955. * @param session The session to use
  1956. **/
  1957. new(session: IEditSession): Selection;
  1958. };
  1959. ////////////////
  1960. /// Split
  1961. ////////////////
  1962. export interface Split {
  1963. /**
  1964. * Returns the number of splits.
  1965. **/
  1966. getSplits(): number;
  1967. /**
  1968. * Returns the editor identified by the index `idx`.
  1969. * @param idx The index of the editor you want
  1970. **/
  1971. getEditor(idx: number): void;
  1972. /**
  1973. * Returns the current editor.
  1974. **/
  1975. getCurrentEditor(): Editor;
  1976. /**
  1977. * Focuses the current editor.
  1978. **/
  1979. focus(): void;
  1980. /**
  1981. * Blurs the current editor.
  1982. **/
  1983. blur(): void;
  1984. /**
  1985. * Sets a theme for each of the available editors.
  1986. * @param theme The name of the theme to set
  1987. **/
  1988. setTheme(theme: string): void;
  1989. /**
  1990. * Sets the keyboard handler for the editor.
  1991. * @param keybinding
  1992. **/
  1993. setKeyboardHandler(keybinding: string): void;
  1994. /**
  1995. * Executes `callback` on all of the available editors.
  1996. * @param callback A callback function to execute
  1997. * @param scope The default scope for the callback
  1998. **/
  1999. forEach(callback: Function, scope: string): void;
  2000. /**
  2001. * Sets the font size, in pixels, for all the available editors.
  2002. * @param size The new font size
  2003. **/
  2004. setFontSize(size: number): void;
  2005. /**
  2006. * Sets a new [[EditSession `EditSession`]] for the indicated editor.
  2007. * @param session The new edit session
  2008. * @param idx The editor's index you're interested in
  2009. **/
  2010. setSession(session: IEditSession, idx: number): void;
  2011. /**
  2012. * Returns the orientation.
  2013. **/
  2014. getOrientation(): number;
  2015. /**
  2016. * Sets the orientation.
  2017. * @param orientation The new orientation value
  2018. **/
  2019. setOrientation(orientation: number): void;
  2020. /**
  2021. * Resizes the editor.
  2022. **/
  2023. resize(): void;
  2024. }
  2025. var Split: {
  2026. new(): Split;
  2027. };
  2028. //////////////////
  2029. /// TokenIterator
  2030. //////////////////
  2031. /**
  2032. * This class provides an essay way to treat the document as a stream of tokens, and provides methods to iterate over these tokens.
  2033. **/
  2034. export interface TokenIterator {
  2035. /**
  2036. * Tokenizes all the items from the current point to the row prior in the document.
  2037. **/
  2038. stepBackward(): string[];
  2039. /**
  2040. * Tokenizes all the items from the current point until the next row in the document. If the current point is at the end of the file, this function returns `null`. Otherwise, it returns the tokenized string.
  2041. **/
  2042. stepForward(): string;
  2043. /**
  2044. * Returns the current tokenized string.
  2045. **/
  2046. getCurrentToken(): TokenInfo;
  2047. /**
  2048. * Returns the current row.
  2049. **/
  2050. getCurrentTokenRow(): number;
  2051. /**
  2052. * Returns the current column.
  2053. **/
  2054. getCurrentTokenColumn(): number;
  2055. }
  2056. var TokenIterator: {
  2057. /**
  2058. * Creates a new token iterator object. The inital token index is set to the provided row and column coordinates.
  2059. * @param session The session to associate with
  2060. * @param initialRow The row to start the tokenizing at
  2061. * @param initialColumn The column to start the tokenizing at
  2062. **/
  2063. new(session: IEditSession, initialRow: number, initialColumn: number): TokenIterator;
  2064. };
  2065. //////////////////
  2066. /// Tokenizer
  2067. //////////////////
  2068. /**
  2069. * This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter).
  2070. **/
  2071. export interface Tokenizer {
  2072. /**
  2073. * Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state.
  2074. **/
  2075. getLineTokens(): any;
  2076. }
  2077. var Tokenizer: {
  2078. /**
  2079. * Constructs a new tokenizer based on the given rules and flags.
  2080. * @param rules The highlighting rules
  2081. * @param flag Any additional regular expression flags to pass (like "i" for case insensitive)
  2082. **/
  2083. new(rules: any, flag: string): Tokenizer;
  2084. };
  2085. //////////////////
  2086. /// UndoManager
  2087. //////////////////
  2088. /**
  2089. * This object maintains the undo stack for an [[EditSession `EditSession`]].
  2090. **/
  2091. export interface UndoManager {
  2092. /**
  2093. * Provides a means for implementing your own undo manager. `options` has one property, `args`, an [[Array `Array`]], with two elements:
  2094. * - `args[0]` is an array of deltas
  2095. * - `args[1]` is the document to associate with
  2096. * @param options Contains additional properties
  2097. **/
  2098. execute(options: any): void;
  2099. /**
  2100. * [Perform an undo operation on the document, reverting the last change.]{: #UndoManager.undo}
  2101. * @param dontSelect {:dontSelect}
  2102. **/
  2103. undo(dontSelect?: boolean): Range;
  2104. /**
  2105. * [Perform a redo operation on the document, reimplementing the last change.]{: #UndoManager.redo}
  2106. * @param dontSelect {:dontSelect}
  2107. **/
  2108. redo(dontSelect: boolean): void;
  2109. /**
  2110. * Destroys the stack of undo and redo redo operations.
  2111. **/
  2112. reset(): void;
  2113. /**
  2114. * Returns `true` if there are undo operations left to perform.
  2115. **/
  2116. hasUndo(): boolean;
  2117. /**
  2118. * Returns `true` if there are redo operations left to perform.
  2119. **/
  2120. hasRedo(): boolean;
  2121. /**
  2122. * Returns `true` if the dirty counter is 0
  2123. **/
  2124. isClean(): boolean;
  2125. /**
  2126. * Sets dirty counter to 0
  2127. **/
  2128. markClean(): void;
  2129. }
  2130. var UndoManager: {
  2131. /**
  2132. * Resets the current undo state and creates a new `UndoManager`.
  2133. **/
  2134. new(): UndoManager;
  2135. };
  2136. ////////////////////
  2137. /// VirtualRenderer
  2138. ////////////////////
  2139. /**
  2140. * The class that is responsible for drawing everything you see on the screen!
  2141. **/
  2142. export interface VirtualRenderer {
  2143. scroller: any;
  2144. characterWidth: number;
  2145. lineHeight: number;
  2146. screenToTextCoordinates(left: number, top: number): void;
  2147. /**
  2148. * Associates the renderer with an [[EditSession `EditSession`]].
  2149. **/
  2150. setSession(session: IEditSession): void;
  2151. /**
  2152. * Triggers a partial update of the text, from the range given by the two parameters.
  2153. * @param firstRow The first row to update
  2154. * @param lastRow The last row to update
  2155. **/
  2156. updateLines(firstRow: number, lastRow: number): void;
  2157. /**
  2158. * Triggers a full update of the text, for all the rows.
  2159. **/
  2160. updateText(): void;
  2161. /**
  2162. * Triggers a full update of all the layers, for all the rows.
  2163. * @param force If `true`, forces the changes through
  2164. **/
  2165. updateFull(force: boolean): void;
  2166. /**
  2167. * Updates the font size.
  2168. **/
  2169. updateFontSize(): void;
  2170. /**
  2171. * [Triggers a resize of the editor.]{: #VirtualRenderer.onResize}
  2172. * @param force If `true`, recomputes the size, even if the height and width haven't changed
  2173. * @param gutterWidth The width of the gutter in pixels
  2174. * @param width The width of the editor in pixels
  2175. * @param height The hiehgt of the editor, in pixels
  2176. **/
  2177. onResize(force: boolean, gutterWidth: number, width: number, height: number): void;
  2178. /**
  2179. * Adjusts the wrap limit, which is the number of characters that can fit within the width of the edit area on screen.
  2180. **/
  2181. adjustWrapLimit(): void;
  2182. /**
  2183. * Identifies whether you want to have an animated scroll or not.
  2184. * @param shouldAnimate Set to `true` to show animated scrolls
  2185. **/
  2186. setAnimatedScroll(shouldAnimate: boolean): void;
  2187. /**
  2188. * Returns whether an animated scroll happens or not.
  2189. **/
  2190. getAnimatedScroll(): boolean;
  2191. /**
  2192. * Identifies whether you want to show invisible characters or not.
  2193. * @param showInvisibles Set to `true` to show invisibles
  2194. **/
  2195. setShowInvisibles(showInvisibles: boolean): void;
  2196. /**
  2197. * Returns whether invisible characters are being shown or not.
  2198. **/
  2199. getShowInvisibles(): boolean;
  2200. /**
  2201. * Identifies whether you want to show the print margin or not.
  2202. * @param showPrintMargin Set to `true` to show the print margin
  2203. **/
  2204. setShowPrintMargin(showPrintMargin: boolean): void;
  2205. /**
  2206. * Returns whether the print margin is being shown or not.
  2207. **/
  2208. getShowPrintMargin(): boolean;
  2209. /**
  2210. * Identifies whether you want to show the print margin column or not.
  2211. * @param showPrintMargin Set to `true` to show the print margin column
  2212. **/
  2213. setPrintMarginColumn(showPrintMargin: boolean): void;
  2214. /**
  2215. * Returns whether the print margin column is being shown or not.
  2216. **/
  2217. getPrintMarginColumn(): boolean;
  2218. /**
  2219. * Returns `true` if the gutter is being shown.
  2220. **/
  2221. getShowGutter(): boolean;
  2222. /**
  2223. * Identifies whether you want to show the gutter or not.
  2224. * @param show Set to `true` to show the gutter
  2225. **/
  2226. setShowGutter(show: boolean): void;
  2227. /**
  2228. * Returns the root element containing this renderer.
  2229. **/
  2230. getContainerElement(): HTMLElement;
  2231. /**
  2232. * Returns the element that the mouse events are attached to
  2233. **/
  2234. getMouseEventTarget(): HTMLElement;
  2235. /**
  2236. * Returns the element to which the hidden text area is added.
  2237. **/
  2238. getTextAreaContainer(): HTMLElement;
  2239. /**
  2240. * [Returns the index of the first visible row.]{: #VirtualRenderer.getFirstVisibleRow}
  2241. **/
  2242. getFirstVisibleRow(): number;
  2243. /**
  2244. * Returns the index of the first fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
  2245. **/
  2246. getFirstFullyVisibleRow(): number;
  2247. /**
  2248. * Returns the index of the last fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen.
  2249. **/
  2250. getLastFullyVisibleRow(): number;
  2251. /**
  2252. * [Returns the index of the last visible row.]{: #VirtualRenderer.getLastVisibleRow}
  2253. **/
  2254. getLastVisibleRow(): number;
  2255. /**
  2256. * Sets the padding for all the layers.
  2257. * @param padding A new padding value (in pixels)
  2258. **/
  2259. setPadding(padding: number): void;
  2260. /**
  2261. * Returns whether the horizontal scrollbar is set to be always visible.
  2262. **/
  2263. getHScrollBarAlwaysVisible(): boolean;
  2264. /**
  2265. * Identifies whether you want to show the horizontal scrollbar or not.
  2266. * @param alwaysVisible Set to `true` to make the horizontal scroll bar visible
  2267. **/
  2268. setHScrollBarAlwaysVisible(alwaysVisible: boolean): void;
  2269. /**
  2270. * Schedules an update to all the front markers in the document.
  2271. **/
  2272. updateFrontMarkers(): void;
  2273. /**
  2274. * Schedules an update to all the back markers in the document.
  2275. **/
  2276. updateBackMarkers(): void;
  2277. /**
  2278. * Deprecated; (moved to [[EditSession]])
  2279. **/
  2280. addGutterDecoration(): void;
  2281. /**
  2282. * Deprecated; (moved to [[EditSession]])
  2283. **/
  2284. removeGutterDecoration(): void;
  2285. /**
  2286. * Redraw breakpoints.
  2287. **/
  2288. updateBreakpoints(): void;
  2289. /**
  2290. * Sets annotations for the gutter.
  2291. * @param annotations An array containing annotations
  2292. **/
  2293. setAnnotations(annotations: any[]): void;
  2294. /**
  2295. * Updates the cursor icon.
  2296. **/
  2297. updateCursor(): void;
  2298. /**
  2299. * Hides the cursor icon.
  2300. **/
  2301. hideCursor(): void;
  2302. /**
  2303. * Shows the cursor icon.
  2304. **/
  2305. showCursor(): void;
  2306. /**
  2307. * Scrolls the cursor into the first visibile area of the editor
  2308. **/
  2309. scrollCursorIntoView(): void;
  2310. /**
  2311. * {:EditSession.getScrollTop}
  2312. **/
  2313. getScrollTop(): number;
  2314. /**
  2315. * {:EditSession.getScrollLeft}
  2316. **/
  2317. getScrollLeft(): number;
  2318. /**
  2319. * Returns the first visible row, regardless of whether it's fully visible or not.
  2320. **/
  2321. getScrollTopRow(): number;
  2322. /**
  2323. * Returns the last visible row, regardless of whether it's fully visible or not.
  2324. **/
  2325. getScrollBottomRow(): number;
  2326. /**
  2327. * Gracefully scrolls from the top of the editor to the row indicated.
  2328. * @param row A row id
  2329. **/
  2330. scrollToRow(row: number): void;
  2331. /**
  2332. * Gracefully scrolls the editor to the row indicated.
  2333. * @param line A line number
  2334. * @param center If `true`, centers the editor the to indicated line
  2335. * @param animate If `true` animates scrolling
  2336. * @param callback Function to be called after the animation has finished
  2337. **/
  2338. scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void;
  2339. /**
  2340. * Scrolls the editor to the y pixel indicated.
  2341. * @param scrollTop The position to scroll to
  2342. **/
  2343. scrollToY(scrollTop: number): number;
  2344. /**
  2345. * Scrolls the editor across the x-axis to the pixel indicated.
  2346. * @param scrollLeft The position to scroll to
  2347. **/
  2348. scrollToX(scrollLeft: number): number;
  2349. /**
  2350. * Scrolls the editor across both x- and y-axes.
  2351. * @param deltaX The x value to scroll by
  2352. * @param deltaY The y value to scroll by
  2353. **/
  2354. scrollBy(deltaX: number, deltaY: number): void;
  2355. /**
  2356. * Returns `true` if you can still scroll by either parameter; in other words, you haven't reached the end of the file or line.
  2357. * @param deltaX The x value to scroll by
  2358. * @param deltaY The y value to scroll by
  2359. **/
  2360. isScrollableBy(deltaX: number, deltaY: number): boolean;
  2361. /**
  2362. * Returns an object containing the `pageX` and `pageY` coordinates of the document position.
  2363. * @param row The document row position
  2364. * @param column The document column position
  2365. **/
  2366. textToScreenCoordinates(row: number, column: number): any;
  2367. /**
  2368. * Focuses the current container.
  2369. **/
  2370. visualizeFocus(): void;
  2371. /**
  2372. * Blurs the current container.
  2373. **/
  2374. visualizeBlur(): void;
  2375. /**
  2376. * undefined
  2377. * @param position
  2378. **/
  2379. showComposition(position: number): void;
  2380. /**
  2381. * Sets the inner text of the current composition to `text`.
  2382. * @param text A string of text to use
  2383. **/
  2384. setCompositionText(text: string): void;
  2385. /**
  2386. * Hides the current composition.
  2387. **/
  2388. hideComposition(): void;
  2389. /**
  2390. * [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme}
  2391. * @param theme The path to a theme
  2392. **/
  2393. setTheme(theme: string): void;
  2394. /**
  2395. * [Returns the path of the current theme.]{: #VirtualRenderer.getTheme}
  2396. **/
  2397. getTheme(): string;
  2398. /**
  2399. * [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
  2400. * @param style A class name
  2401. **/
  2402. setStyle(style: string): void;
  2403. /**
  2404. * [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
  2405. * @param style A class name
  2406. **/
  2407. unsetStyle(style: string): void;
  2408. /**
  2409. * Destroys the text and cursor layers for this renderer.
  2410. **/
  2411. destroy(): void;
  2412. }
  2413. var VirtualRenderer: {
  2414. /**
  2415. * Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`.
  2416. * @param container The root element of the editor
  2417. * @param theme The starting theme
  2418. **/
  2419. new(container: HTMLElement, theme?: string): VirtualRenderer;
  2420. };
  2421. }
  2422. declare var ace: AceAjax.Ace;