【问题标题】:Ace Editor Cursor Current Position in Numeric IndexAce 编辑器光标在数字索引中的当前位置
【发布时间】:2016-04-25 04:29:44
【问题描述】:

在ace编辑器中是否存在任何可以计算光标(插入符号)当前位置之前总字符数的函数或逻辑?

【问题讨论】:

    标签: count ace-editor caret string-length cursor-position


    【解决方案1】:

    session.doc 上有 positionToIndex 和 indexToPosition 方法

    editor.session.doc.positionToIndex(editor.selection.getCursor())
    

    请注意,这会遍历光标之前的所有行,因此对于某些用例可能会很慢。

    【讨论】:

    • 如何通过 Ace.Range 实现这一目标以提高功能速度
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多