X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Ftinfo_driver.c;h=785847bdc1ec034659a4c77e22a0137f18d9dcc1;hp=e97eff6fc8dfb2cc1a3b3ab1246e0176ada4772f;hb=63e3cafac136d773331dee15633f1c9ef08c5493;hpb=03f728e5bb3630a54fffc4a2ff2f8dbfcce9088e diff --git a/ncurses/tinfo/tinfo_driver.c b/ncurses/tinfo/tinfo_driver.c index e97eff6f..785847bd 100644 --- a/ncurses/tinfo/tinfo_driver.c +++ b/ncurses/tinfo/tinfo_driver.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2008-2010,2011 Free Software Foundation, Inc. * + * Copyright (c) 2008-2013,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -50,7 +50,7 @@ # endif #endif -MODULE_ID("$Id: tinfo_driver.c,v 1.16 2011/10/22 17:50:33 tom Exp $") +MODULE_ID("$Id: tinfo_driver.c,v 1.37 2014/04/13 00:17:08 tom Exp $") /* * SCO defines TIOCGSIZE and the corresponding struct. Other systems (SunOS, @@ -93,7 +93,7 @@ NCURSES_EXPORT_VAR(int) COLORS = 0; #define TCBMAGIC NCDRV_MAGIC(NCDRV_TINFO) #define AssertTCB() assert(TCB!=0 && TCB->magic==TCBMAGIC) -#define SetSP() assert(TCB->csp!=0); sp = TCB->csp +#define SetSP() assert(TCB->csp!=0); sp = TCB->csp; (void) sp /* * This routine needs to do all the work to make curscr look @@ -106,6 +106,13 @@ drv_doupdate(TERMINAL_CONTROL_BLOCK * TCB) return TINFO_DOUPDATE(TCB->csp); } +static const char * +drv_Name(TERMINAL_CONTROL_BLOCK * TCB) +{ + (void) TCB; + return "tinfo"; +} + static bool drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) { @@ -114,12 +121,14 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) TERMINAL *termp; SCREEN *sp; + T((T_CALLED("tinfo::drv_CanHandle(%p)"), TCB)); + assert(TCB != 0 && tname != 0); termp = (TERMINAL *) TCB; sp = TCB->csp; TCB->magic = TCBMAGIC; -#if (USE_DATABASE || USE_TERMCAP) +#if (NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP) status = _nc_setup_tinfo(tname, &termp->type); #else status = TGETENT_NO; @@ -169,7 +178,7 @@ drv_CanHandle(TERMINAL_CONTROL_BLOCK * TCB, const char *tname, int *errret) ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", tname); } - return result; + returnBool(result); } static int @@ -184,22 +193,18 @@ drv_dobeepflash(TERMINAL_CONTROL_BLOCK * TCB, int beepFlag) /* FIXME: should make sure that we are not in altchar mode */ if (beepFlag) { if (bell) { - res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "bell", bell); + res = NCURSES_PUTP2("bell", bell); NCURSES_SP_NAME(_nc_flush) (sp); } else if (flash_screen) { - res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx - "flash_screen", - flash_screen); + res = NCURSES_PUTP2("flash_screen", flash_screen); NCURSES_SP_NAME(_nc_flush) (sp); } } else { if (flash_screen) { - res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx - "flash_screen", - flash_screen); + res = NCURSES_PUTP2("flash_screen", flash_screen); NCURSES_SP_NAME(_nc_flush) (sp); } else if (bell) { - res = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "bell", bell); + res = NCURSES_PUTP2("bell", bell); NCURSES_SP_NAME(_nc_flush) (sp); } } @@ -315,7 +320,7 @@ drv_rescol(TERMINAL_CONTROL_BLOCK * TCB) SetSP(); if (orig_pair != 0) { - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "orig_pair", orig_pair); + NCURSES_PUTP2("orig_pair", orig_pair); result = TRUE; } return result; @@ -331,7 +336,7 @@ drv_rescolors(TERMINAL_CONTROL_BLOCK * TCB) SetSP(); if (orig_colors != 0) { - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "orig_colors", orig_colors); + NCURSES_PUTP2("orig_colors", orig_colors); result = TRUE; } return result; @@ -342,14 +347,18 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) { SCREEN *sp; bool useEnv = TRUE; + bool useTioctl = TRUE; AssertTCB(); sp = TCB->csp; /* can be null here */ if (sp) { useEnv = sp->_use_env; - } else + useTioctl = sp->_use_tioctl; + } else { useEnv = _nc_prescreen.use_env; + useTioctl = _nc_prescreen.use_tioctl; + } /* figure out the size of the screen */ T(("screen size: terminfo lines = %d columns = %d", lines, columns)); @@ -357,7 +366,7 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) *linep = (int) lines; *colp = (int) columns; - if (useEnv) { + if (useEnv || useTioctl) { int value; #ifdef __EMX__ @@ -365,7 +374,9 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) int screendata[2]; _scrsize(screendata); *colp = screendata[0]; - *linep = screendata[1]; + *linep = ((sp != 0 && sp->_filtered) + ? 1 + : screendata[1]); T(("EMX screen size: environment LINES = %d COLUMNS = %d", *linep, *colp)); } @@ -394,19 +405,33 @@ drv_size(TERMINAL_CONTROL_BLOCK * TCB, int *linep, int *colp) } #endif /* HAVE_SIZECHANGE */ - /* - * Finally, look for environment variables. - * - * Solaris lets users override either dimension with an environment - * variable. - */ - if ((value = _nc_getenv_num("LINES")) > 0) { - *linep = value; - T(("screen size: environment LINES = %d", *linep)); - } - if ((value = _nc_getenv_num("COLUMNS")) > 0) { - *colp = value; - T(("screen size: environment COLUMNS = %d", *colp)); + if (useEnv) { + if (useTioctl) { + /* + * If environment variables are used, update them. + */ + if ((sp == 0 || !sp->_filtered) && _nc_getenv_num("LINES") > 0) { + _nc_setenv_num("LINES", *linep); + } + if (_nc_getenv_num("COLUMNS") > 0) { + _nc_setenv_num("COLUMNS", *colp); + } + } + + /* + * Finally, look for environment variables. + * + * Solaris lets users override either dimension with an environment + * variable. + */ + if ((value = _nc_getenv_num("LINES")) > 0) { + *linep = value; + T(("screen size: environment LINES = %d", *linep)); + } + if ((value = _nc_getenv_num("COLUMNS")) > 0) { + *colp = value; + T(("screen size: environment COLUMNS = %d", *colp)); + } } /* if we can't get dynamic info about the size, use static */ @@ -521,7 +546,6 @@ drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag) if (sp) { if (sp->_keypad_on) _nc_keypad(sp, TRUE); - NC_BUFFERED(sp, TRUE); } code = OK; } @@ -547,7 +571,6 @@ drv_mode(TERMINAL_CONTROL_BLOCK * TCB, int progFlag, int defFlag) if (sp) { _nc_keypad(sp, FALSE); NCURSES_SP_NAME(_nc_flush) (sp); - NC_BUFFERED(sp, FALSE); } code = drv_sgmode(TCB, TRUE, &(_term->Ottyb)); } @@ -614,13 +637,11 @@ drv_screen_init(SCREEN *sp) static void drv_init(TERMINAL_CONTROL_BLOCK * TCB) { - SCREEN *sp; TERMINAL *trm; AssertTCB(); trm = (TERMINAL *) TCB; - sp = TCB->csp; TCB->info.initcolor = VALID_STRING(initialize_color); TCB->info.canchange = can_change; @@ -651,7 +672,7 @@ drv_init(TERMINAL_CONTROL_BLOCK * TCB) * baudrate. */ if (isatty(trm->Filedes)) { - TCB->drv->mode(TCB, TRUE, TRUE); + TCB->drv->td_mode(TCB, TRUE, TRUE); } } @@ -675,12 +696,11 @@ drv_initpair(TERMINAL_CONTROL_BLOCK * TCB, int pair, int f, int b) tp[f].red, tp[f].green, tp[f].blue, tp[b].red, tp[b].green, tp[b].blue)); - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx - "initialize_pair", - TPARM_7(initialize_pair, - pair, - tp[f].red, tp[f].green, tp[f].blue, - tp[b].red, tp[b].green, tp[b].blue)); + NCURSES_PUTP2("initialize_pair", + TPARM_7(initialize_pair, + pair, + tp[f].red, tp[f].green, tp[f].blue, + tp[b].red, tp[b].green, tp[b].blue)); } } @@ -712,9 +732,8 @@ drv_initcolor(TERMINAL_CONTROL_BLOCK * TCB, AssertTCB(); if (initialize_color != NULL) { - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx - "initialize_color", - TPARM_4(initialize_color, color, r, g, b)); + NCURSES_PUTP2("initialize_color", + TPARM_4(initialize_color, color, r, g, b)); } } @@ -753,7 +772,7 @@ drv_do_color(TERMINAL_CONTROL_BLOCK * TCB, if (old_pair >= 0 && sp != 0 && NCURSES_SP_NAME(pair_content) (NCURSES_SP_ARGx - old_pair, + (short) old_pair, &old_fg, &old_bg) !=ERR) { if ((isDefaultColor(fg) && !isDefaultColor(old_fg)) @@ -839,7 +858,9 @@ drv_initmouse(TERMINAL_CONTROL_BLOCK * TCB) } static int -drv_testmouse(TERMINAL_CONTROL_BLOCK * TCB, int delay) +drv_testmouse(TERMINAL_CONTROL_BLOCK * TCB, + int delay + EVENTLIST_2nd(_nc_eventlist * evl)) { int rc = 0; SCREEN *sp; @@ -854,11 +875,11 @@ drv_testmouse(TERMINAL_CONTROL_BLOCK * TCB, int delay) } else #endif { - rc = TCBOf(sp)->drv->twait(TCBOf(sp), - TWAIT_MASK, - delay, - (int *) 0 - EVENTLIST_2nd(evl)); + rc = TCBOf(sp)->drv->td_twait(TCBOf(sp), + TWAIT_MASK, + delay, + (int *) 0 + EVENTLIST_2nd(evl)); #if USE_SYSMOUSE if ((sp->_mouse_type == M_SYSMOUSE) && (sp->_sysmouse_head < sp->_sysmouse_tail) @@ -876,7 +897,7 @@ drv_mvcur(TERMINAL_CONTROL_BLOCK * TCB, int yold, int xold, int ynew, int xnew) { SCREEN *sp = TCB->csp; AssertTCB(); - return TINFO_MVCUR(sp, yold, xold, ynew, xnew); + return NCURSES_SP_NAME(_nc_mvcur) (sp, yold, xold, ynew, xnew); } static void @@ -886,9 +907,8 @@ drv_hwlabel(TERMINAL_CONTROL_BLOCK * TCB, int labnum, char *text) AssertTCB(); if (labnum > 0 && labnum <= num_labels) { - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx - "plab_norm", - TPARM_2(plab_norm, labnum, text)); + NCURSES_PUTP2("plab_norm", + TPARM_2(plab_norm, labnum, text)); } } @@ -899,9 +919,9 @@ drv_hwlabelOnOff(TERMINAL_CONTROL_BLOCK * TCB, int OnFlag) AssertTCB(); if (OnFlag) { - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "label_on", label_on); + NCURSES_PUTP2("label_on", label_on); } else { - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "label_off", label_off); + NCURSES_PUTP2("label_off", label_off); } } @@ -942,6 +962,11 @@ drv_conattr(TERMINAL_CONTROL_BLOCK * TCB) if (sp && sp->_coloron) attrs |= A_COLOR; +#if USE_ITALIC + if (enter_italics_mode) + attrs |= A_ITALIC; +#endif + return (attrs); } @@ -966,7 +991,7 @@ drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map) AssertTCB(); assert(sp != 0); if (ena_acs != NULL) { - NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx "ena_acs", ena_acs); + NCURSES_PUTP2("ena_acs", ena_acs); } #if NCURSES_EXT_FUNCS /* @@ -985,7 +1010,7 @@ drv_initacs(TERMINAL_CONTROL_BLOCK * TCB, chtype *real_map, chtype *fake_map) size_t i; for (i = 1; i < ACS_LEN; ++i) { if (real_map[i] == 0) { - real_map[i] = i; + real_map[i] = (chtype) i; if (real_map != fake_map) { if (sp != 0) sp->_screen_acs_map[i] = TRUE; @@ -1068,16 +1093,7 @@ _nc_cookie_init(SCREEN *sp) if (magic_cookie_glitch > 0) { /* tvi, wyse */ - sp->_xmc_triggers = sp->_ok_attributes & ( - A_STANDOUT | - A_UNDERLINE | - A_REVERSE | - A_BLINK | - A_DIM | - A_BOLD | - A_INVIS | - A_PROTECT - ); + sp->_xmc_triggers = sp->_ok_attributes & XMC_CONFLICT; #if 0 /* * We "should" treat colors as an attribute. The wyse350 (and its @@ -1203,7 +1219,7 @@ __nc_putp(SCREEN *sp, const char *name GCC_UNUSED, const char *value) int rc = ERR; if (value) { - rc = NCURSES_SP_NAME(_nc_putp) (NCURSES_SP_ARGx name, value); + rc = NCURSES_PUTP2(name, value); } return rc; } @@ -1296,6 +1312,7 @@ drv_kyExist(TERMINAL_CONTROL_BLOCK * TCB, int key) NCURSES_EXPORT_VAR (TERM_DRIVER) _nc_TINFO_DRIVER = { TRUE, + drv_Name, /* Name */ drv_CanHandle, /* CanHandle */ drv_init, /* init */ drv_release, /* release */