character-at-a-time input

character-at-a-time input

Post by Wrayma » Mon, 12 Aug 1996 04:00:00



Hello,

I would like to do character-at-a-time input.  I'm programming in C++, so
curses doesn't seem to work properly.  I've heard that charater-at-a-time
input is not very portable.  I program primarily in Linux, but I'd like to
know how to do it in Solaris and SunOS and other unices as well.  What
I'm really looking for is some example code; I've heard I can accomplish
what I want to with ioctl() and fcntl(), but I haven't been able to
figure it out.  I want to be able to wait for a key press on stdin with
select(), and then read the character in immediately without waiting for
enter to be pressed.

What is the most portable way to do character-at-a-time input without curses?

please respond by email, as my newsfeed is sometimes sketchy.


Duke School of Engineering '98                  http://wrayland.dorm.duke.edu

 
 
 

character-at-a-time input

Post by Andrew Gier » Tue, 13 Aug 1996 04:00:00


 Wrayman> Hello,

 Wrayman> I would like to do character-at-a-time input.  I'm
 Wrayman> programming in C++, so curses doesn't seem to work properly.

Curses can be used from C++, but since it relies heavily on macros and
various non-c++-friendly features, it really needs another layer of
encapsulation on top of it. There is (or was, when I last looked) a
curses class in libg++ (I haven't used it though; libg++'s license
usually prevents me from using it).

 Wrayman> I've heard that charater-at-a-time input is not very
 Wrayman> portable.  I program primarily in Linux, but I'd like to
 Wrayman> know how to do it in Solaris and SunOS and other unices as
 Wrayman> well.  What I'm really looking for is some example code;
 Wrayman> I've heard I can accomplish what I want to with ioctl() and
 Wrayman> fcntl(), but I haven't been able to figure it out.  I want
 Wrayman> to be able to wait for a key press on stdin with select(),
 Wrayman> and then read the character in immediately without waiting
 Wrayman> for enter to be pressed.

The stuff you need to look at is the termios interface; tcgetattr(),
tcflush(), tcsetattr(), tcflow(), etc. etc. Try 'man termios'.

 Wrayman> What is the most portable way to do character-at-a-time
 Wrayman> input without curses?

Termios is part of Posix, so it's as portable as anything is (probably
more so than curses).

--


 
 
 

character-at-a-time input

Post by Jonathan Ch » Wed, 14 Aug 1996 04:00:00



>Hello,

>I would like to do character-at-a-time input.  I'm programming in C++, so
>curses doesn't seem to work properly.

What exactly is the problem here? C++ with curses works real fine with us

[snip]

Quote:>What is the most portable way to do character-at-a-time input without curses?

Use curses. It will save you hair-pulling later on.
--

 
 
 

1. real-time character input

        I'm writing a C program that requires real-time character input (i.e.,
character-by-character, as opposed to line-by-line).  Let's say, for the sake
of argument, that I want to be able to move a cursor on the screen using the
cursor keys.  How can I do this?  I'm already familiar with vt100 escape codes,
so you can skip that part.  Parting from that, I asked around and I got a
rather vague answer:  "That is system specific."  How true is this?  If you
decide to take the task of explaining this to me, please pretend I know
nothing, which isn't too far from the truth... :-)


2. Where can I find SLIP for a SUN?

3. Single character input??

4. What is AIX

5. Non-character input events in Emacs

6. Solaris on Cyrix 233

7. How to input non-ASCII characters in X/shell?

8. UnixWorld

9. Abnormal characters would appear in Netscape input field

10. how to break standard input into 1 character per line

11. Single Character Input

12. Single-character input

13. How to stuff an input prompt with characters?