X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fncurses.c;h=ea5f5f867dc4079ca421e154f989f1fa42f1f570;hp=2fd9b7b6e80557aa043aeec13a92d6b6e3aeaea2;hb=bd257b9d8d715a9a63dab215fcdc53f106e7d050;hpb=52aa842907b31bb56fb5133da3f023b45bd4355f diff --git a/test/ncurses.c b/test/ncurses.c index 2fd9b7b6..ea5f5f86 100644 --- a/test/ncurses.c +++ b/test/ncurses.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. * + * Copyright (c) 1998-2010,2011 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 * @@ -40,7 +40,7 @@ AUTHOR Author: Eric S. Raymond 1993 Thomas E. Dickey (beginning revision 1.27 in 1996). -$Id: ncurses.c,v 1.362 2010/11/14 01:04:13 tom Exp $ +$Id: ncurses.c,v 1.369 2011/08/20 15:49:08 tom Exp $ ***************************************************************************/ @@ -106,6 +106,7 @@ extern unsigned _nc_tracing; #endif #endif /* ACS_S3 */ +#ifndef WACS_S3 #ifdef CURSES_WACS_ARRAY #define WACS_S3 (&(CURSES_WACS_ARRAY['p'])) /* scan line 3 */ #define WACS_S7 (&(CURSES_WACS_ARRAY['r'])) /* scan line 7 */ @@ -115,6 +116,7 @@ extern unsigned _nc_tracing; #define WACS_NEQUAL (&(CURSES_WACS_ARRAY['|'])) /* not equal */ #define WACS_STERLING (&(CURSES_WACS_ARRAY['}'])) /* UK pound sign */ #endif +#endif #endif @@ -488,7 +490,7 @@ ShellOut(bool message) #ifdef __MINGW32__ system("cmd.exe"); #else - system("sh"); + IGNORE_RC(system("sh")); #endif if (message) addstr("returned from shellout.\n"); @@ -688,7 +690,7 @@ wgetch_wrap(WINDOW *win, int first_y) wclrtoeol(win); } -#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE +#if defined(KEY_RESIZE) && HAVE_WRESIZE typedef struct { WINDOW *text; WINDOW *frame; @@ -725,7 +727,7 @@ remember_boxes(unsigned level, WINDOW *txt_win, WINDOW *box_win) winstack[level].frame = box_win; } -#if USE_SOFTKEYS && (NCURSES_VERSION_PATCH < 20071229) && NCURSES_EXT_FUNCS +#if USE_SOFTKEYS && (defined(NCURSES_VERSION_PATCH) && NCURSES_VERSION_PATCH < 20071229) && NCURSES_EXT_FUNCS static void slk_repaint(void) { @@ -739,6 +741,7 @@ slk_repaint(void) #define slk_repaint() /* nothing */ #endif +#if defined(NCURSES_VERSION) && defined(KEY_RESIZE) && HAVE_WRESIZE /* * For wgetch_test(), we create pairs of windows - one for a box, one for text. * Resize both and paint the box in the parent. @@ -774,6 +777,7 @@ resize_boxes(unsigned level, WINDOW *win) } doupdate(); } +#endif /* resize_boxes */ #else #define forget_boxes() /* nothing */ #define remember_boxes(level,text,frame) /* nothing */ @@ -1390,7 +1394,7 @@ show_attr(int row, int skip, bool arrow, chtype attr, const char *name) if (!(termattrs() & test)) { printw(" (N/A)"); } else { - if (ncv > 0 && (getbkgd(stdscr) & A_COLOR)) { + if (ncv > 0 && stdscr && (getbkgd(stdscr) & A_COLOR)) { static const chtype table[] = { A_STANDOUT, @@ -1671,8 +1675,8 @@ wide_show_attr(int row, int skip, bool arrow, chtype attr, short pair, const cha add_wch(&ch); } } else { - attr_t old_attr; - short old_pair; + attr_t old_attr = 0; + short old_pair = 0; (void) attr_get(&old_attr, &old_pair, 0); (void) attr_set(attr, pair, 0); @@ -2577,52 +2581,6 @@ color_edit(void) endwin(); } -/**************************************************************************** - * - * Soft-key label test - * - ****************************************************************************/ - -#if USE_SOFTKEYS - -#define SLK_HELP 17 -#define SLK_WORK (SLK_HELP + 3) - -static void -slk_help(void) -{ - static const char *table[] = - { - "Available commands are:" - ,"" - ,"^L -- repaint this message and activate soft keys" - ,"a/d -- activate/disable soft keys" - ,"c -- set centered format for labels" - ,"l -- set left-justified format for labels" - ,"r -- set right-justified format for labels" - ,"[12345678] -- set label; labels are numbered 1 through 8" - ,"e -- erase stdscr (should not erase labels)" - ,"s -- test scrolling of shortened screen" - ,"v/V -- cycle through video attributes" -#if HAVE_SLK_COLOR - ,"F/f/B/b -- cycle through foreground/background colors" -#endif - ,"ESC -- return to main menu" - ,"" - ,"Note: if activating the soft keys causes your terminal to scroll up" - ,"one line, your terminal auto-scrolls when anything is written to the" - ,"last screen position. The ncurses code does not yet handle this" - ,"gracefully." - }; - unsigned j; - - move(2, 0); - for (j = 0; j < SIZEOF(table); ++j) { - P(table[j]); - } - refresh(); -} - /**************************************************************************** * * Alternate character-set stuff @@ -2707,6 +2665,52 @@ cycle_colors(int ch, int *fg, int *bg, short *pair) return result; } +/**************************************************************************** + * + * Soft-key label test + * + ****************************************************************************/ + +#if USE_SOFTKEYS + +#define SLK_HELP 17 +#define SLK_WORK (SLK_HELP + 3) + +static void +slk_help(void) +{ + static const char *table[] = + { + "Available commands are:" + ,"" + ,"^L -- repaint this message and activate soft keys" + ,"a/d -- activate/disable soft keys" + ,"c -- set centered format for labels" + ,"l -- set left-justified format for labels" + ,"r -- set right-justified format for labels" + ,"[12345678] -- set label; labels are numbered 1 through 8" + ,"e -- erase stdscr (should not erase labels)" + ,"s -- test scrolling of shortened screen" + ,"v/V -- cycle through video attributes" +#if HAVE_SLK_COLOR + ,"F/f/B/b -- cycle through foreground/background colors" +#endif + ,"ESC -- return to main menu" + ,"" + ,"Note: if activating the soft keys causes your terminal to scroll up" + ,"one line, your terminal auto-scrolls when anything is written to the" + ,"last screen position. The ncurses code does not yet handle this" + ,"gracefully." + }; + unsigned j; + + move(2, 0); + for (j = 0; j < SIZEOF(table); ++j) { + P(table[j]); + } + refresh(); +} + #if HAVE_SLK_COLOR static void call_slk_color(int fg, int bg) @@ -4265,8 +4269,10 @@ acs_and_scroll(void) neww->next = current ? current->next : 0; neww->last = current; - neww->last->next = neww; - neww->next->last = neww; + if (neww->last != 0) + neww->last->next = neww; + if (neww->next != 0) + neww->next->last = neww; neww->wind = getwin(fp); @@ -6389,13 +6395,14 @@ do_single_test(const char c) case 'e': slk_test(); break; -#endif #if USE_WIDEC_SUPPORT case 'E': wide_slk_test(); break; #endif +#endif + case 'f': acs_display(); break; @@ -6767,7 +6774,7 @@ main(int argc, char *argv[]) use_default_colors(); min_colors = -1; } -#if NCURSES_VERSION_PATCH >= 20000708 +#if HAVE_ASSUME_DEFAULT_COLORS if (assumed_colors) assume_default_colors(default_fg, default_bg); #endif