诅咒如何保存屏幕内容? [英] How curses preserves screen contents?

查看:96
本文介绍了诅咒如何保存屏幕内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

启动(n)curses程序时,它将从终端仿真器中删除滚动条,清除屏幕,滚动日志(历史记录)也将消失.退出程序时,屏幕内容会再次出现,滚动条返回,滚动缓冲区返回.

When you start the (n)curses program, it will remove the scroll bar from your terminal emulator, clear the screen, the scroll log (history) will also disappear. When you exit the program, the screen contents reappears, the scroll bar returns, and the scroll buffer returns.

它的作用是什么?我已经研究了所有ANSI转义代码,看不到任何可以做这种事情的东西.这背后的技术是什么?

How ncurses does it? I have studied all ANSI escape codes, I cannot see anything that can do such things. What is the technology behind this?

推荐答案

该技术称为备用屏幕缓冲区.终端仿真器提供两种模式:主模式和备用模式.备用屏幕缓冲区没有向后滚动,当您在这些缓冲区之间切换时,将保留其中的内容.要在它们之间切换,请使用smcuprmcup ANSI转义序列.二进制形式为:

The technology is called The Alternate Screen Buffer. Terminal emulator provides two modes: primary and alternate. Alternate screen buffer has no scroll back, when you switch between these buffers the contents in them is preserved. To switch between them use smcup and rmcup ANSI Escape Sequences. In binary form they are:

$ tput smcup|hexdump -C 
00000000  1b 5b 3f 31 30 34 39 68                           |.[?1049h|

$ tput rmcup|hexdump -C 
00000000  1b 5b 3f 31 30 34 39 6c                           |.[?1049l|

这篇关于诅咒如何保存屏幕内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆