[aclug-L] Re: C question..Another one...
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Michael Holmes wrote:
>
> Does ANSI C++ offer an include file which includes cursor placement
> (i.e. locate) and a clear screen. All the books I have just show old
> /n /f /t stuff I put the slashes backwards as not to mess with the
> mail programs.
The ncurses library handles this, but it may seem like overkill at first.
Some simple stuff can be done just using the termcap library to get your
tty's escape sequences (e.g., clear screen, position cursor, clear to
end of line, etc.). But ncurses is comprehensive and very efficient --
it is what things like vi, emacs, etc., use. See:
http://www.linuxdoc.org/LDP/lpg/
Starting with Chatper 8: Character Cell Graphics.
> I am writing one of the programs in a linux environment, but I must
> be able to put the current time on the bottom left corner of the screen,
> with out it blinking! Linux won out, as it has to be able to be
> depended on! reliable.
Ncurses keeps two copies of the screen: one matching the known display,
and one which you write into. You then call wnoutrefresh(), which compares
the two and writes out a minimal, optimized set of escape sequences and
data, so that only the parts of the screen which differ are changed.
Normally this does not do a screen clear and repaint; it usually finds
a way to localize the changes, which should be no problem for your case.
> Also, to write data out the /dev/ttyS1 in the program you just use
> fopen(/dev/ttyS1) ? Right?
Right. It should be recognized as a tty and automatically unbuffered.
Otherwise, you can use setbuf() to unbuffer stdio, or can use the file
descriptor for unbuffered I/O.
> It has been a few years since I have had to sit down and use the
> comm port. I need to set it up at 11k to a Windoz box, and it will
> send data packets to the windoz box.
On Linux/Unix, the comm port is a character special file, which is
basically like any other file, except you cannot lseek() on it, you
should get 1 back from isatty(), and there are various ioctls (wrapped
up under termios) that you can use. The main thing you need to know
is that by default tty input is in "cooked mode", i.e. your program
cannot read any input until the user types Return, Line Feed, or EOF
(normally ^D). In cooked mode, the operating system processes simple
edit functions and canonical signal processing (^C), which is generally
a convenience, except you cannot do something like "Press any key to
continue." For this, you need "raw mode", but if you use raw mode,
you probably need to provide your own edit functions. (The readline
library is one way to do this.)
> Mike
--
/*
* Tom Hull * thull@xxxxxxxxxxx * http://www.ocston.org/~thull/
*/
-- This is the discussion@xxxxxxxxx list. To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi
|
|