<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>chys&#039;s random notes &#187; tiary</title>
	<atom:link href="http://en.chys.info/tag/tiary/feed/" rel="self" type="application/rss+xml" />
	<link>http://en.chys.info</link>
	<description>Study more problems; Talk less of isms.</description>
	<lastBuildDate>Tue, 27 Dec 2011 11:56:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Reduce the delay after ESC in ncurses</title>
		<link>http://en.chys.info/2009/09/esdelay-ncurses/</link>
		<comments>http://en.chys.info/2009/09/esdelay-ncurses/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 15:55:01 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ncurses]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[tiary]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=667</guid>
		<description><![CDATA[In ncurses-based programs, the default delay after the ESC key is way too long. (Such a delay is necessary to differentiate the ESC key from function keys.) There seems to be no such delay in VIM. But with strace, we can find that VIM actually delays, but for only 25 milliseconds, shorter than 100ms &#8211; [...]<hr/>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.gnu.org/software/ncurses/">ncurses</a>-based programs, the default delay after the ESC key is way too long. (Such a delay is necessary to differentiate the ESC key from function keys.)</p>
<p>There seems to be no such delay in <a href="http://www.vim.org">VIM</a>. But with <a href="http://linux.die.net/man/1/strace">strace</a>, we can find that VIM actually delays, but for only 25 milliseconds, shorter than 100ms &#8211; the minimal time interval that human can perceive:</p>
<blockquote><pre>
read(0, "\33"..., 4096)                 = 1
select(6, [0 3 5], NULL, [0 3], {0, 0}) = 0 (Timeout)
gettimeofday({1253979790, 537775}, NULL) = 0
select(6, [0 3 5], NULL, [0 3], {0, <span style="color: red; font-weight: bold;">25000</span>}) = 0 (Timeout)
</pre>
</blockquote>
<p>If 25ms works reliably for VIM, so should it do for other programs. There seems to be no functions setting this interval in ncurses, but we can directly modify the global variable <code>ESCDELAY</code>. Ncurses also accepts the environment variable also named <code>ESCDELAY</code>, so we may also want to honor the user&#8217;s choice:</p>
<blockquote><pre>
if (getenv ("ESCDELAY") == NULL)
  ESCDELAY = 25;
</pre>
</blockquote>
<p>Not confident in its portability, I detect this undocumented (it seems) feature with <a href="http://www.cmake.org">cmake</a> in <a href="http://code.google.com/p/tiary">tiary</a> (my project).</p>
<hr/>
<p>Update (Feb. 22, 2010): It&#8217;s preferable to use the function <code>set_escdelay</code>.</p>
<hr/><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2009/09/esdelay-ncurses/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

