commit - 0ed6bc9021ade98ba6b1574847e83aec980a398e
commit + d627976f5ceada12169aa74630bbc0fd9ce071b7
blob - a752780caccc9b9007daf5bc95cf05bde851090c
blob + 667bfe283076f37b6cb5690da6b2a98d9aae516a
--- tog/tog.1
+++ tog/tog.1
Go to line N in the view (default: last line).
.It Cm g
Go to line N in the view (default: first line).
+.It Cm Right-arrow, l
+Scroll view to the right N increments (default: 1).
+.br
+Output moves left on the screen.
+.It Cm Left-arrow, h
+Scroll view to the left N increments (default: 1).
+.br
+Output moves right on the screen.
+.It Cm $
+Scroll view to the rightmost position.
+.It Cm 0
+Scroll view left to the start of the line.
.El
.Pp
The commands for
Move the selection cursor down N lines (default: 1).
.It Cm Up-arrow, k, <, Comma, Ctrl-p
Move the selection cursor up N lines (default: 1).
-.It Cm Right-arrow, l
-Scroll log message field to the right N increments (default: 1).
-.br
-Log message moves left on the screen.
-.It Cm Left-arrow, h
-Scroll log message field to the left N increments (default: 1).
-.br
-Log message moves right on the screen.
-.It Cm $
-Scroll log message field to the rightmost position.
-.It Cm 0
-Scroll log message field to the leftmost position.
.It Cm Page-down, Space, Ctrl+f, f
Move the selection cursor down N pages (default: 1).
.It Cm Page-up, Ctrl+b, b
Scroll down N lines (default: 1).
.It Cm Up-arrow, k, Ctrl-p
Scroll up N lines (default: 1).
-.It Cm Right-arrow, l
-Scroll view to the right N increments (default: 1).
-.br
-Diff output moves left on the screen.
-.It Cm Left-arrow, h
-Scroll view to the left N increments (default: 1).
-.br
-Diff output moves right on the screen.
-.It Cm $
-Scroll view to the rightmost position.
-.It Cm 0
-Scroll view left to the start of the line.
.It Cm Page-down, Space, Ctrl+f, f
Scroll down N pages (default: 1).
.It Cm Page-up, Ctrl+b, b
Move the selection cursor down N pages (default: 1).
.It Cm Up-arrow, k, Ctrl-p
Move the selection cursor up N pages (default: 1).
-.It Cm Right-arrow, l
-Scroll view to the right N increments (default: 1).
-.br
-File output moves left on the screen.
-.It Cm Left-arrow, h
-Scroll view to the left N increments (default: 1).
-.br
-File output moves right on the screen.
-.It Cm $
-Scroll view to the rightmost position.
-.It Cm 0
-Scroll view left to the start of the line.
.It Cm Page-down, Space, Ctrl+f, f
Move the selection cursor down N pages (default: 1).
.It Cm Page-up, Ctrl+b, b
blob - 73869bfa87df9af7a68e8ec4c44690f950d74ccb
blob + a6351da680ffacc2f47bf1a42b494d77af0b4a3a
--- tog/tog.c
+++ tog/tog.c
select_commit(s);
return NULL;
+
+}
+
+static void
+horizontal_scroll_input(struct tog_view *view, int ch)
+{
+ switch (ch) {
+ case KEY_LEFT:
+ case 'h':
+ view->x -= MIN(view->x, 2);
+ if (view->x <= 0)
+ view->count = 0;
+ break;
+ case KEY_RIGHT:
+ case 'l':
+ if (view->x + view->ncols / 2 < view->maxx)
+ view->x += 2;
+ else
+ view->count = 0;
+ break;
+ case '0':
+ view->x = 0;
+ break;
+ case '$':
+ view->x = MAX(view->maxx - view->ncols / 2, 0);
+ view->count = 0;
+ break;
+ default:
+ break;
+ }
}
static const struct got_error *
s->quit = 1;
break;
case '0':
- view->x = 0;
- break;
case '$':
- view->x = MAX(view->maxx - view->ncols / 2, 0);
- view->count = 0;
- break;
case KEY_RIGHT:
case 'l':
- if (view->x + view->ncols / 2 < view->maxx)
- view->x += 2; /* move two columns right */
- else
- view->count = 0;
- break;
case KEY_LEFT:
case 'h':
- view->x -= MIN(view->x, 2); /* move two columns back */
- if (view->x <= 0)
- view->count = 0;
+ horizontal_scroll_input(view, ch);
break;
case 'k':
case KEY_UP:
switch (ch) {
case '0':
- view->x = 0;
- break;
case '$':
- view->x = MAX(view->maxx - view->ncols / 3, 0);
- view->count = 0;
- break;
case KEY_RIGHT:
case 'l':
- if (view->x + view->ncols / 3 < view->maxx)
- view->x += 2; /* move two columns right */
- else
- view->count = 0;
- break;
case KEY_LEFT:
case 'h':
- view->x -= MIN(view->x, 2); /* move two columns back */
- if (view->x <= 0)
- view->count = 0;
+ horizontal_scroll_input(view, ch);
break;
case 'a':
case 'w':
switch (ch) {
case '0':
- view->x = 0;
- break;
case '$':
- view->x = MAX(view->maxx - view->ncols / 3, 0);
- view->count = 0;
- break;
case KEY_RIGHT:
case 'l':
- if (view->x + view->ncols / 3 < view->maxx)
- view->x += 2; /* move two columns right */
- else
- view->count = 0;
- break;
case KEY_LEFT:
case 'h':
- view->x -= MIN(view->x, 2); /* move two columns back */
- if (view->x <= 0)
- view->count = 0;
+ horizontal_scroll_input(view, ch);
break;
case 'q':
s->done = 1;
wchar_t *wline;
char *index = NULL;
struct tog_color *tc;
- int width, n, nentries, i = 1;
+ int width, n, nentries, scrollx, i = 1;
int limit = view->nlines;
s->ndisplayed = 0;
te = s->first_displayed_entry;
}
+ view->maxx = 0;
for (i = got_tree_entry_get_index(te); i < nentries; i++) {
char *line = NULL, *id_str = NULL, *link_target = NULL;
const char *modestr = "";
}
free(id_str);
free(link_target);
- err = format_line(&wline, &width, NULL, line, 0, view->ncols,
- 0, 0);
+
+ /* use full line width to determine view->maxx */
+ err = format_line(&wline, &width, NULL, line, 0, INT_MAX, 0, 0);
if (err) {
free(line);
break;
}
+ view->maxx = MAX(view->maxx, width);
+ free(wline);
+ wline = NULL;
+
+ err = format_line(&wline, &width, &scrollx, line, view->x,
+ view->ncols, 0, 0);
+ if (err) {
+ free(line);
+ break;
+ }
if (n == s->selected) {
if (view->focussed)
wstandout(view->window);
if (tc)
wattr_on(view->window,
COLOR_PAIR(tc->colorpair), NULL);
- waddwstr(view->window, wline);
+ waddwstr(view->window, &wline[scrollx]);
if (tc)
wattr_off(view->window,
COLOR_PAIR(tc->colorpair), NULL);
return tree_goto_line(view, nscroll);
switch (ch) {
+ case '0':
+ case '$':
+ case KEY_RIGHT:
+ case 'l':
+ case KEY_LEFT:
+ case 'h':
+ horizontal_scroll_input(view, ch);
+ break;
case 'i':
s->show_ids = !s->show_ids;
view->count = 0;
switch (ch) {
case '0':
- view->x = 0;
- break;
case '$':
- view->x = MAX(view->maxx - view->ncols / 2, 0);
- view->count = 0;
- break;
case KEY_RIGHT:
case 'l':
- if (view->x + view->ncols / 2 < view->maxx)
- view->x += 2;
- else
- view->count = 0;
- break;
case KEY_LEFT:
case 'h':
- view->x -= MIN(view->x, 2);
- if (view->x <= 0)
- view->count = 0;
+ horizontal_scroll_input(view, ch);
break;
case 'i':
s->show_ids = !s->show_ids;
switch (ch) {
case '0':
- view->x = 0;
- break;
case '$':
- view->x = MAX(view->maxx - view->ncols / 3, 0);
- view->count = 0;
- break;
case KEY_RIGHT:
case 'l':
- if (view->x + view->ncols / 3 < view->maxx)
- view->x += 2;
- else
- view->count = 0;
- break;
case KEY_LEFT:
case 'h':
- view->x -= MIN(view->x, 2);
- if (view->x <= 0)
- view->count = 0;
+ horizontal_scroll_input(view, ch);
break;
case 'g':
case KEY_HOME: