From c509eed2a58445ada9cfee14cc012f47f44a9668 Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Thu, 1 Nov 2007 10:30:20 +0100 Subject: [PATCH] Added action tree-parent and bound it to backspace by default. This allow to leave the current directory in the tree view and change to the parent tree / directory. At the top of the tree, this closes the tree view. Bound to ',' by default. Example: bind tree Left tree-parent bind tree Right Enter bind blob Left view-close This allows to navigate the tree and blob views just with the cursor keys. [ Cleanup the patch a bit and mention the default keybinding in manual.txt --jonas ] Signed-off-by: Jonas Fonseca --- manual.txt | 2 ++ tig.c | 12 ++++++++++++ tigrc.5.txt | 1 + 3 files changed, 15 insertions(+) diff --git a/manual.txt b/manual.txt index 2471228..1bafd1b 100644 --- a/manual.txt +++ b/manual.txt @@ -343,6 +343,8 @@ u Update status of file. In the status view, this allows you to add an \ M Resolve unmerged file by launching git-mergetool(1). Note, to work \ correctly this might require some initial configuration of your \ preferred merge tool. See the manpage of git-mergetool(1). +',' Move tree view to the parent tree. +e Open file in editor. ----------------------------------------------------------------------------- [[external-commands]] diff --git a/tig.c b/tig.c index 7130943..73c8b25 100644 --- a/tig.c +++ b/tig.c @@ -352,6 +352,7 @@ sq_quote(char buf[SIZEOF_STR], size_t bufsize, const char *src) REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization"), \ REQ_(STATUS_UPDATE, "Update file status"), \ REQ_(STATUS_MERGE, "Merge file using external tool"), \ + REQ_(TREE_PARENT, "Switch to parent directory in tree view"), \ REQ_(EDIT, "Open in editor"), \ REQ_(NONE, "Do nothing") @@ -788,6 +789,7 @@ static struct keybinding default_keybindings[] = { { ':', REQ_PROMPT }, { 'u', REQ_STATUS_UPDATE }, { 'M', REQ_STATUS_MERGE }, + { ',', REQ_TREE_PARENT }, { 'e', REQ_EDIT }, /* Using the ncurses SIGWINCH handler. */ @@ -3020,6 +3022,16 @@ tree_request(struct view *view, enum request request, struct line *line) { enum open_flags flags; + if (request == REQ_TREE_PARENT) { + if (*opt_path) { + /* fake 'cd ..' */ + request = REQ_ENTER; + line = &view->line[1]; + } else { + /* quit view if at top of tree */ + return REQ_VIEW_CLOSE; + } + } if (request != REQ_ENTER) return request; diff --git a/tigrc.5.txt b/tigrc.5.txt index 521880b..f62a007 100644 --- a/tigrc.5.txt +++ b/tigrc.5.txt @@ -246,6 +246,7 @@ toggle-lineno Toggle line numbers toggle-rev-graph Toggle revision graph visualization status-update Update file status status-merge Resolve unmerged file +tree-parent Switch to parent directory in tree view edit Open in editor ------------------------------------------------------------------------------ -- 2.11.0