summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 37157fa)
raw | patch | inline | side by side (parent: 37157fa)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 7 Jun 2006 00:06:01 +0000 (02:06 +0200) | ||
committer | Jonas Fonseca Madsen <fonseca@ask.diku.dk> | |
Wed, 7 Jun 2006 00:06:01 +0000 (02:06 +0200) |
Also use view->ops->read() instead of pager_read().
tig.c | patch | blob | history |
index ae759951b719cb3af18476e899196042d30a31b7..e26b3833ca12b3f5f047f7884b8ccdd60926cf90 100644 (file)
--- a/tig.c
+++ b/tig.c
static int read_properties(FILE *pipe, const char *separators, int (*read)(char *, int, char *, int));
static void set_nonblocking_input(bool loading);
static size_t utf8_length(const char *string, size_t max_width, int *coloffset, int *trimmed);
-static void load_help_page(void);
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
return FALSE;
}
+
+static void open_help_view(struct view *view)
+{
+ char buf[BUFSIZ];
+ int lines = ARRAY_SIZE(req_info) + 2;
+ int i;
+
+ if (view->lines > 0)
+ return;
+
+ for (i = 0; i < ARRAY_SIZE(req_info); i++)
+ if (!req_info[i].request)
+ lines++;
+
+ view->line = calloc(lines, sizeof(*view->line));
+ if (!view->line) {
+ report("Allocation failure");
+ return;
+ }
+
+ view->ops->read(view, "Quick reference for tig keybindings:");
+
+ for (i = 0; i < ARRAY_SIZE(req_info); i++) {
+ char *key;
+
+ if (!req_info[i].request) {
+ view->ops->read(view, "");
+ view->ops->read(view, req_info[i].help);
+ continue;
+ }
+
+ key = get_key(req_info[i].request);
+ if (!string_format(buf, "%-25s %s", key, req_info[i].help))
+ continue;
+
+ view->ops->read(view, buf);
+ }
+}
+
+
enum open_flags {
OPEN_DEFAULT = 0, /* Use default view switching. */
OPEN_SPLIT = 1, /* Split current view. */
}
if (view == VIEW(REQ_VIEW_HELP)) {
- load_help_page();
+ open_help_view(view);
} else if ((reload || strcmp(view->vid, view->id)) &&
!begin_update(view)) {
};
-static void load_help_page(void)
-{
- char buf[BUFSIZ];
- struct view *view = VIEW(REQ_VIEW_HELP);
- int lines = ARRAY_SIZE(req_info) + 2;
- int i;
-
- if (view->lines > 0)
- return;
-
- for (i = 0; i < ARRAY_SIZE(req_info); i++)
- if (!req_info[i].request)
- lines++;
-
- view->line = calloc(lines, sizeof(*view->line));
- if (!view->line) {
- report("Allocation failure");
- return;
- }
-
- pager_read(view, "Quick reference for tig keybindings:");
-
- for (i = 0; i < ARRAY_SIZE(req_info); i++) {
- char *key;
-
- if (!req_info[i].request) {
- pager_read(view, "");
- pager_read(view, req_info[i].help);
- continue;
- }
-
- key = get_key(req_info[i].request);
- if (!string_format(buf, "%-25s %s", key, req_info[i].help))
- continue;
-
- pager_read(view, buf);
- }
-}
-
-
/*
* Unicode / UTF-8 handling
*