ace -- api

The main class required to set up an Ace instance in the browser.

在浏览器中设置一个ace实例所需要的主要类。

Methods

    Creates a new EditSession, and returns the associated Document.

    创建一个新的 EditSession, 并返回相关联的Document

    参数

    1. text (Document | string)

      必须,如果text 是 Document, 则它将 EditSession与它关联起来。否则, 使用初始的text创建一个新的Document。

    2. mode  (TextMode)

      必须,文档使用的初始语言mode。

 

    Embeds the Ace editor into the DOM, at the element provided by el.

    将Ace编辑器嵌入到在el提供的DOM元素中,

    参数

     1. el (String | DOMElement)

      必须。元素id或者 一个 DOM 元素本身。

  

  require(String moduleName) 

    Provides access to require in packed noconflict mode

    提供打包后的无冲突的mode 的引用

    参数

     moduleName (string)

     必须。

 

 

 

Anchor

Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated.

定义文档中的浮动指针。每当在光标之前插入或删除文本时,光标的位置就会被更新。

Constructors

  Creates a new Anchor and associates it with a document.

  创建一个新的 Anchor,并将它与文档关联起来。

  参数:

    1. doc (Document)

      必须。与Anchor关联的文档。

    2. row (Number)

      必须。起始行位置

    3. column (Number)

      必须。起始列位置。

Events

  • Anchor.on("change", function(Object e))

    Fires whenever the anchor position changes. Both of these objects have a row and column property corresponding to the position. Events that can trigger this function include setPosition()

    每当anchor的位置发生变化是触发。 这两个对象都具有与位置对应的row和column的属性。可以触发此函数的事件包括 setPosition()

    参数:

       1.  e  (object)

         必须。包含anchor位置的信息的对象。它有两个属性:

         old:  描述原来 Anchor位置的对象。

         value: 描述新 Anchor位置的对象。

    

Methods

    • detach()

    When called, the 'change' event listener is removed.

    当被调用时, ‘change’事件监听器被删除。

    •   getDocument()  ----->   Document

    Returns the current document.

    返回当前文档。

  • getPosition()   ----->  Object

    Returns an object identifying the row and column position of the current anchor.

    返回一个对象,该对象标识当前 anchor的 row 和column的位置。

  • onChange()   Undocumented  

    Sets the anchor position to the specified row and column. If noClip is true, the position is not clipped.

    将anchor的位置设置为指定的 row 和 column。 如果 noClip 为 true, 则不剪断位置,

    参数

      1. row (Number)

        必须。将anchor移动到 row index

      2. column (Number)

        必须。将anchor 移动到 column index

      3. noCLip (Boolean)

        必须。标识是否希望建材该位置。

 

 

 

 

BackgroundTokenizer

Tokenizes the current Document in the background, and caches the tokenized rows for future use.

在后台标记当前 Document, 并缓存当前标记的 rows以供将来使用。

If a certain row is changed, everything below that row is re-tokenized.

如果某行被更改,则该行下面的所有内容都被重新标记。

 

Constructors

  Creates a new BackgroundTokenizer object.

  创建一个新的 BackgroundTokenizer 对象

  参数:

    1.  tokenizer   (Tokenizer)

      必须。使用的 tokenizer

    2. editor   (Editor)

      必须。与之相关联的编辑器。

Events

  • BackgroundTokenizer.on("update", function(Object e))

    Fires whenever the background tokeniziers between a range of rows are going to be updated.

    每当一个行之间的后台记录器将被更新时触发。

    参数:

      1.  e (Object)

        必须。一个包含两个属性的对象, first 和 last, 指示正在更新的区域的行。

 

Methods

    Emits the 'update' event. firstRow and lastRow are used to define the boundaries of the region to be updated.

    触发 update事件。 firstRow 和 lastRow 用于定义要更新的区域的边界。

    参数

      1. firstRow  (Number)

        必须。 起始行区域。

      2. lastRow   (Number)

        必须。 结束行区域。

    Returns the state of tokenization at the end of a row.

    返回行结束时的标记化状态。

    参数

      1. row (NUmber)

        必须。获取状态的行。

    Gives list of tokens of the row. (tokens are cached)

    给出行的tokens列表 (tokens被缓存)

    参数

      1. row (Number)

        必须。获取token的行。

    Sets a new document to associate with this object.

    设置与此对象关联的新文档

    参数

      1. doc (Document)

        必须。与之关联的新文档。

    Sets a new tokenizer for this object.

    为这个对象设置一个新的记录器。

    参数

      1. tokenizer  (Tokenizer)

        必须。新的tokenizer使用

    Starts tokenizing at the row indicated.

    开始标记所指示的行

    参数

      1. startRow (Number)

        必须。要开始的行。

  • stop()

    Stops tokenizing.

    停止 标记

 

 

 

Document

Contains the text of the document. Document can be attached to several EditSessions.

包含文本的文档。Document可以附加到多个 EditSessin中。

At its core, Documents are just an array of strings, with each row in the document matching up to the array index.

在其核心,Document指示一个字符串数组。文档中的每一行与数组索引匹配。

Constructors

  Creates a new Document. If text is included, the Document contains those strings; otherwise, it's empty.

  创建一个新的文档。如果包含text,Document则包含这些字符串,否则,它是空的。

  

  参数

    1. text (String | Array)

      必须。起始的文本。

Events

  • Document.on("change", function(Object e))

    Fires whenever the document changes.

    文档更改时触发。     

    Several methods trigger different "change" events. Below is a list of each action type, followed by each property that's also available:

     几种方法触发不同的 change 事件。 下面是每个动作类型的列表,后面还有每个可用的属性: 

    • "insertLines" (emitted by Document.insertLines())          通过 Document.insertLines()  触发
    • range: the Range of the change within the document             文档Range更改。
    • lines: the lines in the document that are changing                     文档中行正在改变
    • "insertText" (emitted by Document.insertNewLine())         通过 Document.insertNewLine() 触发
    • range: the Range of the change within the document                 
    • text: the text that's being added                                              正在添加文本
    • "removeLines" (emitted by Document.insertLines())            通过 Document.insertLines()触发
    • range: the Range of the change within the document
    • lines: the lines in the document that were removed                    文档中行移除
    • nl: the new line character (as defined by Document.getNewLineCharacter())                                新行字符 (通过 Document.getNewLineCharater() 定义)
    • "removeText" (emitted by Document.removeInLine() and Document.removeNewLine())
    • range: the Range of the change within the document
    • text: the text that's being removed

 

    参数

      1. e  (Object)

        必须。包含至少一个名为 action 的属性。 action 指示触发更改的操作。每个action也有一组额外的属性。

Methods

    Applies all the changes previously accumulated. These can be either 'includeText''insertLines''removeText', and 'removeLines'.

    应用以前积累的所有更改。这些可以是 includeText,....

    参数

      1. deltas  (Object)

        必须。

    Creates a new Anchor to define a floating point in the document.

    创建一个新的 Anchor 来定义文档中的浮点。

    参数

      1.  row  (Number)

        必须。使用的行数

      2. column (Number)

        必须。使用的列

  • getAllLines()

    Returns all lines in the document as string array.  Warning: The caller should not modify this array!

    将文档中的所有行作为字符串数组返回。  注意: 调用方不应该修改这个数组。

    

  • getLength()

    Returns the number of rows in the document.

    返回文档的行数。

    Returns a verbatim copy of the given line as it is in the document

    返回文档中给定行的逐字拷贝。

    Returns an array of strings of the rows between firstRow and lastRow. This function is inclusive of lastRow.

    返回firstRow 和 lastRow 之间行的字符串数组。这个函数包含 lastRow。

  • getNewLineCharacter() String

    Returns the newline character that's being used, depending on the value of newLineMode.

    返回正在使用的换行符,这取决与newLineMode的值。

    Returns the type of newlines being used; either windowsunix, or auto

    返回正在使用的换行类型。 可以是 windows, unix, 或者 auto。

  • getTextRange(Range range)

    Given a range within the document, this function returns all the text within that range as a single string.

    在给定文档范围中,该函数将该范围内的所有文本作为单个字符串返回。

  • getValue()

    Returns all the lines in the document as a single string, split by the new line character.

    将文档中的所有行作为单个字符串返回,由换行符分隔。

    Converts an index position in a document to a {row, column} object.

    将文档中索引位置替换成 {row, column}对象。

    Index refers to the "absolute position" of a character in the document. For example:

    索引指的是文件中字符的绝对位置。比如

      var x = 0; // 10 characters, plus one for newline
      var y = -1;

    Here, y is an index 15: 11 characters for the first row, and 5 characters until y in the second.

    这里,y 是第一行的索引15:11字符, 第二行的5个字符直到 y。

    Inserts a block of text and the indicated position.

    在指示的位置插入 text 块

    Inserts text into the position at the current row. This method also triggers the 'change' event.

    Inserts the elements in lines into the document, starting at the row index given by row. This method also triggers the 'change' event.

    Inserts a new line into the document at the current row's position. This method also triggers the 'change' event.

    Returns true if text is a newline character (either \r\n\r, or \n).

    Converts the {row, column} position in a document to the character's index.

    Removes the range from the document.

    Removes the specified columns from the row. This method also triggers the 'change' event.

    Removes a range of full lines. This method also triggers the 'change' event.

    Removes the new line between row and the row immediately following it. This method also triggers the 'change' event.

    Replaces a range in the document with the new text.

  • revertDeltas(Object deltas)

    Reverts any changes previously applied. These can be either 'includeText''insertLines''removeText', and 'removeLines'.

    还原先前应用的任何更改。这些更改可以是  includeText .....

  • setNewLineMode(String newLineMode)

    Sets the new line mode.

    Replaces all the lines in the current Document with the value of text.

    将当前Document中所有行替换为 text的值

 

 

EditSession

Stores all the data about Editor state providing easy way to change editors state.

存储所有有关Editor状态的数据,提供更改编辑器状态的方法。

EditSession can be attached to only one Document. Same Document can be attached to several EditSessions.

EditSession只能附加到一个Document。相同的Document可以附加到多个 EditSessin中。

Constructors

    Sets up a new EditSession and associates it with the given Document and TextMode.

    设置一个新的EditSession,并将它与给定的Document和TextMode关联起来。

Events

  • EditSession.on("change", function(Object e))

    Emitted when the document changes.

    当文档改变时触发。

  • EditSession.on("changeAnnotation", function())

    Emitted when an annotation changes, like through EditSession.setAnnotations().

    当注释改变时触发,比如通过 EditSession.setAnnotations()

  • EditSession.on("changeBackMarker", function())

    Emitted when a back marker changes.

    当后置标记发生变化时触发。

  • EditSession.on("changeBreakpoint", function())

    Emitted when the gutter changes, either by setting or removing breakpoints, or when the gutter decorations change.

    当gutters发生变化,或者通过设置或移除断点或者当gutters装饰发生变化时触发。

  • EditSession.on("changeFold", function())

    Emitted when a code fold is added or removed.

    当代码折叠添加或者移除时触发。

  • EditSession.on("changeFrontMarker", function())

    Emitted when a front marker changes.

    当  前标记改变时触发。

  • EditSession.on("changeMode", function())

    Emitted when the current mode changes.

    当 当前mode改变时触发。

  • EditSession.on("changeOverwrite", function())

    Emitted when the ability to overwrite text changes, via EditSession.setOverwrite().

    当通过 EditSession.setOverWrite() 更改覆盖文本的能力时触发。

  • EditSession.on("changeScrollLeft", function(Number scrollLeft))

    Emitted when the scroll left changes.

    当滚动条左改变时触发。

  • EditSession.on("changeScrollTop", function(Number scrollTop))

    Emitted when the scroll top changes.

  • EditSession.on("changeTabSize", function())

    Emitted when the tab size changes, via EditSession.setTabSize().

    通过 EditSession.setTabSize() 改变 tab 大小时触发。

  • EditSession.on("changeWrapLimit", function())

    Emitted when the wrapping limit changes.

    当包装限制改变时触发。

  • EditSession.on("changeWrapMode", function())

    Emitted when the wrap mode changes.

    当包裹mode改变时触发。

  • EditSession.on("tokenizerUpdate", function(Object e))

    Emitted when a background tokenizer asynchronously processes new rows.

    当后台记录器异步处理新行时触发。参数e包含一个data属性的对象,该对象包含关于更改行的信息。

 

Methods

    Adds a dynamic marker to the session.

    向回话添加动态标记。

    Adds className to the row, to be used for CSS stylings and whatnot.

    将 className 添加到 row中,用于CSS样式和其他。

    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.

    在给定的Range中添加新的标记。 如果 inFront为true,则定义一个前端 标记, 并且触发 changeFrontMarker事件,否则,触发changeBackMarker事件。

  • clearAnnotations()

    Clears all the annotations for this session. This function also triggers the 'changeAnnotation' event.

    清除此会话的所有注释。该函数会触发 changeAnnotation事件。

  • clearBreakpoint(Number row)

    Removes a breakpoint on the row number given by rows. This function also emits the 'changeBreakpoint' event.

    移除给定rows上所有的断点。该函数会触发 changeBreakpoint事件。

  • clearBreakpoints()

    Removes all breakpoints on the rows. This function also emites the 'changeBreakpoint' event.

    For the given document row and column, returns the screen column.

    对于给定的文档行和列,返回屏幕列。

    Converts document coordinates to screen coordinates. This takes into account code folding, word wrap, tab size, and any other visual modifications.

    将文档坐标转换为屏幕坐标。这考虑了代码的折叠,字包,标签大小和任何其他视觉修改。

    For the given document row and column, returns the screen row.

    对于给定的文档行和列,返回屏幕行。

    Duplicates all the text between firstRow and lastRow.

    复制 firstRow 和 lastRow之间的所有文本。

    Returns the annotations for the EditSession.

    返回 EditSession的注释。

    Gets the range of a word, including its right whitespace.

    获取单词的范围,包括其右侧空白。

    Returns an array of numbers, indicating which rows have breakpoints.

    返回一个数字数组,指示哪些行具有断点。

    Returns the Document associated with this session.

    返回与此会话关联的Document

  • getDocumentLastRowColumn(Number docRow, Number docColumn)

    For the given document row and column, this returns the column position of the last screen row.

    对于给定的文档行和列,这将返回最后一个屏幕行的位置。

  • getDocumentLastRowColumnPosition(Number docRow, Number docColumn)

    For the given document row and column, this returns the document position of the last row.

    对于给定的文档行和列,这将返回最后一行的文档的位置。

    Returns the number of rows in the document.

    返回文档中的行数。

    Returns a verbatim copy of the given line as it is in the document

    Returns an array of strings of the rows between firstRow and lastRow. This function is inclusive of lastRow.

    Returns an array containing the IDs of all the markers, either front or back.

    返回一个包含所有标记的 IDs 的数组,无论是前面还是后面。 如果 inFront 为true, 则指示只需要前标记,false指示返回 后 标记。

    Returns the current text mode.

    Returns the current new line mode.

  • getOverwrite()

    Returns true if overwrites are enabled; false otherwise.

    如果启用重写,则返回 true,否则返回false。

    Returns number of screenrows in a wrapped line.

    返回已包装行中的屏幕的行数。 row为要检查的行数。

    For the given row, this returns the split data.

    对于给定行,返回拆分的数据。

    Returns the position (on screen) for the last character in the provided screen row.

    返回所提供屏幕行中最后一个字符的位置(屏幕上)。

    Returns the length of the screen.

    获取从屏幕的长度。

    The distance to the next tab stop at the specified screen column.

    到指定屏幕列的下一个tab的距离。

    Returns the width of the screen.

    Returns the value of the distance between the left of the editor and the leftmost part of the visible content.

    返回编辑器左侧与可见内容的最左边部分之间的距离值。

    Returns the value of the distance between the top of the editor and the topmost part of the visible content.

  • getSelection()

    Returns selection object.

    Returns the state of tokenization at the end of a row.

    返回结束行时的标记化状态。

  • getTabSize()

    Returns the current tab size.

  • getTabString()

    Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by getTabSize()); otherwise it's simply '\t'.

    Given a range within the document, this function returns all the text within that range as a single string.

    给定文档中的范围,该函数将该范围内的所有文本作为单个字符串返回。

    Returns an object indicating the token at the current row. The object has two properties: index and start.

    返回指示当前行中的token的对象。对象具有两个属性: index 和 start。

    Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows.

    开始标记所指示的行。返回标记化行的对象列表。

  • getUndoManager()

    Returns the current undo manager.

    返回当前撤销管理器。

    Returns true if soft tabs are being used, false otherwise.

    如果soft tab 正在使用返回true, 否则返回false

  • getUseWorker()

    Returns true if workers are being used.

    如果正在使用workers, 返回true。

    Returns true if wrap mode is being used; false otherwise.

    Returns the current Document as a string.

    Given a starting row and column, this method returns the Range of the first word boundary it finds.

    给定起始行和列,此方法返回其查找的第一个单词边界的范围。

    Returns the value of wrap limit.

    返回 wrap限制值。

    Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this: { min: wrapLimitRange_min, max: wrapLimitRange_max }

    返回定义包限制的最小值和最大值的对象,

  • highlight()   Undocumented
  • highlightLines()    Undocumented

    Indents all the rows, from startRow to endRow (inclusive), by prefixing each row with the token in indentString.  If indentString contains the '\t' character, it's replaced by whatever is defined by getTabString()

    将从startRow到 endRow之间的所有行缩进,通过在indentString中用token预先装订每行。如果缩进字符串包含 '\t' 字符, 则有 getTabString()定的任何内容替换它。

    Inserts a block of text and the indicated position.

    Returns true if the character at the position is a soft tab.

    Shifts all the lines in the document down one, starting from firstRow and ending at lastRow.

    Shifts all the lines in the document up one, starting from firstRow and ending at lastRow.

    Moves a range of text from the given range to the given position. toPosition is an object that looks like this:

     { row: newRowLocation, column: newColumnLocation }
  • onChange()  Undocumented 
  • onChangeFold()  Undocumented
  • onReloadTokenizer(Object e)

    Reloads all the tokens on the current session. This function calls BackgroundTokenizer.start () to all the rows; it also emits the 'tokenizerUpdate' event.

  • outdentRows(Range range)

    Outdents all the rows defined by the start and end properties of range.

  • redo()Undocumented
 

    Re-implements a previously undone change to your document.

    Removes the range from the document.

    Removes className from the row.

  • removeMarker(Number markerId)

    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.

    Replaces a range in the document with the new text.

  • reset()Undocumented
  • resetCaches()Undocumented
  • screenToDocumentColumn()  Undocumented
 

    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.

  • screenToDocumentRow()  Undocumented
  • setAnnotations(Array annotations)

    Sets annotations for the EditSession. This functions emits the 'changeAnnotation' event.

    Sets a breakpoint on the row number given by rows. This function also emites the 'changeBreakpoint'event.

  • setBreakpoints(Array rows)

    Sets a breakpoint on every row number given by rows. This function also emites the 'changeBreakpoint' event.

    Sets the EditSession to point to a new Document. If a BackgroundTokenizer exists, it also points to doc.

  • setMode()  Undocumented
 
  • setNewLineMode(String newLineMode)

    Sets the new line mode.

    Pass in true to enable overwrites in your session, or false to disable.

  • setScrollLeft(Object scrollLeft)

    Sets the value of the distance between the left of the editor and the leftmost part of the visible content.

  • setScrollTop(Number scrollTop)

    This function sets the scroll top value. It also emits the 'changeScrollTop' event.

    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.

    Sets the undo manager.

    Enables or disables highlighting of the range where an undo occured.

  • setUseSoftTabs(Boolean useSoftTabs)

    Pass true to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character ('\t').

    Identifies if you want to use a worker for the EditSession.

  • setUseWrapMode(Boolean useWrapMode)

    Sets whether or not line wrapping is enabled. If useWrapMode is different than the current value, the 'changeWrapMode' event is emitted.

    Sets the session text.

    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.

  • toggleOverwrite()

    Sets the value of overwrite to the opposite of whatever it currently is.

    Returns the current Document as a string.

  • undo()   Undocumented
 

  Reverts previous changes to your document.

 

 

 

posted @ 2018-11-20 15:42  她在村口等我  阅读(486)  评论(0编辑  收藏  举报