# DP: fix guide rendering somewhat and make it consistent
# DP: also allow ISO-2022-JP to ISO-8859-1 return code

--- a/plist.c
+++ b/plist.c
@@ -37,7 +37,6 @@ static Window pl_titlewin = None;
 static Window pg_win = None;
 static Pixmap pg_tmp;
 static int pg_lastpage = -1;
-static struct ctrl *pg_lastcp = NULL;
 
 static int draw_kstring __P((Drawable, char *, int, int));
 
@@ -99,6 +98,7 @@ pl_off(state)
 {
 	int i;
 
+	pg_lastpage = -1;
 	if (!pl_titlewin)
 		return;
 	XUnmapSubwindows(display, window);
@@ -207,7 +207,6 @@ pg_on()
 	pg_tmp = XCreatePixmap(display, pg_win, window_width, pl_fh, depth);
 
 	pg_lastpage = -1;
-	pg_lastcp = NULL;
 }
 
 void
@@ -215,7 +214,6 @@ pg_clean()
 {
 	XClearArea(display, pg_win, 0, 0, window_width, pl_fh, 0);
 	pg_lastpage = -1;
-	pg_lastcp = NULL;
 }
 
 void
@@ -231,19 +229,11 @@ pg_draw(state)
 		return;
 
 	page = state->page;
-#if 0
-	if (page == pg_lastpage && state->cp == pg_lastcp)
-		return;
-#endif
 	if (page == pg_lastpage)
 		return;
 
-	if (!state->cp) {
-		pg_clean();
-		return;
-	}
-
-	showlast = (state->cp->ct_op == CTL_PAUSE && state->cp->cti_value);
+	showlast = /* !state->cp || (state->cp->ct_op == CTL_PAUSE && state->cp->cti_value) */
+	    !(page > 1 && page < maxpage);
 	XSetForeground(display, gc_pta, ctrl_color[caching]);
 	XSetForeground(display, gc_ptk, ctrl_color[caching]);
 	XSetBackground(display, gc_pta, back_color[caching]);
@@ -251,19 +241,19 @@ pg_draw(state)
 
 	pg_clean();
 	if (page > 1) {
-		sprintf(buf, "\033$B\"+\033(B %s",
+		snprintf(buf, sizeof(buf), "\033$B\"+\033(B %s",
 			page_title(page - 1));
 		draw_kstring(pg_win, buf,
 			PL_X_MARGIN, pl_fh - plfs->max_bounds.descent);
 	}
 	if (page < maxpage) {
-		sprintf(buf, "%s\033$B\"*\033(B",
+		snprintf(buf, sizeof(buf), "%s \033$B\"*\033(B",
 			page_title(page + 1));
 		for (p = buf; *p; p++)
 			if (*p == '\n')
 				*p = ' ';
 		n = draw_kstring(pg_tmp, buf, 0, pl_fh);
-		sprintf(buf, "%s\033$B\"*\033(B",
+		snprintf(buf, sizeof(buf), "%s \033$B\"*\033(B",
 			page_title(page + 1));
 		for (p = buf; *p; p++)
 			if (*p == '\n')
@@ -272,7 +262,7 @@ pg_draw(state)
 			pl_fh - plfs->max_bounds.descent);
 	}
 	if (showlast == 0) {
-		sprintf(buf, "-- %d/%d --", page, maxpage);
+		snprintf(buf, sizeof(buf), "-- %d/%d --", page, maxpage);
 		n = draw_kstring(pg_tmp, buf, 0, pl_fh);
 		/*
 		 * The contents of buf is not destroyed by draw_kstring
@@ -283,7 +273,6 @@ pg_draw(state)
 	}
 
 	pg_lastpage = state->page;
-	pg_lastcp = state->cp;
 }
 
 void
@@ -298,7 +287,6 @@ pg_off()
 	XFlush(display);
 	pg_win = None;
 	pg_lastpage = -1;
-	pg_lastcp = NULL;
 }
 
 static int
@@ -323,6 +311,7 @@ draw_kstring(d, buf, x, y)
 			x += XTextWidth(plfs, buf, strlen(buf));
 			buf = p--;
 		} else if (strncmp(p, "\033(B", 3) == 0 ||
+			   strncmp(p, "\033-A", 3) == 0 ||
 			   strncmp(p, "\033(J", 3) == 0) {
 			*p = '\0'; p += 3;
 			/* draw 16bit char */
