Permalink
Browse files

Return a request from open_run_request()

A boolean return value limits the ability of open_run_request() to
handle more complex run requests in the future.  The "quit, refresh, or
do nothing" logic in view_driver(), based on the boolean return value,
is easily represented by returning REQ_QUIT, REQ_REFRESH, or REQ_NONE
from open_run_request() itself.  Returning a request also seems more in
line with workings of other functions which process requests.

The current view is passed to open_run_request(), which enables it to
return REQ_REFRESH as appropriate.  For the future, this also opens the
door for other queries and actions on the view.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
  • Loading branch information...
1 parent 057579a commit b023bf6181c68c71c0af3cb764d2dfa26361fe92 @tsibley tsibley committed with Feb 13, 2013
Showing with 17 additions and 8 deletions.
  1. +17 −8 tig.c
View
25 tig.c
@@ -3440,15 +3440,17 @@ open_editor(const char *file)
open_external_viewer(editor_argv, opt_cdup, TRUE);
}
-static bool
-open_run_request(enum request request)
+static enum request
+open_run_request(struct view *view, enum request request)
{
struct run_request *req = get_run_request(request);
const char **argv = NULL;
+ request = REQ_NONE;
+
if (!req) {
report("Unknown run request");
- return FALSE;
+ return request;
}
if (format_argv(&argv, req->argv, FALSE)) {
@@ -3476,7 +3478,14 @@ open_run_request(enum request request)
argv_free(argv);
free(argv);
- return req->exit;
+ if (request == REQ_NONE) {
+ if (req->exit)
+ request = REQ_QUIT;
+
+ else if (!view->unrefreshable)
+ request = REQ_REFRESH;
+ }
+ return request;
}
/*
@@ -3492,11 +3501,11 @@ view_driver(struct view *view, enum request request)
return TRUE;
if (request > REQ_NONE) {
- if (open_run_request(request))
+ request = open_run_request(view, request);
+
+ // exit quickly rather than going through view_request and back
+ if (request == REQ_QUIT)
return FALSE;
- if (!view->unrefreshable)
- view_request(view, REQ_REFRESH);
- return TRUE;
}
request = view_request(view, request);

0 comments on commit b023bf6

Please sign in to comment.