我在run-with-idle-timer
函数中,
通过(send-string-to-terminal "\e]12;red\a")
向终端发送控制字符修改光标颜色
但是我发现终端并没有立即执行\e]12;red\a
而是在任意敲击键盘之后才起效。
应该不是刷新的问题,
我向终端发送其它字符直接修改emacs buffer,也是一样,
也是敲击键盘之后,emacs才会修改buffer。
所以,
应该是发出去的字符被缓冲了。
如何flush buffer呢?
我在run-with-idle-timer
函数中,
通过(send-string-to-terminal "\e]12;red\a")
向终端发送控制字符修改光标颜色
但是我发现终端并没有立即执行\e]12;red\a
而是在任意敲击键盘之后才起效。
应该不是刷新的问题,
我向终端发送其它字符直接修改emacs buffer,也是一样,
也是敲击键盘之后,emacs才会修改buffer。
所以,
应该是发出去的字符被缓冲了。
如何flush buffer呢?
最后加个\n
。
不行的。。。
\r
呢?
我之前应该是加了一行(send-string-to-terminal "\n")
单独加了一行 (send-string-to-terminal "\n")
,也没有效果
DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
Ssend_string_to_terminal, 1, 2, 0,
doc: /* Send STRING to the terminal without alteration.
Control characters in STRING will have terminal-dependent effects.
Optional parameter TERMINAL specifies the tty terminal device to use.
It may be a terminal object, a frame, or nil for the terminal used by
the currently selected frame. In batch mode, STRING is sent to stdout
when TERMINAL is nil. */)
(Lisp_Object string, Lisp_Object terminal)
{
struct terminal *t = decode_live_terminal (terminal);
FILE *out;
/* ??? Perhaps we should do something special for multibyte strings here. */
CHECK_STRING (string);
block_input ();
if (t->type == output_initial)
out = stdout;
else if (t->type != output_termcap && t->type != output_msdos_raw)
error ("Device %d is not a termcap terminal device", t->id);
else
{
struct tty_display_info *tty = t->display_info.tty;
if (! tty->output)
error ("Terminal is currently suspended");
if (tty->termscript)
{
fwrite_unlocked (SDATA (string), 1, SBYTES (string), tty->termscript);
fflush_unlocked (tty->termscript);
}
out = tty->output;
}
fwrite_unlocked (SDATA (string), 1, SBYTES (string), out);
fflush_unlocked (out);
unblock_input ();
return Qnil;
}
看起来是flush buffer了啊。。。
而事实上,是lock在那里了,
后面的语句都没执行。
搞定了。。。。
是其它原因。
什么原因不妨写出来,即便是乌龙,也可能帮助到别人。
其实问题出在timer上,不是 send-string-to-terminal
上。
timer的参数没理解透彻
尽量把你出问题的代码和问题原因写出来吧,万一其他人也撞到类似的问题。