static int letter5() { /* Prepare path */ sprintf(mail600, "/tmp/#%dmaill600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 604 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" St. Mary's Children's Home\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" These Poor Children\n"); lprcat("\n News of your great conquests has spread to all of Larndom."); lprcat("\nMight I have a moment of a great man's time. We here at St."); lprcat("\nMary's Children's Home are very poor, and many children are"); lprcat("\nstarving. Disease is widespread and very often fatal without"); lprcat("\ngood food. Could you possibly find it in your heart to help us"); lprcat("\nin out plight? Whatever you could give will help much."); lprcat("\n(your gift is tax deductible)\n"); lwclose(); return 1; }
static int letter6() { /* Prepare path */ sprintf(mail600, "/tmp#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 605 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" The National Cancer Society of Larn\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" Hope\n"); lprcat("\n Congratulations on your successful expedition. We are sure much"); lprcat("\ncourage and dtermination were needed on your quest. There are"); lprcat("\nmany though, that could never hope to undertake such a journey"); lprcat("\ndue to an enfeebling disease -- cancer. We at the National"); lprcat("\nCancer Soceity of Larn wish to appeal to your philanthropy in"); lprcat("\norder to save many good people -- possibly even yourself in a few"); lprcat("\nyears from now. Much work needs to be done in researching this"); lprcat("\ndreaded disease, and you can help today. Could you please see it"); lprcat("\nin your heart to give generously? Your continued good health"); lprcat("\ncan be in your everlasting reward.\n"); lwclose(); return 1; }
static int letter4() { /* Prepare path */ sprintf(mail600, "/tmp/$%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 603 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" Mainair, Duke of Larnty\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" High Praise\n"); lprcat("\n With a certainty a hero I declare to be amongst us! A nod of"); lprcat("\nfavour I send to thee. Me thinks Count Endelford this day of"); lprcat("\nright breath'eth fire as a dragon of whom ye are slayer. I"); lprcat("\nyearn to behold his anger and jealously. Should ye choose to"); lprcat("\nunleash some of they wealth upon those whoe be unfortunate, I,"); lprcat("\nDuke Mainair, Shall equal thy gift also.\n"); lwclose(); return 1; }
static int letter3() { /* Prepare path */ sprintf(mail600, "/tmp#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 602 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" Count Endelford\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" You Bastard!\n"); lprcat("\n I heard (from sources) of your journey. Congratulations!"); lprcat("\nYou bastard! With several attempts I have yet to endure the"); lprcat(" caves,\nand you, a nobody, makes the journey! From this time"); lprcat(" onward, be warned\nupon our meeting you shall pay the price!\n"); lwclose(); return 1; }
static int letter2() { /* Prepare path */ sprintf(mail600, "/tmp/#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 601 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" His Majesty King Wilfred of Larndom\n"); standout(); lprcat("\nSubject:"); standend(); lprcat(" A Noble Deed\n"); lprcat("\n I have heard of your magnificent feat, and I, King Wilfred,"); lprcat("\nforthwith declare today to be a national holiday. Furthermore,"); lprcat("\nhence three days, Ye be invited to the castle to receive the"); lprcat("\nhonour of Kinght of the Realm. Upon thy name shall it be written..."); lprcat("\nBravery and courage be yours."); lprcat("\nMay you live in happiness forever...\n"); lwclose(); return 1; }
static int dialog_switch_pos (dialog_t diag, dialog_pos_t new_pos) { if (new_pos != diag->pos) { switch (diag->pos) { case DIALOG_POS_OK: move (diag->ok_y, diag->ok_x); addstr (diag->ok); break; case DIALOG_POS_CANCEL: if (diag->cancel) { move (diag->cancel_y, diag->cancel_x); addstr (diag->cancel); } break; default: break; } diag->pos = new_pos; switch (diag->pos) { case DIALOG_POS_PIN: move (diag->pin_y, diag->pin_x + diag->pin_loc); set_cursor_state (1); break; case DIALOG_POS_OK: set_cursor_state (0); move (diag->ok_y, diag->ok_x); standout (); addstr (diag->ok); standend (); move (diag->ok_y, diag->ok_x); break; case DIALOG_POS_CANCEL: if (diag->cancel) { set_cursor_state (0); move (diag->cancel_y, diag->cancel_x); standout (); addstr (diag->cancel); standend (); move (diag->cancel_y, diag->cancel_x); } break; case DIALOG_POS_NONE: set_cursor_state (0); break; } refresh (); } return 0; }
/* * Update the number-of-files-tagged display in the given viewport header */ static void show_what(VIEW * vp) { RING *gbl = vp->gbl; char buffer[80]; static char datechr[] = "acm"; int y, x; move((int) vp->base_row, 0); if (gbl->tag_count) (void) standout(); buffer[0] = EOS; if (gbl->tag_opt) { sprintf(buffer, "(%d files, %ld %s) ", gbl->tag_count, (long) ((gbl->tag_opt > 1) ? gbl->tag_bytes : gbl->tag_blocks), (gbl->tag_opt > 1) ? "bytes" : "blocks"); } sprintf(buffer + strlen(buffer), "%u of %u [%ctime]", gbl->curfile + 1, gbl->numfiles, datechr[gbl->dateopt]); showpath(gbl->new_wd, 999, -1, (int) strlen(buffer) + 3); getyx(stdscr, y, x); (void) y; x = COLS - (int) strlen(buffer) - x; while (x-- > 0) addch(' '); addstr(buffer); if (gbl->tag_count) (void) standend(); }
/*ARGSUSED*/ AllUsersFunc( int indx, ACCOUNT *acct, struct enum_info *info ) { if (info->topline == info->currline) { move(info->topline-1, 0); prints("%-14s %-30s %s\n","User Id", "User Name", "Last Login"); } prints("%-14s %-30s %c %s", acct->userid, acct->username, BITISSET(acct->flags, FLG_EXEMPT) ? 'X': ' ', (acct->lastlogin == 0) ? "\n":ctime((time_t *)&acct->lastlogin)); info->currline++; info->count++; if (info->currline > info->bottomline) { int ch; standout(); prints("--MORE--"); standend(); clrtoeol(); while((ch = igetch()) != EOF) { if(ch == '\n' || ch == '\r' || ch == ' ') break; if(toupper(ch) == 'Q') { move(info->currline, 0); clrtoeol(); return ENUM_QUIT; } else bell(); } info->currline = info->topline; } return S_OK; }
printchatline(char *str) { int linelen = t_columns-1, len = strlen(str); #if COLOR int color = 0; #endif if (!g_you_have_mail && bbs_check_mail()) { int i; move(g_echatwin, 0); prints("---(You have mail.)"); for (i=19; i<t_columns; i++) prints("-"); g_you_have_mail++; } #if COLOR if (*str == '*') color = (strncmp(str, "***", 3) ? COLOR_GREEN : COLOR_LIGHTBLUE); #endif while (len) { move(g_currline, 0); clrtoeol(); if (linelen < t_columns-1) move(g_currline, CHATID_MAX+2); if (len >= linelen) { int eoln; char c; for (eoln = linelen-1; eoln >= t_columns/4; eoln--) if (isspace(str[eoln])) break; if (!isspace(str[eoln])) eoln = linelen-1; c = str[eoln]; str[eoln] = '\0'; #if COLOR if (color) colorstart(color); #endif prints("%s", str); #if COLOR if (color) colorend(); #endif str[eoln] = c; if (isspace(c)) eoln++; len -= eoln; str += eoln; if (linelen == t_columns-1) linelen -= (CHATID_MAX+2); } else { #if COLOR if (color) colorstart(color); #endif prints("%s", str); #if COLOR if (color) colorend(); #endif len = 0; } if (++g_currline == g_echatwin) g_currline = 0; move(g_currline, 0); standout(); prints(CHAT_PROMPT); standend(); clrtoeol(); } }
void display_menu(MENU *menu) { int i; cls(); title(menu->title); mvcur(0, 0, STARTROW, STARTCOL); refresh(); for (i = 0; i <= menu->num_items - 1; i++) { move(STARTROW + i, STARTCOL); standend(); addstr(menu->items[i]); refresh(); } center_text(STARTROW + menu->num_items + 2, "Enter a number, <up arrow>, or <down arrow>."); if (!level) { center_text(STARTROW + menu->num_items + 3, "Press 'q' to exit, <return> to confirm choice."); } else { center_text(STARTROW + menu->num_items + 3, "Press 'q' to exit, 'r' for main menu, " "<return> to confirm choice."); } if (!level) highlight(main_menu); }
int curs_hilite(int mode) { if(mode) standout(); else standend(); }
int select_menu( Menu *menu, int mselect ) { int eax; if ( mselect < 0 || menu->nitem <= mselect ) { return menu->select; } else { if ( mselect < menu->offset ) up_menu( menu, menu->offset - mselect ); else if ( menu->offset + menu->height <= mselect ) down_menu( menu, ( mselect - menu->offset - menu->height ) + 1 ); if ( menu->offset <= menu->select && menu->select < menu->offset + menu->height ) draw_menu_item( menu, menu->select ); menu->select = mselect; standout( ); draw_menu_item( menu, menu->select ); standend( ); move( ( menu->y + mselect ) - menu->offset, menu->x ); toggle_stand( ); refresh( ); menu->select/*error:'i'*/ = menu->select; return menu->select; } }
void stand_title(char* title) { clear(); standout(); prints("%s",title); standend(); }
void drawmenu(int highlight) { clear(); int numitems = 4; int mLines = (LINES - (numitems * 2)) / 2; // Center height int mCols; int i, largest = 0; char *menuitems[] = { "X Send -- Send chat requests to new users", "R Requests -- View outstanding / unresolved requests", "C Conversations -- View all conversations", "Q Quit -- Exit the program. Bye!" }; for(i = 0; i < numitems; i++) { // Find length of longest menu item if(strlen(menuitems[i]) > largest) largest = strlen(menuitems[i]); } mCols = (COLS - largest) / 2; // Center the items based on longest item for(i = 0; i < numitems; i++) { //if(highlight == i) attron(COLOR_PAIR(1)); if(highlight == i) standout(); move(mLines + (i * 2), mCols); addstr(menuitems[i]); //if(highlight == i) attroff(COLOR_PAIR(1)); if(highlight == i) standend(); } move(LINES - 1, COLS - 1); refresh(); }
void highlight(MENU *menu) { if (oldpos[level] != position[level]) { move(STARTROW + oldpos[level] - 1, STARTCOL); standend(); addstr(menu->items[oldpos[level] - 1]); refresh(); } move(STARTROW + position[level] - 1, STARTCOL); standout(); addstr(menu->items[position[level] - 1]); refresh(); standend(); refresh(); }
void onsig(int sig) { standend(); refresh(); endwin(); exit(sig); }
void clr_scr (void) { standend (); dlg_erase (midnight_dlg); mc_refresh (); doupdate (); }
static WINDOW * show_cmd(const char *scmd, struct winsize *win) { int n, m; WINDOW *actionwin; int nrow; wclear(stdscr); clearok(stdscr, 1); touchwin(stdscr); refresh(); mvaddstr(0, 4, msg_string(MSG_Status)); standout(); addstr(msg_string(MSG_Running)); standend(); mvaddstr(1, 4, msg_string(MSG_Command)); standout(); printw("%s", scmd); standend(); addstr("\n\n"); for (n = win->ws_col; (m = min(n, 30)) > 0; n -= m) addstr( "------------------------------" + 30 - m); refresh(); nrow = getcury(stdscr) + 1; actionwin = subwin(stdscr, win->ws_row - nrow, win->ws_col, nrow, 0); if (actionwin == NULL) { fprintf(stderr, "sysinst: failed to allocate output window.\n"); exit(1); } scrollok(actionwin, TRUE); if (has_colors()) { wbkgd(actionwin, getbkgd(stdscr)); wattrset(actionwin, getattrs(stdscr)); } wmove(actionwin, 0, 0); wrefresh(actionwin); return actionwin; }
static int typeline(int y, int skip) { int found; if ((found = (UsePattern && GOT_REGEX(ToFind, Text))) != 0) HadPattern = TRUE; if (!skip) { move(y, 0); Tlen -= Shift; if (Tlen > COLS) Tlen = COLS; if (found) { (void) standout(); if (Tlen > 0) PRINTW("%.*s", Tlen, Text + Shift); else addstr(" "); (void) standend(); } else if (Tlen > 0) { int now = Shift, j; while (Tlen > 0) { for (j = now; j < now + Tlen; j++) { if (Over[j] != Over[now]) break; } if (Over[now]) (void) standout(); PRINTW("%.*s", (j - now), Text + now); if (Over[now]) (void) standend(); Tlen -= (j - now); now = j; } } clrtoeol(); } typeinit(); return (++y); }
/* * Display the given line. If it is tagged, highlight the name. */ static void show_line(VIEW * vp, unsigned j) { RING *gbl = vp->gbl; char bfr[BUFSIZ]; if (FILE_VISIBLE(vp, j)) { int line = (int) FILE2ROW(vp, j); int trimmed = FALSE; move(line, 0); ded2s(gbl, (int) j, bfr, sizeof(bfr)); if (gbl->Xbase < (int) strlen(bfr)) { int adj = gbl->cmdcol[CCOL_NAME]; int col = adj - gbl->Xbase; int len = COLS - col; #if defined(HAVE_HAS_COLORS) int end = gbl->cmdcol[CCOL_NAME] + gENTRY(j).z_namlen; #endif if (col < 0) { adj -= col; col = 0; len = COLS; } #if defined(HAVE_HAS_COLORS) if (end > COLS + gbl->Xbase) end = COLS + gbl->Xbase; #endif PRINTW("%.*s", COLS, &bfr[gbl->Xbase]); if (len > 0) { /* filename is visible */ if (gFLAG(j)) { trimmed = trim_at(line); move(line, col); (void) standout(); PRINTW("%.*s", len, &bfr[adj]); (void) standend(); } #if defined(HAVE_HAS_COLORS) else if (has_colors() && end > adj) { trimmed = trim_at(line); move(line, col); dedcolor(&(gENTRY(j))); PRINTW("%.*s", end - adj, &bfr[adj]); dedcolor((FLIST *) 0); } #endif /* HAVE_HAS_COLORS */ } } if (!trimmed) (void) trim_at(line); } }
static int FinishPage(RING * gbl, int inlist, int infile, int y) { int shown = FALSE; int foo; off_t length = 0; while (y < LINES - 1) y = typeline(y, FALSE); move(LINES - 1, 0); (void) standout(); PRINTW("---lines %d to %d", TopOfPage(infile, &foo) + 1, infile); if (inlist >= 0) { int oldy, oldx; int save = gbl->AT_opt; getyx(stdscr, oldy, oldx); (void) standend(); gbl->AT_opt = TRUE; shown = reshow(gbl, (unsigned) inlist); gbl->AT_opt = save; gbl->mrkfile = -1; markC(gbl, TRUE); (void) standout(); move(oldy, oldx); } if ((length = MaxP()) != 0) { off_t num = ftell(InFile); PRINTW(": %.1f%%", ((double) num * 100.) / (double) length); } PRINTW("---"); (void) standend(); PRINTW(" "); clrtoeol(); return shown; }
static void show_help_msg() { move(b_line, 0); clrtoeol(); move(b_line - 1, 0); clrtoeol(); move(b_line, 10); standout(); outs(_msg_edit_9); standend(); }
/* * Function to create the tax bill for the user */ static int letter1() { /* Prepare path */ sprintf(mail600, "/tmp/#%dmail600", pid); if(lcreat(mail600) < 0) { if(write(1, "Can't write 600 letter\n", 23) == -1) { exit(1); } return 0; } lprcat("\n\n\n\n\n\n\n\n\n\n\n\n"); standout(); lprcat("From:"); standend(); lprcat(" The LRS (Larn Revenue Service)\n"); standout(); lprcat("\nSubject"); standend(); lprcat(" Undeclared Income\n"); lprcat("\n We heard you survived the caverns of Larn. Let be the"); lprcat("\nfirst to congratulate you on your success. It is quite a feat."); lprcat("\nIt must also have been very profitable for you."); lprcat("\n\n The Dungeon Master has informed us that you brought"); lprintf("\n%d gold pieces back with you from your journey. As the", (long)c[GOLD]); lprcat("\ncounty of Larn is in dire need of funds, we have spared no time"); lprintf("\nin preparing your tax bill. You owe %d gold pieces as", (long)c[GOLD] * TAXRATE); lprcat("\nof this notice, and is due within 5 days. Failure to pay will"); lprcat("\nmean penalties. Once again, congratulations, we look forward"); lprcat("\nto your future successful expeditions.\n"); lwclose(); return 1; }
/********************************************** * function helpme * ***********************************************/ void helpme(int htype) /* routine to show help menu. */ /* htype 0 == editor */ { int i = 0, i2 = 0; /* loop counters */ char *ptr; /* pointer in array.. */ char ch; char **helplist; if (htype) helplist = help; else helplist = edhelp; /* clear board - fullscreen mode is too big to overlay */ for (i = 0; i < 18; i++) { move(i, 0); printw("%43s", ""); } while (helplist[i2]) /* times to show loop. */ { for (i = 0; i < 16; i++) /* show one menu. */ { ptr = helplist[i2++]; move(i, 0); /* move to start of line. */ addstr(ptr); } move(i, 0); /* move to start of line. */ #ifdef TVI addstr(TVI); #else standout(); #endif if (helplist[i2]) addstr("Press any key to continue, <q> to exit"); else addstr("End of help. Press any key to exit "); #ifdef NOTVI addstr(NOTVI); #else standend(); #endif refresh(); /* show on screen. */ ch = (char) getchar(); /* just for now, get anything. */ if (ch == 'q') /* if return or what ever.. */ break; /* exit routine now. */ } move(i, 0); /* move to start of line. */ printw("%40s", ""); }
void progress(char *what, long current, long max) { static long start; long now; char msg[MSGLEN + 1]; int i; /* save the start time */ if (searchcount == 0) { start = time(NULL); } if ((now = time(NULL)) - start >= 1) { if (linemode == NO) { move(MSGLINE, 0); clrtoeol(); addstr(what); snprintf(msg, sizeof(msg), "%ld", current); move(MSGLINE, (COLS / 2) - (strlen(msg) / 2)); addstr(msg); snprintf(msg, sizeof(msg), "%ld", max); move(MSGLINE, COLS - strlen(msg)); addstr(msg); refresh(); } else if (verbosemode == YES) { snprintf(msg, sizeof(msg), "> %s %ld of %ld", what, current, max); } start = now; if ((linemode == NO) && (incurses == YES)) { move(MSGLINE, 0); i = (float)COLS * (float)current / (float)max; standout(); for (; i > 0; i--) addch(inch()); standend(); refresh(); } else if (linemode == NO || verbosemode == YES) postmsg(msg); } ++searchcount; }
void prboard() { PLAY *pp; int i, j, k, temp; for (k = 0; k < 2; k++) { pp = &Player[k]; temp = k * COMP_STRT + CARD_STRT; for (i = 0; i < NUM_SAFE; i++) if (pp->safety[i] == S_PLAYED && !pp->sh_safety[i]) { mvaddstr(i, temp, C_name[i + S_CONV]); if (pp->coups[i]) mvaddch(i, temp - CARD_STRT, '*'); pp->sh_safety[i] = TRUE; } show_card(14, temp, pp->battle, &pp->sh_battle); show_card(16, temp, pp->speed, &pp->sh_speed); for (i = C_25; i <= C_200; i++) { const char *name; int end; if (pp->nummiles[i] == pp->sh_nummiles[i]) continue; name = C_name[i]; temp = k * 40; end = pp->nummiles[i]; for (j = pp->sh_nummiles[i]; j < end; j++) mvwaddstr(Miles, i + 1, (j << 2) + temp, name); pp->sh_nummiles[i] = end; } } prscore(TRUE); temp = CARD_STRT; pp = &Player[PLAYER]; for (i = 0; i < HAND_SZ; i++) show_card(i + 6, temp, pp->hand[i], &pp->sh_hand[i]); mvprintw(6, COMP_STRT + CARD_STRT, "%2d", Topcard - Deck); show_card(8, COMP_STRT + CARD_STRT, Discard, &Sh_discard); if (End == 1000) { move(EXT_Y, EXT_X); standout(); addstr("Extension"); standend(); } wrefresh(Board); wrefresh(Miles); wrefresh(Score); }
void printchatline2(const char *str) { int i = 0; int wrap = 0; int y, x; move(chat_line, i); clrtoeol(); while (*str) { getyx(&y, &x); if (y == 79 || *str == '\n') { chat_line++; if (chat_line == ECHATWIN) chat_line = 0; i = 0; move(chat_line, i); clrtoeol(); #if 1 wrap = 1; refresh(); #endif } else { if (y == 0 && wrap) outs(" "); outc(*str); } str++; } chat_line++; if (chat_line == ECHATWIN) chat_line = 0; else if (chat_line < ECHATWIN - 1) /* lthuang */ { move(chat_line + 1, 0); clrtoeol(); } move(chat_line, 0); clrtoeol(); standout(); outs("-->"); standend(); #if 1 refresh(); #endif }
int main(){ int i; initscr(); clear(); for(i=0; i<LINES; i++){ move(i, i+i); if(i & 1) standout(); addstr("Hello world!"); if(i & 1) standend(); refresh(); sleep(1); move(i, i+i); addstr(" "); } endwin(); }
static void game_finished(int deal) { clear(); (void)printw("You finished the game in %d deals. This is ",deal); standout(); if (deal<2) (void)addstr("excellent"); else if (deal<4) (void)addstr("good"); else if (deal<8) (void)addstr("average"); else (void)addstr("poor"); standend(); (void) addstr(". "); refresh(); }
/* * visuals: * change the characters for the player */ visuals() { register THING *tp; register bool seemonst; if (!after) return; /* * change the things */ for (tp = lvl_obj; tp != NULL; tp = next(tp)) if (cansee(tp->o_pos.y, tp->o_pos.x)) { PC_GFX_PASSGE_COLOR(tp->o_pos.y, tp->o_pos.x, 0, 0x70); mvaddrawch(tp->o_pos.y, tp->o_pos.x, rnd_thing()); PC_GFX_NOCOLOR(0x70); } /* * change the stairs */ if (!seenstairs && cansee(stairs.y, stairs.x)) { PC_GFX_PASSGE_COLOR(stairs.y, stairs.x, 0, 0x70); mvaddrawch(stairs.y, stairs.x, rnd_thing()); PC_GFX_NOCOLOR(0x70); } /* * change the monsters */ seemonst = on(player, SEEMONST); for (tp = mlist; tp != NULL; tp = next(tp)) if (see_monst(tp)){ PC_GFX_PASSGE_COLOR(tp->t_pos.y, tp->t_pos.x, 0, 0x70); if (tp->t_type == 'M' && tp->t_disguise != 'M') mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd_thing()); else mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd(26) + 'A'); PC_GFX_NOCOLOR(0x70); } else if (seemonst) { standout(); mvaddrawch(tp->t_pos.y, tp->t_pos.x, rnd(26) + 'A'); standend(); } }