summaryrefslogtreecommitdiff
path: root/ycurses/src/curses/curses.cpp
blob: 3605e5989281194e5004fa2bd8eb3dc5a50e90cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef CURSES_CPP
#define CURSES_CPP

#include "curses.h"

int curses::i_self_counter = 0;

curses::curses()
{
  if ( ++i_self_counter == 1 )
  {
    initscr();
    raw();
    keypad(stdscr, TRUE);
    noecho();
  }
}

curses::~curses()
{
  if ( --i_self_counter == 0 )
  {
/*
    Factory<attributes>::destroyAll();
    Factory<color>::destroyAll();
    Factory<window>::destroyAll();
    Factory<menu>::destroyAll();
    Factory<pwindow>::destroyAll();
 */ 
    clear();
    endwin();
  }
}

void
curses::finish()
{
}

int
curses::get_char()
{
  return getch();
}

string
curses::get_string()
{
  char c[1024];
  getstr(c); 
  return string(c);
}

void
curses::pause()
{
  getch();
}

void
curses::disable()
{
  refresh();
  def_prog_mode();
  endwin();
}

void
curses::enable()
{
  reset_prog_mode();
  refresh();
}

void
curses::clear()
{
  coordinate coord(LINES, COLS); 
  for ( int i = 0; i < coord.y; ++i )
    for ( int j = 0; j < coord.x; ++j )
      mvaddch(i, j, ' ');

  refresh();
}

#endif