fixed selection highlighting and key handling
This commit is contained in:
parent
26d102377f
commit
a45b6b6b7b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.idea/
|
.idea/
|
||||||
docs/
|
docs/
|
||||||
*.iml
|
*.iml
|
||||||
|
db/test*.sqlite
|
||||||
|
178
app/appui.cls
178
app/appui.cls
@ -29,11 +29,10 @@
|
|||||||
self~SetPanelColor(win, clrset)
|
self~SetPanelColor(win, clrset)
|
||||||
|
|
||||||
if with_box = .true then DO
|
if with_box = .true then DO
|
||||||
win~box(0, 0) /* Draw box with default ACS characters */
|
win~box(0, 0) /* Draw box with default ACS characters */
|
||||||
win~refresh
|
win~refresh
|
||||||
END
|
END
|
||||||
|
return win
|
||||||
return win
|
|
||||||
|
|
||||||
::METHOD DrawSubPanel
|
::METHOD DrawSubPanel
|
||||||
use arg height, width, starty, startx, clrset, title, with_box
|
use arg height, width, starty, startx, clrset, title, with_box
|
||||||
@ -52,7 +51,7 @@
|
|||||||
new_win~box(0,0)
|
new_win~box(0,0)
|
||||||
new_win~refresh
|
new_win~refresh
|
||||||
END
|
END
|
||||||
return new_win
|
return new_win
|
||||||
|
|
||||||
::METHOD SetPanelColor
|
::METHOD SetPanelColor
|
||||||
use arg panel, clrset
|
use arg panel, clrset
|
||||||
@ -79,83 +78,84 @@
|
|||||||
END
|
END
|
||||||
panel~bkgd(panel~color_pair(clrset+1))
|
panel~bkgd(panel~color_pair(clrset+1))
|
||||||
panel~refresh
|
panel~refresh
|
||||||
|
RETURN
|
||||||
|
|
||||||
::method setupMainMenu
|
::method setupMainMenu
|
||||||
expose mainMenu win menuwin menuItems menu_keys
|
expose mainMenu menuwin menu_items menu_keys selected
|
||||||
use arg win
|
use arg win
|
||||||
|
|
||||||
max_y = win~lines
|
max_y = win~lines
|
||||||
max_x = win~cols
|
max_x = win~cols
|
||||||
|
|
||||||
menu_height = 21
|
menu_height = 21
|
||||||
menu_width = 40
|
menu_width = 40
|
||||||
start_y = (max_y - menu_height) % 2
|
start_y = (max_y - menu_height) % 2
|
||||||
start_x = (max_x - menu_width) % 2
|
start_x = (max_x - menu_width) % 2
|
||||||
clrset=1
|
clrset=1
|
||||||
title = "Rexx Address Book"
|
title = "Rexx Address Book"
|
||||||
with_box = .true
|
with_box = .true
|
||||||
|
|
||||||
menuwin = self~DrawSubPanel(menu_height, menu_width, start_y, start_x, clrset, title, with_box)
|
menuwin = self~DrawSubPanel(menu_height, menu_width, start_y, start_x, clrset, title, with_box)
|
||||||
menuItems = .array~of("[A]dd Contact", "[R]emove Contact", "[E]dit Contact", "[S]earch", "[L]ist All", "E[X]it")
|
menu_items = .array~of("[A]dd Contact", "[R]emove Contact", "[E]dit Contact", "[S]earch", "[L]ist All", "[Q]uit")
|
||||||
menu_keys = .array~of("a", "r", "e", "s", "l", "x")
|
menu_keys = .array~of("a", "r", "e", "s", "l", "q")
|
||||||
|
|
||||||
/* Display menu items */
|
/* Display menu items */
|
||||||
selected = 1
|
.environment~selected = 1
|
||||||
self~DrawMenu(menuwin, menuItems, selected, win)
|
self~DrawMenu(menuwin, menu_items, .environment~selected, win)
|
||||||
/* menuwin~mvaddstr(menu_height - 2, 3, "Type 'X' to exit") */
|
menuwin~refresh
|
||||||
menuwin~refresh
|
RETURN
|
||||||
RETURN
|
|
||||||
|
|
||||||
::method DrawMenu
|
::method DrawMenu
|
||||||
expose win menuItems selected mainwin
|
expose win menu_items menu_keys selected mainwin
|
||||||
use arg win, items, selected, mainwin
|
use arg menuwin, items, selected, mainwin
|
||||||
|
|
||||||
do i = 1 to items~items
|
do i = 1 to items~items
|
||||||
if i = selected then do
|
if i = .environment~selected then do
|
||||||
win~attron(mainwin~COLOR_PAIR(2))
|
menuwin~attron(menuwin~attron(menuwin~A_REVERSE))
|
||||||
win~attron(mainwin~A_BOLD)
|
menuwin~attron(menuwin~A_BOLD)
|
||||||
win~mvaddstr(i+3, 2, items[i])
|
menuwin~mvaddstr(i+3, 2, items[i])
|
||||||
win~attroff(mainwin~COLOR_PAIR(2))
|
menuwin~attroff(menuwin~A_REVERSE)
|
||||||
win~attroff(mainwin~A_BOLD)
|
menuwin~attroff(menuwin~A_BOLD)
|
||||||
end
|
end
|
||||||
else do
|
else do
|
||||||
win~mvaddstr(i+3, 2, items[i])
|
menuwin~mvaddstr(i+3, 2, items[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
win~refresh
|
menuwin~refresh
|
||||||
return
|
return
|
||||||
|
|
||||||
/** MAIN LOOP **/
|
/** MAIN LOOP **/
|
||||||
::method mainLoop
|
::method mainLoop
|
||||||
expose win mainMenu menuwin
|
expose win mainMenu menuwin selected menu_items menu_keys
|
||||||
|
menuwin~refresh
|
||||||
running = .true
|
running = .true
|
||||||
|
|
||||||
do while running
|
do while running
|
||||||
menuwin~refresh
|
|
||||||
key = win~getch
|
key = win~getch
|
||||||
|
|
||||||
menu_keys = .array~of("a", "r", "e", "s", "l", "x")
|
old_selected = .environment~selected
|
||||||
|
|
||||||
select
|
select
|
||||||
when key = win~KEY_UP then do
|
when key = menuwin~KEY_UP then do
|
||||||
if selected > 1 then selected = selected - 1
|
if .environment~selected > 1 then .environment~selected = .environment~selected - 1
|
||||||
call DrawMenu menuwin, menuItems, selected, win
|
self~DrawMenu(menuwin, menu_items, .environment~selected, win)
|
||||||
end
|
|
||||||
when key = win~KEY_DOWN then do
|
|
||||||
if selected < menuItems~items then selected = selected + 1
|
|
||||||
call DrawMenu menuwin, menuItems, selected, win
|
|
||||||
end
|
|
||||||
when key = D2C(10) | key = D2C(13) then do /* Enter key - numeric codes only */
|
|
||||||
menuwin~refresh
|
menuwin~refresh
|
||||||
call ProcessSelection menu_keys[selected], home
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
when key = D2C(88) | key = D2C(120) | key = "x" | key = C2D("x") then do
|
when key = menuwin~KEY_DOWN then do
|
||||||
|
if .environment~selected < menu_items~items then .environment~selected = .environment~selected + 1
|
||||||
|
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
|
menuwin~endwin
|
||||||
.environment['STOPNOW'] = 1
|
.environment['STOPNOW'] = 1
|
||||||
RETURN
|
RETURN
|
||||||
end
|
end
|
||||||
|
when key = D2C(10) | key = D2C(13) then do /* Enter key - numeric codes only */
|
||||||
|
menuwin~refresh
|
||||||
|
self~ProcessSelection(menuwin, menu_keys[.environment~selected])
|
||||||
|
return
|
||||||
|
end
|
||||||
otherwise do
|
otherwise do
|
||||||
if datatype(key) = 'CHAR' then do
|
if datatype(key) = 'CHAR' then do
|
||||||
key = lower(key)
|
key = lower(key)
|
||||||
@ -168,43 +168,55 @@
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end /* otherwise */
|
||||||
|
end /* select */
|
||||||
|
/* Only redraw if selection changed */
|
||||||
|
if old_selected \= .environment~selected then do
|
||||||
|
self~DrawMenu(menuwin, menu_items, .environment~selected, win)
|
||||||
end
|
end
|
||||||
end /* do while running */
|
end /* do while running */
|
||||||
return
|
return
|
||||||
|
|
||||||
/* Process selection */
|
/* Process selection */
|
||||||
::METHOD ProcessSelection
|
::METHOD ProcessSelection
|
||||||
use arg menuwin, key_char
|
expose menu_items menu_keys
|
||||||
select
|
use arg menuwin, key_char
|
||||||
when key_char = 'a' then do
|
select
|
||||||
menuwin~mvaddstr(19 - 3, 5, "I would launch the ADD panel ");menuwin~refresh;
|
when key_char = 'a' then do
|
||||||
menuwin~refresh
|
menuwin~mvaddstr(19 - 3, 5, "I would launch the ADD panel ");
|
||||||
call SysWait 1
|
menuwin~refresh
|
||||||
END
|
call SysWait 1
|
||||||
when key_char = 'r' then do
|
END
|
||||||
menuwin~mvaddstr(19 - 3, 5, "I would launch the REMOVE panel ");menuwin~refresh;
|
when key_char = 'r' then do
|
||||||
menuwin~refresh
|
menuwin~mvaddstr(19 - 3, 5, "I would launch the REMOVE panel ");
|
||||||
call SysWait 1
|
menuwin~refresh
|
||||||
END
|
call SysWait 1
|
||||||
when key_char = 'e' then do
|
END
|
||||||
menuwin~mvaddstr(19 - 3, 5, "I would launch the EDIT panel ");menuwin~refresh;
|
when key_char = 'e' then do
|
||||||
menuwin~refresh
|
menuwin~mvaddstr(19 - 3, 5, "I would launch the EDIT panel ");
|
||||||
call SysWait 1
|
menuwin~refresh
|
||||||
END
|
call SysWait 1
|
||||||
when key_char = 's' then do
|
END
|
||||||
menuwin~mvaddstr(19 - 3, 5, "I would launch the SEARCH panel ");menuwin~refresh;
|
when key_char = 's' then do
|
||||||
menuwin~refresh
|
menuwin~mvaddstr(19 - 3, 5, "I would launch the SEARCH panel ");
|
||||||
call SysWait 1
|
menuwin~refresh
|
||||||
END
|
call SysWait 1
|
||||||
when key_char = 'l' then do
|
END
|
||||||
menuwin~mvaddstr(19 - 3, 5, "I would launch the LIST panel ");menuwin~refresh;
|
when key_char = 'l' then do
|
||||||
menuwin~refresh
|
menuwin~mvaddstr(19 - 3, 5, "I would launch the LIST panel ")
|
||||||
call SysWait 1
|
menuwin~refresh
|
||||||
END
|
call SysWait 1
|
||||||
otherwise nop
|
END
|
||||||
end
|
when key_char = 'q' then do
|
||||||
return
|
menuwin~mvaddstr(19 - 3, 5, "Exiting The Application... ");
|
||||||
|
menuwin~refresh
|
||||||
|
call SysWait 1
|
||||||
|
menuwin~endwin
|
||||||
|
.environment['STOPNOW'] = 1
|
||||||
|
END
|
||||||
|
otherwise nop
|
||||||
|
end
|
||||||
|
return
|
||||||
|
|
||||||
::METHOD findInArray
|
::METHOD findInArray
|
||||||
use arg array, item
|
use arg array, item
|
||||||
|
Loading…
Reference in New Issue
Block a user