如何使键绑定在gnuplot哑终端中工作? [英] How to get key bind to work in gnuplot dumb terminal?
问题描述
我试图在文本终端 dumb
中实现绘图循环.为了停止循环,我正在使用 bind
(请检查 help bind
).这可以正常工作,例如在 wxt
终端中,但是,在使用 dumb
终端时循环不会停止.
I tried to implement a plotting loop in the text terminal dumb
.
In order to stop the loop I'm using bind
(check help bind
).
This works fine, e.g. in a wxt
terminal, however, the loop will not stop when using the dumb
terminal.
我知道我可以通过按 Ctrl + C
来停止循环,但是似乎没有任何可能的键绑定.为什么是这样?解决方法?
I know that I could stop the loop by pressing Ctrl+C
, however, it looks like no key bindings seem to be possible. Why is this? How to workaround?
代码:
### key bind in dumb terminal?
reset session
set term dumb 120,30
# random plot
set samples 20
plot '+' u 1:(rand(0)) w l ti strftime("%d.%m.%Y\n%H:%M:%S",time(0))
stop = 0
bind x "stop = 1"
while !stop {
pause 1.5 # delay in seconds
replot
}
### end of code
结果:(但不会像在 wxt
终端中那样按 x
来停止循环)
Result: (but loop will not stop by pressing x
as it would in a wxt
terminal)
1 +---------------------------------------------------------------------+
| + + + |
| *** 24.02.2021 ******* |
0.9 |-+ ** * 10:40:46 +-|
| * * |
0.8 |-+ * * * +-|
| **** * * *** * |
| * * * * ** * ** |
0.7 |-+ * * * * * * ** +-|
| * * * * * * * * |
0.6 |-+ * * * * * * * * +-|
| * * * * * * * * |
| * * * ** * * * * |
0.5 |*+ * * * ** * * * * +-|
|* * * * * * * * * |
|* * *** * * ** * * *|
0.4 |-* * * * * * * * +*|
| * * * * * * * *|
0.3 |-+* * ** * * * *-|
| * * ** * * * * |
| ** * * * * * |
0.2 |-+ * ** * *+-|
| * ** * * |
0.1 |-+ * * *+-|
| * **** |
| + + + * |
0 +---------------------------------------------------------------------+
-10 -5 0 5 10
推荐答案
我认为这行不通.从 help bind
:
请注意,只有当gnuplot是在具有鼠标支持的情况下编译的,并且所有具有鼠标功能的终端都使用时,
bind
才可用.>
Note that
bind
is only available if gnuplot was compiled with mouse support and it is used by all mouse-capable terminals.
据我了解, dumb
终端并不意味着是交互式的.因此,它不是具有鼠标能力"的.并且不会对鼠标操作或按键动作做出反应.
As far as I understand, the dumb
terminal is not meant to be interactive. Therefore it is not "mouse-capable" and does not react on mouse actions or key strokes.
源文件 dumb.trm
中包含行
#ifdef USE_MOUSE
, NULL, NULL, NULL, NULL, NULL
(我认为)支持我的假设:即使您的gnuplot版本具有通用的鼠标支持,在 dumb
终端中也无法使用 bind
.
which (I think) supports my assumption: Even if your gnuplot version has general mouse support, bind
can't be used within the dumb
terminal.
这篇关于如何使键绑定在gnuplot哑终端中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!