summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Pomares <diegop357@gmail.com>2018-05-20 05:04:40 +0200
committerJonas Fonseca <jonas.fonseca@gmail.com>2018-05-19 23:04:40 -0400
commitfceaf3b1cc43b9adc8a54a25bcc6ae50e0801901 (patch)
tree1dc1beccee9d75bc493f2a79751642f7268551a2
parentc0df4500e0dacd2c59a81963a3aa1dddb37db148 (diff)
Fix #463: Add user command flag to skip confirmation after execution (#738)
* Issue #463 Re-open Tig instantly in the last displayed view after executing the command * Forgot to commit tigrc parse test * Set the 'quick' flag to true for external merge tool
-rw-r--r--doc/tigrc.5.adoc2
-rw-r--r--include/tig/display.h2
-rw-r--r--include/tig/keys.h1
-rw-r--r--src/display.c11
-rw-r--r--src/keys.c6
-rw-r--r--src/prompt.c2
-rw-r--r--src/status.c2
-rwxr-xr-xtest/tigrc/parse-test4
-rw-r--r--tigrc1
9 files changed, 21 insertions, 10 deletions
diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc
index 9ba1be4d..12fa954d 100644
--- a/doc/tigrc.5.adoc
+++ b/doc/tigrc.5.adoc
@@ -657,6 +657,8 @@ the command that should be executed.
of output to the status bar.
|? |Prompt the user before executing the command.
|< |Exit Tig after executing the command.
+|> |Re-open Tig instantly in the last displayed view after
+ executing the command.
|=============================================================================
Unless otherwise specified, commands are run in the foreground with their
diff --git a/include/tig/display.h b/include/tig/display.h
index c9f6a236..b4457986 100644
--- a/include/tig/display.h
+++ b/include/tig/display.h
@@ -52,7 +52,7 @@ bool save_view(struct view *view, const char *path);
bool vertical_split_is_enabled(enum vertical_split vsplit, int height, int width);
int apply_vertical_split(int base_width);
-bool open_external_viewer(const char *argv[], const char *dir, bool silent, bool confirm, bool echo, bool refresh, const char *notice);
+bool open_external_viewer(const char *argv[], const char *dir, bool silent, bool confirm, bool echo, bool quick, bool refresh, const char *notice);
void open_editor(const char *file, unsigned int lineno);
void enable_mouse(bool enable);
diff --git a/include/tig/keys.h b/include/tig/keys.h
index 45739c6d..493e58d1 100644
--- a/include/tig/keys.h
+++ b/include/tig/keys.h
@@ -83,6 +83,7 @@ struct run_request_flags {
bool exit;
bool internal;
bool echo;
+ bool quick;
};
struct run_request {
diff --git a/src/display.c b/src/display.c
index 16614190..efc86d75 100644
--- a/src/display.c
+++ b/src/display.c
@@ -61,7 +61,7 @@ open_script(const char *path)
}
bool
-open_external_viewer(const char *argv[], const char *dir, bool silent, bool confirm, bool echo, bool do_refresh, const char *notice)
+open_external_viewer(const char *argv[], const char *dir, bool silent, bool confirm, bool echo, bool quick, bool do_refresh, const char *notice)
{
bool ok;
@@ -88,8 +88,11 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf
if (confirm || !ok) {
if (!ok && *notice)
fprintf(stderr, "%s", notice);
- fprintf(stderr, "Press Enter to continue");
- getc(opt_tty.file);
+
+ if (!ok || !quick) {
+ fprintf(stderr, "Press Enter to continue");
+ getc(opt_tty.file);
+ }
}
fseek(opt_tty.file, 0, SEEK_END);
tcsetattr(opt_tty.fd, TCSAFLUSH, opt_tty.attr);
@@ -145,7 +148,7 @@ open_editor(const char *file, unsigned int lineno)
if (lineno && opt_editor_line_number && string_format(lineno_cmd, "+%u", lineno))
editor_argv[argc++] = lineno_cmd;
editor_argv[argc] = file;
- if (!open_external_viewer(editor_argv, repo.cdup, false, false, false, true, EDITOR_LINENO_MSG))
+ if (!open_external_viewer(editor_argv, repo.cdup, false, false, false, false, true, EDITOR_LINENO_MSG))
opt_editor_line_number = false;
}
diff --git a/src/keys.c b/src/keys.c
index b0b9d374..a1c82ef5 100644
--- a/src/keys.c
+++ b/src/keys.c
@@ -449,7 +449,7 @@ static size_t run_requests;
DEFINE_ALLOCATOR(realloc_run_requests, struct run_request, 8)
-#define COMMAND_FLAGS ":!?@<+"
+#define COMMAND_FLAGS ":!?@<+>"
enum status_code
parse_run_request_flags(struct run_request_flags *flags, const char **argv)
@@ -473,6 +473,8 @@ parse_run_request_flags(struct run_request_flags *flags, const char **argv)
flags->exit = 1;
} else if (*argv[0] == '+') {
flags->echo = 1;
+ } else if (*argv[0] == '>') {
+ flags->quick = 1;
} else if (*argv[0] != '!') {
break;
}
@@ -535,6 +537,8 @@ format_run_request_flags(const struct run_request *req)
flags[flagspos++] = '<';
if (req->flags.echo)
flags[flagspos++] = '+';
+ if (req->flags.quick)
+ flags[flagspos++] = '>';
if (flagspos > 1)
flags[flagspos++] = 0;
diff --git a/src/prompt.c b/src/prompt.c
index a7226b69..3f9c6f98 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -1109,7 +1109,7 @@ exec_run_request(struct view *view, struct run_request *req)
if (confirmed)
open_external_viewer(argv, repo.cdup, req->flags.silent,
- !req->flags.exit, req->flags.echo, false, "");
+ !req->flags.exit, req->flags.echo, req->flags.quick, false, "");
}
if (argv)
diff --git a/src/status.c b/src/status.c
index 4e4f33d9..9710f7f9 100644
--- a/src/status.c
+++ b/src/status.c
@@ -676,7 +676,7 @@ open_mergetool(const char *file)
{
const char *mergetool_argv[] = { "git", "mergetool", file, NULL };
- open_external_viewer(mergetool_argv, repo.cdup, false, true, false, true, "");
+ open_external_viewer(mergetool_argv, repo.cdup, false, true, false, true, true, "");
}
static enum request
diff --git a/test/tigrc/parse-test b/test/tigrc/parse-test
index 1e7bfd7a..2f73894f 100755
--- a/test/tigrc/parse-test
+++ b/test/tigrc/parse-test
@@ -99,8 +99,8 @@ tig warning: ~/.tigrc:25: Unknown color attribute: normally
tig warning: ~/.tigrc:34: Unknown option \`visibility' for column line-number
tig warning: ~/.tigrc:36: Invalid key binding: bind keymap key action
tig warning: ~/.tigrc:37: Invalid key binding: bind keymap key action
-tig warning: ~/.tigrc:38: Unknown command flag '%'; expected one of :!?@<+
-tig warning: ~/.tigrc:39: Unknown command flag '|'; expected one of :!?@<+
+tig warning: ~/.tigrc:38: Unknown command flag '%'; expected one of :!?@<+>
+tig warning: ~/.tigrc:39: Unknown command flag '|'; expected one of :!?@<+>
tig warning: ~/.tigrc:57: Unknown option command: c
tig warning: Errors while loading HOME/.tigrc.
EOF
diff --git a/tigrc b/tigrc
index edd3afa7..9818c864 100644
--- a/tigrc
+++ b/tigrc
@@ -137,6 +137,7 @@ set mouse-wheel-cursor = no # Prefer moving the cursor to scrolling the view?
# @ Run the command in the background with no output.
# ? Prompt the user before executing the command.
# < Exit Tig after executing the command.
+# > Re-open Tig instantly in the last displayed view after executing the command.
#
# User-defined commands can optionally refer to Tig's internal state
# using the following variable names, which are substituted before