From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eplet.mira.net.au (newsin1.mira.net.au [203.0.120.2]) by werple.net.au (8.7/8.7.1) with ESMTP id PAA07346 for ; Sat, 4 Nov 1995 15:48:48 +1100 (EST) Received: from math.gatech.edu (euclid.skiles.gatech.edu [130.207.146.50]) by eplet.mira.net.au (8.7/8.7) with SMTP id PAA25206 for ; Sat, 4 Nov 1995 15:48:42 +1100 (EST) Received: by math.gatech.edu (SMI-8.6/SMI-SVR4) id XAA02578; Fri, 3 Nov 1995 23:32:07 -0500 Resent-Date: Fri, 3 Nov 1995 23:32:07 -0500 Old-Return-Path: From: Geoff Wing Message-Id: <199511040438.PAA06993@werple.net.au> Subject: zle_refresh.c patch resubmit To: zsh-workers@math.gatech.edu (zsh-list) Date: Sat, 4 Nov 1995 15:38:14 +1100 (EST) X-Mailer: ELM [version 2.4 PL23] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"CbcFD.0.9e.6pkcm"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/528 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Heyla, this is a resubmit of the patches from messages 164 & 273 which don't seem to have made it into the baseline. It fixes the line display in several cases. It also removes a chunk of unnecessary code (which introduced a bug) which was made in rev 1.12 *** zle_refresh.c 1995/10/09 23:53:03 1.17 --- zle_refresh.c 1995/11/04 04:17:48 *************** *** 411,416 **** --- 411,417 ---- { char *nl, *ol, *p1; /* line buffer pointers */ int ccs = 0, /* temporary count for cursor position */ + char_ins = 0, /* number of characters inserted/deleted */ col_cleareol, /* clear to end-of-line from this column */ i, j, /* tmp */ nllen, ollen; /* new and old line buffer lengths */ *************** *** 424,430 **** which need to be written. do this now to allow some pre-processing */ if (cleareol || /* request to clear to end of line */ ! !nllen) { /* no line buffer given */ p1 = halloc(winw + 1); if (nllen) strncpy(p1, nl, nllen); --- 425,432 ---- which need to be written. do this now to allow some pre-processing */ if (cleareol || /* request to clear to end of line */ ! !nllen || /* no line buffer given */ ! (ln == 0 && (put_rpmpt != oput_rpmpt))) { /* prompt changed */ p1 = halloc(winw + 1); if (nllen) strncpy(p1, nl, nllen); *************** *** 432,446 **** p1[winw] = '\0'; nl = p1; nllen = winw; - } else if (ln == 0 && put_rpmpt != oput_rpmpt && winw - 1 > nllen) { - /* prompt changed */ - p1 = halloc(winw); - if (nllen) - strncpy(p1, nl, nllen); - memset(p1 + nllen, ' ', winw - 1 - nllen); - p1[winw - 1] = '\0'; - nl = p1; - nllen = winw - 1; } else if (ollen > nllen) { /* make new line at least as long as old */ p1 = halloc(ollen + 1); strncpy(p1, nl, nllen); --- 434,439 ---- *************** *** 456,462 **** col_cleareol = -1; if (tccan(TCCLEAREOL) && (nllen == winw || /* new buffer goes to the end of the line */ ! !put_rpmpt)) { for (i = nllen; i && nl[i - 1] == ' '; i--); for (j = ollen; j && ol[j - 1] == ' '; j--); if ((j > i + tclen[TCCLEAREOL]) || /* new buf's spaces early enough */ --- 449,455 ---- col_cleareol = -1; if (tccan(TCCLEAREOL) && (nllen == winw || /* new buffer goes to the end of the line */ ! put_rpmpt != oput_rpmpt)) { for (i = nllen; i && nl[i - 1] == ' '; i--); for (j = ollen; j && ol[j - 1] == ' '; j--); if ((j > i + tclen[TCCLEAREOL]) || /* new buf's spaces early enough */ *************** *** 473,480 **** /* skip past all matching characters */ for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ; ! if (!*nl) /* we've finished writing the new line */ ! return; moveto(ln, ccs); /* move to where we do all output from */ --- 466,478 ---- /* skip past all matching characters */ for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ; ! if (!*nl) { ! if ((char_ins <= 0) || (ccs >= winw)) /* written everything */ ! return; ! else /* we've got junk on the right yet to clear */ ! if (tccan(TCCLEAREOL) && (char_ins >= tclen[TCCLEAREOL])) ! col_cleareol = 0; /* force a clear to end of line */ ! } moveto(ln, ccs); /* move to where we do all output from */ *************** *** 485,490 **** --- 483,502 ---- return; } + /* we've written out the new but yet to clear rubbish due to inserts */ + if (!*nl) { + i = (winw - ccs < char_ins) ? (winw - ccs) : char_ins; + if (tccan(TCDEL) && (tcdelcost(i) <= i + 1)) + tc_delchars(i); + else { + SELECT_ADD_COST(i); + vcs += i; + while (i-- > 0) + putc(' ', shout); + } + return; + } + /* if we've reached the end of the old buffer, then there are few tricks we can do, so we just dump out what we must and clear if we can */ if (!*ol) { *************** *** 515,520 **** --- 527,533 ---- tc_delchars(i); SELECT_ADD_COST(i); ol = p1; + char_ins -= i; break; } if (*p1) *************** *** 533,538 **** --- 546,552 ---- fwrite(nl, i, 1, shout); ccs = (vcs += i); nl = p1; + char_ins += i; break; } if (*p1) -- Mason [G.C.W] mason@werple.mira.net.au "Hurt...Agony...Pain...LOVE-IT"