From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19904 invoked from network); 7 Mar 1997 07:45:16 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 7 Mar 1997 07:45:16 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id CAA06138; Fri, 7 Mar 1997 02:21:56 -0500 (EST) Resent-Date: Fri, 7 Mar 1997 02:21:56 -0500 (EST) From: gwing@primenet.com.au Message-ID: <19970307072357.19867.qmail@primenet.com.au> Subject: Zle patch - termok change To: zsh-workers@math.gatech.edu (zsh-workers) Date: Fri, 7 Mar 1997 18:23:57 +1100 (EST) X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: application/pgp; format=text; x-action=sign Content-Transfer-Encoding: 7bit Resent-Message-ID: <"T4uyp2.0.rV1.F8y7p"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2970 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- Heyla, OK, given various comments about this, I've made the following changes: shortterm has gone. termok now is flag based, not value based. termok == 0 indicates a `normal' working terminal - this is *opposite* to the previous situation. Flags for termok are defined and explained in zsh.h - currently TERM_NARROW is unused. If a terminal is evaluated as TERM_BAD then that status shouldn't go until $TERM is changed. If it's TERM_UNKNOWN, then it may still be necessary to call init_term() Bart wrote: :Hmm. Well, I dislike ..... because it presumes that init_term() :is independent of the values of "lines" and "columns". I can't see why lines/columns should be any way connected to init_term() . BTW, init_term() is called from the following bin_echotc(): output a termcap in INTERACTIVE shell and TERM_UNKNOWN is set termsetfn() : when $TERM is set (or may delay until putprompt() ) putprompt() : delayed call for non-INTERACTIVE shells zleread() : when shout changes ^ I don't know why it is necessary in zleread- can someone give me an example? OK, I've previously (hand-)applied patches 2865/2956/2957 to 3.0.3-test4 Files affected: builtin.c zle_main.c init.c zle_misc.c params.c zle_refresh.c utils.c zle_tricky.c zle.h zsh.h I've done a small amount of testing - I'm sending this so others can play with it - (and find my bugs) *** builtin.c-2865-2956-2957 Fri Mar 7 16:22:18 1997 - --- builtin.c Fri Mar 7 17:22:42 1997 *************** *** 4356,4362 **** int num, argct; s = *argv++; ! if (!termok && (isset(INTERACTIVE) || !init_term())) return 1; /* if the specified termcap has a numeric value, display it */ if ((num = tgetnum(s)) != -1) { - --- 4356,4364 ---- int num, argct; s = *argv++; ! if (issetflag(termok, TERM_BAD)) ! return 1; ! if (issetflag(termok, TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term())) return 1; /* if the specified termcap has a numeric value, display it */ if ((num = tgetnum(s)) != -1) { *** init.c-2865-2956-2957 Thu Mar 6 15:24:47 1997 - --- init.c Fri Mar 7 17:00:29 1997 *************** *** 398,405 **** static char termbuf[2048]; /* the termcap buffer */ #endif ! if (!*term) ! return termok = TERM_BAD; /* unset zle if using zsh under emacs */ if (!strcmp(term, "emacs")) - --- 398,407 ---- static char termbuf[2048]; /* the termcap buffer */ #endif ! if (!*term) { ! setflag(termok, TERM_UNKNOWN); ! return 0; ! } /* unset zle if using zsh under emacs */ if (!strcmp(term, "emacs")) *************** *** 415,426 **** if (isset(INTERACTIVE)) zerr("can't find termcap info for %s", term, 0); errflag = 0; ! return termok = TERM_BAD; } else { char tbuf[1024], *pp; int t0; ! termok = TERM_OK; for (t0 = 0; t0 != TC_COUNT; t0++) { pp = tbuf; zsfree(tcstr[t0]); - --- 417,430 ---- if (isset(INTERACTIVE)) zerr("can't find termcap info for %s", term, 0); errflag = 0; ! setflag(termok, TERM_BAD); ! return 0; } else { char tbuf[1024], *pp; int t0; ! unsetflag(termok, TERM_BAD); ! unsetflag(termok, TERM_UNKNOWN); for (t0 = 0; t0 != TC_COUNT; t0++) { pp = tbuf; zsfree(tcstr[t0]); *************** *** 440,448 **** /* if there's no termcap entry for cursor up, use single line mode: * * this is flagged by termok which is examined in zle_refresh.c * */ ! if (!tccan(TCUP)) { ! tcstr[TCUP] = NULL; ! termok = TERM_NOUP; } /* if there's no termcap entry for cursor left, use \b. */ - --- 444,454 ---- /* if there's no termcap entry for cursor up, use single line mode: * * this is flagged by termok which is examined in zle_refresh.c * */ ! if (tccan(TCUP)) ! unsetflag(termok, TERM_NOUP); ! else { ! tcstr[TCUP] = NULL; ! setflag(termok, TERM_NOUP); } /* if there's no termcap entry for cursor left, use \b. */ *************** *** 464,470 **** tclen[TCCLEARSCREEN] = 1; } } ! return termok; } /* Initialize lots of global variables and hash tables */ - --- 470,476 ---- tclen[TCCLEARSCREEN] = 1; } } ! return 1; } /* Initialize lots of global variables and hash tables */ *************** *** 492,498 **** bangchar = '!'; hashchar = '#'; hatchar = '^'; ! termok = TERM_BAD; curjob = prevjob = coprocin = coprocout = -1; gettimeofday(&shtimer, &dummy_tz); /* init $SECONDS */ srand((unsigned int)(shtimer.tv_sec + shtimer.tv_usec)); /* seed $RANDOM */ - --- 498,504 ---- bangchar = '!'; hashchar = '#'; hatchar = '^'; ! termok = TERM_UNKNOWN; curjob = prevjob = coprocin = coprocout = -1; gettimeofday(&shtimer, &dummy_tz); /* init $SECONDS */ srand((unsigned int)(shtimer.tv_sec + shtimer.tv_usec)); /* seed $RANDOM */ *************** *** 590,597 **** createparamtable(); /* create paramater hash table */ #ifdef TIOCGWINSZ ! setintenv("COLUMNS", shttyinfo.winsize.ws_col); /* Fixes termok */ ! setintenv("LINES", shttyinfo.winsize.ws_row); /* Fixes termok */ #else columns = 80; lines = 24; - --- 596,603 ---- createparamtable(); /* create paramater hash table */ #ifdef TIOCGWINSZ ! setintenv("COLUMNS", shttyinfo.winsize.ws_col); ! setintenv("LINES", shttyinfo.winsize.ws_row); #else columns = 80; lines = 24; *** params.c-2865-2956-2957 Thu Mar 6 15:26:06 1997 - --- params.c Fri Mar 7 17:00:40 1997 *************** *** 1248,1268 **** zlevarsetfn(Param pm, long x) { if ((long *)pm->data == & columns) { ! if (x < 3) { if (x <= 0) x = 80; /* Arbitary, but same as init.c */ else x = 2; ! termok = TERM_BAD; ! } else if (columns < 3 && lines >= 3 && termok != TERM_OK) ! init_term(); /* Attempt to reset termok properly */ } else if ((long *)pm->data == & lines) { ! if (x < 3) { if (x <= 0) x = 24; /* Arbitrary, but same as init.c */ ! termok = TERM_NOUP; ! } else if (lines < 3 && columns >= 3 && termok != TERM_OK) ! init_term(); /* Attempt to reset termok properly */ } *((long *)pm->data) = x; - --- 1248,1270 ---- zlevarsetfn(Param pm, long x) { if ((long *)pm->data == & columns) { ! if (x > 2) ! unsetflag(termok, TERM_NARROW); ! else { ! setflag(termok, TERM_NARROW); if (x <= 0) x = 80; /* Arbitary, but same as init.c */ else x = 2; ! } } else if ((long *)pm->data == & lines) { ! if (x > 2) ! unsetflag(termok, TERM_SHORT); ! else { ! setflag(termok, TERM_SHORT); if (x <= 0) x = 24; /* Arbitrary, but same as init.c */ ! } } *((long *)pm->data) = x; *************** *** 1776,1782 **** /* If non-interactive, delay setting up term till we need it. */ if (unset(INTERACTIVE) || !*term) ! termok = TERM_BAD; else init_term(); } - --- 1778,1784 ---- /* If non-interactive, delay setting up term till we need it. */ if (unset(INTERACTIVE) || !*term) ! setflag(termok, TERM_UNKNOWN); else init_term(); } *** utils.c-2865-2956-2957 Thu Mar 6 15:26:06 1997 - --- utils.c Fri Mar 7 17:13:10 1997 *************** *** 861,870 **** } } #endif /* TIOCGWINSZ */ - - if (isset(SINGLELINEZLE) || termok != TERM_OK || lines < 3) /* safety */ - - shortterm = 1; - - else - - shortterm = 0; } /* Move a fd to a place >= 10 and mark the new fd in fdtable. If the fd * - --- 861,866 ---- *** zle.h-2865-2956-2957 Thu Mar 6 15:24:24 1997 - --- zle.h Fri Mar 7 16:46:49 1997 *************** *** 106,114 **** /* height of left prompt */ ZLEXTERN int lppth; - - /* terminal is too short to do anything */ - - ZLEXTERN int shortterm; - - /* last named command done */ ZLEXTERN int lastnamed; - --- 106,111 ---- *** zle_main.c-2865-2956-2957 Fri Mar 7 16:37:58 1997 - --- zle_main.c Fri Mar 7 16:37:58 1997 *************** *** 370,376 **** /* We could be smarter and default to a system read. */ /* If we just got a new shout, make sure the terminal is set up. */ ! if (!termok) init_term(); } - --- 370,376 ---- /* We could be smarter and default to a system read. */ /* If we just got a new shout, make sure the terminal is set up. */ ! if (termok) init_term(); } *************** *** 1109,1115 **** if (cmd < 0) return; trashzle(); ! clearflag = (isset(USEZLE) && termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); printbind(keybuf, (len = strlen(keybuf)) ? len : 1, 0); - --- 1109,1115 ---- if (cmd < 0) return; trashzle(); ! clearflag = (isset(USEZLE) && !termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); printbind(keybuf, (len = strlen(keybuf)) ? len : 1, 0); *************** *** 1156,1162 **** return; funcfound = 0; trashzle(); ! clearflag = (isset(USEZLE) && termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); if (func == z_selfinsert || func == z_undefinedkey) - --- 1156,1162 ---- return; funcfound = 0; trashzle(); ! clearflag = (isset(USEZLE) && !termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); if (func == z_selfinsert || func == z_undefinedkey) *** zle_misc.c-2865-2956-2957 Thu Mar 6 15:24:24 1997 - --- zle_misc.c Fri Mar 7 17:28:13 1997 *************** *** 763,769 **** void tsetcap(int cap, int flag) { ! if (!shortterm) { switch(flag) { case -1: tputs(tcstr[cap], 1, putraw); - --- 763,769 ---- void tsetcap(int cap, int flag) { ! if (!issetflag(termok, TERM_SHORT)) { switch(flag) { case -1: tputs(tcstr[cap], 1, putraw); *************** *** 817,823 **** } pmpth = 1; ! if (!termok && (unset(INTERACTIVE))) init_term(); bracepos = -1; - --- 817,823 ---- } pmpth = 1; ! if (issetflag(termok, TERM_UNKNOWN) && (unset(INTERACTIVE))) init_term(); bracepos = -1; *** zle_refresh.c-2865-2956-2957 Thu Mar 6 15:24:24 1997 - --- zle_refresh.c Fri Mar 7 17:06:46 1997 *************** *** 72,78 **** genprompts(); winw = columns; /* terminal width */ ! if (shortterm) winh = 1; else winh = (lines < 2) ? 24 : lines; - --- 72,78 ---- genprompts(); winw = columns; /* terminal width */ ! if (issetflag(termok, TERM_SHORT)) winh = 1; else winh = (lines < 2) ? 24 : lines; *************** *** 226,254 **** cost = 0; /* reset */ #endif ! /* Nov 96: This looks ugly and I haven't checked how complete it is. ! sgtty stuff may or may not work */ ! #if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H) ! oxtabs = (shttyinfo.tio.c_oflag & ! #else /* we're using sgtty */ ! oxtabs = (shttyinfo.sgttyb.sg_flags & ! #endif ! # ifdef TAB3 ! TAB3) == TAB3; ! # else ! # ifdef OXTABS ! OXTABS) == OXTABS; ! # else ! XTABS) == XTABS; ! # endif ! # endif cleareol = 0; /* unset */ more_start = more_end = 0; /* unset */ ! if (isset(SINGLELINEZLE) || termok != TERM_OK || lines < 3) ! shortterm = 1; else ! shortterm = 0; if (resetneeded) { onumscrolls = 0; setterm(); - --- 226,242 ---- cost = 0; /* reset */ #endif ! /* Nov 96: I haven't checked how complete this is. sgtty stuff may ! or may not work */ ! oxtabs = issetflag(SGTTYFLAG, SGTABTYPE); /* defined in zsh.h */ cleareol = 0; /* unset */ more_start = more_end = 0; /* unset */ ! if (isset(SINGLELINEZLE) || lines < 3 ! || isanysetflag(termok, TERM_NOUP | TERM_BAD | TERM_UNKNOWN)) ! setflag(termok, TERM_SHORT); else ! unsetflag(termok, TERM_SHORT); if (resetneeded) { onumscrolls = 0; setterm(); *************** *** 275,281 **** cleareol = 1; /* request: clear to end of line */ if (t0 > -1) olnct = t0; ! if (shortterm) vcs = 0; else if (!clearflag && lpptlen) zwrite(lpptbuf, lpptlen, 1, shout); - --- 263,269 ---- cleareol = 1; /* request: clear to end of line */ if (t0 > -1) olnct = t0; ! if (issetflag(termok, TERM_SHORT)) vcs = 0; else if (!clearflag && lpptlen) zwrite(lpptbuf, lpptlen, 1, shout); *************** *** 292,298 **** /* now winw equals columns and winh equals lines width comparisons can be made with winw, height comparisons with winh */ ! if (shortterm) { singlerefresh(); return; } - --- 280,286 ---- /* now winw equals columns and winh equals lines width comparisons can be made with winw, height comparisons with winh */ ! if (issetflag(termok, TERM_SHORT)) { singlerefresh(); return; } *** zle_tricky.c-2865-2956-2957 Fri Mar 7 16:39:13 1997 - --- zle_tricky.c Fri Mar 7 16:39:13 1997 *************** *** 2143,2149 **** feep(); trashzle(); ! clearflag = (isset(USEZLE) && termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); - --- 2143,2149 ---- feep(); trashzle(); ! clearflag = (isset(USEZLE) && !termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); *************** *** 3515,3521 **** ct = nmatches; showinglist = 0; ! clearflag = (isset(USEZLE) && termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); - --- 3515,3521 ---- ct = nmatches; showinglist = 0; ! clearflag = (isset(USEZLE) && !termok && (isset(ALWAYSLASTPROMPT) && zmult == 1)) || (unset(ALWAYSLASTPROMPT) && zmult != 1); *** zsh.h-2865-2956-2957 Fri Mar 7 16:20:05 1997 - --- zsh.h Fri Mar 7 17:02:49 1997 *************** *** 63,68 **** - --- 63,74 ---- #define DEFAULT_IFS " \t\n\203 " + /* flag defines */ + #define issetflag(X, Y) ((X & (Y)) == Y) + #define isanysetflag(X, Y) (X & (Y)) + #define setflag(X, Y) X |= (Y) + #define unsetflag(X, Y) X &= ~(Y) + /* Character tokens */ #define Pound ((char) 0x84) #define String ((char) 0x85) *************** *** 1186,1198 **** #endif }; ! /* flags for termok state: usually the test for whether termok * ! * is set is enough: in the refresh code we need to know whether * ! * the terminal has an up capability. */ ! ! #define TERM_BAD 0 ! #define TERM_OK 1 ! #define TERM_NOUP 2 /* interesting termcap strings */ - --- 1192,1220 ---- #endif }; ! /* defines for whether tabs expand to spaces */ ! #if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H) ! #define SGTTYFLAG shttyinfo.tio.c_oflag ! #else /* we're using sgtty */ ! #define SGTTYFLAG shttyinfo.sgttyb.sg_flags ! #endif ! # ifdef TAB3 ! #define SGTABTYPE TAB3 ! # else ! # ifdef OXTABS ! #define SGTABTYPE OXTABS ! # else ! #define SGTABTYPE XTABS ! # endif ! # endif ! ! /* flags for termok */ ! ! #define TERM_BAD 0x01 /* terminal has extremely basic capabilities */ ! #define TERM_UNKNOWN 0x02 /* unknown terminal type */ ! #define TERM_NOUP 0x04 /* terminal has no up capability */ ! #define TERM_SHORT 0x08 /* terminal is < 3 lines high */ ! #define TERM_NARROW 0x10 /* terminal is < 3 columns wide */ /* interesting termcap strings */ - -- Geoff Wing [mason@primenet.com.au] Technical Manager Phone : +61-3-9818 2977 PrimeNet - Internet Consultancy Facsimile: +61-3-9819 3788 Web : Mobile : 0412 162 441 -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia Charset: noconv iQCVAwUBMx/ChekZdFsUTaLFAQHyaAP9Ee0gwQS0D4zm9w0H6jkl4Rbt1MMwK0UY XaE36cbsQuU/el6o+6TESviXMTky8T3Mwv9x3UEaR4odzo7oQRxekjTVy83Fw51r srkoiaCNuQ74S0PNRMHor4cIQBIqWp0w1UZldJz4I9io/wxayYGNvWhWbkSby8oL +xG0GROLXKw= =WiNI -----END PGP SIGNATURE-----