summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1ba2ae4)
raw | patch | inline | side by side (parent: 1ba2ae4)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 14 May 2006 02:50:06 +0000 (04:50 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Sun, 14 May 2006 02:50:06 +0000 (04:50 +0200) |
tig.c | patch | blob | history |
index 910c6fcb46c4cb762a378f26ce05df5de3bd0fb2..5ca8a02b9f3386a23d46496ac3c3c776837da544 100644 (file)
--- a/tig.c
+++ b/tig.c
REQ_QUIT,
REQ_PROMPT,
REQ_SCREEN_REDRAW,
+ REQ_SCREEN_RESIZE,
REQ_SCREEN_UPDATE,
REQ_SHOW_VERSION,
REQ_STOP_LOADING,
/* wgetch() with nodelay() enabled returns ERR when there's no input. */
{ ERR, REQ_SCREEN_UPDATE },
+ /* Use the ncurses SIGWINCH handler. */
+ { KEY_RESIZE, REQ_SCREEN_RESIZE },
};
static enum request
report("Version: %s", VERSION);
return TRUE;
+ case REQ_SCREEN_RESIZE:
+ resize_display();
+ /* Fall-through */
case REQ_SCREEN_REDRAW:
foreach_view (view, i) {
redraw_view(view);
static bool
pager_read(struct view *view, char *line)
{
- /* For some reason the piped man page has many empty lines
- * so skip successive emptys lines to work around it. */
- if (view == VIEW(REQ_VIEW_HELP) &&
- !*line &&
- view->lines &&
- !*((char *) view->line[view->lines - 1]))
- return TRUE;
-
view->line[view->lines] = strdup(line);
if (!view->line[view->lines])
return FALSE;
exit(1);
}
+#include <readline/readline.h>
+
int
main(int argc, char *argv[])
{
key = wgetch(status_win);
request = get_request(key);
- if (request == REQ_PROMPT) {
+ /* Some low-level request handling. This keeps handling of
+ * status_win restricted. */
+ switch (request) {
+ case REQ_PROMPT:
report(":");
/* Temporarily switch to line-oriented and echoed
* input. */
noecho();
cbreak();
+ break;
+
+ case REQ_SCREEN_RESIZE:
+ {
+ int height, width;
+
+ getmaxyx(stdscr, height, width);
+
+ /* Resize the status view and let the view driver take
+ * care of resizing the displayed views. */
+ wresize(status_win, 1, width);
+ mvwin(status_win, height - 1, 0);
+ wrefresh(status_win);
+ break;
+ }
+ default:
+ break;
}
}
* ----
* Features that should be explored.
*
- * - Terminal resizing support. I am yet to figure out whether catching
- * SIGWINCH is preferred over using ncurses' built-in support for resizing.
+ * - Searching.
*
* - Locale support.
*