commit d8561bf5886b325a811cc7de9f4046ae519c10c3
parent 3426906612662f864e81cdd8c0f922d938ddcc5f
Author: in0rdr <andreas.gruhler@uzh.ch>
Date: Mon, 12 Dec 2016 10:59:33 +0100
Escape characters
Thanks to @ryanbahneman for this fix (http://bit.ly/2gQyOB7).
Diffstat:
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/diary.c b/diary.c
@@ -125,10 +125,9 @@ bool go_to(WINDOW* calendar, WINDOW* aside, time_t date, int* cur_pad_pos)
/* Update window 'win' with diary entry from date 'date' */
void display_entry(char* dir, size_t dir_size, struct tm* date, WINDOW* win, int width)
{
- char buff[width];
char path[100];
char* ppath = path;
- int i = 0;
+ int c;
// get entry path
fpath(dir, dir_size, date, &ppath, sizeof path);
@@ -139,12 +138,13 @@ void display_entry(char* dir, size_t dir_size, struct tm* date, WINDOW* win, int
wclear(win);
- FILE* fp = fopen(path, "r");
- if (fp != NULL) {
- while(fgets(buff, width, fp) != NULL) {
- mvwprintw(win, i, 0, buff);
- i++;
- }
+ if (date_has_entry(dir, dir_size, date)) {
+ FILE* fp = fopen(path, "r");
+ if (fp == NULL) perror("Error opening file");
+
+ wmove(win, 0, 0);
+ while((c = getc(fp)) != EOF) waddch(win, c);
+
fclose(fp);
}