💾 Archived View for gmi.noulin.net › gitRepositories › easydoneitCTui › file › tui › tui.c.gmi captured on 2024-07-09 at 00:15:23. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
tui.c (1946B)
1 #include "libsheepyObject.h" 2 #include <ncurses.h> 3 4 WINDOW *initScreen(int *row, int *col) { 5 WINDOW *w; 6 7 w = initscr(); 8 pTestErrorCmd(w == NULL, XFAILURE); 9 10 getmaxyx(stdscr,*row,*col); 11 12 // prevent ctrl-c: 13 raw(); 14 //cbreak(); 15 // dont echo what is typed 16 noecho(); 17 // hide cursor 18 curs_set(0); 19 20 if ( has_colors() ) { 21 start_color(); 22 /* Initialize a bunch of colour pairs, where: 23 init_pair(pair number, foreground, background); 24 specifies the pair. */ 25 26 init_pair(1, COLOR_BLUE, COLOR_WHITE); 27 init_pair(2, COLOR_GREEN, COLOR_BLACK); 28 init_pair(3, COLOR_YELLOW, COLOR_BLACK); 29 init_pair(4, COLOR_BLUE, COLOR_BLACK); 30 init_pair(5, COLOR_MAGENTA, COLOR_BLACK); 31 init_pair(6, COLOR_CYAN, COLOR_BLACK); 32 init_pair(7, COLOR_BLUE, COLOR_WHITE); 33 init_pair(8, COLOR_WHITE, COLOR_RED); 34 init_pair(9, COLOR_BLACK, COLOR_GREEN); 35 init_pair(10, COLOR_BLUE, COLOR_YELLOW); 36 init_pair(11, COLOR_WHITE, COLOR_BLUE); 37 init_pair(12, COLOR_WHITE, COLOR_MAGENTA); 38 init_pair(13, COLOR_BLACK, COLOR_CYAN); 39 init_pair(14, COLOR_RED, COLOR_BLACK); 40 } 41 42 /* Get all the mouse events */ 43 // disable mouse to have copy/paste mousemask(ALL_MOUSE_EVENTS, NULL); 44 45 // Enable F keys 46 keypad(w, 1); 47 48 return w; 49 } 50 51 void reInitScreen(WINDOW *w) { 52 // prevent ctrl-c: 53 raw(); 54 //cbreak(); 55 // dont echo what is typed 56 noecho(); 57 // hide cursor 58 curs_set(1); 59 curs_set(0); 60 61 /* Get all the mouse events */ 62 // disable mouse to have copy/paste mousemask(ALL_MOUSE_EVENTS, NULL); 63 64 // Enable F keys 65 keypad(w, 1); 66 } 67 68 void finalizeScreen(WINDOW *w) { 69 delwin(w); 70 endwin(); 71 refresh(); 72 } 73 74 static void **subWins = NULL; 75 76 void setSubwindows(void **subwins) { 77 subWins = subwins; 78 } 79 80 void refreshAll(void) { 81 forEachType(void, subWins, wd) { 82 wnoutrefresh(*wd); 83 } 84 doupdate(); 85 //refresh(); 86 } 87 88 void eraseSubwindows(void) { 89 forEachType(void, subWins, wd) { 90 werase(*wd); 91 } 92 }