51 lines
916 B
C
51 lines
916 B
C
|
#include <ncurses.h>
|
||
|
|
||
|
int terminal_width;
|
||
|
int terminal_height;
|
||
|
|
||
|
WINDOW *tabs;
|
||
|
|
||
|
int get_terminal_size(){
|
||
|
int new_height,new_width;
|
||
|
getmaxyx(stdscr,new_height,new_width);
|
||
|
int changed=(new_width!=terminal_width)||(new_height!=terminal_height);
|
||
|
terminal_width=new_width;
|
||
|
terminal_height=new_height;
|
||
|
return changed;
|
||
|
}
|
||
|
|
||
|
int gui_ncurses_refresh(){
|
||
|
if(refresh()==ERR)
|
||
|
return 1;
|
||
|
if(wrefresh(tabs)==ERR)
|
||
|
return 1;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int start_gui(){
|
||
|
if(!initscr())
|
||
|
return 1;
|
||
|
curs_set(0);
|
||
|
get_terminal_size();
|
||
|
mvprintw((terminal_height-3)/2+3,terminal_width/2-15,"Initialising the simulator...");
|
||
|
tabs = newwin(3,terminal_width,0,0);
|
||
|
box(tabs, 0 , 0);
|
||
|
mvwprintw(tabs,1,2,"[ 0 Overview ]");
|
||
|
mvwprintw(tabs,1,17," 1 Memory ");
|
||
|
if(gui_ncurses_refresh())
|
||
|
return 1;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int gui_continue_request(){
|
||
|
if(getch()==ERR)
|
||
|
return 1;
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int end_gui(){
|
||
|
if(endwin()==ERR)
|
||
|
return 1;
|
||
|
return 0;
|
||
|
}
|