Skip to content

Commit

Permalink
Fix flashing
Browse files Browse the repository at this point in the history
  • Loading branch information
hax0kartik authored Mar 16, 2017
1 parent 9a27e1e commit b5abd91
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions source/draw.c
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
#include "draw.h"

// Print all 'things' in the file name array
#include "common.h"

void print_all_values_in_filear(void) {
consoleSelect(&debugscreen);

int max_files_to_print;

if (size_of_file_array < MAX_FILES_ON_SCREEN) { max_files_to_print = size_of_file_array; }
else { max_files_to_print = MAX_FILES_ON_SCREEN; }

consoleInit(GFX_TOP, &topScreen);
consoleSelect(&topScreen);

if (max_files_to_print > 0) {
if (scroll > 0) { printf("/\\\n"); } // Print up arrow showing you can scroll up
else { printf("\n"); } // Keep all the files in the same place on screen
printf("\x1b[0;0H");

int i;

// Print directories first
for (i=0; i<max_files_to_print; i++) {
// If it is a dir
if (!isfile_arr[i+scroll]) {
// print as white text on black background
if (i == selected) { printf("\n \x1b[31m\x1b[47;30m%s\x1b[0m", file_arr[i+scroll]); }
if (i == selected) { printf("\x1b[31m\x1b[47;30m%-49.49s\x1b[0m\n", file_arr[i+scroll]); }
// Else, just print it without highlight
else { printf("\n \x1b[31;1m %s\x1b[0m", file_arr[i+scroll]); }
else { printf("\x1b[31;1m%-49.49s\x1b[0m\n", file_arr[i+scroll]); }

}

else {
if (i == selected) { printf("\n \x1b[32m \x1b[47;30m%s\x1b[0m", file_arr[i+scroll]); }
else { printf("\n \x1b[32;1m %s\x1b[0m", file_arr[i+scroll]); }
if (i == selected) { printf("\x1b[32m\x1b[47;30m%-49.49s\x1b[0m\n", file_arr[i+scroll]); }
else { printf("\x1b[32;1m%-49.49s\x1b[0m\n", file_arr[i+scroll]); }

}
}

// If there are files below on screen
if ( (size_of_file_array > MAX_FILES_ON_SCREEN) && (selected+scroll != size_of_file_array-1) ) { printf("\n\n\\/ "); }
}
else { printf("\n\n\t\t\x1b[47;30m- Folder is empty -\x1b[0m"); }
}


if(max_files_to_print==0){ printf("\n\n\t\t\x1b[47;30m- Folder is empty -\x1b[0m"); }
}

0 comments on commit b5abd91

Please # to comment.