static void edit_layout(void) { char *cmd; int editing = 1; do { show_layout(); printf("\nLayout options: D)imensions, P)osition, B)ack: "); cmd = getLine(); switch(toupper(*cmd)) { case 'D': number("\nNumber of columns", &mn.ncol, 1, 80/MAX_IMAGE_NAME); number("Entries per column", &mn.maxcol, 1, 30); if (mn.ncol > 1) { getXY("Column pitch", &mn.xpitch, 8, 0); number("Spill threshold", &mn.mincol, 1, mn.maxcol); } break; case 'P': getXY("\nTable UL column", &mn.col, 8, 1); getXY("Table UL row", &mn.row, 16, 1); break; case 'B': editing = 0; break; default: printf("???"); } free(cmd); printf("\n"); } while (editing); }
static void edit_bitmap(char *bitmap_file) { char *cmd; int editing = 1; printf("Editing contents of bitmap file: %s\n", bitmap_file); bmp_file_open(bitmap_file); do { show_layout(); printf("\nText colors:\n"); show_colors(0); show_timer(); printf("\nCommands are: L)ayout, C)olors, T)imer, Q)uit, W)rite: "); cmd = getLine(); switch(toupper(*cmd)) { case 'C': edit_colors(); break; case 'L': edit_layout(); break; case 'T': edit_timer(); break; case 'W': if (yesno("Save companion configuration file?", 0)) dat_file_creat(bitmap_file); editing = !yesno("Save changes to bitmap file?", 0); if (!editing) { printf("Writing output file: %s\n", bitmap_file); bmp_file_close(!test); /* update */ if (test) printf("***The bitmap file has not been changed***\n"); } break; case 'Q': editing = !yesno("Abandon changes?", 0); if (!editing) bmp_file_close(0); /* no update */ break; default: printf("???"); } free(cmd); printf("\n"); } while (editing); exit(0); }
/**************************************************************************** **函数名: int disp_sys_config(u8* param) **描述: 系统设置界面 **输入参数: param :传入参数 **输出参数: **返回值: >= 0:正常状态; < 0:不正常状态。 **备注: ** **版权:郑州友池电子技术有限公司深圳分公司 ** **作者 & 日期: 申伟宏(2015-01-28) **----------------------------------------------------------------------------- **修改记录: ****************************************************************************/ int disp_sys_config(u8* param) { int re = 0; u16 err; //u8 show[3]; const struct _strItemFun menuitem[] = { { (u8*)"1.终端参数", disp_set_terparam }, { (u8*)"2.密钥管理", NULL }, { (u8*)"3.通讯参数", disp_com_config }, { (u8*)"4.IC卡参数", NULL }, {(u8*)"5.修改密码", NULL }, { (u8*)"6.其它功能", NULL }, { (u8*)"7.硬件自检", NULL }, {(u8*)"8.参数下载", NULL } }; struct _strShowLayout showlayout; showlayout.m_light_item = 0; showlayout.m_title = (u8*)"系统设置"; showlayout.m_item = (struct _strItemFun*) menuitem; showlayout.m_column_nums = 2; showlayout.m_show_first_item = 0; showlayout.m_item_nums = sizeof(menuitem) / sizeof(menuitem[0]); showlayout.m_attribute = DISP_LAYOUT_VER | DISP_LAYOUT_PAGEROLL; while (1) { err = show_layout(&showlayout); if (err == ESUCCESS) { re = 0; if(showlayout.m_item[showlayout.m_light_item].m_fun){ sharebuf_input_globalfun(showlayout.m_item[showlayout.m_light_item].m_fun); break; } } else if (err == EINPROGRESS) { } else if (err == ECANCEL) { re = -1; sharebuf_remove_globalfun(); break; } } g_task_step = 0; return re; }
/**************************************************************************** **函数名: int disp_main_menu(u8* param) **描述: 显示主菜单 **输入参数: param :传入参数 **输出参数: **返回值: >= 0:正常状态; < 0:不正常状态。 **备注: ** **版权:郑州友池电子技术有限公司深圳分公司 ** **作者 & 日期: 申伟宏(2015-07-20) **----------------------------------------------------------------------------- **修改记录: ****************************************************************************/ int disp_main_menu(u8* param) { //u8 show[3]; const struct _strItemFun menuitem[] = { { (u8*)"1.消费", trade_consume}, { (u8*)"2.撤销", trade_void}, { (u8*)"3.预授权", NULL }, { (u8*)"4.查余额", trade_query}, { (u8*)"5.结算", trade_settle}, { (u8*)"6.打印", NULL }, { (u8*)"7.签退", trade_logout }, { (u8*)"8.其他", NULL } }; struct _strShowLayout showlayout; //int re; u16 err; //re = 0; showlayout.m_light_item = 0; showlayout.m_title = NULL; showlayout.m_item = (struct _strItemFun*) menuitem; showlayout.m_column_nums = 2; showlayout.m_show_first_item = 0; showlayout.m_item_nums = sizeof(menuitem) / sizeof(menuitem[0]); showlayout.m_attribute = DISP_LAYOUT_VER | DISP_LAYOUT_PAGEROLL; while (1) { err = show_layout(&showlayout); if (err == ESUCCESS) { //re = 0; if(showlayout.m_item[showlayout.m_light_item].m_fun){ sharebuf_input_globalfun(showlayout.m_item[showlayout.m_light_item].m_fun); } break; } else if (err == EINPROGRESS) { } else if (err == ECANCEL) { //re = -1; sharebuf_remove_globalfun(); break; } } return 0; }
/**************************************************************************** **函数名: int disp_ter_oper(u8* param) **描述: 终端操作 **输入参数: param :传入参数 **输出参数: **返回值: >= 0:正常状态; < 0:不正常状态。 **备注: ** **版权:郑州友池电子技术有限公司深圳分公司 ** **作者 & 日期: 申伟宏(2015-03-20) **----------------------------------------------------------------------------- **修改记录: ****************************************************************************/ int disp_ter_oper(u8* param) { int re = 0; u16 err; //u8 show[3]; const struct _strItemFun menuitem[] = { {(u8*) "1.连接设备", disp_connect }, {(u8*) "2.断开连接", disp_disconnect }, { (u8*)"3.查看版本", disp_get_version }}; struct _strShowLayout showlayout; showlayout.m_light_item = 0; showlayout.m_title = (u8*)"终端操作"; showlayout.m_item = (struct _strItemFun*) menuitem; showlayout.m_column_nums = 1; showlayout.m_show_first_item = 0; showlayout.m_item_nums = sizeof(menuitem) / sizeof(menuitem[0]); showlayout.m_attribute = DISP_LAYOUT_VER | DISP_LAYOUT_PAGEROLL; while (1) { err = show_layout(&showlayout); if (err == ESUCCESS) { re = 0; if(showlayout.m_item[showlayout.m_light_item].m_fun){ sharebuf_input_globalfun(showlayout.m_item[showlayout.m_light_item].m_fun); } break; } else if (err == EINPROGRESS) { } else if (err == ECANCEL) { re = -1; sharebuf_remove_globalfun(); break; } } g_task_step = 0; return re; }
/* Add the specified window to the layout in a logical way. This means setting up the most logical layout given the window to be added. */ void tui_add_win_to_layout (enum tui_win_type type) { enum tui_layout_type cur_layout = tui_current_layout (); switch (type) { case SRC_WIN: if (cur_layout != SRC_COMMAND && cur_layout != SRC_DISASSEM_COMMAND && cur_layout != SRC_DATA_COMMAND) { tui_clear_source_windows_detail (); if (cur_layout == DISASSEM_DATA_COMMAND) show_layout (SRC_DATA_COMMAND); else show_layout (SRC_COMMAND); } break; case DISASSEM_WIN: if (cur_layout != DISASSEM_COMMAND && cur_layout != SRC_DISASSEM_COMMAND && cur_layout != DISASSEM_DATA_COMMAND) { tui_clear_source_windows_detail (); if (cur_layout == SRC_DATA_COMMAND) show_layout (DISASSEM_DATA_COMMAND); else show_layout (DISASSEM_COMMAND); } break; case DATA_WIN: if (cur_layout != SRC_DATA_COMMAND && cur_layout != DISASSEM_DATA_COMMAND) { if (cur_layout == DISASSEM_COMMAND) show_layout (DISASSEM_DATA_COMMAND); else show_layout (SRC_DATA_COMMAND); } break; default: break; } }
int disp_com_config(u8* param) { int re = 0; u16 err; //u8 show[3]; const struct _strItemFun menuitem[] = { { (u8*)"1.通讯选择", disp_choose_com }, { (u8*)"2.参数配置", disp_set_comparam }}; struct _strShowLayout showlayout; showlayout.m_light_item = 0; showlayout.m_title = (u8*)"通讯参数"; showlayout.m_item = (struct _strItemFun*) menuitem; showlayout.m_column_nums = 2; showlayout.m_show_first_item = 0; showlayout.m_item_nums = sizeof(menuitem) / sizeof(menuitem[0]); showlayout.m_attribute = DISP_LAYOUT_VER | DISP_LAYOUT_PAGEROLL; while (1) { err = show_layout(&showlayout); if (err == ESUCCESS) { re = 0; if(showlayout.m_item[showlayout.m_light_item].m_fun){ sharebuf_input_globalfun(showlayout.m_item[showlayout.m_light_item].m_fun); break; } } else if (err == EINPROGRESS) { } else if (err == ECANCEL) { re = -1; sharebuf_remove_globalfun(); break; } } g_task_step = 0; return re; }
/* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND, SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND. If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or UNDEFINED_LAYOUT, then the data window is populated according to regs_display_type. */ enum tui_status tui_set_layout (enum tui_layout_type layout_type, enum tui_register_display_type regs_display_type) { enum tui_status status = TUI_SUCCESS; if (layout_type != UNDEFINED_LAYOUT || regs_display_type != TUI_UNDEFINED_REGS) { enum tui_layout_type cur_layout = tui_current_layout (), new_layout = UNDEFINED_LAYOUT; int regs_populate = FALSE; struct gdbarch *gdbarch; CORE_ADDR addr; struct tui_win_info *win_with_focus = tui_win_with_focus (); struct tui_layout_def *layout_def = tui_layout_def (); extract_display_start_addr (&gdbarch, &addr); if (layout_type == UNDEFINED_LAYOUT && regs_display_type != TUI_UNDEFINED_REGS) { if (cur_layout == SRC_DISASSEM_COMMAND) new_layout = DISASSEM_DATA_COMMAND; else if (cur_layout == SRC_COMMAND || cur_layout == SRC_DATA_COMMAND) new_layout = SRC_DATA_COMMAND; else if (cur_layout == DISASSEM_COMMAND || cur_layout == DISASSEM_DATA_COMMAND) new_layout = DISASSEM_DATA_COMMAND; } else new_layout = layout_type; regs_populate = (new_layout == SRC_DATA_COMMAND || new_layout == DISASSEM_DATA_COMMAND || regs_display_type != TUI_UNDEFINED_REGS); if (new_layout != cur_layout || regs_display_type != TUI_UNDEFINED_REGS) { if (new_layout != cur_layout) { show_layout (new_layout); /* Now determine where focus should be. */ if (win_with_focus != TUI_CMD_WIN) { switch (new_layout) { case SRC_COMMAND: tui_set_win_focus_to (TUI_SRC_WIN); layout_def->display_mode = SRC_WIN; layout_def->split = FALSE; break; case DISASSEM_COMMAND: /* The previous layout was not showing code. This can happen if there is no source available: 1. if the source file is in another dir OR 2. if target was compiled without -g We still want to show the assembly though! */ tui_get_begin_asm_address (&gdbarch, &addr); tui_set_win_focus_to (TUI_DISASM_WIN); layout_def->display_mode = DISASSEM_WIN; layout_def->split = FALSE; break; case SRC_DISASSEM_COMMAND: /* The previous layout was not showing code. This can happen if there is no source available: 1. if the source file is in another dir OR 2. if target was compiled without -g We still want to show the assembly though! */ tui_get_begin_asm_address (&gdbarch, &addr); if (win_with_focus == TUI_SRC_WIN) tui_set_win_focus_to (TUI_SRC_WIN); else tui_set_win_focus_to (TUI_DISASM_WIN); layout_def->split = TRUE; break; case SRC_DATA_COMMAND: if (win_with_focus != TUI_DATA_WIN) tui_set_win_focus_to (TUI_SRC_WIN); else tui_set_win_focus_to (TUI_DATA_WIN); layout_def->display_mode = SRC_WIN; layout_def->split = FALSE; break; case DISASSEM_DATA_COMMAND: /* The previous layout was not showing code. This can happen if there is no source available: 1. if the source file is in another dir OR 2. if target was compiled without -g We still want to show the assembly though! */ tui_get_begin_asm_address (&gdbarch, &addr); if (win_with_focus != TUI_DATA_WIN) tui_set_win_focus_to (TUI_DISASM_WIN); else tui_set_win_focus_to (TUI_DATA_WIN); layout_def->display_mode = DISASSEM_WIN; layout_def->split = FALSE; break; default: break; } } /* * Now update the window content. */ if (!regs_populate && (new_layout == SRC_DATA_COMMAND || new_layout == DISASSEM_DATA_COMMAND)) tui_display_all_data (); tui_update_source_windows_with_addr (gdbarch, addr); } if (regs_populate) { tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group); } } } else status = TUI_FAILURE; return status; }
void do_text (char * const text) { int hits, misses; int this_page_size; time_t timeStart, timeFinish, timeCurrent; float speed; char *p = text; char *i; char *this_page_start; curs_set (FALSE); show_layout(' ', PRESSED_NOT); mvaddstr (LINES - 1, 0, "[ ] Press a key to start"); i = (char*) index (text, 0x1); this_page_start = text; this_page_size = i ? i - this_page_start : strlen(this_page_start); move ((hideKeys ? 0 : 17), 0); myaddnstr (text, this_page_size); hits = 0; misses = 0; refresh(); noecho(); move (LINES - 1, 1); getch(); halfdelay (LATENCY); move (LINES - 1, 0); clrtoeol(); timeStart = 0; nextHelp = time(0) + (helpInterval / 1000); while (*p) { int ch = 0; if (*p == 0x2) { ++p; if (!timeStart) { timeStart = time(0); } } if (*p > 27) { show_layout(*p, PRESSED_REQUESTED); } do { ch = myGetch (*p); if (timeStart) { float ratio = hits - misses; ratio = (ratio < 0) ? 0 : (100.0 * ratio / hits); timeCurrent = time(0); speed = calcSpeed (timeStart, timeCurrent, hits); mvprintw (LINES - 1, 0, "CPS %.2f CPM %.2f Hits: %d Misses: %d Seconds: %d Ratio: %.2f%%", speed, speed * 60, hits, misses, time(0) - timeStart, ratio); clrtoeol(); } } while (ch == ERR); show_layout(ch, PRESSED_BY_USER); if (ch == *p || (*p == '\n' && ch == ' ')) { ++p; ++hits; } else { /* any other possibilities? */ if ( (ch == 8 || ch == KEY_BACKSPACE || ch == KEY_DC || ch == 127) && p > this_page_start) { --p; if (*p == '\x2') { --p; } } else if (ch == 27 || ch == KEY_END) { break; } else { if (beepsArentIrritating) { beep(); } if (flashesArentIrritating) { flash(); } ++misses; if (nastiness && p > this_page_start) { --hits; --p; if (*p == '\x2') { --p; } } } } move ((hideKeys ? 0 : 17), 0); i = this_page_start; attron (A_BOLD); while (i < p) { if (*i != 0x2) { addch(*i); } ++i; } if (*i == '\x2') { ++i; } attroff (A_BOLD); attron (A_REVERSE); if (*i != 0x2) { addch(*i); } ++i; attroff (A_REVERSE); while (*i && i < this_page_start + this_page_size) { if (*i != 0x2) { addch(*i); } ++i; } if (*p == 0x1) { char *next; ++p; next = (char*) index (p, 0x1); this_page_start = p; this_page_size = next ? next - this_page_start : strlen(this_page_start); move ((hideKeys ? 0 : 17), 0); clrtobot(); myaddnstr (this_page_start, this_page_size); } } timeFinish = time(0); speed = calcSpeed(timeStart, timeFinish, hits); clear(); cbreak(); if (!timeStart) { mvprintw (0, 0, "You haven't done enough to get a good benchmark."); } else { float ratio = hits - misses; ratio = (ratio < 0) ? 0 : (100.0 * ratio / hits); mvprintw (0, 0, "Elapsed time: %d seconds", timeFinish - timeStart); mvprintw (1, 0, "Total: %d Misses: %d Ratio: %.2f%%", hits, misses, ratio); mvprintw (2, 0, "CPS: %.2f CPM: %.2f", speed, speed * 60); } mvprintw (4, 0, "[ ] Press ESCAPE to continue."); move (4, 1); refresh(); while (getch() != 27); curs_set (TRUE); echo(); clear(); refresh(); }
/**************************************************************************** **函数名: int disp_choose_commode(u8* param) **描述: 选择通讯方式界面 **输入参数: param :传入参数 **输出参数: **返回值: >= 0:正常状态; < 0:不正常状态。 **备注: ** **版权:郑州友池电子技术有限公司深圳分公司 ** **作者 & 日期: 申伟宏(2015-01-28) **----------------------------------------------------------------------------- **修改记录: ****************************************************************************/ int disp_choose_commode(u8* param) { int re = 0; u16 err; u8 show[3]; const struct _strItemFun menuitem[] = { { (u8*)"1.蓝牙", NULL }, { (u8*)"2.USB", NULL }, { (u8*)"3.音频", NULL } }; struct _strShowLayout showlayout; showlayout.m_light_item = -1; showlayout.m_title = (u8*)"通讯方式"; showlayout.m_item = (struct _strItemFun*) menuitem; showlayout.m_column_nums = 3; showlayout.m_show_first_item = 0; showlayout.m_item_nums = sizeof(menuitem) / sizeof(menuitem[0]); showlayout.m_attribute = DISP_LAYOUT_LIGHT | DISP_LAYOUT_PAGEROLL | DISP_LAYOUT_SHOWCHOOSE; if (gSysParam.m_CommMode == DEVICE_BT) { showlayout.m_light_item = 0; } else if (gSysParam.m_CommMode == DEVICE_AUDIO) { showlayout.m_light_item = 2; } else if (gSysParam.m_CommMode == DEVICE_USB) { showlayout.m_light_item = 1; } while (1) { err = show_layout(&showlayout); if (err == ESUCCESS) { re = 0; sdk_close_device(DEVICE_BT); sdk_close_device(DEVICE_USB); sdk_close_device(DEVICE_AUDIO); printf("showlayout.m_light_item = %d\r\n",showlayout.m_light_item); switch (showlayout.m_light_item) { case 0: gSysParam.m_CommMode = DEVICE_BT; break; case 1: gSysParam.m_CommMode = DEVICE_USB; break; case 2: gSysParam.m_CommMode = DEVICE_AUDIO; break; default: break; } save_sysparam(); sdk_clear_lcd(); sdk_fill_lcd(DEV_LCD_FONT_ROW / 2, 0, (char*)"打开通信设备...", SHOW_MID); printf("gSysParam.m_CommMode = %d\r\n",gSysParam.m_CommMode); re = sdk_open_device(gSysParam.m_CommMode, 0); if(re < 0){ sdk_clear_lcd(); sdk_fill_lcd(DEV_LCD_FONT_ROW / 2, 0, (char*)"设备打开失败", SHOW_MID); waitkey_exit(KEY_MASK_ENTER | KEY_MASK_ESC, TIMEOUT_KEYWAIT); } break; } else if (err == EINPROGRESS) { sprintf((char*)show, "%d", showlayout.m_light_item + 1); sdk_fill_lcd(3, 0, (char*)show, SHOW_RIGHT); } else if (err == ECANCEL) { re = -1; break; } } sharebuf_remove_globalfun(); g_task_step = 0; return re; }