first attempt at fixing window sowing outside of screen at marks page
This commit is contained in:
parent
1a882baab6
commit
025c51c3ad
@ -6,6 +6,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <menu.h>
|
#include <menu.h>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <panel.h>
|
#include <panel.h>
|
||||||
@ -41,11 +42,13 @@ SOFTWARE.
|
|||||||
#define NLINES 10
|
#define NLINES 10
|
||||||
#define NCOLS 40
|
#define NCOLS 40
|
||||||
|
|
||||||
|
#define DEFAULT_X_OFFSET 10
|
||||||
|
#define DEFAULT_Y_OFFSET 2
|
||||||
|
|
||||||
void init_wins(WINDOW **wins, int n, json marks_json);
|
void init_wins(WINDOW **wins, int n, json marks_json);
|
||||||
void win_show(WINDOW *win, char *label, int label_color, int width);
|
void win_show(WINDOW *win, char *label, int label_color, int width);
|
||||||
|
|
||||||
void marks_page() {
|
void marks_page() {
|
||||||
|
|
||||||
// DONT FORGET TO UNCOMMENT
|
// DONT FORGET TO UNCOMMENT
|
||||||
// json resp_from_api = bakaapi::get_grades();
|
// json resp_from_api = bakaapi::get_grades();
|
||||||
std::ifstream f("test-data/marks2.json");
|
std::ifstream f("test-data/marks2.json");
|
||||||
@ -70,6 +73,8 @@ void marks_page() {
|
|||||||
noecho();
|
noecho();
|
||||||
keypad(stdscr, TRUE);
|
keypad(stdscr, TRUE);
|
||||||
|
|
||||||
|
std::clog << COLS << " " << LINES << std::endl;
|
||||||
|
|
||||||
/* Initialize all the colors */
|
/* Initialize all the colors */
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
init_pair(i, i, COLOR_BLACK);
|
init_pair(i, i, COLOR_BLACK);
|
||||||
@ -119,8 +124,8 @@ void init_wins(WINDOW **wins, int n, json marks_json) {
|
|||||||
int x, y, i;
|
int x, y, i;
|
||||||
char label[1500];
|
char label[1500];
|
||||||
|
|
||||||
y = 2;
|
y = DEFAULT_Y_OFFSET;
|
||||||
x = 10;
|
x = DEFAULT_X_OFFSET;
|
||||||
uint8_t curent_color = 0;
|
uint8_t curent_color = 0;
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
wins[i] = newwin(NLINES, NCOLS, y, x);
|
wins[i] = newwin(NLINES, NCOLS, y, x);
|
||||||
@ -154,7 +159,12 @@ void init_wins(WINDOW **wins, int n, json marks_json) {
|
|||||||
|
|
||||||
int width = max_text_length + 4;
|
int width = max_text_length + 4;
|
||||||
win_show(wins[i], label, curent_color, width);
|
win_show(wins[i], label, curent_color, width);
|
||||||
x += width + 10;
|
if (x + width > COLS) {
|
||||||
|
x = DEFAULT_X_OFFSET;
|
||||||
|
y += NLINES + 10;
|
||||||
|
} else {
|
||||||
|
x += width + 5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user