Commit Diff


commit - f31d6c3bb64ee3c4dc056588d559b58a9174ba59
commit + 86f4aab9e588b1f19647a7d8a2492a262e960fed
blob - 6ae32ea1ad6c310b00c6dae70527e7313d433e6c
blob + e3dfe0b0fa8499bd5718d635b375246f49a08b43
--- tog/tog.c
+++ tog/tog.c
@@ -2335,16 +2335,14 @@ draw_commits(struct tog_view *view)
 		wstandout(view->window);
 	tc = get_color(&s->colors, TOG_COLOR_COMMIT);
 	if (tc)
-		wattr_on(view->window,
-		    COLOR_PAIR(tc->colorpair), NULL);
+		wattr_on(view->window, COLOR_PAIR(tc->colorpair), NULL);
 	waddwstr(view->window, wline);
-	if (tc)
-		wattr_off(view->window,
-		    COLOR_PAIR(tc->colorpair), NULL);
 	while (width < view->ncols) {
 		waddch(view->window, ' ');
 		width++;
 	}
+	if (tc)
+		wattr_off(view->window, COLOR_PAIR(tc->colorpair), NULL);
 	if (view_needs_focus_indication(view))
 		wstandend(view->window);
 	free(wline);
@@ -3982,10 +3980,10 @@ draw_file(struct tog_view *view, const char *header)
 		waddwstr(view->window, wline);
 		free(wline);
 		wline = NULL;
+		while (width++ < view->ncols)
+			waddch(view->window, ' ');
 		if (view_needs_focus_indication(view))
 			wstandend(view->window);
-		if (width <= view->ncols - 1)
-			waddch(view->window, '\n');
 
 		if (max_lines <= 1)
 			return NULL;
@@ -5219,18 +5217,16 @@ draw_blame(struct tog_view *view)
 		wstandout(view->window);
 	tc = get_color(&s->colors, TOG_COLOR_COMMIT);
 	if (tc)
-		wattr_on(view->window,
-		    COLOR_PAIR(tc->colorpair), NULL);
+		wattr_on(view->window, COLOR_PAIR(tc->colorpair), NULL);
 	waddwstr(view->window, wline);
+	while (width++ < view->ncols)
+		waddch(view->window, ' ');
 	if (tc)
-		wattr_off(view->window,
-		    COLOR_PAIR(tc->colorpair), NULL);
+		wattr_off(view->window, COLOR_PAIR(tc->colorpair), NULL);
 	if (view_needs_focus_indication(view))
 		wstandend(view->window);
 	free(wline);
 	wline = NULL;
-	if (width < view->ncols - 1)
-		waddch(view->window, '\n');
 
 	if (view->gline > blame->nlines)
 		view->gline = blame->nlines;
@@ -6352,6 +6348,7 @@ draw_tree_entries(struct tog_view *view, const char *p
 	const struct got_error *err = NULL;
 	struct got_tree_entry *te;
 	wchar_t *wline;
+	char *index = NULL;
 	struct tog_color *tc;
 	int width, n, nentries, i = 1;
 	int limit = view->nlines;
@@ -6373,16 +6370,18 @@ draw_tree_entries(struct tog_view *view, const char *p
 		wstandout(view->window);
 	tc = get_color(&s->colors, TOG_COLOR_COMMIT);
 	if (tc)
-		wattr_on(view->window,
-		    COLOR_PAIR(tc->colorpair), NULL);
+		wattr_on(view->window, COLOR_PAIR(tc->colorpair), NULL);
 	waddwstr(view->window, wline);
+	free(wline);
+	wline = NULL;
+	while (width++ < view->ncols)
+		waddch(view->window, ' ');
 	if (tc)
-		wattr_off(view->window,
-		    COLOR_PAIR(tc->colorpair), NULL);
+		wattr_off(view->window, COLOR_PAIR(tc->colorpair), NULL);
 	if (view_needs_focus_indication(view))
 		wstandend(view->window);
-	free(wline);
-	wline = NULL;
+	if (--limit <= 0)
+		return NULL;
 
 	i += s->selected;
 	if (s->first_displayed_entry) {
@@ -6391,15 +6390,11 @@ draw_tree_entries(struct tog_view *view, const char *p
 			++i;  /* account for ".." entry */
 	}
 	nentries = got_object_tree_get_nentries(s->tree);
-	wprintw(view->window, " [%d/%d]", i,
-	    nentries + (s->tree == s->root ? 0 : 1));  /* ".." in !root tree */
-
-	if (width < view->ncols - 1)
-		waddch(view->window, '\n');
-	if (--limit <= 0)
-		return NULL;
-	err = format_line(&wline, &width, NULL, parent_path, 0, view->ncols,
-	    0, 0);
+	if (asprintf(&index, "[%d/%d] %s",
+	    i, nentries + (s->tree == s->root ? 0 : 1), parent_path) == -1)
+		return got_error_from_errno("asprintf");
+	err = format_line(&wline, &width, NULL, index, 0, view->ncols, 0, 0);
+	free(index);
 	if (err)
 		return err;
 	waddwstr(view->window, wline);
@@ -7659,14 +7654,14 @@ show_ref_view(struct tog_view *view)
 	if (view_needs_focus_indication(view))
 		wstandout(view->window);
 	waddwstr(view->window, wline);
+	while (width++ < view->ncols)
+		waddch(view->window, ' ');
 	if (view_needs_focus_indication(view))
 		wstandend(view->window);
 	free(wline);
 	wline = NULL;
 	free(line);
 	line = NULL;
-	if (width < view->ncols - 1)
-		waddch(view->window, '\n');
 	if (--limit <= 0)
 		return NULL;