📄 menu.c
字号:
0); for (p = &m1, i = 0; i < 3 && *p != NULL; p++, i++) { mi = menu_create_item( MENU_STRING_ITEM, *p, mv[i+1], MENU_FONT, (i==0) ? bold_bigfont : bigfont, MENU_SELECTED, (i==0) ? TRUE : FALSE, MENU_BOXED, (i==0) ? TRUE : FALSE, MENU_MARGIN, 10, 0); (void)menu_set(menu, MENU_APPEND_ITEM, mi, 0); } (void)panel_set(item, PANEL_EVENT_PROC, show_menu_proc, PANEL_CLIENT_DATA, menu, 0); } return(item);}/**********************************************************************/static Panel_itemcreate_cycle_item(panel, label)/**********************************************************************/Panel panel;char *label;{ Panel_item item; item = panel_create_item(panel, PANEL_CYCLE, PANEL_LABEL_STRING, label, PANEL_LABEL_FONT, bold_bigfont, PANEL_CHOICE_FONTS, bold_bigfont, 0, PANEL_DISPLAY_LEVEL, PANEL_CURRENT, PANEL_CHOICE_STRINGS, " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", " Endless", 0, 0); return(item);}/**********************************************************************/show_menu_proc(item, event)/**********************************************************************/Panel_item item;Event *event;{ Menu me; Menu_item mi; int mv; if (event_id(event) == MS_RIGHT && event_is_down(event)) { me = (Menu)panel_get(item, PANEL_CLIENT_DATA); mv = (int)menu_show(me, sel_panel, event, 0); if (mv != NULL) { /* hightlight choice with bold_bigfont */ mi = menu_find(me, MENU_FONT, bold_bigfont, 0); (void)menu_set(mi, MENU_FONT, bigfont, MENU_BOXED, FALSE, 0); mi = menu_find(me, MENU_VALUE, mv, 0); (void)menu_set(mi, MENU_FONT, bold_bigfont, MENU_BOXED, TRUE, 0); /* set test selection for single board test */ switch ((int)menu_get(me, MENU_CLIENT_DATA)) { case INTEGRATION_TEST: exec_test(INTEGRATION_TEST, NULL); break; case SINGLE_BLOCK_TEST: sb_test_select = get_test_selection(sb_testlist, mv); break; } } } else { (void)panel_default_handle_event(item, event); }}/**********************************************************************/show_msg(text)/**********************************************************************/char *text;{ int length; length = (int)textsw_insert(msg_window, text, (Textsw_index)strlen(text)); if (length != strlen(text)) { (void)fprintf(stderr, "Failed to insert text.\n"); }}/*ARGSUSED*//**********************************************************************/int_exec_proc(item, event)/**********************************************************************/Panel_item item;Event *event;{ exec_test(INTEGRATION_TEST, NULL);}/*ARGSUSED*//**********************************************************************/sb_exec_proc(item, event)/**********************************************************************/Panel_item item;Event *event;{ exec_test(SINGLE_BLOCK_TEST, sb_test_select);}/**********************************************************************/exec_test(type, mode)/**********************************************************************/int type, mode;{ extern char *fork_test(); int blck_cnt, brd_cnt; char *errmsg; blck_cnt = (int)panel_get_value(loops_blck_item) + 1; if (blck_cnt == 10) blck_cnt = -1; brd_cnt = (int)panel_get_value(loops_brd_item) + 1; if (brd_cnt == 10) brd_cnt = -1; errmsg = fork_test(pipe_fd, type, blck_cnt, brd_cnt, mode, &pid); if (errmsg) { pmessage(errmsg); return; } /* start timer */ start_timer(); display_test_title(type); (void)window_set(sel_panel, WIN_SHOW, FALSE, 0); (void)window_set(disp_panel, WIN_SHOW, TRUE, 0);}/*ARGSUSED*//**********************************************************************/Notify_valuechild_finished(me, cpid, status)/**********************************************************************/int *me;int cpid;union wait *status;{ char errtxt[256]; /* unregister function */ (void)notify_set_wait3_func(main_frame, NOTIFY_FUNC_NULL, cpid); if (WIFSTOPPED(*status)) { (void)sprintf(errtxt, "Test has been stopped by signal %d.\n", status->w_stopsig); pmessage(timestamp(errtxt)); } if (WIFSIGNALED(*status)) { (void)sprintf(errtxt, "Test has been terminated by signal %d.\n", status->w_termsig); pmessage(timestamp(errtxt)); } if (WIFSIGNALED(*status) || WIFSTOPPED(*status) || WIFEXITED(*status)) { /* swap command panel */ if (!(int)window_get(main_frame, FRAME_CLOSED)) { (void)window_set(disp_panel, WIN_SHOW, FALSE, 0); (void)window_set(sel_panel, WIN_SHOW, TRUE, 0); } else { swap = 1; } /* stop timer */ stop_timer(); /* done */ return(NOTIFY_DONE); } return(NOTIFY_IGNORED);}/*ARGSUSED*//**********************************************************************/Notify_valuecount_time(me, which)/**********************************************************************/Notify_client me;int which;{ extern struct tm *gmtime(); struct tm *tm; char text[10]; secs++; tm = gmtime((long *)&secs); (void)sprintf(text, "%03d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec); (void)panel_set(timer_item, PANEL_LABEL_STRING, text, 0); return(NOTIFY_DONE);}/*ARGSUSED*//**********************************************************************/stop_proc(item, event)/**********************************************************************/Panel_item item;Event *event;{ if (swap) { (void)panel_set(timer_item, PANEL_LABEL_STRING, "000:00:00", 0); (void)window_set(disp_panel, WIN_SHOW, FALSE, 0); (void)window_set(sel_panel, WIN_SHOW, TRUE, 0); swap = 0; } else { if (kill(pid, SIGKILL)) { perror("kill"); pmessage("Can't stop test.\n"); } }}/**********************************************************************/start_timer()/**********************************************************************/{ extern Notify_value count_time(); secs = 0; (void)notify_set_itimer_func(main_frame, count_time, ITIMER_REAL, &timer, ITIMER_NULL);}/**********************************************************************/stop_timer()/**********************************************************************/{ extern Notify_value count_time(); (void)notify_set_itimer_func(main_frame, count_time, ITIMER_REAL, ITIMER_NULL, ITIMER_NULL); if (!swap) { (void)panel_set(timer_item, PANEL_LABEL_STRING, "000:00:00", 0); }}/**********************************************************************/display_test_title(type)/**********************************************************************/int type;{ char *title; int w; Rect *r; static char int_test[] = "CG12 Integration Test"; static char sb_test[] = "CG12 Functional Blocks Test"; switch (type) { case INTEGRATION_TEST: title = int_test; break; case SINGLE_BLOCK_TEST: title = sb_test; break; } (void)panel_set(test_title_item, PANEL_LABEL_STRING, title, 0); w = (int)window_get(main_frame, WIN_WIDTH); r = (Rect *)panel_get(test_title_item, PANEL_ITEM_RECT); (void)panel_set(test_title_item, PANEL_ITEM_X, (w-r->r_width)/2, 0);}/**********************************************************************/intget_test_selection(tl, m)/**********************************************************************/struct test tl[];int m;{ int s; int i; struct test *tp; Rect *r; if (m == LIST_ALL) { return -1; } if (m == LIST_SELECT) { r = (Rect *)window_get(main_frame, WIN_RECT); s = popup_select(tl, r, bold_bigfont); return s; } for (tp = &tl[0], s=0, i=1; tp ; tp = tp->nexttest) { if (tp->dfault) { s |= i; i <<= 1; } } return s;}/**********************************************************************/register_notifier(npid)/**********************************************************************/int npid;{ extern Notify_value pipe_report(); extern Notify_value child_finished(); /* prepare to catch SIGCHLD */ (void)notify_set_wait3_func(main_frame, child_finished, npid);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -