<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Alternative for getch and getche on Linux</title>
	<atom:link href="http://wesley.vidiqatch.org/code-snippets/alternative-for-getch-and-getche-on-linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://wesley.vidiqatch.org</link>
	<description>This blog does not need a smart-ass tagline</description>
	<lastBuildDate>Tue, 09 Mar 2010 12:01:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Wesley</title>
		<link>http://wesley.vidiqatch.org/code-snippets/alternative-for-getch-and-getche-on-linux/comment-page-1/#comment-22097</link>
		<dc:creator>Wesley</dc:creator>
		<pubDate>Wed, 12 Aug 2009 21:28:23 +0000</pubDate>
		<guid isPermaLink="false">http://wesley.vidiqatch.org/?page_id=443#comment-22097</guid>
		<description>&lt;blockquote cite=&quot;#commentbody-22095&quot;&gt;
&lt;strong&gt;&lt;a href=&quot;#comment-22095&quot; rel=&quot;nofollow&quot;&gt;Arnaud&lt;/a&gt; :&lt;/strong&gt;
&lt;p&gt;A smart change would be to pass a bool to initTermios for whether or not the ECHO flag should removed, and then it will be able to define the new terminal i/o settings itself.&lt;br&gt;
This way you factorize some, and it’s cleaner, it’s more KISS-like.&lt;/p&gt;
&lt;/blockquote&gt;
That would be a bit cleaner indeed. I&#039;ll update the example code a bit.

&lt;em&gt;Edit: code is updated. I have created a new getch_ function as well which is called by both the getch and getche function to minimize duplicated code.&lt;/em&gt;</description>
		<content:encoded><![CDATA[<blockquote cite="#commentbody-22095"><p>
<strong><a href="#comment-22095" rel="nofollow">Arnaud</a> :</strong></p>
<p>A smart change would be to pass a bool to initTermios for whether or not the ECHO flag should removed, and then it will be able to define the new terminal i/o settings itself.<br />
This way you factorize some, and it’s cleaner, it’s more KISS-like.</p>
</blockquote>
<p>That would be a bit cleaner indeed. I&#8217;ll update the example code a bit.</p>
<p><em>Edit: code is updated. I have created a new getch_ function as well which is called by both the getch and getche function to minimize duplicated code.</em></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arnaud</title>
		<link>http://wesley.vidiqatch.org/code-snippets/alternative-for-getch-and-getche-on-linux/comment-page-1/#comment-22095</link>
		<dc:creator>Arnaud</dc:creator>
		<pubDate>Wed, 12 Aug 2009 21:14:30 +0000</pubDate>
		<guid isPermaLink="false">http://wesley.vidiqatch.org/?page_id=443#comment-22095</guid>
		<description>A smart change would be to pass a bool to initTermios for whether or not the ECHO flag should removed, and then it will be able to define the new terminal i/o settings itself.
This way you factorize some, and it&#039;s cleaner, it&#039;s more KISS-like.

void initTermios(int disable_echo) {
    tcgetattr(0, &amp;old); /* grab old terminal i/o settings */
    new = old; /* make new settings same as old settings */
    new.c_lflag &amp;= ~ICANON; /* disable buffered i/o */
    if (disable_echo)
        new.c_lflag &amp;= ~ECHO;
    tcsetattr(0, TCSANOW, &amp;new); /* use these new terminal i/o settings now */
}

Change other functions accordingly...</description>
		<content:encoded><![CDATA[<p>A smart change would be to pass a bool to initTermios for whether or not the ECHO flag should removed, and then it will be able to define the new terminal i/o settings itself.<br />
This way you factorize some, and it&#8217;s cleaner, it&#8217;s more KISS-like.</p>
<p>void initTermios(int disable_echo) {<br />
    tcgetattr(0, &amp;old); /* grab old terminal i/o settings */<br />
    new = old; /* make new settings same as old settings */<br />
    new.c_lflag &amp;= ~ICANON; /* disable buffered i/o */<br />
    if (disable_echo)<br />
        new.c_lflag &amp;= ~ECHO;<br />
    tcsetattr(0, TCSANOW, &amp;new); /* use these new terminal i/o settings now */<br />
}</p>
<p>Change other functions accordingly&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
