Home | History | Annotate | Line # | Download | only in libcurses
acs.c revision 1.10
      1 /*	$NetBSD: acs.c,v 1.10 2002/01/04 13:53:26 blymn Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Julian Coleman.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include <sys/cdefs.h>
     40 #ifndef lint
     41 __RCSID("$NetBSD: acs.c,v 1.10 2002/01/04 13:53:26 blymn Exp $");
     42 #endif				/* not lint */
     43 
     44 #include "curses.h"
     45 #include "curses_private.h"
     46 
     47 chtype _acs_char[NUM_ACS];
     48 
     49 /*
     50  * __init_acs --
     51  *	Fill in the ACS characters.  The 'ac' termcap entry is a list of
     52  *	character pairs - ACS definition then terminal representation.
     53  */
     54 void
     55 __init_acs(SCREEN *screen)
     56 {
     57 	int		count;
     58 	char		*aofac;	/* Address of 'ac' */
     59 	unsigned char	acs, term;
     60 
     61 	/* Default value '+' for all ACS characters */
     62 	for (count=0; count < NUM_ACS; count++)
     63 		_acs_char[count]= '+';
     64 
     65 	/* Add the SUSv2 defaults (those that are not '+') */
     66 	ACS_RARROW = '>';
     67 	ACS_LARROW = '<';
     68 	ACS_UARROW = '^';
     69 	ACS_DARROW = 'v';
     70 	ACS_BLOCK = '#';
     71 /*	ACS_DIAMOND = '+';	*/
     72 	ACS_CKBOARD = ':';
     73 	ACS_DEGREE = 39;	/* ' */
     74 	ACS_PLMINUS = '#';
     75 	ACS_BOARD = '#';
     76 	ACS_LANTERN = '#';
     77 /*	ACS_LRCORNER = '+';	*/
     78 /*	ACS_URCORNER = '+';	*/
     79 /*	ACS_ULCORNER = '+';	*/
     80 /*	ACS_LLCORNER = '+';	*/
     81 /*	ACS_PLUS = '+';		*/
     82 	ACS_HLINE = '-';
     83 	ACS_S1 = '-';
     84 	ACS_S9 = '_';
     85 /*	ACS_LTEE = '+';		*/
     86 /*	ACS_RTEE = '+';		*/
     87 /*	ACS_BTEE = '+';		*/
     88 /*	ACS_TTEE = '+';		*/
     89 	ACS_VLINE = '|';
     90 	ACS_BULLET = 'o';
     91 
     92 	if (screen->tc_ac == NULL)
     93 		return;
     94 
     95 	aofac = screen->tc_ac;
     96 
     97 	while (*aofac != '\0') {
     98 		if ((acs = *aofac) == '\0')
     99 			return;
    100 		if (++aofac == '\0')
    101 			return;
    102 		if ((term = *aofac) == '\0')
    103 			return;
    104 	 	/* Only add characters 1 to 127 */
    105 		if (acs < NUM_ACS)
    106 			_acs_char[acs] = term | __ALTCHARSET;
    107 		aofac++;
    108 #ifdef DEBUG
    109 		__CTRACE("__init_acs: %c = %c\n", acs, term);
    110 #endif
    111 	}
    112 
    113 	for (count=0; count < NUM_ACS; count++)
    114 		screen->acs_char[count]= _acs_char[count];
    115 
    116 	if (screen->tc_eA != NULL)
    117 		t_puts(screen->cursesi_genbuf, screen->tc_eA, 0,
    118 		       __cputchar_args, screen->outfd);
    119 }
    120 
    121 void
    122 _cursesi_reset_acs(SCREEN *screen)
    123 {
    124 	int count;
    125 
    126 	for (count=0; count < NUM_ACS; count++)
    127 		_acs_char[count]= screen->acs_char[count];
    128 }
    129