Skip to content

Commit 052bddc

Browse files
committed
svnbrowse: Implement exiting by ESC.
* subversion/svnbrowse/svnbrowse.c (KEY_ESC): Define. (view_on_event): Add case for the ESC key. (sub_main): Disable ESCDELAY and elaborate my thoughts about ESCDELAY and this shortcut in general. git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1932913 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3136f16 commit 052bddc

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

subversion/svnbrowse/svnbrowse.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ const apr_getopt_option_t svn_browse__options[] =
108108
* alphabetical order. */
109109
#define CTRL(ch) ((ch) - 'a' + 1)
110110

111+
#define KEY_ESC 27
112+
111113
typedef struct svn_browse__view_t {
112114
/* TODO: store information about terminal screen (a WINDOW* in curses world) */
113115
svn_browse__model_t *model;
@@ -152,9 +154,8 @@ view_on_event(svn_browse__view_t *view, int ch, apr_pool_t *scratch_pool)
152154
case 'u':
153155
SVN_ERR(svn_browse__model_go_up(view->model, scratch_pool));
154156
break;
155-
/* TODO: quit via escape. some say just check for 27, but it I think it's
156-
* a bit ugly. */
157157
case 'q':
158+
case KEY_ESC:
158159
return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
159160
}
160161

@@ -401,6 +402,25 @@ sub_main(int *code, int argc, const char *argv[], apr_pool_t *pool)
401402
keypad(stdscr, TRUE);
402403
nonl();
403404

405+
/* ESCDELAY is a ncurses-exclusive variable that controls how curses will
406+
* handle escape sequences - when a user hits ESC and inputs a command for
407+
* the application to potentially do some handling. We don't really care
408+
* about this capability and would rather prefer to get out of svnbrowse by
409+
* ESC. Other backends may require further testing. It still works fine with
410+
* this variable misconfigured.
411+
*
412+
* Generally, the decision to exit by ESC itself is questionable, as the
413+
* majority of default applications don't do that (like vim, less, man). Some
414+
* users would spam escape after each action and the others to would expect
415+
* it to close a 37-deep stacked dialog. Anyway we can just drop associated
416+
* case statement at any time if we found that annoying.
417+
*
418+
* Find more info in 'man ESCDELAY'. */
419+
420+
#ifdef NCURSES_VERSION
421+
ESCDELAY = 0;
422+
#endif /* NCURSES_VERSION */
423+
404424
view = view_make(ctx, pool);
405425

406426
iterpool = svn_pool_create(pool);

0 commit comments

Comments
 (0)