From cdee4a435a7d0d4abac29ea38f8bee9b53e9830e Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sat, 6 Jan 2024 12:44:21 +0000 Subject: Update PDCurses --- scripts/kconfig/libcurses/README.md | 12 +-- scripts/kconfig/libcurses/color.c | 140 +++++++++++++++++++++++++---------- scripts/kconfig/libcurses/curses.h | 80 ++++++++++++++------ scripts/kconfig/libcurses/curspriv.h | 30 ++++++-- scripts/kconfig/libcurses/getch.c | 56 +++++++------- scripts/kconfig/libcurses/initscr.c | 61 +++++++++++---- scripts/kconfig/libcurses/inopts.c | 56 ++++++++++++-- scripts/kconfig/libcurses/outopts.c | 91 ++++++++++++++++++++++- scripts/kconfig/libcurses/pad.c | 66 ++++++++--------- scripts/kconfig/libcurses/pdcdisp.c | 28 ++++++- scripts/kconfig/libcurses/pdckbd.c | 96 +++++++++++++----------- scripts/kconfig/libcurses/pdcscrn.c | 65 +++------------- scripts/kconfig/libcurses/pdcwin.h | 2 +- scripts/kconfig/libcurses/refresh.c | 12 ++- scripts/kconfig/libcurses/touch.c | 31 +++++--- scripts/kconfig/libcurses/window.c | 62 +++++++++++++++- 16 files changed, 610 insertions(+), 278 deletions(-) diff --git a/scripts/kconfig/libcurses/README.md b/scripts/kconfig/libcurses/README.md index 97ad342fe..81f5b2cbe 100644 --- a/scripts/kconfig/libcurses/README.md +++ b/scripts/kconfig/libcurses/README.md @@ -7,14 +7,14 @@ port can just as easily be built for 64-bit systems. Windows 95 through Windows 10 are covered. (Some features require later versions.) -Distribution Status -------------------- - -The files in this directory are released to the public domain. - - Acknowledgements ---------------- Windows console port was originally provided by Chris Szurgot + + +Distribution Status +------------------- + +The files in this directory are released to the public domain. diff --git a/scripts/kconfig/libcurses/color.c b/scripts/kconfig/libcurses/color.c index 83b2336f9..3335ae082 100644 --- a/scripts/kconfig/libcurses/color.c +++ b/scripts/kconfig/libcurses/color.c @@ -17,7 +17,10 @@ color int init_color(short color, short red, short green, short blue); int color_content(short color, short *red, short *green, short *blue); + int alloc_pair(int fg, int bg); int assume_default_colors(int f, int b); + int find_pair(int fg, int bg); + int free_pair(int pair); int use_default_colors(void); int PDC_set_line_color(short color); @@ -68,6 +71,13 @@ color variable PDC_ORIGINAL_COLORS is set at the time start_color() is called, that's equivalent to calling use_default_colors(). + alloc_pair(), find_pair() and free_pair() are also from ncurses. + free_pair() marks a pair as unused; find_pair() returns an existing + pair with the specified foreground and background colors, if one + exists. And alloc_pair() returns such a pair whether or not it was + previously set, overwriting the oldest initialized pair if there are + no free pairs. + PDC_set_line_color() is used to set the color, globally, for the color of the lines drawn for the attributes: A_UNDERLINE, A_LEFT and A_RIGHT. A value of -1 (the default) indicates that the current @@ -77,8 +87,9 @@ color ### Return Value - All functions return OK on success and ERR on error, except for - has_colors() and can_change_colors(), which return TRUE or FALSE. + Most functions return OK on success and ERR on error. has_colors() + and can_change_colors() return TRUE or FALSE. alloc_pair() and + find_pair() return a pair number, or -1 on error. ### Portability X/Open ncurses NetBSD @@ -89,7 +100,10 @@ color can_change_color Y Y Y init_color Y Y Y color_content Y Y Y + alloc_pair - Y - assume_default_colors - Y Y + find_pair - Y - + free_pair - Y - use_default_colors - Y Y PDC_set_line_color - - - @@ -101,11 +115,9 @@ color int COLORS = 0; int COLOR_PAIRS = PDC_COLOR_PAIRS; -/* pair_set[] tracks whether a pair has been set via init_pair() */ - -static bool pair_set[PDC_COLOR_PAIRS]; static bool default_colors = FALSE; static short first_col = 0; +static int allocnum = 0; int start_color(void) { @@ -123,8 +135,6 @@ int start_color(void) PDC_init_atrtab(); - memset(pair_set, 0, PDC_COLOR_PAIRS); - return OK; } @@ -137,13 +147,9 @@ static void _normalize(short *fg, short *bg) *bg = SP->orig_attr ? SP->orig_back : COLOR_BLACK; } -int init_pair(short pair, short fg, short bg) +static void _init_pair_core(short pair, short fg, short bg) { - PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg)); - - if (!SP || !SP->color_started || pair < 1 || pair >= COLOR_PAIRS || - fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS) - return ERR; + PDC_PAIR *p = SP->atrtab + pair; _normalize(&fg, &bg); @@ -151,19 +157,27 @@ int init_pair(short pair, short fg, short bg) curscr if this call to init_pair() alters a color pair created by the user. */ - if (pair_set[pair]) + if (p->set) { - short oldfg, oldbg; - - PDC_pair_content(pair, &oldfg, &oldbg); - - if (oldfg != fg || oldbg != bg) + if (p->f != fg || p->b != bg) curscr->_clear = TRUE; } - PDC_init_pair(pair, fg, bg); + p->f = fg; + p->b = bg; + p->count = allocnum++; + p->set = TRUE; +} + +int init_pair(short pair, short fg, short bg) +{ + PDC_LOG(("init_pair() - called: pair %d fg %d bg %d\n", pair, fg, bg)); + + if (!SP || !SP->color_started || pair < 1 || pair >= COLOR_PAIRS || + fg < first_col || fg >= COLORS || bg < first_col || bg >= COLORS) + return ERR; - pair_set[pair] = TRUE; + _init_pair_core(pair, fg, bg); return OK; } @@ -227,7 +241,10 @@ int pair_content(short pair, short *fg, short *bg) if (pair < 0 || pair >= COLOR_PAIRS || !fg || !bg) return ERR; - return PDC_pair_content(pair, fg, bg); + *fg = SP->atrtab[pair].f; + *bg = SP->atrtab[pair].b; + + return OK; } int assume_default_colors(int f, int b) @@ -238,21 +255,7 @@ int assume_default_colors(int f, int b) return ERR; if (SP->color_started) - { - short fg, bg, oldfg, oldbg; - - fg = f; - bg = b; - - _normalize(&fg, &bg); - - PDC_pair_content(0, &oldfg, &oldbg); - - if (oldfg != fg || oldbg != bg) - curscr->_clear = TRUE; - - PDC_init_pair(0, fg, bg); - } + _init_pair_core(0, f, b); return OK; } @@ -281,6 +284,7 @@ int PDC_set_line_color(short color) void PDC_init_atrtab(void) { + PDC_PAIR *p = SP->atrtab; short i, fg, bg; if (SP->color_started && !default_colors) @@ -294,5 +298,65 @@ void PDC_init_atrtab(void) _normalize(&fg, &bg); for (i = 0; i < PDC_COLOR_PAIRS; i++) - PDC_init_pair(i, fg, bg); + { + p[i].f = fg; + p[i].b = bg; + p[i].set = FALSE; + } +} + +int free_pair(int pair) +{ + if (pair < 1 || pair >= PDC_COLOR_PAIRS || !(SP->atrtab[pair].set)) + return ERR; + + SP->atrtab[pair].set = FALSE; + return OK; +} + +int find_pair(int fg, int bg) +{ + int i; + PDC_PAIR *p = SP->atrtab; + + for (i = 0; i < PDC_COLOR_PAIRS; i++) + if (p[i].set && p[i].f == fg && p[i].b == bg) + return i; + + return -1; +} + +static int _find_oldest() +{ + int i, lowind = 0, lowval = 0; + PDC_PAIR *p = SP->atrtab; + + for (i = 1; i < PDC_COLOR_PAIRS; i++) + { + if (!p[i].set) + return i; + + if (!lowval || (p[i].count < lowval)) + { + lowind = i; + lowval = p[i].count; + } + } + + return lowind; +} + +int alloc_pair(int fg, int bg) +{ + int i = find_pair(fg, bg); + + if (-1 == i) + { + i = _find_oldest(); + + if (ERR == init_pair(i, fg, bg)) + return -1; + } + + return i; } diff --git a/scripts/kconfig/libcurses/curses.h b/scripts/kconfig/libcurses/curses.h index b5b91fda3..e4ba3776a 100644 --- a/scripts/kconfig/libcurses/curses.h +++ b/scripts/kconfig/libcurses/curses.h @@ -9,26 +9,26 @@ Define before inclusion (only those needed): - XCURSES True if compiling for X11. - PDC_RGB True if you want to use RGB color definitions - (Red = 1, Green = 2, Blue = 4) instead of BGR. - PDC_WIDE True if building wide-character support. - PDC_DLL_BUILD True if building a Windows DLL. - PDC_NCMOUSE Use the ncurses mouse API instead - of PDCurses' traditional mouse API. + XCURSES if building / built for X11 + PDC_RGB if you want to use RGB color definitions + (Red = 1, Green = 2, Blue = 4) instead of BGR + PDC_WIDE if building / built with wide-character support + PDC_DLL_BUILD if building / built as a Windows DLL + PDC_NCMOUSE to use the ncurses mouse API instead + of PDCurses' traditional mouse API Defined by this header: - PDCURSES Enables access to PDCurses-only routines. - PDC_BUILD Defines API build version. - PDC_VER_MAJOR Major version number - PDC_VER_MINOR Minor version number - PDC_VERDOT Version string + PDCURSES PDCurses-only features are available + PDC_BUILD API build version + PDC_VER_MAJOR major version number + PDC_VER_MINOR minor version number + PDC_VERDOT version string **man-end****************************************************************/ #define PDCURSES 1 -#define PDC_BUILD 3900 +#define PDC_BUILD 3907 #define PDC_VER_MAJOR 3 #define PDC_VER_MINOR 9 #define PDC_VERDOT "3.9" @@ -300,8 +300,29 @@ typedef struct _win /* definition of a window */ int _delayms; /* milliseconds of delay for getch() */ int _parx, _pary; /* coords relative to parent (0,0) */ struct _win *_parent; /* subwin's pointer to parent win */ + + /* these are used only if this is a pad */ + struct pdat + { + int _pad_y; + int _pad_x; + int _pad_top; + int _pad_left; + int _pad_bottom; + int _pad_right; + } _pad; /* Pad-properties structure */ } WINDOW; +/* Color pair structure */ + +typedef struct +{ + short f; /* foreground color */ + short b; /* background color */ + int count; /* allocation order */ + bool set; /* pair has been set */ +} PDC_PAIR; + /* Avoid using the SCREEN struct directly -- use the corresponding functions if possible. This struct may eventually be made private. */ @@ -347,15 +368,6 @@ typedef struct bool key_code; /* TRUE if last key is a special key; used internally by get_wch() */ MOUSE_STATUS mouse_status; /* last returned mouse status */ -#ifdef XCURSES - bool sb_on; - int sb_viewport_y; - int sb_viewport_x; - int sb_total_y; - int sb_total_x; - int sb_cur_y; - int sb_cur_x; -#endif short line_color; /* color of line attributes - default -1 */ attr_t termattrs; /* attribute capabilities */ WINDOW *lastscr; /* the last screen image */ @@ -364,6 +376,13 @@ typedef struct bool dirty; /* redraw on napms() after init_color() */ int sel_start; /* start of selection (y * COLS + x) */ int sel_end; /* end of selection */ + int *c_buffer; /* character buffer */ + int c_pindex; /* putter index */ + int c_gindex; /* getter index */ + int *c_ungch; /* array of ungotten chars */ + int c_ungind; /* ungetch() push index */ + int c_ungmax; /* allocated size of ungetch() buffer */ + PDC_PAIR *atrtab; /* table of color pairs */ } SCREEN; /*---------------------------------------------------------------------- @@ -1275,14 +1294,29 @@ PDCEX mmask_t getmouse(void); /* ncurses */ +PDCEX int alloc_pair(int, int); PDCEX int assume_default_colors(int, int); PDCEX const char *curses_version(void); +PDCEX int find_pair(int, int); +PDCEX int free_pair(int); PDCEX bool has_key(int); +PDCEX bool is_cleared(const WINDOW *); +PDCEX bool is_idcok(const WINDOW *); +PDCEX bool is_idlok(const WINDOW *); +PDCEX bool is_immedok(const WINDOW *); PDCEX bool is_keypad(const WINDOW *); PDCEX bool is_leaveok(const WINDOW *); +PDCEX bool is_nodelay(const WINDOW *); +PDCEX bool is_notimeout(const WINDOW *); PDCEX bool is_pad(const WINDOW *); +PDCEX bool is_scrollok(const WINDOW *); +PDCEX bool is_subwin(const WINDOW *); +PDCEX bool is_syncok(const WINDOW *); PDCEX int set_tabsize(int); PDCEX int use_default_colors(void); +PDCEX int wgetdelay(const WINDOW *); +PDCEX WINDOW *wgetparent(const WINDOW *); +PDCEX int wgetscrreg(const WINDOW *, int *, int *); PDCEX int wresize(WINDOW *, int, int); PDCEX bool has_mouse(void); @@ -1331,7 +1365,6 @@ PDCEX int PDC_freeclipboard(char *); PDCEX int PDC_getclipboard(char **, long *); PDCEX int PDC_setclipboard(const char *, long); -PDCEX unsigned long PDC_get_input_fd(void); PDCEX unsigned long PDC_get_key_modifiers(void); PDCEX int PDC_return_key_modifiers(bool); @@ -1381,6 +1414,7 @@ PDCEX int wunderscore(WINDOW *); /* Deprecated */ #define PDC_save_key_modifiers(x) (OK) +#define PDC_get_input_fd() 0 /* return codes from PDC_getclipboard() and PDC_setclipboard() calls */ diff --git a/scripts/kconfig/libcurses/curspriv.h b/scripts/kconfig/libcurses/curspriv.h index 8bb712a8e..5a6ec1550 100644 --- a/scripts/kconfig/libcurses/curspriv.h +++ b/scripts/kconfig/libcurses/curspriv.h @@ -7,16 +7,23 @@ #define CURSES_LIBRARY #include "curses.h" +#ifdef __cplusplus +extern "C" { +#endif + #if defined(__TURBOC__) || defined(__EMX__) || defined(__DJGPP__) || \ defined(PDC_99) || defined(__WATCOMC__) # ifndef HAVE_VSSCANF -# define HAVE_VSSCANF /* have vsscanf() */ +# define HAVE_VSSCANF 1 /* have vsscanf() */ # endif #endif #if defined(PDC_99) || defined(__WATCOMC__) +# ifndef HAVE_SNPRINTF +# define HAVE_SNPRINTF 1 /* have snprintf() */ +# endif # ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF /* have vsnprintf() */ +# define HAVE_VSNPRINTF 1 /* have vsnprintf() */ # endif #endif @@ -51,6 +58,7 @@ bool PDC_can_change_color(void); int PDC_color_content(short, short *, short *, short *); bool PDC_check_key(void); int PDC_curs_set(int); +void PDC_doupdate(void); void PDC_flushinp(void); int PDC_get_columns(void); int PDC_get_cursor_mode(void); @@ -59,19 +67,20 @@ int PDC_get_rows(void); void PDC_gotoyx(int, int); bool PDC_has_mouse(void); int PDC_init_color(short, short, short, short); -void PDC_init_pair(short, short, short); int PDC_modifiers_set(void); int PDC_mouse_set(void); void PDC_napms(int); -int PDC_pair_content(short, short *, short *); void PDC_reset_prog_mode(void); void PDC_reset_shell_mode(void); int PDC_resize_screen(int, int); void PDC_restore_screen_mode(int); void PDC_save_screen_mode(int); +#ifdef XCURSES +void PDC_set_args(int, char **); +#endif void PDC_scr_close(void); void PDC_scr_free(void); -int PDC_scr_open(int, char **); +int PDC_scr_open(void); void PDC_set_keyboard_binary(bool); void PDC_transform_line(int, int, int, const chtype *); const char *PDC_sysname(void); @@ -100,8 +109,6 @@ size_t PDC_wcstombs(char *, const wchar_t *, size_t); /* Internal macros for attributes */ -#define PDC_COLOR_PAIRS 256 - #ifndef max # define max(a,b) (((a) > (b)) ? (a) : (b)) #endif @@ -113,7 +120,14 @@ size_t PDC_wcstombs(char *, const wchar_t *, size_t); #define PDC_CLICK_PERIOD 150 /* time to wait for a click, if not set by mouseinterval() */ +#define PDC_COLOR_PAIRS 256 +#define PDC_MAXCOL 768 /* maximum possible COLORS; may be less */ + +#define _INBUFSIZ 512 /* size of terminal input buffer */ +#define NUNGETCH 256 /* max # chars to ungetch() */ -#define PDC_MAXCOL 768 /* maximum possible COLORS; may be less */ +#ifdef __cplusplus +} +#endif #endif /* __CURSES_INTERNALS__ */ diff --git a/scripts/kconfig/libcurses/getch.c b/scripts/kconfig/libcurses/getch.c index fa0c674b5..8719ca39c 100644 --- a/scripts/kconfig/libcurses/getch.c +++ b/scripts/kconfig/libcurses/getch.c @@ -93,14 +93,6 @@ getch #include -#define _INBUFSIZ 512 /* size of terminal input buffer */ -#define NUNGETCH 256 /* max # chars to ungetch() */ - -static int c_pindex = 0; /* putter index */ -static int c_gindex = 1; /* getter index */ -static int c_ungind = 0; /* ungetch() push index */ -static int c_ungch[NUNGETCH]; /* array of ungotten chars */ - static int _get_box(int *y_start, int *y_end, int *x_start, int *x_end) { int start, end; @@ -166,7 +158,7 @@ static void _copy(void) #ifdef PDC_WIDE wtmp = malloc((len + 1) * sizeof(wchar_t)); - len *= 3; + len *= 4; #endif tmp = malloc(len + 1); @@ -204,7 +196,7 @@ static int _paste(void) # define PASTE paste #endif char *paste; - long len; + long len, newmax; int key; key = PDC_getclipboard(&paste, &len); @@ -215,6 +207,14 @@ static int _paste(void) wpaste = malloc(len * sizeof(wchar_t)); len = PDC_mbstowcs(wpaste, paste, len); #endif + newmax = len + SP->c_ungind; + if (newmax > SP->c_ungmax) + { + SP->c_ungch = realloc(SP->c_ungch, newmax * sizeof(int)); + if (!SP->c_ungch) + return -1; + SP->c_ungmax = newmax; + } while (len > 1) PDC_ungetch(PASTE[--len]); key = *PASTE; @@ -322,7 +322,6 @@ static int _mouse_key(void) int wgetch(WINDOW *win) { - static int buffer[_INBUFSIZ]; /* character buffer */ int key, waitcount; PDC_LOG(("wgetch() - called\n")); @@ -357,18 +356,18 @@ int wgetch(WINDOW *win) /* if ungotten char exists, remove and return it */ - if (c_ungind) - return c_ungch[--c_ungind]; + if (SP->c_ungind) + return SP->c_ungch[--(SP->c_ungind)]; /* if normal and data in buffer */ - if ((!SP->raw_inp && !SP->cbreak) && (c_gindex < c_pindex)) - return buffer[c_gindex++]; + if ((!SP->raw_inp && !SP->cbreak) && (SP->c_gindex < SP->c_pindex)) + return SP->c_buffer[SP->c_gindex++]; /* prepare to buffer data */ - c_pindex = 0; - c_gindex = 0; + SP->c_pindex = 0; + SP->c_gindex = 0; /* to get here, no keys are buffered. go and get one. */ @@ -453,17 +452,17 @@ int wgetch(WINDOW *win) if (key == '\b') { - if (c_pindex > c_gindex) - c_pindex--; + if (SP->c_pindex > SP->c_gindex) + SP->c_pindex--; } else - if (c_pindex < _INBUFSIZ - 2) - buffer[c_pindex++] = key; + if (SP->c_pindex < _INBUFSIZ - 2) + SP->c_buffer[SP->c_pindex++] = key; /* if we got a line */ if (key == '\n' || key == '\r') - return buffer[c_gindex++]; + return SP->c_buffer[SP->c_gindex++]; } } @@ -491,10 +490,10 @@ int PDC_ungetch(int ch) { PDC_LOG(("ungetch() - called\n")); - if (c_ungind >= NUNGETCH) /* pushback stack full */ + if (SP->c_ungind >= SP->c_ungmax) /* pushback stack full */ return ERR; - c_ungch[c_ungind++] = ch; + SP->c_ungch[SP->c_ungind++] = ch; return OK; } @@ -503,11 +502,14 @@ int flushinp(void) { PDC_LOG(("flushinp() - called\n")); + if (!SP) + return ERR; + PDC_flushinp(); - c_gindex = 1; /* set indices to kill buffer */ - c_pindex = 0; - c_ungind = 0; /* clear c_ungch array */ + SP->c_gindex = 1; /* set indices to kill buffer */ + SP->c_pindex = 0; + SP->c_ungind = 0; /* clear SP->c_ungch array */ return OK; } diff --git a/scripts/kconfig/libcurses/initscr.c b/scripts/kconfig/libcurses/initscr.c index be0b2a066..66940a3cf 100644 --- a/scripts/kconfig/libcurses/initscr.c +++ b/scripts/kconfig/libcurses/initscr.c @@ -10,7 +10,7 @@ initscr ### Synopsis WINDOW *initscr(void); - WINDOW *Xinitscr(int argc, char *argv[]); + WINDOW *Xinitscr(int argc, char **argv); int endwin(void); bool isendwin(void); SCREEN *newterm(const char *type, FILE *outfd, FILE *infd); @@ -116,19 +116,20 @@ MOUSE_STATUS Mouse_status; extern RIPPEDOFFLINE linesripped[5]; extern char linesrippedoff; -#ifndef XCURSES -static -#endif -WINDOW *Xinitscr(int argc, char *argv[]) +WINDOW *initscr(void) { int i; - PDC_LOG(("Xinitscr() - called\n")); + PDC_LOG(("initscr() - called\n")); if (SP && SP->alive) return NULL; - if (PDC_scr_open(argc, argv) == ERR) + SP = calloc(1, sizeof(SCREEN)); + if (!SP) + return NULL; + + if (PDC_scr_open() == ERR) { fprintf(stderr, "initscr(): Unable to create SP\n"); exit(8); @@ -157,8 +158,8 @@ WINDOW *Xinitscr(int argc, char *argv[]) SP->orig_cursor = PDC_get_cursor_mode(); - LINES = SP->lines; - COLS = SP->cols; + LINES = SP->lines = PDC_get_rows(); + COLS = SP->cols = PDC_get_columns(); if (LINES < 2 || COLS < 2) { @@ -225,6 +226,9 @@ WINDOW *Xinitscr(int argc, char *argv[]) else curscr->_clear = TRUE; + SP->atrtab = calloc(PDC_COLOR_PAIRS, sizeof(PDC_PAIR)); + if (!SP->atrtab) + return NULL; PDC_init_atrtab(); /* set up default colors */ MOUSE_X_POS = MOUSE_Y_POS = -1; @@ -239,15 +243,30 @@ WINDOW *Xinitscr(int argc, char *argv[]) sprintf(ttytype, "pdcurses|PDCurses for %s", PDC_sysname()); + SP->c_buffer = malloc(_INBUFSIZ * sizeof(int)); + if (!SP->c_buffer) + return NULL; + SP->c_pindex = 0; + SP->c_gindex = 1; + + SP->c_ungch = malloc(NUNGETCH * sizeof(int)); + if (!SP->c_ungch) + return NULL; + SP->c_ungind = 0; + SP->c_ungmax = NUNGETCH; + return stdscr; } -WINDOW *initscr(void) +#ifdef XCURSES +WINDOW *Xinitscr(int argc, char **argv) { - PDC_LOG(("initscr() - called\n")); + PDC_LOG(("Xinitscr() - called\n")); - return Xinitscr(0, NULL); + PDC_set_args(argc, argv); + return initscr(); } +#endif int endwin(void) { @@ -274,7 +293,7 @@ SCREEN *newterm(const char *type, FILE *outfd, FILE *infd) { PDC_LOG(("newterm() - called\n")); - return Xinitscr(0, NULL) ? SP : NULL; + return initscr() ? SP : NULL; } SCREEN *set_term(SCREEN *new) @@ -290,9 +309,13 @@ void delscreen(SCREEN *sp) { PDC_LOG(("delscreen() - called\n")); - if (sp != SP) + if (!SP || sp != SP) return; + free(SP->c_ungch); + free(SP->c_buffer); + free(SP->atrtab); + PDC_slk_free(); /* free the soft label keys, if needed */ delwin(stdscr); @@ -304,8 +327,9 @@ void delscreen(SCREEN *sp) SP->alive = FALSE; - PDC_scr_free(); /* free SP */ + PDC_scr_free(); + free(SP); SP = (SCREEN *)NULL; } @@ -316,10 +340,17 @@ int resize_term(int nlines, int ncols) if (!stdscr || PDC_resize_screen(nlines, ncols) == ERR) return ERR; + SP->resized = FALSE; + SP->lines = PDC_get_rows(); LINES = SP->lines - SP->linesrippedoff - SP->slklines; SP->cols = COLS = PDC_get_columns(); + if (SP->cursrow >= SP->lines) + SP->cursrow = SP->lines - 1; + if (SP->curscol >= SP->cols) + SP->curscol = SP->cols - 1; + if (wresize(curscr, SP->lines, SP->cols) == ERR || wresize(stdscr, LINES, COLS) == ERR || wresize(SP->lastscr, SP->lines, SP->cols) == ERR) diff --git a/scripts/kconfig/libcurses/inopts.c b/scripts/kconfig/libcurses/inopts.c index 918b7d1af..30e18f611 100644 --- a/scripts/kconfig/libcurses/inopts.c +++ b/scripts/kconfig/libcurses/inopts.c @@ -27,12 +27,15 @@ inopts void qiflush(void); void timeout(int delay); void wtimeout(WINDOW *win, int delay); + int wgetdelay(const WINDOW *win); int typeahead(int fildes); int crmode(void); int nocrmode(void); bool is_keypad(const WINDOW *win); + bool is_nodelay(const WINDOW *win); + bool is_notimeout(const WINDOW *win); ### Description @@ -83,6 +86,8 @@ inopts delay is given; i.e., 1-99 will wait 50ms, 100-149 will wait 100ms, etc. + wgetdelay() returns the delay timeout as set in wtimeout(). + intrflush(), notimeout(), noqiflush(), qiflush() and typeahead() do nothing in PDCurses, but are included for compatibility with other curses implementations. @@ -92,10 +97,13 @@ inopts is_keypad() reports whether the specified window is in keypad mode. + is_nodelay() reports whether the specified window is in nodelay mode. + ### Return Value - All functions except is_keypad() and the void functions return OK on - success and ERR on error. + is_keypad() and is_nodelay() return TRUE or FALSE. is_notimeout() is + provided for compatibility with other curses implementations, and + always returns FALSE. All others return OK on success and ERR on error. ### Portability X/Open ncurses NetBSD @@ -117,10 +125,13 @@ inopts qiflush Y Y Y timeout Y Y Y wtimeout Y Y Y + wgetdelay - Y - typeahead Y Y Y crmode Y Y Y nocrmode Y Y Y is_keypad - Y Y + is_nodelay - Y - + is_notimeout - Y - **man-end****************************************************************/ @@ -295,11 +306,11 @@ void qiflush(void) PDC_LOG(("qiflush() - called\n")); } -int typeahead(int fildes) +void timeout(int delay) { - PDC_LOG(("typeahead() - called\n")); + PDC_LOG(("timeout() - called\n")); - return OK; + wtimeout(stdscr, delay); } void wtimeout(WINDOW *win, int delay) @@ -336,11 +347,21 @@ void wtimeout(WINDOW *win, int delay) } } -void timeout(int delay) +int wgetdelay(const WINDOW *win) { - PDC_LOG(("timeout() - called\n")); + PDC_LOG(("wgetdelay() - called\n")); - wtimeout(stdscr, delay); + if (!win) + return 0; + + return win->_delayms; +} + +int typeahead(int fildes) +{ + PDC_LOG(("typeahead() - called\n")); + + return OK; } int crmode(void) @@ -366,3 +387,22 @@ bool is_keypad(const WINDOW *win) return win->_use_keypad; } + +bool is_nodelay(const WINDOW *win) +{ + PDC_LOG(("is_nodelay() - called\n")); + + if (!win) + return FALSE; + + return win->_nodelay; +} + +bool is_notimeout(const WINDOW *win) +{ + (void) win; + + PDC_LOG(("is_notimeout() - called - returning FALSE...\n")); + + return FALSE; +} diff --git a/scripts/kconfig/libcurses/outopts.c b/scripts/kconfig/libcurses/outopts.c index 28f93f1f2..e0a55e437 100644 --- a/scripts/kconfig/libcurses/outopts.c +++ b/scripts/kconfig/libcurses/outopts.c @@ -16,11 +16,17 @@ outopts int leaveok(WINDOW *win, bool bf); int setscrreg(int top, int bot); int wsetscrreg(WINDOW *win, int top, int bot); + int wgetscrreg(const WINDOW *win, int *top, int *bot); int scrollok(WINDOW *win, bool bf); int raw_output(bool bf); + bool is_cleared(const WINDOW *win); + bool is_idlok(const WINDOW *win); + bool is_idcok(const WINDOW *win); + bool is_immedok(const WINDOW *win); bool is_leaveok(const WINDOW *win); + bool is_scrollok(const WINDOW *win); ### Description @@ -42,19 +48,31 @@ outopts will cause all lines in the scrolling region to scroll up one line. setscrreg() is the stdscr version. + wgetscrreg() gets the top and bottom margins as set in wsetscrreg(). + idlok() and idcok() do nothing in PDCurses, but are provided for - compatibility with other curses implementations. + compatibility with other curses implementations, likewise is_idlok() + and is_idcok(). raw_output() enables the output of raw characters using the standard *add* and *ins* curses functions (that is, it disables translation of control characters). + is_cleared() reports whether the specified window causes clear at next + refresh. + + is_immedok() reports whether the specified window is in immedok mode. + is_leaveok() reports whether the specified window is in leaveok mode. + is_scrollok() reports whether the specified window allows scrolling. + ### Return Value - All functions except is_leaveok() return OK on success and ERR on - error. + is_cleared(), is_immedok(), is_leaveok() and is_scrollok() return TRUE + or FALSE. is_idlok() and is_idcok() are provided for compatibility with + other curses implementations, and always return FALSE. All others + return OK on success and ERR on error. ### Portability X/Open ncurses NetBSD @@ -65,8 +83,14 @@ outopts leaveok Y Y Y setscrreg Y Y Y wsetscrreg Y Y Y + wgetscrreg - Y - scrollok Y Y Y + is_cleared - Y - + is_idlok - Y - + is_idcok - Y - + is_immedok - Y - is_leaveok - Y Y + is_scrollok - Y - raw_output - - - **man-end****************************************************************/ @@ -140,6 +164,19 @@ int wsetscrreg(WINDOW *win, int top, int bottom) return ERR; } +int wgetscrreg(const WINDOW *win, int *top, int *bot) +{ + PDC_LOG(("wgetscrreg() - called\n")); + + if (!win || !top || !bot) + return ERR; + + *top = win->_tmarg; + *bot = win->_bmarg; + + return OK; +} + int scrollok(WINDOW *win, bool bf) { PDC_LOG(("scrollok() - called\n")); @@ -164,6 +201,44 @@ int raw_output(bool bf) return OK; } +bool is_cleared(const WINDOW *win) +{ + PDC_LOG(("is_cleared() - called\n")); + + if (!win) + return FALSE; + + return win->_clear; +} + +bool is_idlok(const WINDOW *win) +{ + (void) win; + + PDC_LOG(("is_idlok() - called\n")); + + return FALSE; +} + +bool is_idcok(const WINDOW *win) +{ + (void) win; + + PDC_LOG(("is_idcok() - called\n")); + + return FALSE; +} + +bool is_immedok(const WINDOW *win) +{ + PDC_LOG(("is_immedok() - called\n")); + + if (!win) + return FALSE; + + return win->_immed; +} + bool is_leaveok(const WINDOW *win) { PDC_LOG(("is_leaveok() - called\n")); @@ -173,3 +248,13 @@ bool is_leaveok(const WINDOW *win) return win->_leaveit; } + +bool is_scrollok(const WINDOW *win) +{ + PDC_LOG(("is_scrollok() - called\n")); + + if (!win) + return FALSE; + + return win->_scroll; +} diff --git a/scripts/kconfig/libcurses/pad.c b/scripts/kconfig/libcurses/pad.c index 5003ecbb4..3dfdfe5d6 100644 --- a/scripts/kconfig/libcurses/pad.c +++ b/scripts/kconfig/libcurses/pad.c @@ -75,11 +75,6 @@ pad #include -/* save values for pechochar() */ - -static int save_pminrow, save_pmincol; -static int save_sminrow, save_smincol, save_smaxrow, save_smaxcol; - WINDOW *newpad(int nlines, int ncols) { WINDOW *win; @@ -96,16 +91,12 @@ WINDOW *newpad(int nlines, int ncols) werase(win); win->_flags = _PAD; - - /* save default values in case pechochar() is the first call to - prefresh(). */ - - save_pminrow = 0; - save_pmincol = 0; - save_sminrow = 0; - save_smincol = 0; - save_smaxrow = min(LINES, nlines) - 1; - save_smaxcol = min(COLS, ncols) - 1; + win->_pad._pad_y = 0; + win->_pad._pad_x = 0; + win->_pad._pad_top = 0; + win->_pad._pad_left = 0; + win->_pad._pad_bottom = min(LINES, nlines) - 1; + win->_pad._pad_right = min(COLS, ncols) - 1; return win; } @@ -151,16 +142,12 @@ WINDOW *subpad(WINDOW *orig, int nlines, int ncols, int begy, int begx) win->_y[i] = orig->_y[begy + i] + begx; win->_flags = _SUBPAD; - - /* save default values in case pechochar() is the first call - to prefresh(). */ - - save_pminrow = 0; - save_pmincol = 0; - save_sminrow = 0; - save_smincol = 0; - save_smaxrow = min(LINES, nlines) - 1; - save_smaxcol = min(COLS, ncols) - 1; + win->_pad._pad_y = 0; + win->_pad._pad_x = 0; + win->_pad._pad_top = 0; + win->_pad._pad_left = 0; + win->_pad._pad_bottom = min(LINES, nlines) - 1; + win->_pad._pad_right = min(COLS, ncols) - 1; return win; } @@ -179,14 +166,11 @@ int prefresh(WINDOW *win, int py, int px, int sy1, int sx1, int sy2, int sx2) int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2) { int num_cols; - int sline = sy1; - int pline = py; + int sline; + int pline; PDC_LOG(("pnoutrefresh() - called\n")); - if (!w || !(w->_flags & (_PAD|_SUBPAD)) || (sy2 >= LINES) || (sx2 >= COLS)) - return ERR; - if (py < 0) py = 0; if (px < 0) @@ -196,9 +180,14 @@ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2) if (sx1 < 0) sx1 = 0; - if (sy2 < sy1 || sx2 < sx1) + if ((!w || !(w->_flags & (_PAD|_SUBPAD)) || + (sy2 >= LINES) || (sx2 >= COLS)) || + (sy2 < sy1) || (sx2 < sx1)) return ERR; + sline = sy1; + pline = py; + num_cols = min((sx2 - sx1 + 1), (w->_maxx - px)); while (sline <= sy2) @@ -240,6 +229,13 @@ int pnoutrefresh(WINDOW *w, int py, int px, int sy1, int sx1, int sy2, int sx2) curscr->_curx = (w->_curx - px) + sx1; } + w->_pad._pad_y = py; + w->_pad._pad_x = px; + w->_pad._pad_top = sy1; + w->_pad._pad_left = sx1; + w->_pad._pad_bottom = sy2; + w->_pad._pad_right = sx2; + return OK; } @@ -250,8 +246,8 @@ int pechochar(WINDOW *pad, chtype ch) if (waddch(pad, ch) == ERR) return ERR; - return prefresh(pad, save_pminrow, save_pmincol, save_sminrow, - save_smincol, save_smaxrow, save_smaxcol); + return prefresh(pad, pad->_pad._pad_y, pad->_pad._pad_x, pad->_pad._pad_top, + pad->_pad._pad_left, pad->_pad._pad_bottom, pad->_pad._pad_right); } #ifdef PDC_WIDE @@ -262,8 +258,8 @@ int pecho_wchar(WINDOW *pad, const cchar_t *wch) if (!wch || (waddch(pad, *wch) == ERR)) return ERR; - return prefresh(pad, save_pminrow, save_pmincol, save_sminrow, - save_smincol, save_smaxrow, save_smaxcol); + return prefresh(pad, pad->_pad._pad_y, pad->_pad._pad_x, pad->_pad._pad_top, + pad->_pad._pad_left, pad->_pad._pad_bottom, pad->_pad._pad_right); } #endif diff --git a/scripts/kconfig/libcurses/pdcdisp.c b/scripts/kconfig/libcurses/pdcdisp.c index a0a4a0659..f6115ecb0 100644 --- a/scripts/kconfig/libcurses/pdcdisp.c +++ b/scripts/kconfig/libcurses/pdcdisp.c @@ -153,7 +153,7 @@ void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp) return; } - PDC_pair_content(PAIR_NUMBER(attr), &fore, &back); + pair_content(PAIR_NUMBER(attr), &fore, &back); ansi = pdc_ansi || (fore >= 16 || back >= 16); blink = (SP->termattrs & A_BLINK) && (attr & A_BLINK); @@ -181,8 +181,13 @@ void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp) chtype ch = srcp[j]; if (ch & A_ALTCHARSET && !(ch & 0xff80)) + { ch = acs_map[ch & 0x7f]; + if (pdc_wt && (ch & A_CHARTEXT) < ' ') + goto NONANSI; + } + if (blink && blinked_off) ch = ' '; @@ -198,6 +203,7 @@ void _new_packet(attr_t attr, int lineno, int x, int len, const chtype *srcp) #endif } else +NONANSI: { CHAR_INFO buffer[512]; COORD bufSize, bufPos; @@ -276,7 +282,17 @@ void PDC_transform_line(int lineno, int x, int len, const chtype *srcp) void PDC_blink_text(void) { + CONSOLE_CURSOR_INFO cci; int i, j, k; + bool oldvis; + + GetConsoleCursorInfo(pdc_con_out, &cci); + oldvis = cci.bVisible; + if (oldvis) + { + cci.bVisible = FALSE; + SetConsoleCursorInfo(pdc_con_out, &cci); + } if (!(SP->termattrs & A_BLINK)) blinked_off = FALSE; @@ -299,5 +315,15 @@ void PDC_blink_text(void) } PDC_gotoyx(SP->cursrow, SP->curscol); + if (oldvis) + { + cci.bVisible = TRUE; + SetConsoleCursorInfo(pdc_con_out, &cci); + } + pdc_last_blink = GetTickCount(); } + +void PDC_doupdate(void) +{ +} diff --git a/scripts/kconfig/libcurses/pdckbd.c b/scripts/kconfig/libcurses/pdckbd.c index 958697140..cbab60d63 100644 --- a/scripts/kconfig/libcurses/pdckbd.c +++ b/scripts/kconfig/libcurses/pdckbd.c @@ -2,26 +2,6 @@ #include "pdcwin.h" -/*man-start************************************************************** - -pdckbd ------- - -### Synopsis - - unsigned long PDC_get_input_fd(void); - -### Description - - PDC_get_input_fd() returns the file descriptor that PDCurses reads - its input from. It can be used for select(). - -### Portability - X/Open ncurses NetBSD - PDC_get_input_fd - - - - -**man-end****************************************************************/ - /* These variables are used to store information about the next Input Event. */ @@ -210,7 +190,37 @@ static KPTAB kptab[] = {0, 0, 0x27, ALT_FQUOTE, 0 }, /* 222 */ {0, 0, 0, 0, 0 }, /* 223 */ {0, 0, 0, 0, 0 }, /* 224 */ - {0, 0, 0, 0, 0 } /* 225 */ + {0, 0, 0, 0, 0 }, /* 225 */ + {0, 0, 0, 0, 0 }, /* 226 */ + {0, 0, 0, 0, 0 }, /* 227 */ + {0, 0, 0, 0, 0 }, /* 228 */ + {0, 0, 0, 0, 0 }, /* 229 */ + {0, 0, 0, 0, 0 }, /* 230 */ + {0, 0, 0, 0, 0 }, /* 231 */ + {0, 0, 0, 0, 0 }, /* 232 */ + {0, 0, 0, 0, 0 }, /* 233 */ + {0, 0, 0, 0, 0 }, /* 234 */ + {0, 0, 0, 0, 0 }, /* 235 */ + {0, 0, 0, 0, 0 }, /* 236 */ + {0, 0, 0, 0, 0 }, /* 237 */ + {0, 0, 0, 0, 0 }, /* 238 */ + {0, 0, 0, 0, 0 }, /* 239 */ + {0, 0, 0, 0, 0 }, /* 240 */ + {0, 0, 0, 0, 0 }, /* 241 */ + {0, 0, 0, 0, 0 }, /* 242 */ + {0, 0, 0, 0, 0 }, /* 243 */ + {0, 0, 0, 0, 0 }, /* 244 */ + {0, 0, 0, 0, 0 }, /* 245 */ + {0, 0, 0, 0, 0 }, /* 246 */ + {0, 0, 0, 0, 0 }, /* 247 */ + {0, 0, 0, 0, 0 }, /* 248 */ + {0, 0, 0, 0, 0 }, /* 249 */ + {0, 0, 0, 0, 0 }, /* 250 */ + {0, 0, 0, 0, 0 }, /* 251 */ + {0, 0, 0, 0, 0 }, /* 252 */ + {0, 0, 0, 0, 0 }, /* 253 */ + {0, 0, 0, 0, 0 }, /* 254 */ + {0, 0, 0, 0, 0 } /* 255 */ }; static KPTAB ext_kptab[] = @@ -233,16 +243,15 @@ static KPTAB ext_kptab[] = /* End of kptab[] */ -unsigned long PDC_get_input_fd(void) -{ - PDC_LOG(("PDC_get_input_fd() - called\n")); - - return 0L; -} - void PDC_set_keyboard_binary(bool on) { + DWORD mode; + PDC_LOG(("PDC_set_keyboard_binary() - called\n")); + + GetConsoleMode(pdc_con_in, &mode); + SetConsoleMode(pdc_con_in, !on ? (mode | ENABLE_PROCESSED_INPUT) : + (mode & ~ENABLE_PROCESSED_INPUT)); } /* check if a key or mouse event is waiting */ @@ -352,7 +361,12 @@ static int _get_key_count(void) static int _process_key_event(void) { - int key = (unsigned short)KEV.uChar.UnicodeChar; + int key = +#ifdef PDC_WIDE + KEV.uChar.UnicodeChar; +#else + KEV.uChar.AsciiChar; +#endif WORD vk = KEV.wVirtualKeyCode; DWORD state = KEV.dwControlKeyState; @@ -466,6 +480,9 @@ static int _process_mouse_event(void) memset(&SP->mouse_status, 0, sizeof(MOUSE_STATUS)); + SP->mouse_status.x = MEV.dwMousePosition.X; + SP->mouse_status.y = MEV.dwMousePosition.Y; + /* Handle scroll wheel */ if (MEV.dwEventFlags == 4) @@ -473,9 +490,6 @@ static int _process_mouse_event(void) SP->mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ? PDC_MOUSE_WHEEL_DOWN : PDC_MOUSE_WHEEL_UP; - SP->mouse_status.x = -1; - SP->mouse_status.y = -1; - memset(&old_mouse_status, 0, sizeof(old_mouse_status)); return KEY_MOUSE; @@ -486,9 +500,6 @@ static int _process_mouse_event(void) SP->mouse_status.changes = (MEV.dwButtonState & 0xFF000000) ? PDC_MOUSE_WHEEL_RIGHT : PDC_MOUSE_WHEEL_LEFT; - SP->mouse_status.x = -1; - SP->mouse_status.y = -1; - memset(&old_mouse_status, 0, sizeof(old_mouse_status)); return KEY_MOUSE; @@ -537,9 +548,6 @@ static int _process_mouse_event(void) } } - SP->mouse_status.x = MEV.dwMousePosition.X; - SP->mouse_status.y = MEV.dwMousePosition.Y; - SP->mouse_status.changes = 0; for (i = 0; i < 3; i++) @@ -662,13 +670,17 @@ bool PDC_has_mouse(void) int PDC_mouse_set(void) { + DWORD mode; + /* If turning on mouse input: Set ENABLE_MOUSE_INPUT, and clear - all other flags, including the extended flags; + all other flags, except processed input mode; If turning off the mouse: Set QuickEdit Mode to the status it - had on startup, and clear all other flags */ + had on startup, and clear all other flags, except etc. */ - SetConsoleMode(pdc_con_in, SP->_trap_mbe ? - (ENABLE_MOUSE_INPUT|0x0088) : (pdc_quick_edit|0x0088)); + GetConsoleMode(pdc_con_in, &mode); + mode = (mode & 1) | 0x0088; + SetConsoleMode(pdc_con_in, mode | (SP->_trap_mbe ? + ENABLE_MOUSE_INPUT : pdc_quick_edit)); memset(&old_mouse_status, 0, sizeof(old_mouse_status)); diff --git a/scripts/kconfig/libcurses/pdcscrn.c b/scripts/kconfig/libcurses/pdcscrn.c index e6640a379..e2f4ddd90 100644 --- a/scripts/kconfig/libcurses/pdcscrn.c +++ b/scripts/kconfig/libcurses/pdcscrn.c @@ -4,10 +4,6 @@ #include -/* COLOR_PAIR to attribute encoding table. */ - -static struct {short f, b;} atrtab[PDC_COLOR_PAIRS]; - /* Color component table */ PDCCOLOR pdc_color[PDC_MAXCOL]; @@ -36,7 +32,7 @@ static short ansitocurs[16] = short pdc_curstoreal[16], pdc_curstoansi[16]; short pdc_oldf, pdc_oldb, pdc_oldu; -bool pdc_conemu, pdc_ansi; +bool pdc_conemu, pdc_wt, pdc_ansi; enum { PDC_RESTORE_NONE, PDC_RESTORE_BUFFER }; @@ -363,9 +359,6 @@ void PDC_scr_close(void) void PDC_scr_free(void) { - if (SP) - free(SP); - if (pdc_con_out != std_con_out) { CloseHandle(pdc_con_out); @@ -376,10 +369,10 @@ void PDC_scr_free(void) SetConsoleCtrlHandler(_ctrl_break, FALSE); } -/* open the physical screen -- allocate SP, miscellaneous intialization, - and may save the existing screen for later restoration */ +/* open the physical screen -- miscellaneous initialization, may save + the existing screen for later restoration */ -int PDC_scr_open(int argc, char **argv) +int PDC_scr_open(void) { const char *str; CONSOLE_SCREEN_BUFFER_INFO csbi; @@ -389,11 +382,6 @@ int PDC_scr_open(int argc, char **argv) PDC_LOG(("PDC_scr_open() - called\n")); - SP = calloc(1, sizeof(SCREEN)); - - if (!SP) - return ERR; - for (i = 0; i < 16; i++) { pdc_curstoreal[realtocurs[i]] = i; @@ -413,9 +401,10 @@ int PDC_scr_open(int argc, char **argv) is_nt = !(GetVersion() & 0x80000000); - str = getenv("ConEmuANSI"); + pdc_wt = !!getenv("WT_SESSION"); + str = pdc_wt ? NULL : getenv("ConEmuANSI"); pdc_conemu = !!str; - pdc_ansi = pdc_conemu ? !strcmp(str, "ON") : FALSE; + pdc_ansi = pdc_wt ? TRUE : pdc_conemu ? !strcmp(str, "ON") : FALSE; GetConsoleScreenBufferInfo(pdc_con_out, &csbi); GetConsoleScreenBufferInfo(pdc_con_out, &orig_scr); @@ -427,9 +416,6 @@ int PDC_scr_open(int argc, char **argv) pdc_quick_edit = old_console_mode & 0x0040; - SP->lines = (str = getenv("LINES")) ? atoi(str) : PDC_get_rows(); - SP->cols = (str = getenv("COLS")) ? atoi(str) : PDC_get_columns(); - SP->mouse_wait = PDC_CLICK_PERIOD; SP->audible = TRUE; @@ -437,22 +423,6 @@ int PDC_scr_open(int argc, char **argv) if (pdc_ansi) SP->termattrs |= A_UNDERLINE | A_ITALIC; - if (SP->lines < 2 || SP->lines > csbi.dwMaximumWindowSize.Y) - { - fprintf(stderr, "LINES value must be >= 2 and <= %d: got %d\n", - csbi.dwMaximumWindowSize.Y, SP->lines); - - return ERR; - } - - if (SP->cols < 2 || SP->cols > csbi.dwMaximumWindowSize.X) - { - fprintf(stderr, "COLS value must be >= 2 and <= %d: got %d\n", - csbi.dwMaximumWindowSize.X, SP->cols); - - return ERR; - } - SP->orig_fore = csbi.wAttributes & 0x0f; SP->orig_back = (csbi.wAttributes & 0xf0) >> 4; @@ -586,9 +556,6 @@ int PDC_resize_screen(int nlines, int ncols) PDC_flushinp(); - SP->resized = FALSE; - SP->cursrow = SP->curscol = 0; - return OK; } @@ -645,20 +612,6 @@ void PDC_save_screen_mode(int i) { } -void PDC_init_pair(short pair, short fg, short bg) -{ - atrtab[pair].f = fg; - atrtab[pair].b = bg; -} - -int PDC_pair_content(short pair, short *fg, short *bg) -{ - *fg = atrtab[pair].f; - *bg = atrtab[pair].b; - - return OK; -} - bool PDC_can_change_color(void) { return is_nt; @@ -666,7 +619,7 @@ bool PDC_can_change_color(void) int PDC_color_content(short color, short *red, short *green, short *blue) { - if (color < 16 && !pdc_conemu) + if (color < 16 && !(pdc_conemu || pdc_wt)) { COLORREF *color_table = _get_colors(); @@ -705,7 +658,7 @@ int PDC_init_color(short color, short red, short green, short blue) return OK; } - if (color < 16 && !pdc_conemu) + if (color < 16 && !(pdc_conemu || pdc_wt)) { COLORREF *color_table = _get_colors(); diff --git a/scripts/kconfig/libcurses/pdcwin.h b/scripts/kconfig/libcurses/pdcwin.h index f23a71fd1..cee76931b 100644 --- a/scripts/kconfig/libcurses/pdcwin.h +++ b/scripts/kconfig/libcurses/pdcwin.h @@ -22,6 +22,6 @@ extern DWORD pdc_quick_edit; extern DWORD pdc_last_blink; extern short pdc_curstoreal[16], pdc_curstoansi[16]; extern short pdc_oldf, pdc_oldb, pdc_oldu; -extern bool pdc_conemu, pdc_ansi; +extern bool pdc_conemu, pdc_wt, pdc_ansi; extern void PDC_blink_text(void); diff --git a/scripts/kconfig/libcurses/refresh.c b/scripts/kconfig/libcurses/refresh.c index c7122332e..306f4efb3 100644 --- a/scripts/kconfig/libcurses/refresh.c +++ b/scripts/kconfig/libcurses/refresh.c @@ -64,8 +64,16 @@ int wnoutrefresh(WINDOW *win) PDC_LOG(("wnoutrefresh() - called: win=%p\n", win)); - if ( !win || (win->_flags & (_PAD|_SUBPAD)) ) + if (!win) return ERR; + if (is_pad(win)) + return pnoutrefresh(win, + win->_pad._pad_y, + win->_pad._pad_x, + win->_pad._pad_top, + win->_pad._pad_left, + win->_pad._pad_bottom, + win->_pad._pad_right); begy = win->_begy; begx = win->_begx; @@ -215,6 +223,8 @@ int doupdate(void) SP->cursrow = curscr->_cury; SP->curscol = curscr->_curx; + PDC_doupdate(); + return OK; } diff --git a/scripts/kconfig/libcurses/touch.c b/scripts/kconfig/libcurses/touch.c index 619fbc6e1..2fd03cce5 100644 --- a/scripts/kconfig/libcurses/touch.c +++ b/scripts/kconfig/libcurses/touch.c @@ -168,31 +168,40 @@ bool is_wintouched(WINDOW *win) int touchoverlap(const WINDOW *win1, WINDOW *win2) { - int y, endy, endx, starty, startx; + int y, endy, endx, starty, startx, begy1, begx1, begy2, begx2; PDC_LOG(("touchoverlap() - called: win1=%p win2=%p\n", win1, win2)); if (!win1 || !win2) return ERR; - starty = max(win1->_begy, win2->_begy); - startx = max(win1->_begx, win2->_begx); - endy = min(win1->_maxy + win1->_begy, win2->_maxy + win2->_begy); - endx = min(win1->_maxx + win1->_begx, win2->_maxx + win2->_begx); + begy1 = win1->_begy; + begx1 = win1->_begx; + begy2 = win2->_begy; + begx2 = win2->_begy; + + starty = max(begy1, begy2); + startx = max(begx1, begx2); + endy = min(win1->_maxy + begy1, win2->_maxy + begy2); + endx = min(win1->_maxx + begx1, win2->_maxx + begx2); if (starty >= endy || startx >= endx) return OK; - starty -= win2->_begy; - startx -= win2->_begx; - endy -= win2->_begy; - endx -= win2->_begx; + starty -= begy2; + startx -= begx2; + endy -= begy2; + endx -= begx2; endx -= 1; for (y = starty; y < endy; y++) { - win2->_firstch[y] = startx; - win2->_lastch[y] = endx; + int first = win2->_firstch[y]; + + if (first == _NO_CHANGE || win2->_lastch[y] < endx) + win2->_lastch[y] = endx; + if (first == _NO_CHANGE || first > startx) + win2->_firstch[y] = startx; } return OK; diff --git a/scripts/kconfig/libcurses/window.c b/scripts/kconfig/libcurses/window.c index 495d7dbea..4ae5b0861 100644 --- a/scripts/kconfig/libcurses/window.c +++ b/scripts/kconfig/libcurses/window.c @@ -15,10 +15,13 @@ window WINDOW *subwin(WINDOW* orig, int nlines, int ncols, int begy, int begx); WINDOW *dupwin(WINDOW *win); + WINDOW *wgetparent(const WINDOW *win); int delwin(WINDOW *win); int mvwin(WINDOW *win, int y, int x); int mvderwin(WINDOW *win, int pary, int parx); int syncok(WINDOW *win, bool bf); + bool is_subwin(const WINDOW *win); + bool is_syncok(const WINDOW *win); void wsyncup(WINDOW *win); void wcursyncup(WINDOW *win); void wsyncdown(WINDOW *win); @@ -64,11 +67,19 @@ window dupwin() creates an exact duplicate of the window win. + wgetparent() returns the parent WINDOW pointer for subwindows, or NULL + for windows having no parent. + wsyncup() causes a touchwin() of all of the window's parents. - If wsyncok() is called with a second argument of TRUE, this causes a + If syncok() is called with a second argument of TRUE, this causes a wsyncup() to be called every time the window is changed. + is_subwin() reports whether the specified window is a subwindow, + created by subwin() or derwin(). + + is_syncok() reports whether the specified window is in syncok mode. + wcursyncup() causes the current cursor position of all of a window's ancestors to reflect the current cursor position of the current window. @@ -101,6 +112,8 @@ window syncok() return OK or ERR. wsyncup(), wcursyncup() and wsyncdown() return nothing. + is_subwin() and is_syncok() returns TRUE or FALSE. + ### Errors It is an error to call resize_window() before calling initscr(). @@ -119,8 +132,11 @@ window derwin Y Y Y mvderwin Y Y Y dupwin Y Y Y + wgetparent - Y - wsyncup Y Y Y syncok Y Y Y + is_subwin - Y - + is_syncok - Y - wcursyncup Y Y Y wsyncdown Y Y Y wresize - Y Y @@ -185,6 +201,15 @@ WINDOW *PDC_makenew(int nlines, int ncols, int begy, int begx) win->_bmarg = nlines - 1; win->_parx = win->_pary = -1; + /* initialize pad variables*/ + + win->_pad._pad_y = -1; + win->_pad._pad_x = -1; + win->_pad._pad_top = -1; + win->_pad._pad_left = -1; + win->_pad._pad_bottom = -1; + win->_pad._pad_right = -1; + /* init to say window all changed */ touchwin(win); @@ -319,9 +344,9 @@ WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx) k = begx - orig->_begx; if (!nlines) - nlines = orig->_maxy - 1 - j; + nlines = orig->_maxy - j; if (!ncols) - ncols = orig->_maxx - 1 - k; + ncols = orig->_maxx - k; win = PDC_makenew(nlines, ncols, begy, begx); if (!win) @@ -438,6 +463,16 @@ WINDOW *dupwin(WINDOW *win) return new; } +WINDOW *wgetparent(const WINDOW *win) +{ + PDC_LOG(("wgetparent() - called\n")); + + if (!win || !win->_parent) + return NULL; + + return win->_parent; +} + WINDOW *resize_window(WINDOW *win, int nlines, int ncols) { WINDOW *new; @@ -488,6 +523,7 @@ WINDOW *resize_window(WINDOW *win, int nlines, int ncols) if (!new) return (WINDOW *)NULL; + new->_bkgd = win->_bkgd; werase(new); copywin(win, new, 0, 0, 0, 0, min(win->_maxy, new->_maxy) - 1, @@ -554,6 +590,26 @@ int syncok(WINDOW *win, bool bf) return OK; } +bool is_subwin(const WINDOW *win) +{ + PDC_LOG(("is_subwin() - called\n")); + + if (!win) + return FALSE; + + return ((win->_flags & _SUBWIN) ? TRUE : FALSE); +} + +bool is_syncok(const WINDOW *win) +{ + PDC_LOG(("is_syncok() - called\n")); + + if (!win) + return FALSE; + + return win->_sync; +} + void wcursyncup(WINDOW *win) { WINDOW *tmp; -- cgit v1.2.3-55-g6feb