Skip to content

Commit

Permalink
confirm dialog for Reset triggered by menu or Alt+F8 (#1173),
Browse files Browse the repository at this point in the history
user-definable function reset-noask
  • Loading branch information
mintty committed Oct 16, 2022
1 parent 5933cdd commit 7c90db2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
8 changes: 5 additions & 3 deletions docs/mintty.1
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ Once keyboard selecting mode is entered, the following keys are applied:
.br
\(en \fBAlt+F4\fP: Close
.br
\(en \fBAlt+F8\fP: Reset
\(en \fBAlt+F8\fP: Reset (with confirm dialog)
.br
\(en \fBAlt+F10\fP: Default terminal size (rows/columns)
.br
Expand Down Expand Up @@ -974,7 +974,7 @@ Keys pane of the Options dialog.
.br
\(en \fBCtrl+Shift+W\fP: Close
.br
\(en \fBCtrl+Shift+R\fP: Reset
\(en \fBCtrl+Shift+R\fP: Reset (without confirm dialog)
.br
\(en \fBCtrl+Shift+D\fP: Default terminal size (rows/columns)
.br
Expand Down Expand Up @@ -2989,7 +2989,9 @@ Supported actions are described as follows:
.br
\(en \fBlock-title\fP: locks the window title from being changed
.br
\(en \fBreset\fP: resets the terminal
\(en \fBreset\fP: resets the terminal (with confirm dialog)
.br
\(en \fBreset-noask\fP: resets the terminal (no confirm dialog)
.br
\(en \fBtek-reset\fP: Tek mode RESET
.br
Expand Down
1 change: 1 addition & 0 deletions src/winids.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define IDM_TEKPAGE 0x0260
#define IDM_TEKCOPY 0x0360
#define IDM_SAVEIMG 0x0460
#define IDM_RESET_NOASK 0x0560
#define IDM_DEFSIZE 0x0070
#define IDM_DEFSIZE_ZOOM 0x0170
#define IDM_SCROLLBAR 0x0280
Expand Down
3 changes: 2 additions & 1 deletion src/wininput.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,7 @@ static struct function_def cmd_defs[] = {
{"lock-title", {.fct = lock_title}, mflags_lock_title},
{"clear-title", {.fct = clear_title}, 0},
{"reset", {IDM_RESET}, 0},
{"reset-noask", {IDM_RESET_NOASK}, 0},
{"tek-reset", {IDM_TEKRESET}, mflags_tek_mode},
{"tek-page", {IDM_TEKPAGE}, mflags_tek_mode},
{"tek-copy", {IDM_TEKCOPY}, mflags_tek_mode},
Expand Down Expand Up @@ -2822,7 +2823,7 @@ static LONG last_key_time = 0;
when 'I': open_popup_menu(true, "ls", mods);
when 'N': send_syscommand(IDM_TAB); // deprecated default assignment
when 'W': send_syscommand(SC_CLOSE);
when 'R': send_syscommand(IDM_RESET);
when 'R': send_syscommand(IDM_RESET_NOASK);
when 'D': send_syscommand(IDM_DEFSIZE);
when 'F': send_syscommand(cfg.zoom_font_with_window ? IDM_FULLSCREEN_ZOOM : IDM_FULLSCREEN);
when 'S': send_syscommand(IDM_FLIPSCREEN);
Expand Down
24 changes: 21 additions & 3 deletions src/winmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -3090,6 +3090,19 @@ confirm_exit(void)
return !ret || ret == IDOK;
}

static bool
confirm_reset(void)
{
int ret = message_box_w(
wnd, _W("Reset terminal?"),
W(APPNAME), MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2,
null
);

// Treat failure to show the dialog as confirmation.
return !ret || ret == IDOK;
}

void
win_close(void)
{
Expand Down Expand Up @@ -3577,9 +3590,14 @@ static struct {
when IDM_TOGVT220KB: toggle_vt220();
when IDM_PASTE: win_paste();
when IDM_SELALL: term_select_all(); win_update(false);
when IDM_RESET: winimgs_clear(); term_reset(true); win_update(false);
if (tek_mode)
tek_reset();
when IDM_RESET or IDM_RESET_NOASK:
if ((wp & ~0xF) == IDM_RESET_NOASK || confirm_reset()) {
winimgs_clear();
term_reset(true);
win_update(false);
if (tek_mode)
tek_reset();
}
when IDM_TEKRESET:
if (tek_mode)
tek_reset();
Expand Down
2 changes: 2 additions & 0 deletions wiki/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ Initialisation
Configuration
* Option OldKeyFunctionsKeypad (~#1161, not listed in manual).
* Option LinkMod (#1169).
* New user-definable function reset-noask.

Other
* Fixed crash condition on user-defined commands (#1174).
* Add confirm dialog to Reset triggered by menu or Alt+F8 (#1173).

### 3.6.1 (24 April 2022) ###

Expand Down

0 comments on commit 7c90db2

Please sign in to comment.