Created
April 12, 2024 01:52
-
-
Save philopaterwaheed/86dd4c01a254d922f34b17a11cd9843b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
initscr(); | |
noecho(); | |
keypad(stdscr(), true); | |
start_color(); | |
init_pair(REGULAR_PAIR, COLOR_WHITE, COLOR_BLACK); | |
init_pair(HIGHLIGHT_PAIR, COLOR_BLACK, COLOR_WHITE); | |
let mut quit = false ; | |
let mut rows = 0; | |
let mut cols = 0; | |
timeout(16); // running in 60 FPS for better gaming experience | |
while !quit{ | |
getmaxyx(stdscr(), &mut rows, &mut cols); | |
// Clear the screen | |
// clear(); | |
// Calculate window dimensions and positions | |
let window_height = rows * 3 / 4 - 5; | |
let window_width = cols / 3; | |
let window_y = 0; | |
let window_x = 0; | |
// Create previous window | |
let prev_window = newwin(window_height, window_width, window_y, window_x); | |
box_(prev_window, 0, 0); | |
mvwprintw(prev_window, 1, 1, "Previous Window"); | |
wrefresh(prev_window); | |
// Create input window | |
let in_window_x = cols / 3; | |
let in_window = newwin(window_height, window_width, window_y, in_window_x); | |
box_(in_window, 0, 0); | |
mvwprintw(in_window, 1, 1, "Input Window"); | |
wrefresh(in_window); | |
// Create next window | |
let next_window_x = cols * 2 / 3; | |
let next_window = newwin(window_height, window_width, window_y, next_window_x); | |
box_(next_window, 0, 0); | |
mvwprintw(next_window, 1, 1, "Next Window"); | |
wrefresh(next_window); | |
// Calculate dimensions for the fourth window at the bottom | |
let fourth_window_height = rows - window_height - 1; // Remaining space | |
let fourth_window_width = cols; // Full width | |
// Create the fourth window | |
let fourth_window = newwin(fourth_window_height, fourth_window_width, rows - fourth_window_height , 0); | |
box_(fourth_window, 0, 0); | |
mvwprintw(fourth_window, 1, 1, "Fourth Window"); | |
wrefresh(fourth_window); | |
let input = getch(); | |
if input == KEY_RESIZE { | |
clear(); | |
continue; | |
} | |
let input = std::char::from_u32(input as u32); | |
match input { | |
Some('q') => { | |
quit = true; | |
} | |
_=>{} | |
} | |
} | |
endwin(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment