MCPcopy Create free account
hub / github.com/SimHacker/micropolis / IntervalWidgetCmd

Function IntervalWidgetCmd

micropolis-activity/src/sim/w_inter.c:401–496  ·  view source on GitHub ↗
(clientData, interp, argc, argv)

Source from the content-addressed store, hash-verified

399 *
400 *--------------------------------------------------------------
401 */
402
403static int
404IntervalWidgetCmd(clientData, interp, argc, argv)
405 ClientData clientData; /* Information about interval
406 * widget. */
407 Tcl_Interp *interp; /* Current interpreter. */
408 int argc; /* Number of arguments. */
409 char **argv; /* Argument strings. */
410{
411 register Interval *intervalPtr = (Interval *) clientData;
412 int result = TCL_OK;
413 int length;
414 char c;
415
416 if (argc < 2) {
417 Tcl_AppendResult(interp, "wrong # args: should be \"",
418 argv[0], " option ?arg arg ...?\"", (char *) NULL);
419 return TCL_ERROR;
420 }
421 Tk_Preserve((ClientData) intervalPtr);
422 c = argv[1][0];
423 length = strlen(argv[1]);
424 if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)) {
425 if (argc == 2) {
426 result = Tk_ConfigureInfo(interp, intervalPtr->tkwin, configSpecs,
427 (char *) intervalPtr, (char *) NULL, 0);
428 } else if (argc == 3) {
429 result = Tk_ConfigureInfo(interp, intervalPtr->tkwin, configSpecs,
430 (char *) intervalPtr, argv[2], 0);
431 } else {
432 result = ConfigureInterval(interp, intervalPtr, argc-2, argv+2,
433 TK_CONFIG_ARGV_ONLY);
434 }
435 } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
436 if (argc != 2) {
437 Tcl_AppendResult(interp, "wrong # args: should be \"",
438 argv[0], " get\"", (char *) NULL);
439 goto error;
440 }
441 sprintf(interp->result, "%d %d", intervalPtr->minValue, intervalPtr->maxValue);
442 } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) {
443 int minValue, maxValue;
444
445 if (argc != 4) {
446 Tcl_AppendResult(interp, "wrong # args: should be \"",
447 argv[0], " set minValue maxValue\"", (char *) NULL);
448 goto error;
449 }
450 if (Tcl_GetInt(interp, argv[2], &minValue) != TCL_OK) {
451 goto error;
452 }
453 if (Tcl_GetInt(interp, argv[3], &maxValue) != TCL_OK) {
454 goto error;
455 }
456 if (minValue > maxValue) {
457 int temp = minValue;
458 minValue = maxValue; maxValue = temp;

Callers

nothing calls this directly

Calls 7

Tcl_AppendResultFunction · 0.85
Tk_PreserveFunction · 0.85
Tk_ConfigureInfoFunction · 0.85
ConfigureIntervalFunction · 0.85
Tcl_GetIntFunction · 0.85
SetIntervalFunction · 0.85
Tk_ReleaseFunction · 0.85

Tested by

no test coverage detected