Author: rinrab
Date: Wed Apr 8 21:26:10 2026
New Revision: 1932913
Log:
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.
Modified:
subversion/trunk/subversion/svnbrowse/svnbrowse.c
Modified: subversion/trunk/subversion/svnbrowse/svnbrowse.c
==============================================================================
--- subversion/trunk/subversion/svnbrowse/svnbrowse.c Wed Apr 8 20:48:06 2026 (r1932912)
+++ subversion/trunk/subversion/svnbrowse/svnbrowse.c Wed Apr 8 21:26:10 2026 (r1932913)
@@ -108,6 +108,8 @@ const apr_getopt_option_t svn_browse__op
* alphabetical order. */
#define CTRL(ch) ((ch) - 'a' + 1)
+#define KEY_ESC 27
+
typedef struct svn_browse__view_t {
/* TODO: store information about terminal screen (a WINDOW* in curses world) */
svn_browse__model_t *model;
@@ -152,9 +154,8 @@ view_on_event(svn_browse__view_t *view,
case 'u':
SVN_ERR(svn_browse__model_go_up(view->model, scratch_pool));
break;
- /* TODO: quit via escape. some say just check for 27, but it I think it's
- * a bit ugly. */
case 'q':
+ case KEY_ESC:
return svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
}
@@ -401,6 +402,25 @@ sub_main(int *code, int argc, const char
keypad(stdscr, TRUE);
nonl();
+ /* ESCDELAY is a ncurses-exclusive variable that controls how curses will
+ * handle escape sequences - when a user hits ESC and inputs a command for
+ * the application to potentially do some handling. We don't really care
+ * about this capability and would rather prefer to get out of svnbrowse by
+ * ESC. Other backends may require further testing. It still works fine with
+ * this variable misconfigured.
+ *
+ * Generally, the decision to exit by ESC itself is questionable, as the
+ * majority of default applications don't do that (like vim, less, man). Some
+ * users would spam escape after each action and the others to would expect
+ * it to close a 37-deep stacked dialog. Anyway we can just drop associated
+ * case statement at any time if we found that annoying.
+ *
+ * Find more info in 'man ESCDELAY'. */
+
+#ifdef NCURSES_VERSION
+ ESCDELAY = 0;
+#endif /* NCURSES_VERSION */
+
view = view_make(ctx, pool);
iterpool = svn_pool_create(pool);
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.