From 5e81a528a904d6f12751165b73fe8978b8c98d76 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Mon, 5 May 2025 21:44:11 +0100 Subject: [PATCH] fix quit selection --- addbook.rex | 2 -- app/appui.cls | 31 +++++++++++++++++-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/addbook.rex b/addbook.rex index eee7c4d..d8acd1d 100755 --- a/addbook.rex +++ b/addbook.rex @@ -19,8 +19,6 @@ Do forever if .environment['STOPNOW'] = 1 then do app~cleanup() /* Clean up before exiting */ call SysCls - /* Say .environment["REXX_PATH"] */ - /* Say "Address Book Exited." */ exit 0 end app~reloop() diff --git a/app/appui.cls b/app/appui.cls index 1853c19..4e8ac0e 100644 --- a/app/appui.cls +++ b/app/appui.cls @@ -146,30 +146,29 @@ self~DrawMenu(menuwin, menu_items, .environment~selected, win) menuwin~refresh end - when key = D2C(81) | key = D2C(113) | key = "q" | key = C2D("q") then do - menuwin~endwin - .environment['STOPNOW'] = 1 + when key = D2C(81) | key = D2C(113) then do /* Q for quit */ + call SysWait 0.25 + .environment~selected = self~findInArray(menu_keys, key) + self~ProcessSelection(menuwin, menu_keys[.environment~selected]) RETURN - end + END when key = D2C(10) | key = D2C(13) then do /* Enter key - numeric codes only */ menuwin~mvaddstr(19 - 1, 18, "Letter selection ["||menu_keys[.environment~selected]||"]") menuwin~refresh - call SysWait 0.25 self~ProcessSelection(menuwin, menu_keys[.environment~selected]) return end otherwise do - if datatype(key) = 'CHAR' then do key = lower(key) - pos = self~findInArray(menu_keys, key) - if pos > 0 then do + poz = self~findInArray(menu_keys, key) + if poz > 0 then do + .environment~selected = poz + self~DrawMenu(menuwin, menu_items, .environment~selected, win) menuwin~mvaddstr(19 - 1, 18, "Letter selection ["||key||"]") menuwin~refresh call SysWait 0.25 self~ProcessSelection(menuwin, key) - return - end - end + end /* if pos > 0 */ end /* otherwise */ end /* select */ /* Only redraw if selection changed */ @@ -210,7 +209,7 @@ call SysWait 0.25 END when key_char = 'q' then do - menuwin~mvaddstr(19 - 3, 5, "Exiting The Application... "); + menuwin~mvaddstr(19 - 3, 5, "Exiting the application... ") menuwin~refresh call SysWait 0.25 menuwin~endwin @@ -228,7 +227,11 @@ return 0 /* Not found */ ::method cleanup - expose win + expose win menuwin /* Clean up ncurses */ + menuwin~endwin win~endwin - return + exit 0 + return + +