Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame^] | 1 | /**************************************************************************** |
| 2 | * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. * |
| 3 | * * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a * |
| 5 | * copy of this software and associated documentation files (the * |
| 6 | * "Software"), to deal in the Software without restriction, including * |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, * |
| 8 | * distribute, distribute with modifications, sublicense, and/or sell * |
| 9 | * copies of the Software, and to permit persons to whom the Software is * |
| 10 | * furnished to do so, subject to the following conditions: * |
| 11 | * * |
| 12 | * The above copyright notice and this permission notice shall be included * |
| 13 | * in all copies or substantial portions of the Software. * |
| 14 | * * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 18 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 19 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 20 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 21 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 22 | * * |
| 23 | * Except as contained in this notice, the name(s) of the above copyright * |
| 24 | * holders shall not be used in advertising or otherwise to promote the * |
| 25 | * sale, use or other dealings in this Software without prior written * |
| 26 | * authorization. * |
| 27 | ****************************************************************************/ |
| 28 | /* |
| 29 | * This test was written by Alexander V. Lukyanov to demonstrate difference |
| 30 | * between ncurses 4.1 and SVR4 curses |
| 31 | * |
| 32 | * $Id: firstlast.c,v 1.5 2006/04/01 19:03:18 tom Exp $ |
| 33 | */ |
| 34 | |
| 35 | #include <test.priv.h> |
| 36 | |
| 37 | static void |
| 38 | fill(WINDOW *w, const char *str) |
| 39 | { |
| 40 | const char *s; |
| 41 | for (;;) { |
| 42 | for (s = str; *s; s++) { |
| 43 | if (waddch(w, UChar(*s)) == ERR) { |
| 44 | wmove(w, 0, 0); |
| 45 | return; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | int |
| 52 | main(int argc GCC_UNUSED, |
| 53 | char *argv[]GCC_UNUSED) |
| 54 | { |
| 55 | WINDOW *large, *small; |
| 56 | initscr(); |
| 57 | noecho(); |
| 58 | |
| 59 | large = newwin(20, 60, 2, 10); |
| 60 | small = newwin(10, 30, 7, 25); |
| 61 | |
| 62 | /* test 1 - addch */ |
| 63 | fill(large, "LargeWindow"); |
| 64 | |
| 65 | refresh(); |
| 66 | wrefresh(large); |
| 67 | wrefresh(small); |
| 68 | |
| 69 | mvwaddstr(small, 5, 5, " Test <place to change> String "); |
| 70 | wrefresh(small); |
| 71 | getch(); |
| 72 | |
| 73 | touchwin(large); |
| 74 | wrefresh(large); |
| 75 | |
| 76 | mvwaddstr(small, 5, 5, " Test <***************> String "); |
| 77 | wrefresh(small); |
| 78 | |
| 79 | /* DIFFERENCE! */ |
| 80 | getch(); |
| 81 | |
| 82 | /* test 2: erase */ |
| 83 | erase(); |
| 84 | refresh(); |
| 85 | getch(); |
| 86 | |
| 87 | /* test 3: clrtoeol */ |
| 88 | werase(small); |
| 89 | wrefresh(small); |
| 90 | touchwin(large); |
| 91 | wrefresh(large); |
| 92 | wmove(small, 5, 0); |
| 93 | waddstr(small, " clrtoeol>"); |
| 94 | wclrtoeol(small); |
| 95 | wrefresh(small); |
| 96 | |
| 97 | /* DIFFERENCE! */ ; |
| 98 | getch(); |
| 99 | |
| 100 | /* test 4: clrtobot */ |
| 101 | werase(small); |
| 102 | wrefresh(small); |
| 103 | touchwin(large); |
| 104 | wrefresh(large); |
| 105 | wmove(small, 5, 3); |
| 106 | waddstr(small, " clrtobot>"); |
| 107 | wclrtobot(small); |
| 108 | wrefresh(small); |
| 109 | |
| 110 | /* DIFFERENCE! */ |
| 111 | getch(); |
| 112 | |
| 113 | endwin(); |
| 114 | |
| 115 | ExitProgram(EXIT_SUCCESS); |
| 116 | } |