Trying a few things
This commit is contained in:
parent
64fc6ec652
commit
5c64c11460
2 changed files with 17 additions and 7 deletions
|
@ -22,6 +22,8 @@ void polonius::pl_window::init(string file_path) {
|
||||||
|
|
||||||
getmaxyx(stdscr, height, width);
|
getmaxyx(stdscr, height, width);
|
||||||
|
|
||||||
|
maximum_number_of_chars_on_screen = (height * width);
|
||||||
|
|
||||||
polonius_window = newwin(height, width, 0, 0);
|
polonius_window = newwin(height, width, 0, 0);
|
||||||
|
|
||||||
attached_cursor = create_new_cursor();
|
attached_cursor = create_new_cursor();
|
||||||
|
@ -37,9 +39,8 @@ void polonius::pl_window::init(string file_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void polonius::pl_window::write_from_file() {
|
void polonius::pl_window::write_from_file() {
|
||||||
int maximum_read_length = (height * width);
|
|
||||||
|
|
||||||
string file_contents = attached_file.read(0, maximum_read_length);
|
string file_contents = attached_file.read(0, maximum_number_of_chars_on_screen);
|
||||||
|
|
||||||
put_string(file_contents, false);
|
put_string(file_contents, false);
|
||||||
}
|
}
|
||||||
|
@ -81,12 +82,20 @@ void polonius::pl_window::put_char(int ch, bool and_move_cursor) {
|
||||||
|
|
||||||
void polonius::pl_window::put_string(string &input, bool and_move_cursor) {
|
void polonius::pl_window::put_string(string &input, bool and_move_cursor) {
|
||||||
|
|
||||||
int current_y = attached_cursor.get_y_coordinate();
|
int cols = 0;
|
||||||
int current_x = attached_cursor.get_x_coordinate();
|
|
||||||
|
int amount_to_read = min((int)input.length(), maximum_number_of_chars_on_screen);
|
||||||
for (int i = 0; i < input.length(); i++) {
|
|
||||||
|
for (int i = 0; i < amount_to_read; i++) {
|
||||||
put_char(input.at(i));
|
put_char(input.at(i));
|
||||||
refresh_window();
|
|
||||||
|
if (input.at(i) == '\n') {
|
||||||
|
cols = cols + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cols == height) {
|
||||||
|
break; // Stop printing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!and_move_cursor) {
|
if (!and_move_cursor) {
|
||||||
|
|
|
@ -107,6 +107,7 @@ namespace polonius {
|
||||||
|
|
||||||
int height = 0;
|
int height = 0;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
|
int maximum_number_of_chars_on_screen = 0;
|
||||||
|
|
||||||
void raw_move_cursor(int y, int x);
|
void raw_move_cursor(int y, int x);
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue