本文整理汇总了C++中setupterm函数的典型用法代码示例。如果您正苦于以下问题:C++ setupterm函数的具体用法?C++ setupterm怎么用?C++ setupterm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setupterm函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: gettermname
static const char *
gettermname(void)
{
char *tname;
static const char **tnamep = NULL;
static const char **next;
int err;
if (resettermname) {
resettermname = 0;
if (tnamep && tnamep != unknown)
free(tnamep);
if ((tname = env_getvalue("TERM")) &&
(setupterm(tname, 1, &err) == 0)) {
tnamep = mklist(termbuf, tname);
} else {
if (tname && (strlen(tname) <= 40)) {
unknown[0] = tname;
upcase(tname);
} else
unknown[0] = name_unknown;
tnamep = unknown;
}
next = tnamep;
}
if (*next == NULL)
next = tnamep;
return(*next++);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:29,代码来源:telnet.c
示例2: sial_setofile
void
sial_setofile(void * f)
{
int out;
int ret;
char *term;
ofile=(FILE *)f;
bold_on="";
bold_off="";
cols=80;
out=fileno(ofile);
if(isatty(out))
{
if(!(term = getenv ("TERM"))) term="dumb";
if(setupterm(term, out, &ret)!=ERR)
{
bold_on=tigetstr("bold");
if(!bold_on) bold_on="";
bold_off=tigetstr("sgr0");
if(!bold_off) bold_off="";
}
sial_getwinsize();
}
}
开发者ID:Meticulus,项目名称:vendor_st-ericsson_u8500,代码行数:28,代码来源:sial_util.c
示例3: rt_setupterm
/*
* TermInfo#setupterm(term, fd) => int
*
* TermInfo#setupterm initializes TermInfo object.
*
* term is a string of nil.
* If nil is given, the environment variable $TERM is used.
*
* fd is a file descriptor for target terminal.
*/
static VALUE
rt_setupterm(VALUE self, VALUE v_term, VALUE v_fd)
{
char *term;
int fd;
int err;
int ret;
if (check_rt(self) != NULL) { rb_raise(eTermInfoError, "terminfo object already initialized"); }
if (v_term == Qnil)
term = NULL;
else
term = StringValueCStr(v_term);
fd = NUM2INT(v_fd);
ret = setupterm(term, fd, &err);
if (ret == ERR) {
if (err == 1) rb_raise(eTermInfoError, "hardcopy terminal");
else if (err == 0) rb_raise(eTermInfoError, "terminal could not be found");
else if (err == -1) rb_raise(eTermInfoError, "terminfo database could not be found");
else rb_raise(eTermInfoError, "unexpected setupterm error");
}
DATA_PTR(self) = cur_term;
return INT2NUM(err);
}
开发者ID:akr,项目名称:ruby-terminfo,代码行数:37,代码来源:terminfo.c
示例4: tgetent
/* ARGSUSED */
int
tgetent(__unused char *bp, const char *name)
{
int errret;
static TERMINAL *last = NULL;
_DIAGASSERT(name != NULL);
/* Free the old term */
if (cur_term != NULL) {
if (last != NULL && cur_term != last)
del_curterm(last);
last = cur_term;
}
errret = -1;
if (setupterm(name, STDOUT_FILENO, &errret) != 0)
return errret;
if (last == NULL)
last = cur_term;
if (pad_char != NULL)
PC = pad_char[0];
UP = __UNCONST(cursor_up);
BC = __UNCONST(cursor_left);
return 1;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:28,代码来源:termcap.c
示例5: line_editor_build_sequences
/*
** Builds termcaps sequences
** @params self, env
** @return bool; Success => TRUE, Error => FALSE
*/
bool line_editor_build_sequences(t_line_editor *self, char **env)
{
int ret;
char *key_pad;
setupterm(get_term(env), 1, &ret);
if (ret <= 0)
return (false);
if ((key_pad = tigetstr("smkx")) == NULL)
return (false);
putp(key_pad);
if ((self->keys[L_KEY_LEFT].sequence = dup_key("kcub1")) == NULL)
return (false);
self->keys[L_KEY_LEFT].handle = line_editor_handle_left;
if ((self->keys[L_KEY_RIGHT].sequence = dup_key("kcuf1")) == NULL)
return (false);
self->keys[L_KEY_RIGHT].handle = line_editor_handle_right;
if ((self->keys[L_KEY_UP].sequence = dup_key("kcuu1")) == NULL)
return (false);
self->keys[L_KEY_UP].handle = line_editor_handle_up;
if ((self->keys[L_KEY_DOWN].sequence = dup_key("kcud1")) == NULL)
return (false);
self->keys[L_KEY_DOWN].handle = line_editor_handle_down;
if (line_editor_build_second_sequences(self) == false)
return (false);
return (true);
}
开发者ID:vdnet,项目名称:42sh_2016,代码行数:32,代码来源:build_sequences.c
示例6: main
int main(int argc, const char *argv[])
{
setupterm("unlist", fileno(stdout), (int *)0);
printf("Done.\n");
return 0;
}
开发者ID:linq,项目名称:unix_learn,代码行数:7,代码来源:badterm.c
示例7: setupterm
int FocusClient::init ()
{
rts2core::Configuration *config;
int ret;
ret = rts2core::Client::init ();
if (ret)
return ret;
setupterm (NULL, 2, NULL);
signal (SIGWINCH, signal_winch);
config = rts2core::Configuration::instance ();
ret = config->loadFile (configFile);
if (ret)
{
std::cerr << "Cannot load configuration file '"
<< (configFile ? configFile : "/etc/rts2/rts2.ini")
<< ")" << std::endl;
return ret;
}
addTimer (CHECK_TIMER, new rts2core::Event (EVENT_EXP_CHECK));
return 0;
}
开发者ID:RTS2,项目名称:rts2,代码行数:25,代码来源:focusclient.cpp
示例8: init_tty
void
init_tty(void)
{
struct termios new_attributes;
int i;
if ((tty_in = fopen("/dev/tty", "r")) == NULL) {
err(1, "fopen");
}
tcgetattr(fileno(tty_in), &original_attributes);
new_attributes = original_attributes;
new_attributes.c_lflag &= ~(ICANON | ECHO);
tcsetattr(fileno(tty_in), TCSANOW, &new_attributes);
if ((tty_out = fopen("/dev/tty", "w")) == NULL)
err(1, "fopen");
setupterm((char *)0, fileno(tty_out), (int *)0);
if (use_alternate_screen)
tty_putp(enter_ca_mode);
/* Emit enough lines to fit all choices. */
for (i = 0; i < (ssize_t)choices.length && i < lines - 1; ++i)
tty_putp(cursor_down);
for (; i > 0; --i)
tty_putp(cursor_up);
tty_putp(save_cursor);
signal(SIGINT, handle_sigint);
}
开发者ID:ScoreUnder,项目名称:pick,代码行数:32,代码来源:pick.c
示例9: init_terminal
static void init_terminal(struct setterm_control *ctl)
{
int term_errno;
if (!ctl->opt_te_terminal_name) {
ctl->opt_te_terminal_name = getenv("TERM");
if (ctl->opt_te_terminal_name == NULL)
errx(EXIT_FAILURE, _("$TERM is not defined."));
}
/* Find terminfo entry. */
if (setupterm(ctl->opt_te_terminal_name, STDOUT_FILENO, &term_errno))
switch (term_errno) {
case -1:
errx(EXIT_FAILURE, _("terminfo database cannot be found"));
case 0:
errx(EXIT_FAILURE, _("%s: unknown terminal type"), ctl->opt_te_terminal_name);
case 1:
errx(EXIT_FAILURE, _("terminal is hardcopy"));
}
/* See if the terminal is a virtual console terminal. */
ctl->vcterm = (!strncmp(ctl->opt_te_terminal_name, "con", 3) ||
!strncmp(ctl->opt_te_terminal_name, "linux", 5));
}
开发者ID:Webster-WXH,项目名称:util-linux,代码行数:25,代码来源:setterm.c
示例10: input_init
int input_init()
{
if( is_init )
return 1;
is_init = 1;
input_common_init( &interrupt_handler );
if( setupterm( 0, STDOUT_FILENO, 0) == ERR )
{
debug( 0, _( L"Could not set up terminal" ) );
exit(1);
}
output_set_term( env_get( L"TERM" ) );
input_terminfo_init();
/*
If we have no keybindings, add a few simple defaults
*/
if( !al_get_count( &mappings ) )
{
input_mapping_add( L"", L"self-insert" );
input_mapping_add( L"\n", L"execute" );
input_mapping_add( L"\t", L"complete" );
input_mapping_add( L"\x3", L"commandline \"\"" );
input_mapping_add( L"\x4", L"exit" );
input_mapping_add( L"\x5", L"bind" );
}
return 1;
}
开发者ID:cardmagic,项目名称:lucash,代码行数:33,代码来源:input.c
示例11: term_init
void
term_init(void)
{
setupterm(NULL, 1, NULL);
if (tcgetattr(0, &term_init_termios) < 0)
epanic("failed to get terminal attributes");
// Handle terminal resize
struct sigaction act = {
.sa_handler = term_on_sigwinch
};
if (sigaction(SIGWINCH, &act, NULL) < 0)
epanic("failed to install SIGWINCH handler");
atexit(term_reset);
term_initialized = true;
// Enter cursor mode
putp(enter_ca_mode);
// Enter invisible mode
putp(cursor_invisible);
// Disable echo and enter canonical (aka cbreak) mode so we
// get input without waiting for newline
struct termios tc = term_init_termios;
tc.c_lflag &= ~(ICANON | ECHO);
tc.c_iflag &= ~ICRNL;
tc.c_lflag |= ISIG;
tc.c_cc[VMIN] = 1;
tc.c_cc[VTIME] = 0;
if (tcsetattr(0, TCSAFLUSH, &tc) < 0)
epanic("failed to set terminal attributes");
}
开发者ID:aclements,项目名称:cpubars,代码行数:32,代码来源:cpubars.c
示例12: getchoice
int getchoice(char *greet, char *choices[], FILE *in, FILE *out)
{
int chosen = 0;
int selected;
char **option;
int screenrow = 0, screencol = 10;
char *cursor, *clear;
output_stream = out;
setupterm(NULL, fileno(out), (int *)0);
cursor = tigetstr("cup");
clear = tigetstr("clear");
screenrow = 4;
tputs(clear, 1, (int *) char_to_terminal);
tputs(tparm(cursor, screenrow, screencol), 1, char_to_terminal);
fprintf(out, "Choice: %s", greet);
screenrow += 2;
option = choices;
while(*option){
tputs(tparm(cursor, screenrow, screencol), 1, char_to_terminal);
fprintf(out, "%s", *option);
screenrow ++;
option ++;
}
fprintf(out, "\n");
do{
fflush(out);
selected = fgetc(in);
option = choices;
while(*option){
if(selected == *option[0]){
chosen = 1;
break;
}
option ++;
}
if(!chosen){
tputs(tparm(cursor, screenrow, screencol), 1, char_to_terminal);
fprintf(out, "Incorrect choice, select again\n");
}
}while(!chosen);
tputs(clear, 1, char_to_terminal);
return selected;
}
开发者ID:BlueCabbage,项目名称:BeginningLinuxProgramming,代码行数:59,代码来源:menu5.c
示例13: setup_terminal
static int setup_terminal(char *term)
{
int ret;
if (setupterm(term, STDOUT_FILENO, &ret) != OK || ret != 1)
return -1;
return 0;
}
开发者ID:marineam,项目名称:util-linux,代码行数:8,代码来源:cal.c
示例14: main
int main(void)
{
int nrows, ncols;
setupterm(NULL, fileno(stdout), (int *)0);
nrows = tigetnum("lines");
ncols = tigetnum("cols");
printf("This terminal has %d columns and %d rows\n", ncols, nrows);
exit(0);
}
开发者ID:initpidzero,项目名称:circular_buffer,代码行数:9,代码来源:sizeterm.c
示例15: detect_colors
/**
* Detect if we can generate colored output
*/
bool detect_colors() {
int erret = 0;
if(setupterm(NULL, 1, &erret) == ERR) {
return false;
}
// colorize if the terminal supports colors and we're writing to a terminal
return has_colors() && isatty(STDOUT_FILENO);
}
开发者ID:susannvorberg,项目名称:CCMpred,代码行数:12,代码来源:ccmpred.c
示例16: main
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;
}
开发者ID:crowejoshua,项目名称:markdown-to-terminal,代码行数:9,代码来源:cursesdemo.c
示例17: mcurses_init
void mcurses_init()
{
if(setupterm(NULL, STDOUT_FILENO, (int*) 0) == ERR) {
fprintf(stderr, "invalid TERM setting");
exit(1);
}
gMCTtyFd = open("/dev/tty", O_RDWR);
}
开发者ID:ab25cq,项目名称:xyzsh,代码行数:9,代码来源:curses.c
示例18: initputvar
static void initputvar() {
if (putvarc)
free(putvarc);
putvarc=(char *)calloc(256, sizeof(char));
putvari=0;
if (!istermsetup)
istermsetup = (OK == setupterm(NULL, STDERR_FILENO, NULL));
}
开发者ID:kvj,项目名称:MasterPasswordCli,代码行数:9,代码来源:mpw-util.c
示例19: setup_terminal
static int setup_terminal(char *term)
{
#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW)
int ret;
if (setupterm(term, STDOUT_FILENO, &ret) != OK || ret != 1)
return -1;
#endif
return 0;
}
开发者ID:Kaligule,项目名称:util-linux,代码行数:10,代码来源:cal.c
示例20: sc_isAvailable
int
sc_isAvailable ()
{
int err;
if (setupterm((char *)0, 1, &err) == ERR)
return FALSE;
return tigetstr("cup") != NULL;
}
开发者ID:krfkeith,项目名称:slate-language,代码行数:10,代码来源:ncurses-console.c
注:本文中的setupterm函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论