int work_thread_start() { Win *L1 = get_win("L1"); Win *R1 = get_win("R1"); start_work_thread(L1, R1); return 0; }
void play_game() { Win *disp= get_win("R2"); if (NULL == disp) { return; } Win *input = get_win("RCMD"); if (NULL == input) { return; } game_main_loop(disp, input); }
// return value: 0:running; not 0:quit; static int on_keypress() { int ch = 0; static char keybuf[32] = {0}; static int cursor = 0; Win *win = get_win("RCMD"); if (NULL == win) { return 0; } ch = readch(); keybuf[cursor++] = ch; if (ch == '\n' || cursor >= (int)sizeof(keybuf) - 1) { cursor = 0; process_command(keybuf); memset(keybuf, 0, sizeof(keybuf)); werase(win->win); wclear(win->win); mvwaddch(win->win, 1, 1, '>'); wrefresh(win->win); } else { waddch(win->win, ch); wrefresh(win->win); } return ch != 'q'; }
void *query_menu(int x, int format_x, char *sql, FUNCP callback, void *cb_arg, int col, ...) { va_list field; va_start(field, col); int col_type[col]; for (int i = 0; i < col; ++i) { col_type[i] = va_arg(field, int); } char **res = db_select(get_db_main(), sql, col, col_type); if (callback) { struct daily_total *total = (struct daily_total *)callback(res, cb_arg); print_notice("今日截止目前共%d笔生意 总收入%.1f 总成本%.1f 总盈利%.1f\n" "平均每桌盈利%.1f", total->cnt, total->sales, total->cost, total->profil, total->profil / total->cnt); } mt.x = x; mt.format_x = format_x; mt.choice = res; mt.choice_n = get_sql_item_cnt(); mt.win = get_win(W_MID); mt.format_y = LINES - 3; menu_interact(&mt); free(res); return NULL; }
void clear_R2() { Win *win = get_win("R2"); if (NULL == win) { return; } wclear(win->win); wrefresh(win->win); }
void bar_upd(int sig) { static char barstr[750]; snprintf(barstr, 750, "%%{l}%s %s %s%%{c}%s%%{r}%s %s %s %s\n", get_win((sig == -2 ? false : true)), get_hname(), get_xtitle((sig == -1 ? false : true)), get_mpd(), get_vol(), get_load(), get_uname(), get_time()); fputs(barstr, barfp); fflush(barfp); }
void update_allwin() { time_t t; Win *win = get_win("L1"); if (NULL == win) { return; } time(&t); lock_L1(); wprintw(win->win, "%d\n", t); wrefresh(win->win); unlock_L1(); }
void show_weibo() { FILE *fp = NULL; char buf[1024] = {0};\ char *ret = NULL; fp = fopen("./weibo", "r"); Win *win = get_win("R2"); if (NULL == win) { return; } do { ret = fgets(buf, sizeof(buf), fp); wprintw(win->win, "%s\n", buf); } while (ret != NULL); wrefresh(win->win); fclose(fp); fp = NULL; }
struct fvec* fill_frame(struct fvec* sptr, struct fhistory* hptr, struct param* pptr, int nframe) { static struct fvec *outbufptr = NULL; static struct fvec *inbufptr; static struct fvec *window; int i, start, end; char *funcname; funcname = "fill_frame"; if (outbufptr == (struct fvec*) NULL) /* first frame in analysis */ { outbufptr = alloc_fvec(pptr->winpts); inbufptr = alloc_fvec(pptr->winpts); window = get_win(pptr, outbufptr->length); if (pptr->padInput == TRUE) { const int npad = (pptr->winpts - pptr->steppts) >> 1; for (i = 0; i < npad; i++) { inbufptr->values[i] = sptr->values[npad - i]; } for (i = npad; i < inbufptr->length; i++) { inbufptr->values[i] = sptr->values[i - npad]; } } else { for (i = 0; i < pptr->winpts; i++)