From 33781be4d6268e6e02d6bf4c902d5ddfb66b4282 Mon Sep 17 00:00:00 2001 From: Lennart Buhl Date: Sat, 2 Nov 2013 20:24:50 +0100 Subject: [PATCH] find correct positions in pic --- src/display.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/display.c b/src/display.c index bb1ce67..9d8496e 100644 --- a/src/display.c +++ b/src/display.c @@ -24,20 +24,19 @@ void cleanup_display() { char *image; // dimension is width x height */ void print_current_image(struct message* msg, int start, int end) { - end++; // suppress unused warning :-> - // end is ignored and 80 is used, should be considered later + end = 80; // end is ignored and 80 is used, should be handled properly later - move(0,0); // start in the upper left corner + //move(0,0); // start in the upper left corner char *pic = msg->image; // get a ptr to the actual image for (int row=0; row < 25; row++) { // iterate over rows - char *original_line; - original_line = strtok(pic, "\n"); - - char *line = (char*) malloc(81); // allocate a line because we modify it + char *original_line = pic + row * msg->width; // pointer to the start of the line to print + char *line = (char*) malloc(end+1); // allocate a line because we modify it strcpy(line, original_line + start); // get a line from the right start - line[80] = '\0'; // terminate it - printw("%s", line); // print it + line[end] = '\0'; // terminate it + + mvprintw(row, 0, "%s", line); // print it + free(line); // free it }