这篇教程C++ tgetstr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tgetstr函数的典型用法代码示例。如果您正苦于以下问题:C++ tgetstr函数的具体用法?C++ tgetstr怎么用?C++ tgetstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tgetstr函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: set_titlevoid set_title (char *s){#if defined(USE_NCURSES) || defined (USE_NCURSES_W) if (tgetflag ("hs")) { // terminal has status line support char buf[255] = {0}; char *p = buf; // tgetstr modifies its second argument, let buf keep pointing to the beginning char *ok; // tgetstr's return value is apparently undocumented, except that it's NULL on errors ok = tgetstr ("tsl", &p); // "to status line" if (ok == NULL) return; strcpy (p - 1, s); // tgetstr leaves us *after* the null, so skip back a bit p += strlen (s) - 1; // same here ok = tgetstr ("fsl", &p); // "from status line" if (ok == NULL) return; putp (buf); }#else // assume pdcurses PDC_set_title(s);#endif}
开发者ID:TerminalHunter,项目名称:lunar-crime-squad,代码行数:22,
示例2: get_capabilitystatic int get_capability(const char* label, const char* name, const char** pptr, char** p_buf_ptr){ const char* ptr; ptr = tgetstr(name, p_buf_ptr); printf("%-22s (%s) = ", label, name); print_text(ptr); printf("/n"); *pptr = ptr; return ptr != NULL;}
开发者ID:hio,项目名称:c-tty-termcap-sample,代码行数:13,
示例3: do_clearvoid do_clear(t_var *v, char **line){ int i; short col; col = getsing_col(-1); tputs(tgetstr("cl", NULL), 0, ret_putchar); tputs(tgetstr("sc", NULL), 0, ret_putchar); i = prompt(); i += ft_strlen(*line); ft_putstr(*line); while (i > v->cursor) { i--; if (i % col == 0 && i >= col) { tputs(tgetstr("up", NULL), 0, ret_putchar); tputs(tgoto(tgetstr("ch", NULL), 0, col), 0, ret_putchar); } else tputs(tgetstr("le", NULL), 0, ret_putchar); }}
开发者ID:mgouault,项目名称:42-projects,代码行数:23,
示例4: intochar *insert_char(char *line, char buffer[3], int i, int len){ char *new_line; if (line && i != (int)ft_strlen(line)) new_line = into(line, buffer, i); else { new_line = ft_strjoin(line, buffer); ft_strdel(&line); } tputs(tgetstr("im", NULL), 0, outputc); tputs(tgetstr("ic", NULL), 0, outputc); write(1, &buffer[0], 1); if (!((len + i + 1) % (g_sz.ws_col))) { tputs(tgetstr("ic", NULL), 0, outputc); write(1, " ", 1); tputs(tgetstr("le", NULL), 0, outputc); } tputs(tgetstr("ei", NULL), 0, outputc); return (new_line);}
开发者ID:Nayruuu,项目名称:Unix,代码行数:23,
示例5: apply_deletevoid apply_delete(void){ int win_size; t_hist **historic; historic = init_historic(0); if ((*historic)->copy->index != -1) { (*historic)->copy->line = update_line((*historic)->copy->line, (*historic)->copy->index); if ((win_size = check_beginning((*historic)->copy->index))) { tputs(tgetstr("up", NULL), 1, aff_c); tputs(tgoto(tgetstr("ch", NULL), 0, win_size), 1, aff_c); } else tputs(tgetstr("le", NULL), 1, aff_c); tputs(tgetstr("dc", NULL), 1, aff_c); (*historic)->copy->index -= 1; (*historic)->copy->size = ft_strlen((*historic)->copy->line); display_line(); }}
开发者ID:wtrembla,项目名称:New_42sh,代码行数:23,
示例6: keyboard_line_upvoid keyboard_line_up(t_line **l_line, size_t *position, int len_prompt){ if ((*l_line)->prev) { if (!((*l_line)->prev->prev)) prompt_up(l_line, position, len_prompt); else if (*position <= ft_strlen((*l_line)->prev->line)) { tputs(tgetstr("up", NULL), 1, ft_outc); *l_line = (*l_line)->prev; } else { tputs(tgetstr("up", NULL), 1, ft_outc); *l_line = (*l_line)->prev; while (*position > ft_strlen((*l_line)->line)) { tputs(tgetstr("le", NULL), 1, ft_outc); (*position)--; } } }}
开发者ID:Liliaze,项目名称:Projets,代码行数:23,
示例7: special_key_initvoidspecial_key_init(void){ static char sbuf[1024]; char *sp = sbuf; char *res = NULL; /* Arrow up */ res = tgetstr("ku", &sp); add_cmdtable(res, A_B_LINE); /* Arrow down */ res = tgetstr("kd", &sp); add_cmdtable(res, A_F_LINE); /* Page up */ res = tgetstr("kP", &sp); add_cmdtable(res, A_B_SCREEN); /* Page down */ res = tgetstr("kN", &sp); add_cmdtable(res, A_F_SCREEN);}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:23,
示例8: exitchar *xtgetstr(char *cap, char **area){ char *capstr; if ((capstr = tgetstr(cap, area)) == NULL) { my_putstr("Problem getting "); my_putstr(cap); my_putchar('/n'); my_putstr("Run './42sh t' for non-termcaps mode/n"); exit(1); } return (capstr);}
开发者ID:DbilliT,项目名称:42sh,代码行数:14,
示例9: tclearint tclear(void){ char *res; if ((res = tgetstr("cd", NULL)) == NULL) { ft_putstr_fd("Attempt to clear the term failed", 2); return (-1); } tho(); tputs(res, 2, ft_outc); tvi(); return (0);}
开发者ID:Magatte,项目名称:ft_select,代码行数:14,
示例10: ft_loopint ft_loop(int *buff, t_list **list, int ac){ while (1) { g_list = list; ft_chk_sig(); tputs(tgoto(tgetstr("cm", NULL), 0, (*list)->y), FD, ft_putint); buff[0] = 0; read(0, buff, 3); ft_chk_up(buff, list); ft_chk_down(buff, list); if (buff[0] == 32) { ft_chk_slct(list); ft_down(list); } ft_del(buff, list); ft_echap(buff, ac); if (buff[0] == 10) return (0); tputs(tgetstr("me", NULL), FD, ft_putint); }}
开发者ID:valouche,项目名称:perso,代码行数:23,
示例11: set_next_promptint set_next_prompt(char *prompt, int cursor, char *to_edit){ int i; i = -1; cursor = 0; (void)prompt; while (++i < 2) if ((tputs(tgetstr("cr", NULL), 1, t_puts)) == -1) ft_exit("Tputs error"); ft_refresh(to_edit, cursor); cursor = -1; return (cursor);}
开发者ID:bciss,项目名称:projets_42,代码行数:14,
示例12: get_terminfovoid get_terminfo(t_env *e){ if ((tgetent((char *)NULL, getenv("TERM"))) != 1) error_call_system("tgetent"); if ((tcgetattr(0, &(e->term_default))) == (-1)) error_call_system("tcgetattr"); if ((tcgetattr(0, &(e->term_update))) == (-1)) error_call_system("tcgetattr"); update_struct(&(e->term_update), 1); if ((tcsetattr(0, TCSADRAIN, &(e->term_update))) == (-1)) error_call_system("tcsetattr"); tputs(tgetstr("vi", NULL), 1, myputc); ft_putstr_fd("/033[?1049h/033[H", 2);}
开发者ID:Ibouch,项目名称:beta_pacman,代码行数:14,
示例13: insert_charvoid insert_char(char c, t_print *print){ int i; i = 0; tputs(tgetstr("im", NULL), 1, out); tputs(tgetstr("ic", NULL), 1, out); write(1, &c, 1); if (print->pos != (i = ft_strlen(print->line))) { while (i >= print->pos) { print->line[i + 1] = print->line[i]; i--; } print->line[print->pos] = c; } print->line[print->pos] = c; print->pos += 1; tputs(tgetstr("ip", NULL), 1, out); tputs(tgetstr("ei", NULL), 1, out); check_length_and_realloc(print);}
开发者ID:Succubae,项目名称:42,代码行数:23,
示例14: move_cursor_endint move_cursor_end(t_line *rdl){ if (rdl->line == NULL) return (FALSE); if (rdl->line[rdl->pos]) { if ((get_nb_char_line(rdl)) == get_winsize_x()) go_down(rdl, 0); else my_putstr(tgetstr("nd", NULL)); ++rdl->pos; } return (TRUE);}
开发者ID:rapier992,项目名称:42sh,代码行数:14,
示例15: mainint main(int argc, char *argv[]){ char *op = output; char *rp = result; const char *t = getenv("TERM"); char *prop, *pe; int n; if (argc != 2) { fprintf(stderr, "%s [props]/n", argv[0]); exit(1); } if (t == NULL) t = "dumb"; if ((n = tgetent(buf, t)) != 1) { fprintf(stderr, "%s is not a known terminal type/n", t); putw(0, stdout); exit(1); } prop = argv[1]; pe = prop + strlen(prop) - 2; while(prop < pe) { id[0] = *prop++; id[1] = *prop++; if (*prop == '$') { char *r = tgetstr(id, &op); if (r) { size_t l = strlen(r); memcpy(rp, r, l); rp += l; } *rp++= 0; prop++; continue; } if (*prop == '#') { n = tgetnum(id); prop++; } else n = tgetflag(id); /* Intentionally native type and endian */ memcpy(rp, &n, sizeof(n)); rp += sizeof(n); } putw(rp - result, stdout); fwrite(result, rp - result, 1, stdout); return 0;}
开发者ID:EtchedPixels,项目名称:FUZIX,代码行数:50,
示例16: capGoto/* Move cursor to the column _col and the line _li */void capGoto(int col, int li){ char *stringCap; stringCap = tgetstr("cm", NULL); if (stringCap != NULL) { stringCap = tgoto(stringCap, col, li); } if (stringCap != NULL) { tputs(stringCap, 1, putchar); }}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:15,
示例17: keyboard_line_downvoid keyboard_line_down(t_line **l_line, size_t *position, int len_prompt){ if ((*l_line)->next) { if (!(*l_line)->prev) { *position = len_prompt + *position + 1; } if (*position >= ft_strlen((*l_line)->next->line)) { tputs(tgetstr("do", NULL), 1, ft_outc); *l_line = (*l_line)->next; *position = 0; while (*position < ft_strlen((*l_line)->line)) { tputs(tgetstr("nd", NULL), 1, ft_outc); (*position)++; } } else else_down(l_line, position); }}
开发者ID:Liliaze,项目名称:Projets,代码行数:23,
示例18: move_absint move_abs(int x, int y){ char *cap; cap = tgetstr("cm", NULL); if (cap != NULL) cap = tgoto(cap, x, y); if (cap != NULL) { my_putstr_fd(cap); return (1); } return (0);}
开发者ID:Shintouney,项目名称:MixedStuff,代码行数:14,
示例19: set_init/* Output startup string. */voidset_init(void){ char *bp, buf[1024]; int settle; bp = buf; if (tgetstr("pc", &bp) != 0) /* Get/set pad character. */ PC = buf[0];#ifdef TAB3 if (oldmode.c_oflag & (TAB3 | ONLCR | OCRNL | ONLRET)) { oldmode.c_oflag &= (TAB3 | ONLCR | OCRNL | ONLRET); tcsetattr(STDERR_FILENO, TCSADRAIN, &oldmode); }#endif settle = set_tabs(); if (isreset) { bp = buf; if (tgetstr("rs", &bp) != 0 || tgetstr("is", &bp) != 0) { tputs(buf, 0, outc); settle = 1; } bp = buf; if (tgetstr("rf", &bp) != 0 || tgetstr("if", &bp) != 0) { cat(buf); settle = 1; } } if (settle) { (void)putc('/r', stderr); (void)fflush(stderr); (void)sleep(1); /* Settle the terminal. */ }}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:38,
示例20: initkbdvoidinitkbd(){ register struct key_map *kp; register i,j; char *p = keyarea; char *ktmp; static char buf[1024]; /* Why do I have to do this again? */ if (!(ktmp = getenv("TERM"))) { (void) fprintf(stderr, "TERM environment variable not set/n"); exit (1); } if (tgetent(buf, ktmp) <= 0) return; km[0].k_str = tgetstr("kl", &p); km[0].k_val = KEY_LEFT; km[1].k_str = tgetstr("kr", &p); km[1].k_val = KEY_RIGHT; km[2].k_str = tgetstr("ku", &p); km[2].k_val = ctl('p'); km[3].k_str = tgetstr("kd", &p); km[3].k_val = ctl('n'); ktmp = tgetstr("ks",&p); if (ktmp) { (void) strcpy(ks_buf, ktmp); ks = ks_buf; tputs(ks, 1, charout); } ktmp = tgetstr("ke",&p); if (ktmp) { (void) strcpy(ke_buf, ktmp); ke = ke_buf; } /* Unmap arrow keys which conflict with our ctl keys */ /* Ignore unset, longer than length 1, and 1-1 mapped keys */ for (i = 0; i < N_KEY; i++) { kp = &km[i]; if (kp->k_str && (kp->k_str[1] == 0) && (kp->k_str[0] != kp->k_val)) for (j = 0; dont_use[j] != 0; j++) if (kp->k_str[0] == dont_use[j]) { kp->k_str = (char *)0; break; } }#ifdef TIOCSLTC (void)ioctl(fileno(stdin), TIOCGLTC, (char *)&old_chars); new_chars = old_chars; if (old_chars.t_lnextc == ctl('v')) new_chars.t_lnextc = -1; if (old_chars.t_rprntc == ctl('r')) new_chars.t_rprntc = -1; (void)ioctl(fileno(stdin), TIOCSLTC, (char *)&new_chars);#endif}
开发者ID:recalcc,项目名称:sc,代码行数:57,
示例21: initialize_stringsstatic voidinitialize_strings (void){#if HAVE_TPUTS if (find_termcap) { const char *name; /* terminal capability name */ char term_buffer[2048]; /* terminal description */ static char *buffer; /* buffer for capabilities */ char *filler; /* cursor into allocated strings */ int success; /* tgetent results */ name = getenv ("TERM"); if (name == NULL) errexit (1, 0, _("Select a terminal through the TERM environment variable.")); success = tgetent (term_buffer, name); if (success < 0) errexit (1, 0, _("Could not access the termcap data base.")); if (success == 0) errexit (1, 0, _("Terminal type `%s' is not defined."), name); buffer = (char *) malloc (strlen (term_buffer)); filler = buffer; if (no_init_term) { termcap_init_string = NULL; termcap_end_string = NULL; } else { termcap_init_string = tgetstr ("ti", &filler); termcap_end_string = tgetstr ("te", &filler); } term_delete_start = tgetstr ("us", &filler); term_delete_end = tgetstr ("ue", &filler); term_insert_start = tgetstr ("so", &filler); term_insert_end = tgetstr ("se", &filler); }#endif /* HAVE_TPUTS */ /* Ensure some default strings. */ if (!overstrike) { if (!term_delete_start && !user_delete_start) { user_delete_start = "<s><del>"; } if (!term_delete_end && !user_delete_end) { user_delete_end = "</del></s>"; } if (!term_insert_start && !user_insert_start) { user_insert_start = "<u><ins>"; } if (!term_insert_end && !user_insert_end) { user_insert_end = "</ins></u>"; } }}
开发者ID:davidsteinsland,项目名称:htmldiff,代码行数:57,
示例22: ft_select_print_onestatic void ft_select_print_one(t_selector *selector, int index, int *x, int *y){ t_select *select; select = ft_select_recover(); if ((index + ft_selected_get_page_offset()) == select->cursor_index) { tputs(tgetstr("us", NULL), 0, tputs_putchar); select->cursor_x = *x; select->cursor_y = *y - 1; } if (*y == select->win.ws_row) { *y = 0; select->cols++; *x += select->max_len + 2; } if (selector->is_selected) tputs(tgetstr("mr", NULL), 0, tputs_putchar); ft_putstr_fd(selector->str, select->tty); selector->y = *y; tputs(tgetstr("me", NULL), 0, tputs_putchar); tputs(tgoto(tgetstr("cm", NULL), *x, *y), 1, tputs_putchar);}
开发者ID:mywaystar,项目名称:ft_select,代码行数:24,
示例23: turn_onvoid turn_on(struct termios *term){ char buffer[2048]; if (tgetent(buffer, getenv("TERM")) < 1) { write(2, "TERM: not found/n", 16); exit(0); } tcgetattr(0, term); term->c_lflag &= ~(ICANON); term->c_lflag &= ~(ECHO); tputs(tgetstr("ve", NULL), 1, tputs_putchar); tcsetattr(0, 0, term);}
开发者ID:BenjaminRepingon,项目名称:42SH,代码行数:15,
示例24: return_selectedvoid return_selected(t_env *env){ t_item_list *lst; int printed; terminal_normal_mode(); ft_putstr(tgetstr("te", 0)); ft_putstr(tgetstr("ve", 0)); printed = 0; lst = env->items; while (lst) { if (lst->item->selected) { if (printed) ft_putchar(' '); else printed = 1; ft_putstr(lst->item->name); } lst = lst->next; } exit(0);}
开发者ID:acazuc,项目名称:42_ft_select,代码行数:24,
示例25: ft_press_keyint ft_press_key(t_list *list){ char buffer[5]; t_list *tmp; tmp = list; while (42) { ft_action(list); buffer[2] = 0; read(0, buffer, 5); tmp = ft_press_key2(tmp, buffer); if ((buffer[0] == 'q' || buffer[0] == 10) || (buffer[0] == 27 && buffer[2] == 0)) { ft_putstr(tgetstr("cl", NULL)); ft_putstr(tgetstr("me", NULL)); if (buffer[0] == 10) ft_print_list_selected(list); return (0); } } return (0);}
开发者ID:sbran,项目名称:42,代码行数:24,
示例26: print_wordsvoid print_words(t_environment *env){ int row; int column; int current; row = 0; while (row < env->height && row < env->word_count) { ft_putstr_fd(tgoto(tgetstr("cm", NULL), 0, row), 2); ft_putstr_fd(tgetstr("ce", NULL), 2); column = 0; while (((current = (env->height * column) + row)) < env->word_count) { turn_on_special_text(env, current); ft_putstr_fd(env->words[current], 2); turn_off_special_text(env, current); ft_putcharn_fd(' ', env->single_column_width - ft_strlen(env->words[current]), 2); column++; } row++; }}
开发者ID:mokolodi1,项目名称:ft_select,代码行数:24,
示例27: clear_command_linevoid clear_command_line(t_char *list){ int i; int j; int numcols; numcols = get_num_cols(); j = 0; i = 0; while (list) { i++; list = list->next; } tputs(tgetstr("rc", NULL), 1, t_write); while (j <= (i + 3) / numcols) { tputs(tgetstr("ce", NULL), 1, t_write); if ((i + 3) > ((j + 1) * numcols)) tputs(tgetstr("do", NULL), 1, t_write); j++; } tputs(tgetstr("rc", NULL), 1, t_write);}
开发者ID:darkael88,项目名称:42sh,代码行数:24,
示例28: ft_actionint ft_action(t_list *list){ t_list *tmp; ft_putstr(tgetstr("cl", NULL)); tmp = list; ft_action2(tmp); tmp = tmp->next; while (tmp != list) { ft_action2(tmp); tmp = tmp->next; } return (0);}
开发者ID:sbran,项目名称:42,代码行数:15,
示例29: apply_movenextvoid apply_movenext(t_historic **historic){ t_comline *tmp; tmp = (*historic)->copy->comline; if (tmp->c == ' ') tmp = tmp->right; while (tmp && tmp->c != ' ') tmp = tmp->right; while (tmp && tmp->c == ' ') tmp = tmp->right; if (tmp) tmp = tmp->left; if (tmp && tmp->c == ' ') { while ((*historic)->copy->comline->col != tmp->col) { tputs(tgetstr("nd", NULL), 1, aff_c); (*historic)->copy->comline = (*historic)->copy->comline->right; if (check_ending((*historic)->copy->comline)) tputs(tgetstr("do", NULL), 1, aff_c); } }}
开发者ID:kasou,项目名称:42sh,代码行数:24,
注:本文中的tgetstr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tgoto函数代码示例 C++ tgetnum函数代码示例 |