2011년8월9일_네트워크프로젝트(6일차)-출력창 스크롤하여 내용이 살아 있나 확인. (테스트 결과 실패)




네이트온 메신저나 구글토크와 같은 프로그램들은 모두 채팅log window가 스크롤이 되고, (자동스크롤 이야기 아님.)
마우스 훨을 돌려 이전 기록을 확인할 수 있다.
그 기능을 추가하고 싶다.


● 소스코드

   1: //출력창 스크롤 테스트...결과 내용이 짤린다.
   2: #include <ncurses.h>
   3: #include <string.h>
   4:  
   5: int main()
   6: {
   7:     WINDOW *win_input;
   8:     WINDOW *win_output;
   9:     WINDOW *win_output_panel;
  10:     WINDOW *win_input_panel;
  11:     int i;
  12:     
  13:     char buf[100];
  14:     const char *exit = "exit";
  15:  
  16:     initscr();
  17:     refresh();
  18:  
  19:     win_output = newwin(LINES - 7, COLS - 2, 1, 1);
  20:     scrollok(win_output, TRUE);
  21:     wrefresh(win_output);
  22:     win_output_panel = newwin(LINES - 5, COLS, 0, 0);
  23:     box(win_output_panel, 0, 0);
  24:     wrefresh(win_output_panel);
  25:  
  26:     win_input_panel = newwin(5, COLS, LINES - 5 , 0);
  27:     box(win_input_panel, 0, 0);
  28:     wrefresh(win_input_panel);
  29:     win_input = newwin(3, COLS - 2, LINES - 4 , 1);
  30:     scrollok(win_input, TRUE);
  31:  
  32:     mvwprintw(win_output, 1, 10, "window내에 글자쓰기 테스트!!\n");
  33:     wrefresh(win_output);
  34:     
  35:     while(1)
  36:     {
  37:         mvwgetstr(win_input, 1, 1, buf);
  38:  
  39:         if(NULL != strstr(buf, "exit"))
  40:         {
  41:             break;
  42:         }
  43:         else if(NULL != strstr(buf, "+"))
  44:         {
  45:             wscrl(win_output, 1);
  46:         }
  47:         else if(NULL != strstr(buf, "-"))
  48:         {
  49:             wscrl(win_output, -1);
  50:         }
  51:         else
  52:         {
  53:             wprintw(win_output, "%s\n", buf);
  54:         }
  55:  
  56:         wclear(win_input);
  57:         wrefresh(win_output);
  58:         wrefresh(win_input);
  59:     }
  60:     
  61:     endwin();
  62: }


<실행결과>

한 번 위로 스크롤한 결과


한 번 더…한 번 더...
위에 기록된 내용들이 사라졌다. ㅠㅠ


아래로 한 번 스크롤한 결과..


 

한 번 더...한 번 더…아래로 스크롤한 결과..
아래에 있던 내용도 없다. ㅠㅠ
window자체는 모두 기록하지 않는다...흑흑