int lock_scr(void) /* Leeward 98.02.22 */ { char passbuf[STRLEN]; if (!strcmp(getCurrentUser()->userid, "guest")) return 1; modify_user_mode(LOCKSCREEN); clear(); /* * lock_monitor(); */ while (1) { move(19, 32); clrtobot(); prints("\033[1m\033[32m%s\033[m", BBS_FULL_NAME); move(21, 0); clrtobot(); getdata(21, 0, "屏幕现在已经锁定,要解除锁定,请输入密码:", passbuf, 39, NOECHO, NULL, true); move(22, 32); if (!checkpasswd2(passbuf, getCurrentUser())) { prints("\033[1m\033[31m密码输入错误...\033[m\n"); pressanykey(); } else { prints("\033[1m\033[31m屏幕现在已经解除锁定\033[m\n"); /* * pressanykey(); */ break; } } return 0; }
OnlineUsers() { struct enum_info info; info.count = 0; info.topline = info.currline = 4; info.bottomline = t_lines-2; move(3,0); clrtobot(); bbs_enum_users(t_lines-5, 0, NULL, OnlineUsersFunc, &info); clrtobot(); move(t_lines-1, 0); prints("%d %s displayed\n", info.count, info.count==1?"user":"******"); return PARTUPDATE; }
static int find_text(int index) { int i = 0, value = index, max_y = 0, max_x = 0, c = 0, y = 0, x = 0; unsigned long keymask = (F3_BIT|F10_BIT); char buf[256]; (void)memset(buf, '\0', 256); getmaxyx(stdscr, max_y, max_x); if ( (max_y < MIN_Y) || (max_x < MIN_X) ) { return (-1); } move(max_y-10, 0); clrtobot(); mvaddch(max_y-10, 0, '+'); mvaddch(max_y-10, max_x-1, '+'); mvaddch(max_y-1, 0, '+'); mvaddch(max_y-1, max_x-1, '+'); for ( x = 1; x < max_x-1; x++ ) { mvaddch(max_y-10, x, '-'); mvaddch(max_y-1, x, '-'); } for ( y = max_y-9; y < max_y-1; y++ ) { mvaddch(y, 0, '|'); mvaddch(y, max_x-1, '|'); } mvaddstr(max_y-9, (max_x/2)-2, "Find"); refresh(); c = io_text(max_y-7, 4, buf, 256, keymask); if ( KEY_F(3) == c ) { value = FIND_CANCEL; } else if ( KEY_F(10) == c ) { value = FIND_EXIT; } else if ( KEY_ENTER == c ) { if ( '\0' != buf[0] ) { if ( NULL != (srch_txt = strdup(buf)) ) { value = find_next(index); } else { value = FIND_CANCEL; } } else { value = FIND_CANCEL; } } else { value = FIND_CANCEL; } move(max_y-10, 0); clrtobot(); return (value); }
void help() { int option; char **ns = intro; while((option = pscreen(ns)) != 'q' && option != 'Q') { switch (option) { case 'a': case 'A': ns = intro; break; case 'b': case 'B': ns = toggleoptions; break; case 'c': case 'C': ns = setoptions; break; case 'd': case 'D': ns = cursor; break; case 'e': case 'E': ns = cell; break; case 'f': case 'F': ns = vi; break; case 'g': case 'G': ns = file; break; case 'h': case 'H': ns = row; break; case 'i': case 'I': ns = range; break; case 'j': case 'J': ns = misc; break; case 'k': case 'K': ns = var; break; case 'l': case 'L': ns = rangef; break; case 'm': case 'M': ns = numericf; break; case 'n': case 'N': ns = stringf; break; case 'o': case 'O': ns = finf; break; case 'p': case 'P': ns = timef; break; default: ns = intro; break; } } FullUpdate++; (void) move(1,0); (void) clrtobot(); }
void Util::moverHistorial(string * procesamiento, int * estado, int * columna) { int y, x; getyx(stdscr, y, x); move(y, 6); clrtobot(); if(procesamiento->compare(INICIO)==0) { *estado=0; *columna=0; *procesamiento=""; } else { printw(procesamiento->c_str()); refresh(); *columna=procesamiento->length(); if(comando.compare(procesamiento->substr(0, 1))==0) { *estado=2; } else if(sentencia.compare(procesamiento->substr(procesamiento->length()-1, 1))==0) { *estado=3; } } }
int namecomplete_board(BOARDHEADER *bhp, char *data, BOOL simple) { struct word *bwtop = NULL; int i; if (!num_brds) { CreateBoardList(&curuser); if (num_brds <= 0) return -1; } if (!simple) { move(1, 0); clrtobot(); move(2, 0); outs(_msg_board_5); move(1, 0); outs(_msg_board_6); } for (i = 0; i < num_brds; i++) add_wlist(&bwtop, (all_brds[i].bhr)->filename, NULL); namecomplete(bwtop, data, simple); free_wlist(&bwtop, NULL); if (data[0] == '\0') return -1; if (bhp) return get_board(bhp, data); return 0; }
static int choose_dict(void) { int c; FILE *fp; char buf[10][21], data[10][21], cho[130]; move(12, 0); clrtobot(); outs(" " "● \033[45;33m字典唷 ◇ 要查哪一本?\033[m ●"); if((fp = fopen(REFER, "r"))) { for(c = 0; fscanf(fp, "%s %s", buf[c], data[c]) != EOF; c++ ) { sprintf(cho,"\n " "(\033[36m%d\033[m) %-20s大字典",c+1,buf[c]); outs(cho); } getdata(22, 14, " ★ 請選擇,[Enter]離開:", cho, 3, LCECHO); cho[0] -= '1'; if(cho[1]) cho[0] = (cho[0] + 1) * 10 + (cho[1] - '1'); if(cho[0] >= 0 && cho[0] < c) { strcpy(dict, buf[(int)cho[0]]); strcpy(database, data[(int)cho[0]]); return 1; } else return 0; } return 0; }
/* 進站水球宣傳 */ int m_loginmsg(void) { char msg[100]; move(21,0); clrtobot(); if(SHM->loginmsg.pid && SHM->loginmsg.pid != currutmp->pid) { outs("目前已經有以下的 進站水球設定請先協調好再設定.."); getmessage(SHM->loginmsg); } getdata(22, 0, "進站水球:本站活動,不干擾使用者為限,設定者離站自動取消,確定要設?(y/N)", msg, 3, LCECHO); if(msg[0]=='y' && getdata_str(23, 0, "設定進站水球:", msg, 56, DOECHO, SHM->loginmsg.last_call_in)) { SHM->loginmsg.pid=currutmp->pid; /*站長不多 就不管race condition */ strlcpy(SHM->loginmsg.last_call_in, msg, sizeof(SHM->loginmsg.last_call_in)); strlcpy(SHM->loginmsg.userid, cuser.userid, sizeof(SHM->loginmsg.userid)); } return 0; }
void help (void) { int option; const char* ns = intro; while ((option = tolower(pscreen(ns))) != 'q') { switch (option) { default: case 'a': ns = intro; break; case 'b': ns = toggleoptions; break; case 'c': ns = setoptions; break; case 'd': ns = cursor; break; case 'e': ns = cell; break; case 'f': ns = vi; break; case 'g': ns = file; break; case 'h': ns = row; break; case 'i': ns = range; break; case 'j': ns = misc; break; case 'k': ns = var; break; case 'l': ns = rangef; break; case 'm': ns = numericf; break; case 'n': ns = stringf; break; case 'o': ns = finf; break; case 'p': ns = timef; break; } } FullUpdate++; move(1,0); clrtobot(); }
static void draw_editarea() { move(window_y - INPUT_MAXLINE - 1, 0); hline('-', window_x); mvprintw(window_y - INPUT_MAXLINE, 0, "> "); clrtobot(); refresh(); }
SetTermtype() { TERM terminal; int rc; move(3,0); clrtobot(); if (getdata(3,0, "Enter new terminal type: ", terminal, sizeof terminal, DOECHO, 1) == -1) return FULLUPDATE; if(terminal[0] == '\0') return PARTUPDATE; if(term_init(terminal) == -1) { prints("Invalid terminal type.\n"); #ifndef REMOTE_CLIENT return PARTUPDATE; #endif } else { initscr(); clear(); } rc = bbs_set_terminal(terminal); if (rc == S_OK) prints("New terminal type was saved.\n"); else bbperror(rc, "New terminal type not saved."); pressreturn(); return FULLUPDATE; }
SetCharset() { CSET charset; int rc; move(3,0); clrtobot(); if (getdata(3,0, "Enter new charset: ", charset, sizeof charset, DOECHO, 1) == -1) return FULLUPDATE; if(charset[0] == '\0') return PARTUPDATE; if(conv_init(charset) == -1) { prints("Invalid character set.\n"); #ifndef REMOTE_CLIENT return PARTUPDATE; #endif } else { initscr(); clear(); } rc = bbs_set_charset(charset); if (rc == S_OK) prints("New character set was saved.\n"); else prints("New character set NOT saved.\n"); pressreturn(); return FULLUPDATE; }
DeleteAccount() { NAME namebuf; int rc; char ans[4]; move(2,0); clrtobot(); bbs_acctnames(&acctlist, NULL); namecomplete(NULL, acctlist, "Userid to delete: ", namebuf, sizeof(NAME)); if (namebuf[0] == '\0' || !is_in_namelist(acctlist, namebuf)) { bbperror(S_NOSUCHUSER, NULL); pressreturn(); return FULLUPDATE; } prints("Deleting user '%s'.\n", namebuf); getdata(5,0,"Are you sure (Y/N)? [N]: ",ans,sizeof(ans),DOECHO,0); if (ans[0] != 'Y' && ans[0] != 'y') { prints("Account not deleted.\n"); pressreturn(); return FULLUPDATE; } rc = bbs_delete_account(namebuf); if (rc == S_OK) prints("Account deleted.\n"); else bbperror(rc, "Account deletion failed"); pressreturn(); return FULLUPDATE; }
void menu_redraw_full (MUTTMENU * menu) { SETCOLOR (MT_COLOR_NORMAL); /* clear() doesn't optimize screen redraws */ move (0, 0); clrtobot (); if (option (OPTHELP)) { SETCOLOR (MT_COLOR_STATUS); move (option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW); mutt_paddstr (COLS-SW, menu->help); SETCOLOR (MT_COLOR_NORMAL); menu->offset = 1; menu->pagelen = LINES - 3; } else { menu->offset = option (OPTSTATUSONTOP) ? 1 : 0; menu->pagelen = LINES - 2; } sidebar_draw_frames(); mutt_show_error (); menu->redraw = REDRAW_INDEX | REDRAW_STATUS; }
void MenuEscape::update() { move(0, 0); clrtobot(); setColor(C_WHITE); int a = ( terminalSize.y / 2 ) - 4; printCenter(a++, "%sResume%s", selection == 0 ? "- " : " ", selection == 0 ? " -" : " "); printCenter(a++, "%sControls%s", selection == 1 ? "- " : " ", selection == 1 ? " -" : " "); printCenter(a++, "%sSettings%s", selection == 2 ? "- " : " ", selection == 2 ? " -" : " "); printCenter(a++, " %sMain Menu%s", selection == 3 ? "- " : " ", selection == 3 ? " -" : " "); a = terminalSize.y - 2; if(Settings::autoSave && menuGame->currentWorld && menuTime == Settings::autoSaveDelay){ printCenter(a++, " Auto Saving..."); WorldLoader::save(menuGame->currentWorld); } if(menuTime > Settings::autoSaveDelay){ printCenter(a++, " Auto Saved "); } menuTime++; }
static int select_by_aid(const keeploc_t * locmem, int *pnew_ln, int *pnewdirect_new_ln, char *pdefault_ch) { char aidc[100]; aidu_t aidu = 0; char dirfile[PATHLEN]; char *sp; int n = -1; if(!getdata(b_lines, 0, "搜尋" AID_DISPLAYNAME ": #", aidc, 20, DOECHO)) { move(b_lines, 0); clrtoeol(); return FULLUPDATE; } if((currmode & MODE_SELECT) || (currstat == RMAIL)) { move(21, 0); clrtobot(); move(22, 0); prints("此狀態下無法使用搜尋" AID_DISPLAYNAME "功\能"); pressanykey(); return FULLUPDATE; }
void Clrtobot(void) { if (ScreenMode) { (void) clrtobot(); } }
BLAPI_PROTO bl_clrtobot(lua_State* L) { (void)L; /* to avoid warnings */ clrtobot(); return 0; }
// Display the player's word list, the list of words not found, and the running stats void results(void) { int col, row; int denom1, denom2; move(LIST_LINE, LIST_COL); clrtobot(); printw("Words you found (%d):", npwords); refresh(); move(LIST_LINE + 1, LIST_COL); prtable(pword, npwords, 0, ncols, prword, prwidth); getyx(stdscr, row, col); move(row + 1, col); printw("Words you missed (%d):", nmwords); refresh(); move(row + 2, col); prtable(mword, nmwords, 0, ncols, prword, prwidth); denom1 = npwords + nmwords; denom2 = tnpwords + tnmwords; move(SCORE_LINE, SCORE_COL); printw("Percentage: %0.2f%% (%0.2f%% over %d game%s)\n", denom1 ? (100.0 * npwords) / (double) (npwords + nmwords) : 0.0, denom2 ? (100.0 * tnpwords) / (double) (tnpwords + tnmwords) : 0.0, ngames, ngames > 1 ? "s" : ""); }
AddAccount() { int rc; ACCOUNT acct; char ans[4]; move(3,0); clrtobot(); if (PromptForAccountInfo(&acct, 0) == -1) { return PARTUPDATE; } getdata(12, 0, "Are you sure (Y/N)? [N]: ", ans, sizeof ans, DOECHO, 0); move(13,0); if (ans[0] != 'Y' && ans[0] != 'y') { prints("Account not added.\n"); return PARTUPDATE; } rc = bbs_add_account(&acct, 0); switch (rc) { case S_OK: prints("New account added.\n"); break; default: bbperror(rc, "Account add failed"); } return PARTUPDATE; }
void sigwinch(int sig) { scrollup(cursor_y); cursor_y = 0; fprintf(stdout, "%c[2K\r", 0x1b); clrtobot(); termio_update(); /* XXX: this is probably a bad idea */ }
/* * Clear the work-area, and move the cursor there. */ void clear_work(void) { if (!in_dedtype) { move(mark_W + 1, 0); clrtobot(); } move(mark_W + 1, 0); }
void showprocs(struct myproc **procs, struct procstat *pst) { int y = -pos_top + TOP_OFFSET - 1; struct myproc *topproc; // this f***s up everything. why? /* for(topproc = gui_proc_first(procs)->child_first; topproc; topproc = topproc->child_next) */ topproc = gui_proc_first(procs); showproc(topproc, &y, 0); if(++y < LINES){ move(y, 0); clrtobot(); } if(search){ const int red = !search_proc && *search_str;; if(red) attron(COLOR_PAIR(1 + COLOR_RED)); mvprintw(0, 0, "%d %c%s", search_offset, "/?"[search_pid], search_str); if(red) attroff(COLOR_PAIR(1 + COLOR_RED)); clrtoeol(); if(search_proc){ int ty; if(search_proc_to_idx(&ty, procs)){ pos_top = ty - LINES / 2; if(pos_top < 0) pos_top = 0; } } }else{ int y; time_t now; time(&now); STATUS(0, 0, "%d processes, %d running, %d owned, %d zombies, load averages: %.2f, %.2f, %.2f, uptime: %s", pst->count, pst->running, pst->owned, pst->zombies, pst->loadavg[0], pst->loadavg[1], pst->loadavg[2], uptime_from_boottime(pst->boottime.tv_sec)); // Mem stuf STATUS(1, 0, "Mem: %s", format_memory(pst->memory)); // CPU % STATUS(2,0, "CPU: %s", format_cpu_pct(pst->cpu_pct)); clrtoeol(); y = 3 + pos_y - pos_top; mvchgat(y, 0, 47, A_UNDERLINE, 0, NULL); move(y, 47); } }
int main() { int ch; initscr(); raw(); noecho(); keypad(stdscr, TRUE); /* * erase() and werase(win): werase(...) and erase() will * copy blanks to every position on the window */ printw("Hello World! Press F1 to erase the window [ erase() ]"); refresh(); while((ch = getch()) != KEY_F(1)) {} erase(); /* * clear() and wclear(win): the same as erase(); * when we set clearok() the screen will be cleared with * the next refresh */ printw("Hello World! Press F1 to erase the window [ clear() ]"); refresh(); while((ch = getch()) != KEY_F(1)) {} clear(); //refresh(); /* * clrtobot() and wclrtobot(win): clearing the current cursor line * (start is one character right from the cursor) * and the line below the cursor */ mvprintw(20, 20, "Hello!!"); //-- this line gets cleared mvprintw(10, 10, "Press F1 to erase the line bellow [ clrtobot() ]"); refresh(); while((ch = getch()) != KEY_F(1)) {} clrtobot(); /* * clrtoeol() and wclrtoeol(win): clear the current line right * from the cursor up to its end */ mvprintw(0, 40, "Hello!! Hello!! Hello!! Hello!! Hello!!"); mvprintw(0, 0, "Press F1 to erase to eol[ clrtoeol() ]"); refresh(); while((ch = getch()) != KEY_F(1)) {} clrtoeol(); printw("Press any key to exit.."); refresh(); getch(); endwin(); return 0; }
void menuInteractive() { int i, num; char buf[255]; while (1) { mvprintw (2, 0, "Dvorak7Min, Ragnar Hojland Espinosa, 1998-2003" ); mvprintw (3, 0, "enhanced by Smoke of CRAP, 1999 and Nopik, 2003"); for (i = 0; lessons[i*2]; ++i) { mvprintw (i/2 + 5, (i%2) * 40, "%2d. %s", i+1, lessons[i*2]); } move (21, 0); clrtobot(); mvprintw (21, 0, "Type a lesson number ([N]astiness [H]ide keyboard [Q]uit)? "); refresh(); echo(); getnstr (buf, sizeof(buf)); buf[0] = toupper(buf[0]); if (buf[0] == 'N') { nastiness = !nastiness; if (nastiness) mvprintw (23, 0, "Nastiness is now turned ON. Press any key."); else mvprintw (23, 0, "Nastiness is now turned OFF. Press any key."); getch(); continue; } if (buf[0] == 'H') { hideKeys = !hideKeys; if (hideKeys) mvprintw (23, 0, "Keyboard layout is now OFF. Press any key."); else mvprintw (23, 0, "Keyboard layout is now ON. Press any key."); getch(); continue; } if (buf[0] == 'Q' || buf[0] == 27) { clear(); move (0,0); refresh(); return; } num = atoi (buf); if (!buf[0] || num < 1 || num > i) { mvprintw (23, 0, "Invalid lesson number. Press any key."); getch(); continue; } clear(); refresh(); do_text(lessons[(num-1)*2+1]); } }
void sigwinch(int sig) { if (cursor_y > 0) fprintf(stdout, "%c[%dA\r", 0x1b, cursor_y); fprintf(stdout, "\r%c[s", 0x1b); cursor_y = 0; fprintf(stdout, "%c[2K\r", 0x1b); clrtobot(); termio_update(NULL); /* XXX: this is probably a bad idea */ }
void ipt_vis::render_samples(void) { int i; int linenum = 0; FILE *outf = (outfile ? outfile : stdout); //std::cout << *this << std::endl; if(output_method == "curses") { if(do_resize) { endwin(); start_curses(); refresh(); do_resize = 0; getmaxyx(stdscr,screen_max_rows,screen_max_cols); } move(0,0); // get ready to draw if(title != "") { const char *c = title.c_str(); mvprintw(0, (screen_max_cols-strlen(c))/2,c); move(1,0); } } // position back at start if(outfile) { rewind(outf); // and lock lockf(fileno(outf), F_LOCK, 0); } // now render each line for(i = 0; i < lines.size(); i++) { if(output_method == "curses") { linenum = lines[i]->curses_render(); } else { linenum = lines[i]->plain_render((outfile ? outfile : stdout)); } } if(output_method == "curses") { max_rows = linenum; move(max_rows,0); clrtobot(); // rest of the screen refresh(); } else { fprintf(outf,"\n"); fflush(outf); if(outfile) { // and unlock rewind(outf); lockf(fileno(outf), F_ULOCK, 0); } } }
static int backnumbertitle() { showtitle("ÔĶÁ¹ý¿¯", MY_BBS_NAME); prints ("À뿪[[1;32m¡û[m,[1;32me[m] Ñ¡Ôñ[[1;32m¡ü[m,[1;32m¡ý[m] ÔĶÁ" "[[1;32m¡ú[m,[1;32mRtn[m] ÇóÖú[[1;32mh[m][m\n"); prints("[1;44m±àºÅ %-12s %6s %-50s[m\n", "¿¯µÇÕß", "ÈÕÆÚ", "±êÌâ"); clrtobot(); return 0; }
static int do1984title() { showtitle("审查文章", MY_BBS_NAME); prints ("离开[\033[1;32m←\033[m,\033[1;32me\033[m] 选择[\033[1;32m↑\033[m,\033[1;32m↓\033[m] 阅读" "[\033[1;32m→\033[m,\033[1;32mRtn\033[m] 求助[\033[1;32mh\033[m]\033[m\n"); prints("\033[1;44m编号 %-12s %6s %-50s\033[m\n", "刊登者", "日期", "标题"); clrtobot(); return 0; }
ShowOwnInfo() { ACCOUNT acct; int rc; move(3,0); clrtobot(); rc = bbs_owninfo(&acct); if (rc != S_OK) { bbperror(rc, "Can't get user info:\n"); } else UserDisplay(&acct); return PARTUPDATE; }