diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-02-22 04:16:37 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-02-22 04:16:37 +0000 |
commit | 98742c91331e6772410df6e9d0a0d9f08b522dac (patch) | |
tree | be13678e0217bee0152d46755923a1b6a2bf4b94 /lib/libcurses++ | |
parent | eb05d20ac3c4c642fe84cebb15f94ebb6ba65d69 (diff) |
Update to ncurses-5.2-20010210:
o remove macro callPutChar() from tty_update.c, since this is no longer
needed (reported by Philippe Blain).
o add a null-pointer check in tic.c to handle the case when the input
file is really empty. Modify the next_char() function in comp_scan.c
to allow arbitrarily long lines, and incidentally supply a newline to
files that do not end in a newline. These changes improve tic's
recovery from attempts to read binary files, e.g., its output from
the terminfo database (reported by Bernhard Rosenkraenzer).
o revert change to c++/demo.cc from 20001209, which changed definition
of main() apparently to accommodate cygwin linker, but broke the demo
program.
Diffstat (limited to 'lib/libcurses++')
-rw-r--r-- | lib/libcurses++/cursesw.cc | 14 | ||||
-rw-r--r-- | lib/libcurses++/cursesw.h | 118 | ||||
-rw-r--r-- | lib/libcurses++/demo.cc | 12 |
3 files changed, 68 insertions, 76 deletions
diff --git a/lib/libcurses++/cursesw.cc b/lib/libcurses++/cursesw.cc index baa7a373045..c23f8b578f8 100644 --- a/lib/libcurses++/cursesw.cc +++ b/lib/libcurses++/cursesw.cc @@ -25,7 +25,7 @@ #include "cursesw.h" #include "internal.h" -MODULE_ID("$From: cursesw.cc,v 1.17 2000/09/02 18:55:31 tom Exp $") +MODULE_ID("$From: cursesw.cc,v 1.18 2001/01/28 01:17:41 tom Exp $") #define COLORS_NEED_INITIALIZATION -1 #define COLORS_NOT_INITIALIZED 0 @@ -142,8 +142,7 @@ NCursesWindow::initialize() { } NCursesWindow::NCursesWindow() { - if (!b_initialized) - initialize(); + initialize(); w = (WINDOW *)0; init(); @@ -154,8 +153,7 @@ NCursesWindow::NCursesWindow() { NCursesWindow::NCursesWindow(int lines, int cols, int begin_y, int begin_x) { - if (!b_initialized) - initialize(); + initialize(); w = ::newwin(lines, cols, begin_y, begin_x); if (w == 0) { @@ -170,8 +168,7 @@ NCursesWindow::NCursesWindow(int lines, int cols, int begin_y, int begin_x) NCursesWindow::NCursesWindow(WINDOW* &window) { - if (!b_initialized) - initialize(); + initialize(); w = window; init(); @@ -183,6 +180,7 @@ NCursesWindow::NCursesWindow(WINDOW* &window) NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c, int begin_y, int begin_x, char absrel) { + initialize(); if (absrel == 'a') { // absolute origin begin_y -= win.begy(); begin_x -= win.begx(); @@ -208,6 +206,7 @@ NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c, NCursesWindow::NCursesWindow(NCursesWindow& win, bool do_box NCURSES_PARAM_INIT(TRUE)) { + initialize(); w = :: derwin(win.w,win.height()-2,win.width()-2,1,1); if (w == 0) { err_handler("Cannot construct subwindow"); @@ -244,6 +243,7 @@ static RIPOFFINIT* prip = R_INIT; extern "C" int _nc_ripoffline(int,int (*init)(WINDOW*,int)); NCursesWindow::NCursesWindow(WINDOW *win, int cols) { + initialize(); w = win; assert((w->_maxx+1)==cols); alloced = FALSE; diff --git a/lib/libcurses++/cursesw.h b/lib/libcurses++/cursesw.h index fab04b960e4..135bc835784 100644 --- a/lib/libcurses++/cursesw.h +++ b/lib/libcurses++/cursesw.h @@ -2,7 +2,7 @@ #ifndef _CURSESW_H #define _CURSESW_H -// $From: cursesw.h,v 1.20 2000/12/10 03:22:35 tom Exp $ +// $From: cursesw.h,v 1.21 2001/01/28 01:18:23 tom Exp $ #include <etip.h> #include <stdio.h> @@ -152,7 +152,7 @@ inline int UNDEF(erase)() { return erase(); } #endif #ifdef flushok -inline int UNDEF(flushok)(WINDOW* _win, bool _bf) { +inline int UNDEF(flushok)(WINDOW* _win, bool _bf) { return flushok(_win, _bf); } #undef flushok #define flushok UNDEF(flushok) @@ -185,49 +185,49 @@ inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str,n); } #endif #ifdef mvwinnstr -inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) { +inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) { return mvwinnstr(win,y,x,_str,n); } #undef mvwinnstr #define mvwinnstr UNDEF(mvwinnstr) #endif #ifdef mvinnstr -inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) { +inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) { return mvinnstr(y,x,_str,n); } #undef mvinnstr #define mvinnstr UNDEF(mvinnstr) #endif #ifdef winsstr -inline int UNDEF(winsstr)(WINDOW *w, const char *_str) { +inline int UNDEF(winsstr)(WINDOW *w, const char *_str) { return winsstr(w,_str); } #undef winsstr #define winsstr UNDEF(winsstr) #endif #ifdef mvwinsstr -inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) { +inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) { return mvwinsstr(w,y,x,_str); } #undef mvwinsstr #define mvwinsstr UNDEF(mvwinsstr) #endif #ifdef insstr -inline int UNDEF(insstr)(const char *_str) { +inline int UNDEF(insstr)(const char *_str) { return insstr(_str); } #undef insstr #define insstr UNDEF(insstr) #endif #ifdef mvinsstr -inline int UNDEF(mvinsstr)(int y, int x,const char *_str) { +inline int UNDEF(mvinsstr)(int y, int x,const char *_str) { return mvinsstr(y,x,_str); } #undef mvinsstr #define mvinsstr UNDEF(mvinsstr) #endif #ifdef insnstr -inline int UNDEF(insnstr)(const char *_str, int n) { +inline int UNDEF(insnstr)(const char *_str, int n) { return insnstr(_str,n); } #undef insnstr #define insnstr UNDEF(insnstr) @@ -254,7 +254,7 @@ inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str,n); } #endif #ifdef getyx -inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) { +inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) { getyx(win, y, x); } #undef getyx #define getyx UNDEF(getyx) @@ -365,7 +365,7 @@ inline int UNDEF(standout)() { return standout(); } #endif #ifdef subpad -inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x) +inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x) { return derwin(p,l,c,y,x); } #undef subpad #define subpad UNDEF(subpad) @@ -434,7 +434,7 @@ inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); } #endif #ifdef chgat -inline int UNDEF(chgat)(int n,attr_t attr, short color, const void *opts) { +inline int UNDEF(chgat)(int n,attr_t attr, short color, const void *opts) { return chgat(n,attr,color,opts); } #undef chgat #define chgat UNDEF(chgat) @@ -442,7 +442,7 @@ inline int UNDEF(chgat)(int n,attr_t attr, short color, const void *opts) { #ifdef mvchgat inline int UNDEF(mvchgat)(int y, int x, int n, - attr_t attr, short color, const void *opts) { + attr_t attr, short color, const void *opts) { return mvchgat(y,x,n,attr,color,opts); } #undef mvchgat #define mvchgat UNDEF(mvchgat) @@ -450,7 +450,7 @@ inline int UNDEF(mvchgat)(int y, int x, int n, #ifdef mvwchgat inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n, - attr_t attr, short color, const void *opts) { + attr_t attr, short color, const void *opts) { return mvwchgat(win,y,x,n,attr,color,opts); } #undef mvwchgat #define mvwchgat UNDEF(mvwchgat) @@ -538,7 +538,7 @@ inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n) #endif #ifdef mvwinch -inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { +inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { return mvwinch(win, y, x);} #undef mvwinch #define mvwinch UNDEF(mvwinch) @@ -675,14 +675,14 @@ class NCURSES_IMPEXP NCursesWindow { friend class NCursesMenu; friend class NCursesForm; - + private: static bool b_initialized; static void initialize(); static int ripoff_init(WINDOW *,int); - void init(); - + void init(); + short getcolor(int getback) const; static int setpalette(short fore, short back, short pair); @@ -700,15 +700,15 @@ protected: // We rely on the c++ promise that // all otherwise uninitialized // static class vars are set to 0 - + WINDOW* w; // the curses WINDOW - + bool alloced; // TRUE if we own the WINDOW - + NCursesWindow* par; // parent, if subwindow NCursesWindow* subwins; // head of subwindows list NCursesWindow* sib; // next subwindow of parent - + void kill_subwindows(); // disable all subwindows // Destroy all subwindows. @@ -718,12 +718,12 @@ protected: public: NCursesWindow(WINDOW* &window); // useful only for stdscr - + NCursesWindow(int lines, // number of lines int cols, // number of columns int begin_y, // line origin int begin_x); // col origin - + NCursesWindow(NCursesWindow& par,// parent window int lines, // number of lines int cols, // number of columns @@ -751,9 +751,9 @@ public: int (*init)(NCursesWindow& win)); // This function is used to generate a window of ripped-of lines. // If the argument is positive, lines are removed from the top, if it - // is negative lines are removed from the bottom. This enhances the - // lowlevel ripoffline() function because it uses the internal - // implementation that allows to remove more than just a single line. + // is negative lines are removed from the bottom. This enhances the + // lowlevel ripoffline() function because it uses the internal + // implementation that allows to remove more than just a single line. // This function must be called before any other ncurses function. The // creation of the window is defered until ncurses gets initialized. // The initialization function is then called. @@ -761,13 +761,13 @@ public: // ------------------------------------------------------------------------- // terminal status // ------------------------------------------------------------------------- - int lines() const { return LINES; } + int lines() const { initialize(); return LINES; } // Number of lines on terminal, *not* window - int cols() const { return COLS; } + int cols() const { initialize(); return COLS; } // Number of cols on terminal, *not* window - int tabsize() const { return TABSIZE; } + int tabsize() const { initialize(); return TABSIZE; } // Size of a tab on terminal, *not* window static int NumberOfColors(); @@ -775,7 +775,7 @@ public: int colors() const { return NumberOfColors(); } // Number of available colors - + // ------------------------------------------------------------------------- // window status // ------------------------------------------------------------------------- @@ -811,7 +811,7 @@ public: int setcolor(short pair); // Set actually used palette entry - + // ------------------------------------------------------------------------- // window positioning // ------------------------------------------------------------------------- @@ -827,12 +827,12 @@ public: // Move cursor the this position void getyx(int& y, int& x) const { ::getyx(w, y, x); } - // Get current position of the cursor + // Get current position of the cursor - int mvcur(int oldrow, int oldcol, int newrow, int newcol) const { + int mvcur(int oldrow, int oldcol, int newrow, int newcol) const { return ::mvcur(oldrow, oldcol, newrow, newcol); } // Perform lowlevel cursor motion that takes effect immediately. - + // ------------------------------------------------------------------------- // input // ------------------------------------------------------------------------- @@ -842,13 +842,13 @@ public: int getch(int y, int x) { return ::mvwgetch(w,y,x); } // Move cursor to position and get a keystroke from the window - int getstr(char* str, int n=-1) { + int getstr(char* str, int n=-1) { return ::wgetnstr(w, str,n); } // Read a series of characters into str until a newline or carriage return // is received. Read at most n characters. If n is negative, the limit is // ignored. - int getstr(int y, int x, char* str, int n=-1) { + int getstr(int y, int x, char* str, int n=-1) { return ::mvwgetnstr(w,y,x,str,n); } // Move the cursor to the requested position and then perform the getstr() // as described above. @@ -880,12 +880,12 @@ public: #else ; #endif - + // ------------------------------------------------------------------------- // output // ------------------------------------------------------------------------- int addch(const chtype ch) { return ::waddch(w, ch); } - // Put attributed character to the window. + // Put attributed character to the window. int addch(int y, int x, const chtype ch) { return ::mvwaddch(w,y,x,ch); } @@ -895,10 +895,10 @@ public: int echochar(const chtype ch) { return ::wechochar(w,ch); } // Put attributed character to the window and refresh it immediately. - int addstr(const char* str, int n=-1) { + int addstr(const char* str, int n=-1) { return ::waddnstr(w, (char*)str,n); } // Write the string str to the window, stop writing if the terminating - // NUL or the limit n is reached. If n is negative, it is ignored. + // NUL or the limit n is reached. If n is negative, it is ignored. int addstr(int y, int x, const char * str, int n=-1) { return ::mvwaddnstr(w,y,x,(char*)str,n); } @@ -939,7 +939,7 @@ public: int insertln() { return ::winsdelln(w,1); } // Insert an empty line above the current line. - + int insdelln(int n=1) { return ::winsdelln(w,n); } // If n>0 insert that many lines above the current line. If n<0 delete // that many lines beginning with the current line. @@ -949,7 +949,7 @@ public: // Insert the string into the window before the current cursor position. // Insert stops at end of string or when the limit n is reached. If n is // negative, it is ignored. - + int insstr(int y, int x, const char *s, int n=-1) { return ::mvwinsnstr(w,y,x,s,n); } // Move the cursor to the requested position and then perform the insstr() @@ -957,7 +957,7 @@ public: int attron (chtype at) { return ::wattron (w, at); } // Switch on the window attributes; - + int attroff(chtype at) { return ::wattroff(w, (int) at); } // Switch off the window attributes; @@ -995,7 +995,7 @@ public: // ------------------------------------------------------------------------- // borders // ------------------------------------------------------------------------- - int box(chtype vert=0, chtype hor=0) { + int box(chtype vert=0, chtype hor=0) { return ::wborder(w, vert, vert, hor, hor, 0, 0 ,0, 0); } // Draw a box around the window with the given vertical and horizontal // drawing characters. If you specifiy a zero as character, curses will try @@ -1016,7 +1016,7 @@ public: // ------------------------------------------------------------------------- int hline(int len, chtype ch=0) { return ::whline(w, ch, len); } // Draw a horizontal line of len characters with the given character. If - // you pass zero for the character, curses will try to find a "nice" one. + // you pass zero for the character, curses will try to find a "nice" one. int hline(int y, int x, int len, chtype ch=0) { return ::mvwhline(w,y,x,ch,len); } @@ -1029,7 +1029,7 @@ public: int vline(int y, int x, int len, chtype ch=0) { return ::mvwvline(w,y,x,ch,len); } // Move the cursor to the requested position and then draw a vertical line. - + // ------------------------------------------------------------------------- // erasure // ------------------------------------------------------------------------- @@ -1050,7 +1050,7 @@ public: // Clear to the end of the line. int delch() { return ::wdelch(w); } - // Delete character under the cursor. + // Delete character under the cursor. int delch(int y, int x) { return ::mvwdelch(w,y,x); } // Move cursor to requested position and delete the character under the @@ -1090,18 +1090,18 @@ public: int untouchwin() { return ::wtouchln(w,0,height(),0); } // Mark the whole window as unmodified. - int touchln(int s, int cnt, bool changed=TRUE) { + int touchln(int s, int cnt, bool changed=TRUE) { return ::wtouchln(w,s,cnt,(int)(changed?1:0)); } // Mark cnt lines beginning from line s as changed or unchanged, depending // on the value of the changed flag. - bool is_linetouched(int line) const { + bool is_linetouched(int line) const { return (::is_linetouched(w,line) ? TRUE:FALSE); } - // Return TRUE if line is marked as changed, FALSE otherwise + // Return TRUE if line is marked as changed, FALSE otherwise - bool is_wintouched() const { + bool is_wintouched() const { return (::is_wintouched(w) ? TRUE:FALSE); } - // Return TRUE if window is marked as changed, FALSE otherwise + // Return TRUE if window is marked as changed, FALSE otherwise int leaveok(bool bf) { return ::leaveok(w, bf); } // If bf is TRUE, curses will leave the cursor after an update whereever @@ -1141,7 +1141,7 @@ public: int meta(bool bf) { return ::meta(w,bf); } // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise - // 7-Bit characters are generated. + // 7-Bit characters are generated. int standout() { return ::wstandout(w); } // Enable "standout" attributes @@ -1158,9 +1158,9 @@ public: // doupdate(). This is redefined in NCursesPanel. virtual int noutrefresh() { return ::wnoutrefresh(w); } - // Propagate the changes in this window to the virtual screen. This is + // Propagate the changes in this window to the virtual screen. This is // redefined in NCursesPanel. - + // ------------------------------------------------------------------------- // multiple window control // ------------------------------------------------------------------------- @@ -1228,8 +1228,8 @@ public: char absrel = 'a') // if `a', by & bx are : NCursesWindow(par,lines,cols, // absolute screen pos, begin_y,begin_x, // else if `r', they are - absrel ) { // relative to par origin - useColors(); } + absrel ) { // relative to par origin + useColors(); } }; // These enum definitions really belong inside the NCursesPad class, but only @@ -1301,7 +1301,7 @@ public: int echochar(const chtype ch) { return ::pechochar(w,ch); } // Put the attributed character onto the pad and immediately do a // prefresh(). - + int refresh(); // If a viewport is defined the pad is displayed in this window, otherwise // this is a noop. diff --git a/lib/libcurses++/demo.cc b/lib/libcurses++/demo.cc index f08cbe9a874..d09b718b0a8 100644 --- a/lib/libcurses++/demo.cc +++ b/lib/libcurses++/demo.cc @@ -6,7 +6,7 @@ * Demo code for NCursesMenu and NCursesForm written by * Juergen Pfeifer <juergen.pfeifer@gmx.net> * - * $From: demo.cc,v 1.19 2000/12/09 23:46:12 tom Exp $ + * $From: demo.cc,v 1.20 2001/01/28 02:26:27 tom Exp $ */ #include "cursesapp.h" @@ -446,12 +446,4 @@ int TestApplication::run() { // // ------------------------------------------------------------------------- // -// static TestApplication Demo; - -int main() -{ - TestApplication * Demo = new TestApplication(); - Demo->run(); - return 0; -} - +static TestApplication Demo; |