You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
3.4 KiB
147 lines
3.4 KiB
/**
|
|
* This is a menu made with ncurses, i wil do my best to comment every aspect of it
|
|
**/
|
|
|
|
#include <ncurses.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
// Variable declarations
|
|
int height, width, start_y, start_x = 0;
|
|
height = 10;
|
|
width = 30;
|
|
start_y = 10;
|
|
start_x = 10;
|
|
|
|
//Init sequence. to set up the screen and init the memory usage
|
|
initscr(); // inits the screen and sets up the screen
|
|
|
|
// To use the standart linux bash commanc lije ctrl-c ctrl-x and so on : Is active as default
|
|
cbreak();
|
|
|
|
// To use every input as raw input and not a command
|
|
//raw();
|
|
|
|
// Doesn't show the pressed char in the scrren
|
|
noecho();
|
|
|
|
// Creating a window
|
|
WINDOW * win= newwin(height,width,start_y, start_x);
|
|
//This refresh will initialize the base screen.
|
|
refresh();
|
|
|
|
// Making a box out of the window
|
|
box(win,'|','#');
|
|
|
|
// this will print on 0,0 coordinate of rhtis window
|
|
wprintw(win,"this is an new window");
|
|
|
|
//and this refresh will only refresh the created window
|
|
wrefresh(win);
|
|
|
|
getch();
|
|
|
|
// Adwanced border customization variables
|
|
int left, right, top, bottom, tlc, trc, blc, brc = 0;
|
|
left = '|'; // Left side of the box
|
|
right = '/'; // Right side of the box
|
|
top = '#'; // Top side of the box
|
|
bottom = '-'; // Bottom side of the box
|
|
tlc = '0'; // Top Left Corner of the box
|
|
trc = '1'; // Top Roght Corner of the box
|
|
blc = '2'; // Bottom Left Corner of the box
|
|
brc = '3'; // Bottom Right Corner of the box
|
|
|
|
// Adwanced border customization function call
|
|
wborder(win, left, right, top, bottom, tlc, trc, blc, brc);
|
|
|
|
//and this refresh will only refresh the created window
|
|
wrefresh(win);
|
|
|
|
//this will moove inside of the window an print to tth given coordinate
|
|
mvwprintw(win,5,5,"Content of the box");
|
|
|
|
//and this refresh will only refresh the created window
|
|
wrefresh(win);
|
|
|
|
// Gets the user input before quiting
|
|
getch();
|
|
|
|
// Delocates memory and ends ncurses
|
|
endwin();
|
|
return 0;
|
|
}
|
|
|
|
int tutorial_0_1() // Hello Word and user input
|
|
{
|
|
int c,y,x = 0;
|
|
|
|
y=10;
|
|
x=10;
|
|
|
|
//Init sequence. to set up the screen and init the memory usage
|
|
initscr(); // inits the screen and sets up the screen
|
|
|
|
move(y,x);// Moving to the given coordinates
|
|
|
|
printw("Hello World!");
|
|
//Refeshes the screen to match what is in the memory
|
|
refresh();
|
|
|
|
// Gets the user input
|
|
c = getch();
|
|
|
|
// Clreasthe screen
|
|
clear();
|
|
|
|
move(0,0);
|
|
printw("You pressed %d", c);
|
|
|
|
// Gets the user input before quiting
|
|
getch();
|
|
|
|
// Delocates memory and ends ncurses
|
|
endwin();
|
|
return 0;
|
|
}
|
|
|
|
int tutorial_2() // create a box and write into it
|
|
{
|
|
// VAriable declarations
|
|
int height, width, start_y, start_x = 0;
|
|
height = 10;
|
|
width = 30;
|
|
start_y = 10;
|
|
start_x = 10;
|
|
|
|
//Init sequence. to set up the screen and init the memory usage
|
|
initscr(); // inits the screen and sets up the screen
|
|
|
|
// Creating a window
|
|
WINDOW * win= newwin(height,width,start_y, start_x);
|
|
//This refresh will initialize the base screen.
|
|
refresh();
|
|
|
|
// Making a box out of the window
|
|
box(win,0,0);
|
|
|
|
// this will print on 0,0 coordinate of rhtis window
|
|
wprintw(win,"this is an new window");
|
|
|
|
//and this refresh will only refresh the created window
|
|
wrefresh(win);
|
|
|
|
//this will moove inside of the window an print to tth given coordinate
|
|
mvwprintw(win,5,5,"Content of the box");
|
|
|
|
//and this refresh will only refresh the created window
|
|
wrefresh(win);
|
|
|
|
// Gets the user input before quiting
|
|
getch();
|
|
|
|
// Delocates memory and ends ncurses
|
|
endwin();
|
|
return 0;
|
|
}
|