【问题标题】:How does VIM display to the terminal and then take it back?vim如何显示到终端,然后取回?
【发布时间】:2011-05-29 16:57:00
【问题描述】:

VIM(运行时)如何将文件的内容显示到终端,然后(关闭时)可以取回显示的内容?我已经制作了几个应用程序,我希望在这些应用程序中实现此功能……例如,在制作带有终端图形的程序时,通常必须在单个“对象”移动时更新整个屏幕。

【问题讨论】:

    标签: vim terminal


    【解决方案1】:

    存储旧缓冲区的是您的终端,而不是 Vim。

    如果您使用 XTerm 仿真,Vim 会在启动时切换到“备用”终端屏幕。退出时,Vim 切换回正常屏幕。

    启动时的Terminfo字符串:

    \E7 saves the cursor's position 
    \E[?47h switches to the alternate screen 
    

    退出时的Terminfo字符串:

    \E[2J clears the screen (assumed to be the alternate screen) 
    \E[?47l switches back to the normal screen 
    \E8 restores the cursor's position. 
    

    【讨论】:

    • 至少对于 XTerm 和 screen,终端模拟器是否处理 altscreens 是可配置的。 IIRC 在 XTerm 中默认启用,在屏幕中默认禁用。 Linux 控制台根本没有 altscreen 处理。
    猜你喜欢
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-08
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多