From 4f9b667ad30556aa9754c92973f9b801c62e3456 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Fri, 19 May 2006 22:19:19 +0200 Subject: [PATCH] Add close view request; bound to 'q' by default If only one view is open it will quit. More compatible with Mutt behavior. Based on patch by Aneesh Kumar --- tig.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tig.c b/tig.c index 9019947..ca57f75 100644 --- a/tig.c +++ b/tig.c @@ -109,6 +109,7 @@ enum request { REQ_STOP_LOADING, REQ_TOGGLE_LINE_NUMBERS, REQ_VIEW_NEXT, + REQ_VIEW_CLOSE, REQ_MOVE_UP, REQ_MOVE_UP_ENTER, @@ -1398,6 +1399,17 @@ view_driver(struct view *view, enum request request) doupdate(); return TRUE; + case REQ_VIEW_CLOSE: + if (display[1]) { + view = display[(current_view + 1) % ARRAY_SIZE(display)]; + memset(display, 0, sizeof(display)); + current_view = 0; + display[current_view] = view; + resize_display(); + redraw_display(); + break; + } + /* Fall-through */ case REQ_QUIT: return FALSE; @@ -1765,6 +1777,8 @@ static struct keymap keymap[] = { * Switch to pager view. * h:: * Show man page. + * q:: + * Close view if multiple views are open, else quit. * Enter:: * This key is "context sensitive" depending on what view you are * currently in. When in log view on a commit line or in the main @@ -1779,6 +1793,7 @@ static struct keymap keymap[] = { { 'p', REQ_VIEW_PAGER }, { 'h', REQ_VIEW_HELP }, + { 'q', REQ_VIEW_CLOSE }, { KEY_TAB, REQ_VIEW_NEXT }, { KEY_RETURN, REQ_ENTER }, -- 2.30.2