int main() { setupterm(NULL, 1, NULL); const char* setf = tigetstr("setaf"); // putp(setf); const char* red = tparm(setf, 1); putp(red); printf("whooo!\n"); return 1; }
/* --------------------------------------------- function PrintBuffer9pin().print data in buffer. include left-right trim functions to fasten graphic print. In text mode the printer print nothing when it reaches blank (' '). -------------------------------------------- */ void PrintBuffer9pin(unsigned char c[]) { extern int maxdot ; register int i; int left,right,length; charwidth(c) ; /* alternate character width in cpi.obj */ left = ltrim(c,0,maxdot); right = rtrim(c,0,maxdot); for(i=0; i<left; i++) putp(' '); /* text mode */ length = right - (left * 24) ; if(length != 0){ PrinterSetGraphicMode9pinQuadrupleDensity(length); for(i=0;i< length ; i++) { putp(c[(left * 24) + i]); /* graphic (bit image) print */ } } }
static void reset_scroll_region(void) /* Set the scroll-region to a known state (the default) */ { if (change_scroll_region) { TPUTS_TRACE("change_scroll_region"); putp(tparm(change_scroll_region, 0, screen_lines - 1)); } }
/* * Below are the functions which perform all the * terminal-specific screen manipulation. */ int short_file; /* if file less than a screen */ void lower_left(void) { if (short_file) { putchar('\r'); fflush(stdout); } else putp(sc_lower_left); }
void cls() { if (!cur_term) { int result; setupterm( NULL, STDOUT_FILENO, &result ); if (result <= 0) return; } putp( tigetstr( "clear" ) ); }
int beep(void) { int res = ERR; T((T_CALLED("beep()"))); /* FIXME: should make sure that we are not in altchar mode */ if (bell) { TPUTS_TRACE("bell"); res = putp(bell); fflush(SP->_ofp); } else if (flash_screen) { TPUTS_TRACE("flash_screen"); res = putp(flash_screen); fflush(SP->_ofp); } returnCode(res); }
static void curses_off() { if ((is_curses_on == TRUE) && (opts.o_outpmode & OPT_TERMCAP)) { (void) putp(t_rmcup); (void) endwin(); is_curses_on = FALSE; } (void) fflush(stdout); }
static void enable_xterm_mouse(SCREEN *sp, int enable) { #if USE_EMX_MOUSE sp->_emxmouse_activated = enable; #else putp(TPARM_1(sp->_mouse_xtermcap, enable)); #endif sp->_mouse_active = enable; }
/* Learn a single map. */ static void learn_map(map_t *mode) { sequence_t *current, *before_insert; size_t i; printf("Starting mode %s (press Control R to restart)\n", mode->name); if (mode->esc_seq_enter != NULL) { putp(mode->esc_seq_enter); } fflush(stdout); if (option_auto_learn) { usleep(100000); } for (i = 0; i < SIZEOF(modifiers); i++) { before_insert = head; if (getkeys(keynames, SIZEOF(keynames), i) < 0) { printf("\nRestarting...\n"); goto skip; } if (getkeys(functionkeys, maxfkeys, i) < 0) { printf("\nRestarting...\n"); goto skip; } if (!option_auto_learn && !confirm("Are you satisfied with the above keys [y/n]")) { skip: while (head != before_insert) { current = head; head = current->next; free(current); } i--; } } mode->sequences = reverse_key_list(head); head = NULL; if (mode->esc_seq_leave != NULL) { putp(mode->esc_seq_leave); } }
/* * Write the soft labels to the soft-key window. */ static void slk_intern_refresh(SLK * slk) { int i; int fmt = SP->slk_format; for (i = 0; i < slk->labcnt; i++) { if (slk->dirty || slk->ent[i].dirty) { if (slk->ent[i].visible) { if (num_labels > 0 && SLK_STDFMT(fmt)) { if (i < num_labels) { TPUTS_TRACE("plab_norm"); putp(TPARM_2(plab_norm, i + 1, slk->ent[i].form_text)); } } else { if (fmt == 4) slk_paint_info(slk->win); wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].ent_x); if (SP->_slk) { wattrset(slk->win, AttrOf(SP->_slk->attr)); } waddstr(slk->win, slk->ent[i].form_text); /* if we simulate SLK's, it's looking much more natural to use the current ATTRIBUTE also for the label window */ wattrset(slk->win, WINDOW_ATTRS(stdscr)); } } slk->ent[i].dirty = FALSE; } } slk->dirty = FALSE; if (num_labels > 0) { if (slk->hidden) { TPUTS_TRACE("label_off"); putp(label_off); } else { TPUTS_TRACE("label_on"); putp(label_on); } } }
NCURSES_SP_NAME(flash) (NCURSES_SP_DCL0) { int res = ERR; T((T_CALLED("flash()"))); /* FIXME: should make sure that we are not in altchar mode */ if (flash_screen) { TPUTS_TRACE("flash_screen"); res = putp(flash_screen); _nc_flush(); } else if (bell) { TPUTS_TRACE("bell"); res = putp(bell); _nc_flush(); } returnCode(res); }
static void curses_on() { if ((opts.o_outpmode & OPT_TERMCAP) && (is_curses_on == FALSE)) { (void) initscr(); (void) nonl(); (void) putp(t_smcup); is_curses_on = TRUE; } }
/*-----------------------------------------------------------------------------------*/ void console_init(void) { /* mouse support is ncurses-specific */ #ifdef NCURSES_MOUSE_VERSION mmask_t oldmask; #endif static unsigned char done; int bg, fg; if(done) { return; } done = 1; initscr(); start_color(); cbreak(); /* don't echo typed characters */ noecho(); /* disable return -> newline translation */ nonl(); /* hide text cursor, CTK draws its own */ curs_set(0); intrflush(stdscr, FALSE); keypad(stdscr, TRUE); #ifdef NCURSES_MOUSE_VERSION /* done here because ctk_mouse_init() is called before anyway */ mousemask(ALL_MOUSE_EVENTS, &oldmask); #endif screensize(&width, &height); /* we must declare all possible color pairs */ for(fg = 0; fg < 8; fg++) { for(bg = 0; bg < 8; bg++) { init_pair(MKPAIR(bg, fg), fg, bg); } } /* set window title */ putp("\033]0;Contiki\a"); /* don't block on read, just timeout 1ms */ timeout(1); /* make sure we return the terminal in a clean state */ signal(SIGINT, ctrlhandler); atexit(console_exit); }
/* * Write the soft labels to the soft-key window. */ static void slk_intern_refresh(SLK * slk) { int i; int fmt = SP->slk_format; for (i = 0; i < slk->labcnt; i++) { if (slk->dirty || slk->ent[i].dirty) { if (slk->ent[i].visible) { if (num_labels > 0 && SLK_STDFMT(fmt)) { if (i < num_labels) { TPUTS_TRACE("plab_norm"); putp(tparm(plab_norm, i + 1, slk->ent[i].form_text)); } } else { wmove(slk->win, SLK_LINES(fmt) - 1, slk->ent[i].x); if (SP && SP->_slk) wattrset(slk->win, SP->_slk->attr); waddnstr(slk->win, slk->ent[i].form_text, MAX_SKEY_LEN(fmt)); /* if we simulate SLK's, it's looking much more natural to use the current ATTRIBUTE also for the label window */ wattrset(slk->win, stdscr->_attrs); } } slk->ent[i].dirty = FALSE; } } slk->dirty = FALSE; if (num_labels > 0) { if (slk->hidden) { TPUTS_TRACE("label_off"); putp(label_off); } else { TPUTS_TRACE("label_on"); putp(label_on); } } }
void voce_perdeu(){ setupterm(NULL, STDOUT_FILENO, NULL); putp(tparm(set_a_foreground, 1)); printf("\n"); printf("# ####### ########## #########\n"); printf("# ## ## # # \n"); printf("# ## ## # # \n"); printf("# ## ## #### ##### \n"); printf("# ## ## # # \n"); printf("# ## ## # # \n"); printf("####### ####### ###### #########\n"); }
/* Repeat character c, n times. "a" indicates alternate character set. * x is the first column that we should be printing on. (used for a little * optimization) */ static void TI_REPEAT_CHAR( char c, int n, bool a, ORD x ) { bool blank; int len; char *cparm_right; if( n == 0 ) return; blank = OptimizeTerminfo && ( TI_FillColourSet ) && c == ' ' && !a; if( blank && x == ( UIData->width - n ) && (len = strlen( clr_eol )) > 0 && n > len ) { putp( clr_eol ); } else if( blank && x == 0 && clr_bol[0] != '\0' && n > (len = (strlen( cparm_right = tparm( parm_right_cursor, n )) + strlen( clr_bol ) )) && len > 0 ) { putp( cparm_right ); putp( clr_bol ); } else { if( a ) { TI_ACS_ON(); } if( n >= TI_repeat_cutoff ) { putp( tparm( repeat_char, c, n ) ); } else { for( ; n > 0; n-- ) { __putchar( c ); } } if( a ) { TI_ACS_OFF(); } } }
static int outputcap(char *cap, int argc, char **argv) { int parmset = 0; char *thisstr; int i; if ((i = tigetflag(cap)) >= 0) return (1 - i); if ((i = tigetnum(cap)) >= -1) { (void) printf("%d\n", i); return (0); } if ((thisstr = tigetstr(cap)) != (char *)-1) { if (!thisstr) { return (1); } for (parmset = 0; optind < argc; optind++, parmset++) if (allnumeric(argv[optind])) parm[parmset] = atoi(argv[optind]); else parm[parmset] = (int)argv[optind]; if (parmset) putp(tparm(thisstr, parm[0], parm[1], parm[2], parm[3], parm[4], parm[5], parm[6], parm[7], parm[8])); else putp(thisstr); return (0); } (void) fprintf(stderr, gettext("%s: unknown terminfo capability '%s'\n"), progname, cap); exit(4); /* NOTREACHED */ }
int my_set_term() { int err; int ret; char *s; if ((err = setupterm(NULL, 1, &ret)) == ERR) return (1); if ((s = tigetstr("smkx")) == (char *)-1) return (2); putp(s); return (0); }
/* * Extension (1997/1/18) - Allow negative f/b values to set default color * values. */ int init_pair(short pair, short f, short b) { T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b)); if ((pair < 1) || (pair >= COLOR_PAIRS)) returnCode(ERR); if (SP->_default_color) { if (f < 0) f = C_MASK; if (b < 0) b = C_MASK; if (f >= COLORS && f != C_MASK) returnCode(ERR); if (b >= COLORS && b != C_MASK) returnCode(ERR); } else if ((f < 0) || (f >= COLORS) || (b < 0) || (b >= COLORS)) returnCode(ERR); /* * FIXME: when a pair's content is changed, replace its colors * (if pair was initialized before a screen update is performed * replacing original pair colors with the new ones) */ SP->_color_pairs[pair] = PAIR_OF(f,b); if (initialize_pair) { const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette; T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)", pair, tp[f].red, tp[f].green, tp[f].blue, tp[b].red, tp[b].green, tp[b].blue)); if (initialize_pair) { TPUTS_TRACE("initialize_pair"); putp(tparm(initialize_pair, pair, tp[f].red, tp[f].green, tp[f].blue, tp[b].red, tp[b].green, tp[b].blue)); } } returnCode(OK); }
int use_terminfo_color(int ansicolor,int boldp){ if(use_terminfo){ const char *attrstr = boldp ? "bold" : "sgr0"; const char *color,*attr; char *setaf; if((attr = tigetstr(attrstr)) == NULL){ bitch("Couldn't get terminfo %s\n",attrstr); return -1; } putp(attr); if((setaf = tigetstr("setaf")) == NULL){ bitch("Couldn't get terminfo setaf\n"); return -1; } if((color = tparm(setaf,ansicolor)) == NULL){ bitch("Couldn't get terminfo color %d\n",ansicolor); return -1; } putp(color); } return 0; }
int tty_vmsg( const char *fmt, va_list ap ) { int r; putchar(13); putp( tcap.clreol ); r = vprintf( fmt, ap ); rl_on_new_line(); if(! RL_ISSTATE(RL_STATE_DONE) ) rl_redisplay(); return r; }
/* does real job on setting terminal title */ static void set_terminal_title(const char *path) { #ifdef _WIN32 wchar_t buf[2048]; vifm_swprintf(buf, ARRAY_LEN(buf), L"%" WPRINTF_MBSTR L" - VIFM", path); SetConsoleTitleW(buf); #else char *const title = format_str("\033]2;%s - VIFM\007", path); putp(title); fflush(stdout); free(title); #endif }
static void ui_show_pane(struct ui_pane *pane) { int row, col; int lastBack = -1, lastFore = -1; for (row = 0; row < ui_bar_length; row++) { putp(tiparm(cursor_address, LINES - pane->start - row - 1, 0)); // What's the width of this row? Beyond this, we can // just clear the line. int endCol = 0; for (col = pane->barpos; col < pane->barpos + pane->width; col++) { if (UIXY(ui_back, col, row) != 0xff || UIXY(ui_display, col, row) != 0) endCol = col + 1; } for (col = pane->barpos; col < endCol; col++) { int cell = UIXY(ui_display, col, row); int back = UIXY(ui_back, col, row); int fore = UIXY(ui_fore, col, row); // If it's a space, we don't care what the // foreground color is. if (ui_chars[cell][0] == ' ' && lastFore != -1) fore = lastFore; // Set attributes if (lastBack != back || lastFore != fore) { if (back == 0xff || fore == 0xff) { putp(exit_attribute_mode); lastBack = lastFore = 0xff; } if (lastBack != back) { putp(tiparm(set_a_background, back)); lastBack = back; } if (lastFore != fore) { putp(tiparm(set_a_foreground, fore)); lastFore = fore; } } fputs(ui_chars[cell], stdout); } // Clear to the end of the line if (endCol < pane->barpos + pane->width) { if (lastBack != 0xff || lastFore != 0xff) { putp(exit_attribute_mode); lastBack = lastFore = 0xff; } putp(clr_eol); } } }
/* * From where we are, get to our proposed position, for row we just * move up or down as needed. For col we see if we are closer to col. */ void move_to(int r, int c) { if(have_multi_move) { if(r > row) { putp(tparm(parm_down_cursor, r-row)); } if(r < row) { putp(tparm(parm_up_cursor, row-r)); } if(c > col) { putp(tparm(parm_right_cursor, c-col)); } if(c < col) { putp(tparm(parm_left_cursor, col-c)); } row = r; col = c; } else { while(r > row) { putp(cursor_down); row++; } while(r < row) { putp(cursor_up); row--; } if(abs(col-c) > c) { putp(carriage_return); col = 0; } while(c > col) { putp(cursor_right); col++; } while(c < col) { putp(cursor_left); col--; } } }
NCURSES_SP_NAME(init_color) (NCURSES_SP_DCLx short color, short r, short g, short b) { int result = ERR; int maxcolors; T((T_CALLED("init_color(%p,%d,%d,%d,%d)"), (void *) SP_PARM, color, r, g, b)); if (SP_PARM == 0) returnCode(result); maxcolors = MaxColors; if (InitColor && SP_PARM->_coloron && (color >= 0 && OkColorHi(color)) && (okRGB(r) && okRGB(g) && okRGB(b))) { SP_PARM->_color_table[color].init = 1; SP_PARM->_color_table[color].r = r; SP_PARM->_color_table[color].g = g; SP_PARM->_color_table[color].b = b; if (UseHlsPalette) { rgb2hls(r, g, b, &SP_PARM->_color_table[color].red, &SP_PARM->_color_table[color].green, &SP_PARM->_color_table[color].blue); } else { SP_PARM->_color_table[color].red = r; SP_PARM->_color_table[color].green = g; SP_PARM->_color_table[color].blue = b; } #ifdef USE_TERM_DRIVER CallDriver_4(SP_PARM, initcolor, color, r, g, b); #else TPUTS_TRACE("initialize_color"); putp(TPARM_4(initialize_color, color, r, g, b)); #endif SP_PARM->_color_defs = max(color + 1, SP_PARM->_color_defs); result = OK; } returnCode(result); }
static int term_raw(lua_State *L) { int rc; struct termios tios; putp(tparm(keypad_xmit)); rc = tcgetattr(0, &saved_termios); if (rc != 0) luaL_error(L, "unable to tcgetattr: %d", rc); memcpy(&tios, &saved_termios, sizeof(struct termios)); tios.c_lflag &= ~(ECHO|ICANON); rc = tcsetattr(0, TCSANOW, &tios); if (rc != 0) luaL_error(L, "unable to tcsetattr: %d", rc); return 0; }
/* * Reset the color pair, e.g., to whatever color pair 0 is. */ static bool reset_color_pair(NCURSES_SP_DCL0) { #ifdef USE_TERM_DRIVER return CallDriver(SP_PARM, rescol); #else bool result = FALSE; (void) SP_PARM; if (orig_pair != 0) { TPUTS_TRACE("orig_pair"); putp(orig_pair); result = TRUE; } return result; #endif }
/* Does all the real work on setting terminal title. */ static void set_terminal_title(const char path[]) { #ifdef _WIN32 wchar_t *utf16; char title[2048]; snprintf(title, sizeof(title), "%s - VIFM", path); utf16 = utf8_to_utf16(title); SetConsoleTitleW(utf16); free(utf16); #else char *const title = format_str("\033]2;%s - VIFM\007", path); putp(title); fflush(stdout); free(title); #endif }
static bool write_color(char *todo, unsigned char idx, bool is_fg) { bool result = false; if (idx < 16 || term256_support_is_native()) { /* Use tparm */ putp( tparm( todo, idx ) ); result = true; } else { /* We are attempting to bypass the term here. Generate the ANSI escape sequence ourself. */ char stridx[128]; format_long_safe(stridx, (long)idx); char buff[128] = "\x1b["; strcat(buff, is_fg ? "38;5;" : "48;5;"); strcat(buff, stridx); strcat(buff, "m"); write_loop(STDOUT_FILENO, buff, strlen(buff)); result = true; } return result; }
int iniciar_jogo(){ //Inteiras int senha[row/2], tela[row][col]; int ult_linha_lida=0; int status = 0; //Boelanas bool terminou = false, ganhou = false, jogando = true; //Outro srand (time (0)); carregamento(0); while(jogando == true){ //Limpa, gera senha primeira_execucao(tela,senha); do{ ganhou = interface_user(tela,ult_linha_lida,senha); ult_linha_lida++; }while(ult_linha_lida != 10 && ganhou == false); desenha_tela(tela); ultima_palavra(ganhou); jogando = continuar(); if(jogando == true){ ult_linha_lida = 0; ganhou = false; } } carregamento(3); system("clear"); printf("\n\n"); putp(exit_attribute_mode); return 0; }