@@ -20,9 +20,12 @@ in the source distribution for its full text.
2020#include "ProvideCurses.h"
2121
2222
23- static const char * const DisplayOptionsFunctions [] = {"(De)Select " ,"Increment " , "Decrement " , "Done " , NULL };
24- static const char * const DisplayOptionsKeys [] = {"Enter" ,"+" , "-" , "F10" , "Esc" };
25- static const int DisplayOptionsEvents [] = {KEY_ENTER , '+' , '-' , KEY_F (10 ), 27 };
23+ static const char * const BooleanDisplayOptionsFunctions [] = {"Select " , "Done " , NULL };
24+ static const char * const BooleanDisplayOptionsKeys [] = {"Enter" , "F10" , "Esc" };
25+ static const int BooleanDisplayOptionsEvents [] = {KEY_ENTER , KEY_F (10 ), 27 };
26+ static const char * const NumericDisplayOptionsFunctions [] = {"Decrement " , "Increment " , "Done " , NULL };
27+ static const char * const NumericDisplayOptionsKeys [] = {"-" , "+" , "F10" , "Esc" };
28+ static const int NumericDisplayOptionsEvents [] = {'-' , '+' , KEY_F (10 ), 27 };
2629
2730static void DisplayOptionsPanel_delete (Object * object ) {
2831 Panel * super = (Panel * ) object ;
@@ -31,13 +34,40 @@ static void DisplayOptionsPanel_delete(Object* object) {
3134 free (this );
3235}
3336
37+ static void DisplayOptionsPanel_setFunctionBar (Panel * super , OptionItem * item ){
38+ if (OptionItem_kind (item ) == OPTION_ITEM_NUMBER ) {
39+ FunctionBar * fuBar = FunctionBar_new (NumericDisplayOptionsFunctions , NumericDisplayOptionsKeys , NumericDisplayOptionsEvents );
40+ super -> currentBar = fuBar ;
41+ } else {
42+ FunctionBar * fuBar = FunctionBar_new (BooleanDisplayOptionsFunctions , BooleanDisplayOptionsKeys , BooleanDisplayOptionsEvents );
43+ super -> currentBar = fuBar ;
44+ }
45+ }
46+
3447static HandlerResult DisplayOptionsPanel_eventHandler (Panel * super , int ch ) {
3548 DisplayOptionsPanel * this = (DisplayOptionsPanel * ) super ;
3649
3750 HandlerResult result = IGNORED ;
3851 OptionItem * selected = (OptionItem * ) Panel_getSelected (super );
3952
4053 switch (ch ) {
54+
55+ case KEY_UP : {
56+ int selected_index = Panel_getSelectedIndex (super );
57+ if (selected_index > 1 ) {
58+ OptionItem * next_to_select = (OptionItem * ) Panel_get (super , selected_index - 1 );
59+ DisplayOptionsPanel_setFunctionBar (super , next_to_select );
60+ }
61+ break ;
62+ }
63+ case KEY_DOWN : {
64+ int selected_index = Panel_getSelectedIndex (super );
65+ if (selected_index < Panel_size (super ) - 1 ) {
66+ OptionItem * next_to_select = (OptionItem * ) Panel_get (super , selected_index + 1 );
67+ DisplayOptionsPanel_setFunctionBar (super , next_to_select );
68+ }
69+ break ;
70+ }
4171 case '\n' :
4272 case '\r' :
4373 case KEY_ENTER :
@@ -92,7 +122,7 @@ const PanelClass DisplayOptionsPanel_class = {
92122DisplayOptionsPanel * DisplayOptionsPanel_new (Settings * settings , ScreenManager * scr ) {
93123 DisplayOptionsPanel * this = AllocThis (DisplayOptionsPanel );
94124 Panel * super = (Panel * ) this ;
95- FunctionBar * fuBar = FunctionBar_new (DisplayOptionsFunctions , DisplayOptionsKeys , DisplayOptionsEvents );
125+ FunctionBar * fuBar = FunctionBar_new (BooleanDisplayOptionsFunctions , BooleanDisplayOptionsKeys , BooleanDisplayOptionsEvents );
96126 Panel_init (super , 1 , 1 , 1 , 1 , Class (OptionItem ), true, fuBar );
97127
98128 this -> settings = settings ;
0 commit comments