Home | History | Annotate | Line # | Download | only in libcurses
color.c revision 1.12
      1  1.12      jdc /*	$NetBSD: color.c,v 1.12 2000/05/06 19:03:39 jdc Exp $	*/
      2   1.1      jdc 
      3   1.1      jdc /*
      4   1.1      jdc  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5   1.1      jdc  * All rights reserved.
      6   1.1      jdc  *
      7   1.1      jdc  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1      jdc  * by Julian Coleman.
      9   1.1      jdc  *
     10   1.1      jdc  * Redistribution and use in source and binary forms, with or without
     11   1.1      jdc  * modification, are permitted provided that the following conditions
     12   1.1      jdc  * are met:
     13   1.1      jdc  * 1. Redistributions of source code must retain the above copyright
     14   1.1      jdc  *    notice, this list of conditions and the following disclaimer.
     15   1.1      jdc  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1      jdc  *    notice, this list of conditions and the following disclaimer in the
     17   1.1      jdc  *    documentation and/or other materials provided with the distribution.
     18   1.1      jdc  * 3. All advertising materials mentioning features or use of this software
     19   1.1      jdc  *    must display the following acknowledgement:
     20   1.1      jdc  *        This product includes software developed by the NetBSD
     21   1.1      jdc  *        Foundation, Inc. and its contributors.
     22   1.1      jdc  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23   1.1      jdc  *    contributors may be used to endorse or promote products derived
     24   1.1      jdc  *    from this software without specific prior written permission.
     25   1.1      jdc  *
     26   1.1      jdc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27   1.1      jdc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28   1.1      jdc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29   1.1      jdc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30   1.1      jdc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31   1.1      jdc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32   1.1      jdc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33   1.1      jdc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34   1.1      jdc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35   1.1      jdc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36   1.1      jdc  * POSSIBILITY OF SUCH DAMAGE.
     37   1.1      jdc  */
     38   1.8    blymn 
     39   1.8    blymn #include <sys/cdefs.h>
     40   1.8    blymn #ifndef lint
     41  1.12      jdc __RCSID("$NetBSD: color.c,v 1.12 2000/05/06 19:03:39 jdc Exp $");
     42   1.8    blymn #endif				/* not lint */
     43   1.1      jdc 
     44   1.1      jdc #include "curses.h"
     45   1.1      jdc #include "curses_private.h"
     46   1.1      jdc 
     47   1.9      jdc /* the following is defined and set up in setterm.c */
     48   1.9      jdc extern struct tinfo *_cursesi_genbuf;
     49   1.9      jdc 
     50   1.1      jdc /* Maximum colours */
     51   1.1      jdc #define	MAX_COLORS	64
     52   1.1      jdc /* Maximum colour pairs - determined by number of colour bits in attr_t */
     53   1.1      jdc #define	MAX_PAIRS	64	/* PAIR_NUMBER(__COLOR) + 1 */
     54   1.1      jdc 
     55   1.1      jdc /* Flags for colours and pairs */
     56   1.1      jdc #define	__USED		0x01
     57   1.1      jdc 
     58   1.1      jdc /* List of colours */
     59   1.1      jdc struct color {
     60   1.1      jdc 	short	num;
     61   1.1      jdc 	short	red;
     62   1.1      jdc 	short	green;
     63   1.1      jdc 	short	blue;
     64   1.1      jdc 	int	flags;
     65   1.1      jdc } colors[MAX_COLORS];
     66   1.1      jdc 
     67   1.1      jdc /* List of colour pairs */
     68   1.1      jdc struct pair {
     69   1.1      jdc 	short	fore;
     70   1.1      jdc 	short	back;
     71   1.1      jdc 	int	flags;
     72   1.1      jdc } pairs[MAX_PAIRS];
     73   1.1      jdc 
     74   1.1      jdc /* Attributes that clash with colours */
     75   1.1      jdc attr_t	__nca;
     76   1.1      jdc 
     77   1.1      jdc /* Style of colour manipulation */
     78   1.1      jdc #define COLOR_NONE	0
     79   1.1      jdc #define COLOR_ANSI	1	/* ANSI/DEC-style colour manipulation */
     80   1.1      jdc #define COLOR_HP	2	/* HP-style colour manipulation */
     81   1.1      jdc #define COLOR_TEK	3	/* Tektronix-style colour manipulation */
     82   1.6      jdc #define COLOR_OTHER	4	/* None of the others but can set fore/back */
     83   1.1      jdc int	__color_type = COLOR_NONE;
     84   1.1      jdc 
     85   1.2      jdc static void
     86   1.2      jdc __change_pair __P((short));
     87   1.1      jdc /*
     88   1.1      jdc  * has_colors --
     89   1.1      jdc  *	Check if terminal has colours.
     90   1.1      jdc  */
     91   1.1      jdc bool
     92   1.3    blymn has_colors(void)
     93   1.1      jdc {
     94  1.12      jdc 	if (cO > 0 && PA > 0 && ((af != NULL && ab != NULL) || iP != NULL ||
     95  1.12      jdc 	    iC != NULL || (sB != NULL && sF != NULL)))
     96   1.1      jdc 		return(TRUE);
     97   1.1      jdc 	else
     98   1.1      jdc 		return(FALSE);
     99   1.1      jdc }
    100   1.1      jdc 
    101   1.1      jdc /*
    102   1.1      jdc  * can_change_colors --
    103   1.1      jdc  *	Check if terminal can change colours.
    104   1.1      jdc  */
    105   1.1      jdc bool
    106   1.3    blymn can_change_colors(void)
    107   1.1      jdc {
    108   1.1      jdc 	if (CC)
    109   1.1      jdc 		return(TRUE);
    110   1.1      jdc 	else
    111   1.1      jdc 		return(FALSE);
    112   1.1      jdc }
    113   1.1      jdc 
    114   1.1      jdc /*
    115   1.1      jdc  * start_color --
    116   1.1      jdc  *	Initialise colour support.
    117   1.1      jdc  */
    118   1.1      jdc int
    119   1.5    blymn start_color(void)
    120   1.1      jdc {
    121   1.1      jdc 	int	i;
    122   1.1      jdc 	attr_t	temp_nc;
    123   1.1      jdc 
    124   1.1      jdc 	if (has_colors() == FALSE)
    125   1.1      jdc 		return(ERR);
    126   1.1      jdc 
    127   1.1      jdc 	/* Max colours and colour pairs */
    128   1.1      jdc 	if (cO == -1)
    129   1.1      jdc 		COLORS = 0;
    130   1.1      jdc 	else {
    131   1.1      jdc 		COLORS = cO > MAX_COLORS ? MAX_COLORS : cO;
    132   1.1      jdc 		if (PA == -1) {
    133   1.1      jdc 			COLOR_PAIRS = 0;
    134   1.1      jdc 			COLORS = 0;
    135   1.1      jdc 		} else {
    136   1.1      jdc 			COLOR_PAIRS = PA > MAX_PAIRS ? MAX_PAIRS : PA;
    137   1.1      jdc 		}
    138   1.1      jdc 	}
    139   1.6      jdc 	if (!COLORS)
    140   1.6      jdc 		return (ERR);
    141   1.1      jdc 
    142   1.1      jdc 	/* Reset terminal colour and colour pairs. */
    143   1.1      jdc 	if (OC != NULL)
    144   1.1      jdc 		tputs(OC, 0, __cputchar);
    145   1.1      jdc 	if (OP != NULL) {
    146   1.1      jdc 		tputs(OP, 0, __cputchar);
    147  1.11  mycroft 		curscr->wattr &= __mask_OP;
    148   1.1      jdc 	}
    149   1.1      jdc 
    150   1.7      jdc 	/* Type of colour manipulation - ANSI/TEK/HP/other */
    151   1.1      jdc 	if (af != NULL && ab != NULL)
    152   1.1      jdc 		__color_type = COLOR_ANSI;
    153   1.1      jdc 	else if (iP != NULL)
    154   1.1      jdc 		__color_type = COLOR_HP;
    155   1.1      jdc 	else if (iC != NULL)
    156   1.1      jdc 		__color_type = COLOR_TEK;
    157   1.6      jdc 	else if (sB != NULL && sF != NULL)
    158   1.6      jdc 		__color_type = COLOR_OTHER;
    159   1.1      jdc 	else
    160   1.1      jdc 		return(ERR);		/* Unsupported colour method */
    161   1.1      jdc 
    162   1.1      jdc #ifdef DEBUG
    163   1.6      jdc 	__CTRACE("start_color: COLORS = %d, COLOR_PAIRS = %d",
    164   1.6      jdc 	    COLORS, COLOR_PAIRS);
    165   1.1      jdc 	switch (__color_type) {
    166   1.1      jdc 	case COLOR_ANSI:
    167   1.6      jdc 		__CTRACE(" (ANSI style)\n");
    168   1.1      jdc 		break;
    169   1.1      jdc 	case COLOR_HP:
    170   1.6      jdc 		__CTRACE(" (HP style)\n");
    171   1.1      jdc 		break;
    172   1.1      jdc 	case COLOR_TEK:
    173   1.6      jdc 		__CTRACE(" (Tektronics style)\n");
    174   1.6      jdc 		break;
    175   1.6      jdc 	case COLOR_OTHER:
    176   1.6      jdc 		__CTRACE(" (Other style)\n");
    177   1.1      jdc 		break;
    178   1.1      jdc 	}
    179   1.1      jdc #endif
    180   1.1      jdc 
    181   1.1      jdc 	/*
    182   1.1      jdc 	 * Attributes that cannot be used with color.
    183   1.1      jdc 	 * Store these in an attr_t for wattrset()/wattron().
    184   1.1      jdc 	 */
    185   1.1      jdc 	__nca = __NORMAL;
    186   1.1      jdc 	if (nc != -1) {
    187   1.9      jdc 		temp_nc = (attr_t) t_getnum(_cursesi_genbuf, "NC");
    188   1.1      jdc 		if (temp_nc & 0x0001)
    189   1.1      jdc 			__nca |= __STANDOUT;
    190   1.1      jdc 		if (temp_nc & 0x0002)
    191   1.1      jdc 			__nca |= __UNDERSCORE;
    192   1.1      jdc 		if (temp_nc & 0x0004)
    193   1.1      jdc 			__nca |= __REVERSE;
    194   1.1      jdc 		if (temp_nc & 0x0008)
    195   1.1      jdc 			__nca |= __BLINK;
    196   1.1      jdc 		if (temp_nc & 0x0010)
    197   1.1      jdc 			__nca |= __DIM;
    198   1.1      jdc 		if (temp_nc & 0x0020)
    199   1.1      jdc 			__nca |= __BOLD;
    200   1.1      jdc 		if (temp_nc & 0x0040)
    201   1.1      jdc 			__nca |= __BLANK;
    202   1.1      jdc 		if (temp_nc & 0x0080)
    203   1.1      jdc 			__nca |= __PROTECT;
    204   1.1      jdc 		if (temp_nc & 0x0100)
    205   1.1      jdc 			__nca |= __ALTCHARSET;
    206   1.1      jdc 	}
    207   1.1      jdc #ifdef DEBUG
    208   1.6      jdc 	__CTRACE ("start_color: __nca = %d\n", __nca);
    209   1.1      jdc #endif
    210   1.9      jdc 
    211   1.9      jdc 	/* Set up initial 8 colours */
    212   1.9      jdc 	if (COLORS >= COLOR_BLACK)
    213   1.9      jdc 		(void) init_color(COLOR_BLACK, 0, 0, 0);
    214   1.9      jdc 	if (COLORS >= COLOR_RED)
    215   1.9      jdc 		(void) init_color(COLOR_RED, 1000, 0, 0);
    216   1.9      jdc 	if (COLORS >= COLOR_GREEN)
    217   1.9      jdc 		(void) init_color(COLOR_GREEN, 0, 1000, 0);
    218   1.9      jdc 	if (COLORS >= COLOR_YELLOW)
    219   1.9      jdc 		(void) init_color(COLOR_YELLOW, 1000, 1000, 0);
    220   1.9      jdc 	if (COLORS >= COLOR_BLUE)
    221   1.9      jdc 		(void) init_color(COLOR_BLUE, 0, 0, 1000);
    222   1.9      jdc 	if (COLORS >= COLOR_MAGENTA)
    223   1.9      jdc 		(void) init_color(COLOR_MAGENTA, 1000, 0, 1000);
    224   1.9      jdc 	if (COLORS >= COLOR_CYAN)
    225   1.9      jdc 		(void) init_color(COLOR_CYAN, 0, 1000, 1000);
    226   1.9      jdc 	if (COLORS >= COLOR_WHITE)
    227   1.9      jdc 		(void) init_color(COLOR_WHITE, 1000, 1000, 1000);
    228   1.9      jdc 
    229   1.9      jdc 	/* Initialise other colours */
    230   1.9      jdc 	for (i = 8; i < COLORS; i++) {
    231   1.9      jdc 		colors[i].red = 0;
    232   1.9      jdc 		colors[i].green = 0;
    233   1.9      jdc 		colors[i].blue = 0;
    234   1.9      jdc 		colors[i].flags = 0;
    235   1.9      jdc 	}
    236   1.9      jdc 
    237   1.9      jdc 	/* Initialise colour pairs to default (white on black) */
    238   1.9      jdc 	for (i = 0; i < COLOR_PAIRS; i++) {
    239   1.9      jdc 		pairs[i].fore = COLOR_WHITE;
    240   1.9      jdc 		pairs[i].back = COLOR_BLACK;
    241   1.9      jdc 		pairs[i].flags = 0;
    242   1.9      jdc 	}
    243   1.9      jdc 
    244   1.1      jdc 	return(OK);
    245   1.1      jdc }
    246   1.1      jdc 
    247   1.1      jdc /*
    248   1.1      jdc  * init_pair --
    249   1.1      jdc  *	Set pair foreground and background colors.
    250   1.1      jdc  */
    251   1.1      jdc int
    252   1.3    blymn init_pair(short pair, short fore, short back)
    253   1.1      jdc {
    254   1.1      jdc 	int	changed;
    255   1.1      jdc 
    256   1.1      jdc #ifdef DEBUG
    257   1.1      jdc 	__CTRACE("init_pair: %d, %d, %d\n", pair, fore, back);
    258   1.1      jdc #endif
    259  1.10  mycroft 
    260   1.1      jdc 	if (pair < 0 || pair >= COLOR_PAIRS)
    261  1.10  mycroft 		return (ERR);
    262  1.10  mycroft 	if (fore < 0 || fore >= COLORS)
    263  1.10  mycroft 		return (ERR);
    264  1.10  mycroft 	if (back < 0 || back >= COLORS)
    265  1.10  mycroft 		return (ERR);
    266   1.1      jdc 
    267   1.1      jdc 	if ((pairs[pair].flags & __USED) && (fore != pairs[pair].fore ||
    268   1.1      jdc 	    back != pairs[pair].back))
    269   1.1      jdc 		changed = 1;
    270   1.1      jdc 	else
    271   1.1      jdc 		changed = 0;
    272   1.1      jdc 
    273   1.1      jdc 	pairs[pair].flags |= __USED;
    274  1.10  mycroft 	pairs[pair].fore = fore;
    275  1.10  mycroft 	pairs[pair].back = back;
    276   1.1      jdc 
    277   1.1      jdc 	/* XXX: need to initialise HP style (iP) */
    278   1.1      jdc 
    279  1.10  mycroft 	if (changed)
    280  1.10  mycroft 		__change_pair(pair);
    281  1.10  mycroft 	return (OK);
    282   1.1      jdc }
    283   1.1      jdc 
    284   1.1      jdc /*
    285   1.1      jdc  * pair_content --
    286   1.1      jdc  *	Get pair foreground and background colours.
    287   1.1      jdc  */
    288   1.1      jdc int
    289   1.3    blymn pair_content(short pair, short *forep, short *backp)
    290   1.1      jdc {
    291   1.1      jdc 	if (pair < 0 || pair >= COLOR_PAIRS)
    292   1.1      jdc 		return(ERR);
    293   1.1      jdc 
    294   1.1      jdc 	*forep = pairs[pair].fore;
    295   1.1      jdc 	*backp = pairs[pair].back;
    296   1.1      jdc 	return(OK);
    297   1.1      jdc }
    298   1.1      jdc 
    299   1.1      jdc /*
    300   1.1      jdc  * init_color --
    301   1.1      jdc  *	Set colour red, green and blue values.
    302   1.1      jdc  */
    303   1.1      jdc int
    304   1.3    blymn init_color(short color, short red, short green, short blue)
    305   1.1      jdc {
    306   1.1      jdc #ifdef DEBUG
    307   1.1      jdc 	__CTRACE("init_color: %d, %d, %d, %d\n", color, red, green, blue);
    308   1.1      jdc #endif
    309   1.1      jdc 	if (color < 0 || color >= COLORS)
    310   1.1      jdc 		return(ERR);
    311   1.1      jdc 
    312   1.1      jdc 	colors[color].red = red;
    313   1.1      jdc 	colors[color].green = green;
    314   1.1      jdc 	colors[color].blue = blue;
    315   1.1      jdc 	/* XXX Not yet implemented */
    316   1.1      jdc 	return(ERR);
    317   1.6      jdc 	/* XXX: need to initialise Tek style (iC) and support HLS */
    318   1.1      jdc }
    319   1.1      jdc 
    320   1.1      jdc /*
    321   1.1      jdc  * color_content --
    322   1.1      jdc  *	Get colour red, green and blue values.
    323   1.1      jdc  */
    324   1.1      jdc int
    325   1.3    blymn color_content(short color, short *redp, short *greenp, short *bluep)
    326   1.1      jdc {
    327   1.1      jdc 	if (color < 0 || color >= COLORS)
    328   1.1      jdc 		return(ERR);
    329   1.1      jdc 
    330   1.1      jdc 	*redp = colors[color].red;
    331   1.1      jdc 	*greenp = colors[color].green;
    332   1.1      jdc 	*bluep = colors[color].blue;
    333   1.1      jdc 	return(OK);
    334   1.1      jdc }
    335   1.1      jdc 
    336   1.1      jdc /*
    337   1.1      jdc  * __set_color --
    338   1.1      jdc  *	Set terminal foreground and background colours.
    339   1.1      jdc  */
    340   1.1      jdc void
    341   1.3    blymn __set_color(attr_t attr)
    342   1.1      jdc {
    343   1.1      jdc 	short	pair;
    344   1.1      jdc 
    345   1.1      jdc 	pair = PAIR_NUMBER(attr);
    346   1.1      jdc #ifdef DEBUG
    347   1.1      jdc 	__CTRACE("__set_color: %d, %d, %d\n", pair, pairs[pair].fore,
    348   1.1      jdc 	    pairs[pair].back);
    349   1.1      jdc #endif
    350   1.1      jdc 	switch (__color_type) {
    351   1.1      jdc 	/* Set ANSI forground and background colours */
    352   1.1      jdc 	case COLOR_ANSI:
    353   1.1      jdc 		tputs(__parse_cap(af, pairs[pair].fore), 0, __cputchar);
    354   1.1      jdc 		tputs(__parse_cap(ab, pairs[pair].back), 0, __cputchar);
    355   1.1      jdc 		break;
    356   1.1      jdc 	case COLOR_HP:
    357   1.1      jdc 		/* XXX: need to support HP style */
    358   1.1      jdc 		break;
    359   1.1      jdc 	case COLOR_TEK:
    360   1.1      jdc 		/* XXX: need to support Tek style */
    361   1.6      jdc 		break;
    362   1.6      jdc 	case COLOR_OTHER:
    363   1.6      jdc 		tputs(__parse_cap(sF, pairs[pair].fore), 0, __cputchar);
    364   1.6      jdc 		tputs(__parse_cap(sB, pairs[pair].back), 0, __cputchar);
    365   1.1      jdc 		break;
    366   1.1      jdc 	}
    367   1.1      jdc }
    368   1.1      jdc 
    369   1.1      jdc /*
    370   1.1      jdc  * __restore_colors --
    371   1.1      jdc  *	Redo color definitions after restarting 'curses' mode.
    372   1.1      jdc  */
    373   1.1      jdc void
    374   1.3    blymn __restore_colors(void)
    375   1.1      jdc {
    376   1.1      jdc 	if (CC != NULL)
    377   1.1      jdc 		switch (__color_type) {
    378   1.1      jdc 		case COLOR_HP:
    379   1.1      jdc 			/* XXX: need to re-initialise HP style (iP) */
    380   1.1      jdc 			break;
    381   1.1      jdc 		case COLOR_TEK:
    382   1.1      jdc 			/* XXX: need to re-initialise Tek style (iC) */
    383   1.1      jdc 			break;
    384   1.1      jdc 		}
    385   1.2      jdc }
    386   1.2      jdc 
    387   1.2      jdc /*
    388   1.2      jdc  * __change_pair --
    389   1.2      jdc  *	Mark dirty all positions using pair.
    390   1.2      jdc  */
    391   1.2      jdc void
    392   1.3    blymn __change_pair(short pair)
    393   1.2      jdc {
    394   1.2      jdc 	struct __winlist	*wlp;
    395   1.2      jdc 	WINDOW			*win;
    396   1.2      jdc 	int			 y, x;
    397   1.2      jdc 
    398   1.2      jdc 
    399   1.2      jdc 	for (wlp = __winlistp; wlp != NULL; wlp = wlp->nextp) {
    400   1.2      jdc #ifdef DEBUG
    401   1.2      jdc 		__CTRACE("__change_pair: win = %0.2o\n", wlp->winp);
    402   1.2      jdc #endif
    403   1.2      jdc 		if (wlp->winp == curscr) {
    404   1.2      jdc 			/* Reset colour attribute on curscr */
    405   1.2      jdc #ifdef DEBUG
    406   1.2      jdc 			__CTRACE("__change_pair: win == curscr\n");
    407   1.2      jdc #endif
    408   1.2      jdc 			for (y = 0; y < curscr->maxy; y++)
    409   1.2      jdc 				for (x = 0; x < curscr->maxx; x++)
    410   1.2      jdc 					if ((curscr->lines[y]->line[x].attr &
    411   1.2      jdc 					    __COLOR) == COLOR_PAIR(pair))
    412   1.2      jdc 						curscr->lines[y]->line[x].attr
    413   1.2      jdc 						    &= ~__COLOR;
    414   1.2      jdc 		} else {
    415   1.2      jdc 			/* Mark dirty those positions with color pair "pair" */
    416   1.2      jdc 			win = wlp->winp;
    417   1.2      jdc 			for (y = 0; y < win->maxy; y++) {
    418   1.2      jdc 				for (x = 0; x < win->maxx; x++)
    419   1.2      jdc 					if ((win->lines[y]->line[x].attr &
    420   1.2      jdc 					    __COLOR) == COLOR_PAIR(pair)) {
    421   1.2      jdc 						if (!(win->lines[y]->flags &
    422   1.4      jdc 						    __ISDIRTY))
    423   1.2      jdc 							win->lines[y]->flags |=
    424   1.2      jdc 							    __ISDIRTY;
    425   1.4      jdc 						/*
    426   1.4      jdc 						 * firstchp/lastchp are shared
    427   1.4      jdc 						 * between parent window and
    428   1.4      jdc 						 * sub-window.
    429   1.4      jdc 						 */
    430   1.4      jdc 						if (*win->lines[y]->firstchp >
    431   1.4      jdc 						    x)
    432   1.2      jdc 							*win->lines[y]->firstchp
    433   1.2      jdc 							    = x;
    434   1.4      jdc 						if (*win->lines[y]->lastchp < x)
    435   1.2      jdc 							*win->lines[y]->lastchp
    436   1.2      jdc 							    = x;
    437   1.2      jdc 					}
    438   1.2      jdc #ifdef DEBUG
    439   1.4      jdc 				if ((win->lines[y]->flags & __ISDIRTY))
    440   1.2      jdc 					__CTRACE("__change_pair: first = %d, last = %d\n", *win->lines[y]->firstchp, *win->lines[y]->lastchp);
    441   1.2      jdc #endif
    442   1.2      jdc 			}
    443   1.2      jdc 		}
    444   1.2      jdc 	}
    445   1.1      jdc }
    446