From fa8c4115b3f3fbdf6bfa4be4ed4424aaa7b5a9b5 Mon Sep 17 00:00:00 2001 From: atomega Date: Mon, 13 Jun 2022 22:40:54 +0200 Subject: [PATCH] Started with ncurses for the menu --- ked/ncurses/compile_run.sh | 5 ++ ked/ncurses/main.c | 146 +++++++++++++++++++++++++++++++++++++ ked/ncurses/menu | Bin 0 -> 17432 bytes 3 files changed, 151 insertions(+) create mode 100755 ked/ncurses/compile_run.sh create mode 100644 ked/ncurses/main.c create mode 100755 ked/ncurses/menu diff --git a/ked/ncurses/compile_run.sh b/ked/ncurses/compile_run.sh new file mode 100755 index 0000000..c49fe20 --- /dev/null +++ b/ked/ncurses/compile_run.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +gcc main.c -o menu -lncurses + +./menu diff --git a/ked/ncurses/main.c b/ked/ncurses/main.c new file mode 100644 index 0000000..d89f96b --- /dev/null +++ b/ked/ncurses/main.c @@ -0,0 +1,146 @@ +/** + * This is a menu made with ncurses, i wil do my best to comment every aspect of it + **/ + +#include + +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; +} diff --git a/ked/ncurses/menu b/ked/ncurses/menu new file mode 100755 index 0000000000000000000000000000000000000000..eb9588943aeba053822f572ad4fde58188b57dea GIT binary patch literal 17432 zcmeHPeQ;b=6~CKp+CbZFT3RV>v5&8@2-zm34Qa8mn`G0CCZ)6q1*N=hvYTcx*{!>8 zn-q#hD-6pLt%_P0b?{>tL1sj89H@xY*0%V;q)x@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