简体   繁体   English

在 GNOME 终端中模拟一个更高的终端并上下平移

[英]Emulate a taller terminal within GNOME Terminal and pan up and down

The problem:问题:

I need to be able to run TUI programs that do no fit in a 9-line high terminal inside a nine-line terminal by panning up and down.我需要能够通过上下平移在九行终端内运行不适合九行高终端的 TUI 程序。

The set-up:设置:

I have a Raspian computer connected to a 9-line Braille display (Canute 360).我有一台连接到 9 行盲文显示器 (Canute 360) 的 Raspian 计算机。 The Braille is automatically sent the last 9 lines of the terminal by screenreader software called brltty .盲文由名为brltty的屏幕阅读器软件自动发送到终端的最后 9 行。 The terminal emulator is gnome-terminal which is pre-set to 9 lines by 40 characters.终端仿真器是gnome-terminal ,它被预设为 9 行 40 个字符。

I am coming across TUI programs that we need to run (such as raspi-config ) that assume the terminal will be more than 9 lines high and therefore do not work as certain options are hidden off the top of the terminal window. This means they are invisible on the Canute Braille display.我遇到了我们需要运行的 TUI 程序(例如raspi-config ),这些程序假定终端将超过 9 行高,因此无法工作,因为某些选项隐藏在终端 window 的顶部。这意味着它们在 Canute 盲文显示器上是不可见的。

I cannot edit or change the size of the gnome-terminal (it needs to stay as-is to meet the client specification).我无法编辑或更改gnome-terminal的大小(它需要保持原样以满足客户端规范)。 I can't change brltty 's behaviour as that is an external program, or the Braille display's behaviour.我无法更改brltty的行为,因为它是一个外部程序,或者是盲文显示器的行为。 I can install any program within Raspian, but I cannot realistically patch and fix every TUI application with this behaviour, I need a fix that can be applied any time a user comes across a problem.我可以在 Raspian 中安装任何程序,但我无法现实地修补和修复具有这种行为的每个 TUI 应用程序,我需要一个可以在用户遇到问题时随时应用的修复程序。

Using raspi-conf as the test case:使用raspi-conf作为测试用例:

It assumes at least 12-line terminal but currently only the bottom 9 lines are visible, cutting off critical options from view (on the monitor and on the Braille display).它假设至少有 12 行终端,但目前只有底部的 9 行可见,从视图中切断了关键选项(在监视器和盲文显示器上)。 If I can run a command or create a script that lets the user pan up and down, perhaps by running a taller terminal instance inside the 9-line one, then using keyboard short cuts to scroll up and down, then I assume I have solved the issue for all similar TUI applications.如果我可以运行一个命令或创建一个允许用户上下平移的脚本,也许是通过在 9 行终端实例中运行一个更高的终端实例,然后使用键盘快捷键上下滚动,那么我假设我已经解决了所有类似的 TUI 应用程序的问题。

Tried:试过:

  • I cannot use gnome-terminal history buffer as raspi-conf is fixed to the full terminal screen.我无法使用gnome-terminal历史缓冲区,因为raspi-conf固定在整个终端屏幕上。

  • I have looked at gnu-screen and tmux resize options, but I cannot see how to make a terminal window inside gnome-terminal that is larger than it rather than smaller than it or a portion of it.我查看了gnu-screentmux resize 选项,但我看不到如何在gnome-terminal中制作一个大于它而不是小于它或它的一部分的终端 window。 From this answer I read that "tmux limits the dimensions of a window to the smallest of each dimension across all the sessions to which the window is attached," so I assume that tmux is not an appropriate tool for this task.这个答案中,我读到“tmux 将 window 的维度限制为 window 所附加的所有会话中每个维度中的最小维度”,因此我认为 tmux 不是完成此任务的合适工具。

  • I cannot resize the gnome-terminal window (to, say, 18 lines high) then use brltty commands to send either the top or bottom half of the screen to the Braille display as its multiline support is not yet developed enough to allow this.我无法调整gnome-terminal window 的大小(比如 18 行高),然后使用brltty命令将屏幕的上半部分或下半部分发送到盲文显示器,因为它的多行支持还不够发达,无法做到这一点。

I tried with GNU screen in a 40x9 iTerm window on macOS (also tried with PuTYY on Windows) and the following "works" for me.我在 macOS 上的 40x9 iTerm window 中尝试使用 GNU 屏幕(也尝试在 Windows 上使用 PuTYY) ,以下对我“有效”。

  • Start a screen session. In the shell prompt, echo $LINES $COLUMNS (or stty size ) outputs 9 40 .启动screen session。在 shell 提示中, echo $LINES $COLUMNS (或stty size )输出9 40

  • At this time, long lines would be wrapped at column 40 as usual.这时,长行会像往常一样在第 40 列换行。 See this ls -l / output:看到这个ls -l / output:

    在此处输入图像描述

  • Press Ca: and run screen command width -w 80 .Ca:并运行屏幕命令width -w 80

  • Press Ca: and run screen command height -w 24 .Ca:并运行屏幕命令height -w 24

  • Now echo $LINES $COLUMNS would output 24 80 and the earlier ls -l / output is re-wrapped at 80 column.现在echo $LINES $COLUMNS将 output 24 80和更早的ls -l / output 重新包装在 80 列。 Since the phyiscal window is 40 columns you need to press Ca [ to enter copy mode and then use direction keys to move around.由于物理 window 是 40 列,您需要按Ca [进入复制模式,然后使用方向键移动。

    在此处输入图像描述

  • Now I start vim and only the top-left part is visible.现在我开始vim ,只有左上角的部分是可见的。

    在此处输入图像描述

  • To see other part of the vim window, I press Ca [ to enter copy mode and then I can move around.要查看vim window 的其他部分,我按Ca [进入复制模式,然后我可以四处移动。 The following is when I moved to the bottom-left corner to see vim 's status line.以下是我移至左下角查看vim的状态行时的情况。

    在此处输入图像描述


So for your TUI app, if some input area or buttons are not visible you can also do the similar things:因此,对于您的 TUI 应用程序,如果某些输入区域或按钮不可见,您也可以执行类似的操作:

  • Enter copy mode ( Ca [ )进入复制模式 ( Ca [ )
  • Move to where you need to input something移动到需要输入内容的地方
  • Exit copy mode退出复制模式
  • Input data ( Esc )输入数据 ( Esc )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM