summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog/ccurses.cxx
blob: 21b07e3f8f07f24888de26fa1e0d157d848adaec (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
#include "cmCursesMainForm.h"
#include "cmCacheManager.h"
#include "cmSystemTools.h"

#include <curses.h>
#include <form.h>
#include <signal.h>
#include <sys/ioctl.h>

static cmCursesMainForm* myform=0;
//std::ofstream log("log.txt", std::ios::out);

void onsig(int sig)
{
  if (myform)
    {
    endwin();
    WINDOW* w= initscr(); /* Initialization */ 
    noecho(); /* Echo off */ 
    cbreak(); /* nl- or cr not needed */ 
    keypad(stdscr,TRUE); /* Use key symbols as 
			    KEY_DOWN*/ 
    refresh();
    int x,y;
    getmaxyx(w, y, x);
    myform->SetWindow(w);
    myform->Render(1,1,x,y);
    std::cerr << "Size change: " << x << " " << y << std::endl;
    }
  signal(SIGWINCH, onsig);
}

int main(int argc, char** argv)
{

  if ( argc != 2 )
    {
    std::cerr << "Usage: " << argv[0] << " source_directory" 
	      << std::endl;
    return -1;
    }

  int newCache = false;
  if (!cmCacheManager::GetInstance()->LoadCache(cmSystemTools::GetCurrentWorkingDirectory().c_str()))
   {
   newCache = true;
   }


  WINDOW* w=initscr(); /* Initialization */ 
  noecho(); /* Echo off */ 
  cbreak(); /* nl- or cr not needed */ 
  keypad(stdscr,TRUE); /* Use key symbols as 
                          KEY_DOWN*/ 

  signal(SIGWINCH, onsig);

  int x,y;
  getmaxyx(w, y, x);

  myform = new cmCursesMainForm(argv[1], newCache);
  myform->InitializeUI(w);
  myform->Render(1, 1, x, y);
  myform->HandleInput();
  
  // Need to clean-up better
  endwin();
  delete myform;
  return 0;

}