int main(void) { char Ham1[] = "To be, or not to be: that is the quesiton:\n"; char Ham2[] = "Whether tis nobler in the mind to suffer\n"; char Ham3[] = "The slings and arrows of outrageous fortune,\n"; char Ham4[] = "Or to take arms against a sea of troubles,\n"; char Ham5[] = "And by opposing end them?\n"; initscr(); addstr(Ham1); addstr(Ham3); addstr(Ham5); refresh(); getch(); // Wait for key press move(1,0); insertln(); // Inserts a blank line, scroll text down addstr(Ham2); // line to insert refresh(); getch(); move(3,0); insertln(); // Inserts a blank line, scroll text down addstr(Ham4); // line to insert refresh(); getch(); endwin(); return 0; }
void * animation (void *arg) { srand ((unsigned) time (NULL)); int ch; int i; char charToPrint; int column; int M = (ROWS - 1) * (COLUMNS + 1); while (1) { ch = rand () % 36; //0-35 column = rand () % (COLUMNS + 1); move (0, column); if (ch >= 0 && ch <= 9) { charToPrint = (char) (ch + 48); } if (ch >= 10 && ch <= 35) { charToPrint = (char) (ch + 87); } addch (charToPrint); ScreenTable[column] = charToPrint; CharTable[ch]++; refresh (); usleep ((55 - LEVEL) * 500 * 1000); insertln (); refresh (); for (i = 0; i < N; ++i) { if (ScreenTable[i] != 0 && Move[i] == 0) { if (i >= M) { game_over (); //clean up the windows save_exit (GAME_OVER); //keep this call in 'main' } ScreenTable[i + COLUMNS + 1] = ScreenTable[i]; ScreenTable[i] = 0; Move[i + COLUMNS + 1] = 1; } if ((ScreenTable[i] == TYPINGCHAR) && (isOld == 0)) { move (i / (COLUMNS + 1), i % (COLUMNS + 1)); addch (' '); flash (); refresh (); if (TYPINGCHAR >= 48 && (TYPINGCHAR <= 57)) { if (--CharTable[TYPINGCHAR - 48] == 0) isOld = 1; } ScreenTable[i] = 0; SCORE++; } } memset (Move, 0, N); } }
// SIMPLE TEMPORARY MESSAGE ROUTINE // When you call this by passing a string, it will be stored in the // message buffer until the next draw cycle. The message will be shown // for one turn, then disappear or be replaced with new message. void message(char* msg, bool immediate) { if (immediate) { // write message now! need this for mid-turn prompts like open/close etc. // skips the buffer & will be erased at beginning of next turn move(MESSAGE_POS_Y, MESSAGE_POS_X); deleteln(); deleteln(); deleteln(); insertln(); insertln(); insertln(); addstr(msg); napms(1); } else if (msg == nullptr) { // PRINTS TO SCREEN - ONLY CALLED FROM MAIN LOOP mvaddstr(MESSAGE_POS_Y, MESSAGE_POS_X, msgBuf); // clear message msgBuf[0] = '\0'; } else { strncpy(msgBuf, msg, 80); } }
static TACommandVerdict insertln_cmd(TAThread thread,TAInputStream stream) { int res; START_TARGET_OPERATION(thread); res = insertln(); END_TARGET_OPERATION(thread); writeInt(thread, res); sendResponse(thread); return taDefaultVerdict; }
static void test_insdelln(void) { STATUS st; int n; init_status(stdscr, &st); do { (void) attrset(st.attr | COLOR_PAIR(st.pair)); switch (st.ch) { case 'i': for (n = 0; n < st.count; ++n) insertln(); break; case 'd': for (n = 0; n < st.count; ++n) deleteln(); break; case 'I': insdelln(st.count); break; case 'D': insdelln(-st.count); break; case 'f': fill_window(stdscr); reshow_status(stdscr, &st); break; case 'w': do_subwindow(stdscr, &st, test_winsdelln); break; case 'q': return; default: update_status(stdscr, &st); break; } } while ((st.ch = getch()) != ERR); }
static void msglist_add(const char *msg) { int x, y; getyx(stdscr, y, x); move(0, 0); int n = compute_line(msg); int i; for (i = 0; i < n; ++i) { deleteln(); } int newy = window_y - INPUT_MAXLINE - 2 - n + 1; move(newy, 0); for (i = 0; i < n; ++i) { insertln(); } printw("%s", msg); move(y, x); refresh(); }
void term_scroll_up(int x, int y, int width, int height) /* x and width are ignored. */ /* scroll_up between line y to line y+height-1 */ { #ifdef CURSES term_gotoxy(0, y); deleteln(); term_gotoxy(0, y+height-1); insertln(); #else term_gotoxy(0, y); #ifdef FMR printf("\033R"); #else del_ln(1); #endif FMR term_gotoxy(0, y+height-1); #ifdef FMR printf("\033E"); #else ins_ln(1); #endif #endif }
cell pp_curs_insertln(cell x) { if (!Running) return UNSPECIFIC; insertln(); return UNSPECIFIC; }
/* Prints file selection menu. */ int fileselmenu(int tot, struct finfo *thingie, const char *title) { int a, cpos, k; drawscreen(); xcolor_set(4); mvprintw(2, 5, _("Choose a %s (UP/DOWN/ENTER):"), title); if (tot > 17) for (k = 0; k < 17; k++) mvaddstr(k + 4, 5, thingie[k].descr); else for (k = 0; k < tot; k++) mvaddstr(k + 4, 5, thingie[k].descr); cpos = k = 0; mvaddstr(4, 1, "->"); for (a = 1; a;) { /* * And thanks for xmunkki, he made my day and * "solved" this, what i didn't get right (or did * but i used 2 extra variables. :) */ switch (getch()) { case 27: return -1; break; case KEY_UP: case 'k': if (k <= 0) break; k--; if (cpos > 0) { cpos--; break; } move(20, 5); deleteln(); move(4, 5); insertln(); mvaddstr(4, 5, thingie[k].descr); break; case KEY_DOWN: case 'j': if (k > tot - 2) break; k++; if (cpos < 16 && cpos < tot - 1) { cpos++; break; } move(4, 5); deleteln(); move(20, 5); insertln(); mvaddstr(20, 5, thingie[k].descr); break; case ' ': case '\n': a = 0; break; default: break; } mvaddstr(cpos + 3, 1, " "); mvaddstr(cpos + 5, 1, " "); mvaddstr(cpos + 4, 1, "->"); } return k; }
void edit() { int c; while(1) { move(row, col); refresh(); c = getch(); /* Editor commands */ switch (c) { /* hjkl and arrow keys: move cursor * in direction indicated */ case 'h': case KEY_LEFT: if (col > 0) col--; else flash(); break; case 'j': case KEY_DOWN: if (row < LINES - 1) row++; else flash(); break; case 'k': case KEY_UP: if (row > 0) row--; else flash(); break; case 'l': case KEY_RIGHT: if (col < COLS - 1) col++; else flash(); break; /* i: enter input mode */ case KEY_IC: case 'i': input(); break; /* x: delete current character */ case KEY_DC: case 'x': delch(); break; /* o: open up a new line and enter input mode */ case KEY_IL: case 'o': move(++row, col = 0); insertln(); input(); break; /* d: delete current line */ case KEY_DL: case 'd': deleteln(); break; /* ^L: redraw screen */ case KEY_CLEAR: case CTRL('L'): wrefresh(curscr); break; /* w: write and quit */ case 'w': return; /* q: quit without writing */ case 'q': endwin(); exit(2); default: flash(); break; } } }