/* * This injects a single character into the widget. */ static int _injectCDKButton (CDKOBJS *object, chtype input) { CDKBUTTON *widget = (CDKBUTTON *)object; int ret = unknownInt; bool complete = FALSE; setExitType (widget, 0); /* Check a predefined binding. */ if (checkCDKObjectBind (vBUTTON, widget, input) != 0) { checkEarlyExit (widget); complete = TRUE; } else { switch (input) { case KEY_ESC: setExitType (widget, input); complete = TRUE; break; case KEY_ERROR: setExitType (widget, input); complete = TRUE; break; case KEY_ENTER: case SPACE: if (widget->callback) widget->callback (widget); setExitType (widget, KEY_ENTER); ret = 0; complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (widget)); refreshCDKScreen (ScreenOf (widget)); break; default: BEEP (); break; } } if (!complete) { setExitType (widget, 0); } ResultOf (widget).valueInt = ret; return (ret != unknownInt); }
static int time_preprocess (EObjectType cdktype, void *object, void *clientData, chtype input) { CDKENTRY *entry = object; /* Check a predefined binding... */ if (checkCDKObjectBind (vENTRY, entry, input) != 0) return (1); /* Check ':' */ if ((input == ':') || ((input >= '0') && (input <= '9'))) return (1); /* Check other known keys */ switch (input) { case KEY_UP: case KEY_DOWN: case CDK_BEGOFLINE: case CDK_TRANSPOSE: case CDK_ENDOFLINE: case KEY_LEFT: case CDK_BACKCHAR: case KEY_RIGHT: case CDK_FORCHAR: case DELETE: case ('H') & 0x1f: case KEY_BACKSPACE: case KEY_DC: case KEY_ESC: case CDK_ERASE: case CDK_CUT: case CDK_COPY: case CDK_PASTE: case KEY_RETURN: case KEY_TAB: case KEY_ENTER: case CDK_REFRESH: return (1); default: Beep (); return (0); } }
/* * This function injects a single character into the widget. */ float injectCDKFScale (CDKFSCALE *scale, chtype input) { /* Declare some local variables. */ int ppReturn = 1; /* Set the exit type. */ scale->exitType = vEARLY_EXIT; /* Draw the field. */ drawCDKFScaleField (scale); /* Check if there is a pre-process function to be called. */ if (scale->preProcessFunction != 0) { /* Call the pre-process function. */ ppReturn = scale->preProcessFunction (vFSCALE, scale, scale->preProcessData, input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind(vFSCALE, scale, input) != 0) { scale->exitType = vESCAPE_HIT; return 0.; } else { switch (input) { case KEY_LEFT : case 'd' : case '-' : case KEY_DOWN : if (scale->current > scale->low) { scale->current -= scale->inc; if (scale->current < scale->low) { scale->current = scale->low; } } else { Beep(); } break; case KEY_RIGHT : case 'u' : case '+' : case KEY_UP : if (scale->current < scale->high) { scale->current += scale->inc; if (scale->current > scale->high) { scale->current = scale->high; } } else { Beep(); } break; case KEY_PPAGE : case 'U' : case CONTROL('B') : if ((scale->current + scale->fastinc) <= scale->high) { scale->current += scale->fastinc; } else { Beep(); } break; case KEY_NPAGE : case 'D' : case CONTROL('F') : if ((scale->current - scale->fastinc) >= scale->low) { scale->current -= scale->fastinc; } else { Beep(); } break; case KEY_HOME : case 'g' : case '0' : scale->current = scale->low; break; case KEY_END : case 'G' : case '$' : scale->current = scale->high; break; case KEY_RETURN : case TAB : case KEY_ENTER : scale->exitType = vNORMAL; return (scale->current); case KEY_ESC : scale->exitType = vESCAPE_HIT; return (scale->current); case CDK_REFRESH : eraseCDKScreen (ScreenOf(scale)); refreshCDKScreen (ScreenOf(scale)); break; default : break; } } /* Should we call a post-process? */ if (scale->postProcessFunction != 0) { scale->postProcessFunction (vFSCALE, scale, scale->postProcessData, input); } } /* Draw the field window. */ drawCDKFScaleField (scale); /* Set the exit type and return. */ scale->exitType = vEARLY_EXIT; return 0.; }
/* * This injects a single character into the widget. */ static int _injectCDKScroll (CDKOBJS *object, chtype input) { CDKSCROLL *widget = (CDKSCROLL *)object; int ppReturn = 1; int ret = unknownInt; bool complete = FALSE; /* Set the exit type for the widget. */ setExitType (widget, 0); /* Draw the scrolling list */ drawCDKScrollList (widget, ObjOf (widget)->box); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf (widget) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf (widget) (vSCROLL, widget, PreProcessDataOf (widget), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a predefined key binding. */ if (checkCDKObjectBind (vSCROLL, widget, input) != 0) { checkEarlyExit (widget); complete = TRUE; } else { switch (input) { case KEY_UP: scroller_KEY_UP (widget); break; case KEY_DOWN: scroller_KEY_DOWN (widget); break; case KEY_RIGHT: scroller_KEY_RIGHT (widget); break; case KEY_LEFT: scroller_KEY_LEFT (widget); break; case KEY_PPAGE: scroller_KEY_PPAGE (widget); break; case KEY_NPAGE: scroller_KEY_NPAGE (widget); break; case KEY_HOME: scroller_KEY_HOME (widget); break; case KEY_END: scroller_KEY_END (widget); break; case '$': widget->leftChar = widget->maxLeftChar; break; case '|': widget->leftChar = 0; break; case KEY_ESC: setExitType (widget, input); complete = TRUE; break; case KEY_ERROR: setExitType (widget, input); complete = TRUE; break; case CDK_REFRESH: eraseCDKScreen (ScreenOf (widget)); refreshCDKScreen (ScreenOf (widget)); break; case KEY_TAB: case KEY_ENTER: setExitType (widget, input); ret = widget->currentItem; complete = TRUE; break; default: break; } } /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf (widget) != 0)) { PostProcessFuncOf (widget) (vSCROLL, widget, PostProcessDataOf (widget), input); } } if (!complete) { drawCDKScrollList (widget, ObjOf (widget)->box); setExitType (widget, 0); } fixCursorPosition (widget); ResultOf (widget).valueInt = ret; return (ret != unknownInt); }
/* * This function injects a single character into the widget. */ static int _injectCDKUScale (CDKOBJS *object, chtype input) { CDKUSCALE *widget = (CDKUSCALE *)object; int ppReturn = 1; unsigned ret = unknownUnsigned; bool complete = FALSE; /* Set the exit type. */ setExitType(widget, 0); /* Draw the field. */ drawCDKUScaleField (widget); /* Check if there is a pre-process function to be called. */ if (PreProcessFuncOf(widget) != 0) { /* Call the pre-process function. */ ppReturn = PreProcessFuncOf(widget) (vUSCALE, widget, PreProcessDataOf(widget), input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind(vUSCALE, widget, input) != 0) { checkEarlyExit(widget); complete = TRUE; } else { switch (input) { case KEY_LEFT : setEditPosition(widget, widget->fieldEdit + 1); break; case KEY_RIGHT : setEditPosition(widget, widget->fieldEdit - 1); break; case KEY_DOWN : Decrement(widget->current, widget->inc); break; case KEY_UP : Increment(widget->current, widget->inc); break; case KEY_PPAGE : Increment(widget->current, widget->fastinc); break; case KEY_NPAGE : Decrement(widget->current, widget->fastinc); break; case KEY_HOME : widget->current = widget->low; break; case KEY_END : widget->current = widget->high; break; case KEY_TAB : case KEY_ENTER : setExitType(widget, input); ret = (widget->current); complete = TRUE; break; case KEY_ESC : setExitType(widget, input); complete = TRUE; break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(widget)); refreshCDKScreen (ScreenOf(widget)); break; default : if (widget->fieldEdit) { if (!performEdit(widget, input)) BEEP(); } else { /* * The cursor is not within the editable text. Interpret * input as commands. */ switch (input) { case 'd': case '-': return _injectCDKUScale(object, KEY_DOWN); case '+': return _injectCDKUScale(object, KEY_UP); case 'D': return _injectCDKUScale(object, KEY_NPAGE); case '0': return _injectCDKUScale(object, KEY_HOME); default: BEEP(); break; } } break; } } limitCurrentValue(widget); /* Should we call a post-process? */ if (!complete && (PostProcessFuncOf(widget) != 0)) { PostProcessFuncOf(widget) (vUSCALE, widget, PostProcessDataOf(widget), input); } } if (!complete) { drawCDKUScaleField (widget); setExitType(widget, 0); } ResultOf(widget).valueUnsigned = ret; return (ret != unknownUnsigned); }
/* * This injects a single character into the dialog widget. */ int injectCDKDialog (CDKDIALOG *dialog, chtype input) { int firstButton = 0; int lastButton = dialog->buttonCount - 1; int ppReturn = 1; /* Set the exit type. */ dialog->exitType = vEARLY_EXIT; /* Check if there is a pre-process function to be called. */ if (dialog->preProcessFunction != 0) { ppReturn = dialog->preProcessFunction (vDIALOG, dialog, dialog->preProcessData, input); } /* Should we continue? */ if (ppReturn != 0) { /* Check for a key binding. */ if (checkCDKObjectBind (vDIALOG, dialog, input) != 0) { dialog->exitType = vESCAPE_HIT; return -1; } else { switch (input) { case KEY_LEFT : case CDK_PREV : if (dialog->currentButton == firstButton) { dialog->currentButton = lastButton;; } else { dialog->currentButton--; } break; case KEY_RIGHT : case CDK_NEXT : case KEY_TAB : case ' ' : if (dialog->currentButton == lastButton) { dialog->currentButton = firstButton; } else { dialog->currentButton++; } break; case KEY_UP : case KEY_DOWN : Beep(); break; case CDK_REFRESH : eraseCDKScreen (ScreenOf(dialog)); refreshCDKScreen (ScreenOf(dialog)); break; case KEY_ESC : dialog->exitType = vESCAPE_HIT; return -1; case KEY_RETURN : case KEY_ENTER : dialog->exitType = vNORMAL; return dialog->currentButton; default : break; } } /* Should we call a post-process? */ if (dialog->postProcessFunction != 0) { dialog->postProcessFunction (vDIALOG, dialog, dialog->postProcessData, input); } } /* Redraw the buttons. */ drawCDKDialogButtons (dialog); wrefresh (dialog->win); /* Exit the dialog box. */ dialog->exitType = vEARLY_EXIT; return -1; }