【问题标题】:How do I autoscroll in Ace Editor?如何在 Ace Editor 中自动滚动?
【发布时间】:2019-10-18 10:37:28
【问题描述】:

出于日志输出的目的,我使用 ace 编辑器文本框作为只读文本区域。

每当有新的日志条目时,我都希望自动滚动。

这些是我现在的设置。

this.editor.setOptions({
    readOnly: true,
    showGutter: false,
    // showLineNumbers: false,
    vScrollBarAlwaysVisible: true,
    wrapBehavioursEnabled: true,
    autoScrollEditorIntoView: true,
    wrap: true,
})

如何让框在新输入时滚动到底部?

【问题讨论】:

    标签: ace-editor autoscroll


    【解决方案1】:

    在这种情况下,一个非常简单的解决方案不考虑用户向上滚动(这是一个方便的功能),如下所示。

    this.editor.session.on('change', () => {
        this.editor.renderer.scrollToLine(Number.POSITIVE_INFINITY)
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-23
      • 1970-01-01
      相关资源
      最近更新 更多