File:  [MW Coherent from dump] / coherent / d / usr / src / examples / curses.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:38 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

#include <curses.h>
#include <ctype.h>
#define	NORMAL 0
#define	INY  1
#define	INX  2
main()
{
     int c, y, x, state;
     initscr();		 /* initialize curses */
     noecho();
     raw();
     clear();
     move(0, 0);
     for(state = NORMAL;;) {
	 refresh();
	 c = getch();
	 if(isdigit(c))	{
		 switch	(state)	{
		 case NORMAL:
			  y = x	= 0;
			  state	= INY;
		 case INY:
			  y *= 10;
			  y += c - '0';
			  break;
		 case INX:
			  x *= 10;
			  x += c - '0';
		 }
	 } else	{
		 if (3 == c) { /* ctrl-C	*/
			  noraw();
			  echo();
			  endwin();
			  exit(0);
		 }
		 switch	(state)	{
		 case INX:
			  state	= NORMAL;
			  move(y, x);
		 case NORMAL:
			  addch(c);
			  break;
		 case INY:
			  state	= INX;
		 }
	 }
     }
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.