diff -x '.svn*' -ruN yapet-0.3a/ui/button.cc yapet/ui/button.cc --- yapet-0.3a/ui/button.cc 2009-06-11 17:06:09.000000000 +0200 +++ yapet/ui/button.cc 2009-07-05 13:28:49.748643329 +0200 @@ -105,7 +105,7 @@ onClick(); goto BAILOUT; break; - case '\t': + case KEY_TAB: case KEY_LEFT: case KEY_RIGHT: case KEY_UP: @@ -113,6 +113,9 @@ ch = '\t'; goto BAILOUT; break; + case KEY_ESC: + goto BAILOUT; + break; case KEY_REFRESH: BaseWindow::refreshAll(); break; diff -x '.svn*' -ruN yapet-0.3a/ui/curswa.h yapet/ui/curswa.h --- yapet-0.3a/ui/curswa.h 2009-06-11 17:06:10.000000000 +0200 +++ yapet/ui/curswa.h 2009-07-05 13:20:52.748663493 +0200 @@ -65,16 +65,30 @@ # include #endif + +enum { #ifdef KEY_REFRESH #undef KEY_REFRESH -enum { /** * The value returned by \c [w]getch() when the user presses \c * ^L. */ - KEY_REFRESH = 12 -}; + KEY_REFRESH = 12, #endif // KEY_REFRESH +#ifndef KEY_ESC + /** + * The value returned by \c [w]getch() upon pressing the escape key + */ + KEY_ESC = 27, +#endif // KEY_ESC +#ifndef KEY_TAB + /** + * The value returned by \c [w]getch() upon pressing the tab key + */ + KEY_TAB = '\t' +#endif // KEY_TAB +}; + diff -x '.svn*' -ruN yapet-0.3a/ui/dialogbox.cc yapet/ui/dialogbox.cc --- yapet-0.3a/ui/dialogbox.cc 2009-06-11 17:06:10.000000000 +0200 +++ yapet/ui/dialogbox.cc 2009-07-05 13:51:13.308643199 +0200 @@ -47,9 +47,14 @@ #else // HAVE_RESIZE int ch = MessageBox::run(); #endif // HAVE_RESIZE - if (ch == '\n') { + switch (ch) { + case '\n': answer = ANSWER_OK; return ch; + break; + case KEY_ESC: + answer = ANSWER_CANCEL; + return ch; } #ifdef HAVE_WRESIZE @@ -58,7 +63,7 @@ #else // HAVE_RESIZE ch = cancelbutton->focus(); #endif // HAVE_RESIZE - if (ch == '\n') { + if (ch == '\n' || ch == KEY_ESC) { answer = ANSWER_CANCEL; return ch; } diff -x '.svn*' -ruN yapet-0.3a/ui/inputwidget.cc yapet/ui/inputwidget.cc --- yapet-0.3a/ui/inputwidget.cc 2009-06-11 17:06:11.000000000 +0200 +++ yapet/ui/inputwidget.cc 2009-07-05 13:22:42.688643251 +0200 @@ -177,8 +177,19 @@ visibleCursor(true); int ch; - while ( (ch=wgetch(window)) != '\n' && ch != '\t') { + while (true) { + ch=wgetch(window); switch (ch) { + // Bailout keys +#ifdef HAVE_WRESIZE + case KEY_RESIZE: +#endif // HAVE_WRESIZE + case '\n': + case KEY_TAB: + case KEY_ESC: + goto BAILOUT; + break; + // Motion and other keys case KEY_UP: case KEY_LEFT: moveBackward(); @@ -205,11 +216,6 @@ case 127: processBackspace(); break; -#ifdef HAVE_WRESIZE - case KEY_RESIZE: - goto BAILOUT; - break; -#endif // HAVE_WRESIZE case KEY_REFRESH: BaseWindow::refreshAll(); break; diff -x '.svn*' -ruN yapet-0.3a/yapet/fileopen.cc yapet/yapet/fileopen.cc --- yapet-0.3a/yapet/fileopen.cc 2009-06-11 17:06:26.000000000 +0200 +++ yapet/yapet/fileopen.cc 2009-07-05 13:48:41.732643218 +0200 @@ -222,6 +222,10 @@ YAPETUI::BaseWindow::resizeAll(); break; #endif // HAVE_WRESIZE + case KEY_ESC: + canceled = true; + return; + break; case KEY_ENTER: case '\n': { try { @@ -252,6 +256,10 @@ YAPETUI::BaseWindow::resizeAll(); break; #endif // HAVE_WRESIZE + case KEY_ESC: + canceled = true; + return; + break; case KEY_ENTER: case '\n': filename = files->getSelectedItem(); @@ -266,6 +274,10 @@ #else // HAVE_WRESIZE ch = input->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) { + canceled = true; + return; + } filename = input->getText(); @@ -276,9 +288,16 @@ #else // HAVE_WRESIZE ch = okbutton->focus(); #endif // HAVE_WRESIZE - if (ch == '\n' || ch == KEY_ENTER) { + switch (ch) { + case KEY_ESC: + canceled = true; + return; + break; + case '\n': + case KEY_ENTER: canceled = false; return; + break; } // The cancel button @@ -288,7 +307,7 @@ #else // HAVE_WRESIZE ch = cancelbutton->focus(); #endif // HAVE_WRESIZE - if (ch == '\n' || ch == KEY_ENTER) { + if (ch == '\n' || ch == KEY_ENTER || ch == KEY_ESC) { canceled = true; return; } diff -x '.svn*' -ruN yapet-0.3a/yapet/passworddialog.cc yapet/yapet/passworddialog.cc --- yapet-0.3a/yapet/passworddialog.cc 2009-06-11 17:06:27.000000000 +0200 +++ yapet/yapet/passworddialog.cc 2009-07-05 13:51:11.384643210 +0200 @@ -80,8 +80,10 @@ while ( (ch = pwidget1->focus()) == KEY_RESIZE) YAPETUI::BaseWindow::resizeAll(); #else // HAVE_WRESIZE - pwidget1->focus(); + ch = pwidget1->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) + return; // Password input widget 2 only if we prompt for a new password if (pwtype == NEW_PW) { @@ -89,8 +91,10 @@ while ( (ch = pwidget2->focus()) == KEY_RESIZE) YAPETUI::BaseWindow::resizeAll(); #else // HAVE_WRESIZE - pwidget2->focus(); + ch = pwidget2->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) + return; } #ifdef HAVE_WRESIZE @@ -99,6 +103,9 @@ #else // HAVE_WRESIZE ch = okbutton->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) + return; + if (ch == '\n') { if (pwtype == NEW_PW) { if (pwidget1->getText() == pwidget2->getText()) { @@ -131,7 +138,7 @@ #else // HAVE_WRESIZE ch = cancelbutton->focus(); #endif // HAVE_WRESIZE - if (ch == '\n') + if (ch == '\n' || ch == KEY_ENTER || ch == KEY_ESC) return; } diff -x '.svn*' -ruN yapet-0.3a/yapet/passwordrecord.cc yapet/yapet/passwordrecord.cc --- yapet-0.3a/yapet/passwordrecord.cc 2009-06-11 17:06:28.000000000 +0200 +++ yapet/yapet/passwordrecord.cc 2009-07-05 13:27:40.200622913 +0200 @@ -110,7 +110,10 @@ #else // HAVE_WRESIZE ch = name->focus(); #endif // HAVE_WRESIZE - + if (ch == KEY_ESC) { + encentry = NULL; + return; + } #ifdef HAVE_WRESIZE while ( (ch = host->focus()) == KEY_RESIZE) @@ -118,6 +121,10 @@ #else // HAVE_WRESIZE ch = host->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) { + encentry = NULL; + return; + } #ifdef HAVE_WRESIZE @@ -126,6 +133,10 @@ #else // HAVE_WRESIZE ch = username->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) { + encentry = NULL; + return; + } #ifdef HAVE_WRESIZE @@ -134,6 +145,10 @@ #else // HAVE_WRESIZE ch = password->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) { + encentry = NULL; + return; + } #ifdef HAVE_WRESIZE @@ -142,6 +157,10 @@ #else // HAVE_WRESIZE ch = comment->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) { + encentry = NULL; + return; + } #ifdef HAVE_WRESIZE @@ -150,6 +169,10 @@ #else // HAVE_WRESIZE ch = okbutton->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) { + encentry = NULL; + return; + } if (ch == '\n') { if (!entryChanged()) { @@ -193,7 +216,7 @@ #else // HAVE_WRESIZE ch = cancelbutton->focus(); #endif // HAVE_WRESIZE - if (ch == '\n') { + if (ch == '\n' || ch == KEY_ESC) { encentry = NULL; return; } diff -x '.svn*' -ruN yapet-0.3a/yapet/searchdialog.cc yapet/yapet/searchdialog.cc --- yapet-0.3a/yapet/searchdialog.cc 2009-06-11 17:06:28.000000000 +0200 +++ yapet/yapet/searchdialog.cc 2009-07-05 14:14:35.548643222 +0200 @@ -68,8 +68,12 @@ while ( (ch = searchtermw->focus()) == KEY_RESIZE) YAPETUI::BaseWindow::resizeAll(); #else // HAVE_WRESIZE - searchtermw->focus(); + ch = searchtermw->focus(); #endif // HAVE_WRESIZE + if (ch == KEY_ESC) { + canceled = true; + return; + } #ifdef HAVE_WRESIZE while ( (ch = okbutton->focus()) == KEY_RESIZE) @@ -77,7 +81,11 @@ #else // HAVE_WRESIZE ch = okbutton->focus(); #endif // HAVE_WRESIZE - if (ch == '\n') { + switch (ch) { + case KEY_ESC: + canceled = true; + return; + case '\n': canceled = false; return; } @@ -87,7 +95,7 @@ #else // HAVE_WRESIZE ch = cancelbutton->focus(); #endif // HAVE_WRESIZE - if (ch == '\n') { + if (ch == '\n' || ch == KEY_ESC) { canceled = true; return; }