본문 바로가기
프로그래밍/C·C++

리눅스 curses.h 사용 예

by ITPro 2010. 8. 11.

원문 curses 의 간단한 사용예

 

#include <stdio.h>
#include <curses.h>
#include <stdlib.h>
#include <unistd.h>

#include <string.h>

 

//이동 삽입 특성 등의 실습 예

 

int main()
{
 const char witch_one[]=" First Witch  ";
 const char witch_Two[]=" Second Witch ";
 const char * scan_ptr;
 int i,j;
 
 initscr();
 
 move(5,15);
 //=========문자의 특성을 켠다
 attron(A_BOLD);//  <===  <===
 printw("%s","Macbeth");
 //=========문자의 특성을 off한다.
 attroff(A_BOLD);//  <===  <===
 refresh();
 sleep(1);

 move(8,15);
 attron(A_STANDOUT);
 printw("%s","Thunder and Lightning");
 attroff(A_STANDOUT);
 refresh();
 sleep(1);

 move(10,10);
 printw("%s","When shall we three meet again");
 move(11,23);
 printw("%s","In thunder, lightning, or in rain ?");
 move(13,10);
 printw("%s","When the hurlyburly's done,");
 move(14,23);
 printw("%s","When the batle's lost and won.");
 refresh();
 sleep(1);

 attron(A_DIM);
 scan_ptr = witch_one + strlen(witch_one) -1;
 while(scan_ptr != witch_one)
 {
  move(10,10);
  insch(*scan_ptr--);// <== <== 배우의 이름을 한문자 단위로 삽입
  
 }
 scan_ptr = witch_Two + strlen(witch_Two)-1;
 while(scan_ptr != witch_Two)
 {
  move(13,10);
  insch(*scan_ptr--);// <== <== 배우의 이름을 한문자 단위로 삽입
  
 }
 attroff(A_DIM);
 refresh();
 sleep(1);

//커서를 하위 우측으로 이동시킨다.

 move(LINES -1 ,COLS -1);
 refresh();
 sleep(1);
 
 endwin();

 return 0;
}

반응형

'프로그래밍 > C·C++' 카테고리의 다른 글

리눅스 로케일 세팅  (0) 2010.08.11
리눅스 curses.h 설명  (0) 2010.08.11
전역변수&extern  (0) 2010.08.11
char ch = getchar();의 문제의 원인  (0) 2010.08.11
getc(), getch(), getchar()  (1) 2010.08.11