首页 > 解决方案 > 打开使用 Ncurses 的图形窗口

问题描述

假设我在一些图形 X Window 环境之上运行 xterm 或其他一些终端仿真器。例如,KDE 上的 xterm。我想编写一个可以在一个终端仿真器的命令行上调用的应用程序,在执行时,该应用程序创建一个的KDE/Environment 窗口,与当前终端仿真器分开,并在该新窗口上运行 Ncurses 上下文应用目的。

我该怎么做?这个终端模拟器依赖吗?桌面环境依赖?我会使用裸 X 窗口系统调用吗?

标签: user-interfaceterminalncurses

解决方案


它依赖于终端(模拟器)。

诅咒在终端和终端仿真器中运行。后者(终端仿真器)中的大多数都有某种方式来告诉在终端仿真器中运行什么程序(除了你的 shell)。

例如,可以使用-e选项告诉 xterm,

   -e program [ arguments ... ]
           This option specifies the program (and its command line
           arguments) to be run in the xterm window.  It also sets the
           window title and icon name to be the basename of the program
           being executed if neither -T nor -n are given on the command
           line.

           NOTE: This must be the last option on the command line.

让您像这样启动运行MyApplication的xterm

xterm -e MyApplication

同样,您可能在 X 中运行的大多数终端仿真器都接受该选项。KDE konsole 就是这样做的。没有说明书,但是

konsole --help-all

最后显示它。


推荐阅读