diff options
Diffstat (limited to 'ncurses/widechar')
-rw-r--r-- | ncurses/widechar/lib_add_wch.c | 6 | ||||
-rw-r--r-- | ncurses/widechar/lib_cchar.c | 21 | ||||
-rw-r--r-- | ncurses/widechar/lib_erasewchar.c | 34 | ||||
-rw-r--r-- | ncurses/widechar/lib_get_wch.c | 6 | ||||
-rw-r--r-- | ncurses/widechar/lib_get_wstr.c | 27 | ||||
-rw-r--r-- | ncurses/widechar/lib_ins_wch.c | 6 | ||||
-rw-r--r-- | ncurses/widechar/lib_vid_attr.c | 23 | ||||
-rw-r--r-- | ncurses/widechar/widechars.c | 6 |
8 files changed, 77 insertions, 52 deletions
diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c index 5d6d554..b817647 100644 --- a/ncurses/widechar/lib_add_wch.c +++ b/ncurses/widechar/lib_add_wch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 2004-2011,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -40,7 +40,7 @@ #include <wctype.h> #endif -MODULE_ID("$Id: lib_add_wch.c,v 1.16 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_add_wch.c,v 1.17 2021/06/17 21:26:02 tom Exp $") /* clone/adapt lib_addch.c */ static const cchar_t blankchar = NewChar(BLANK_TEXT); @@ -133,7 +133,7 @@ newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos) * wrapped the cursor. We don't do anything with this flag except set it when * wrapping, and clear it whenever we move the cursor. If we try to wrap at * the lower-right corner of a window, we cannot move the cursor (since that - * wouldn't be legal). So we return an error (which is what SVr4 does). + * wouldn't be legal). So we return an error (which is what SVr4 does). * Unlike SVr4, we can successfully add a character to the lower-right corner * (Solaris 2.6 does this also, however). */ diff --git a/ncurses/widechar/lib_cchar.c b/ncurses/widechar/lib_cchar.c index ed1d236..714be3b 100644 --- a/ncurses/widechar/lib_cchar.c +++ b/ncurses/widechar/lib_cchar.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 2001-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -35,10 +35,11 @@ */ #include <curses.priv.h> +#include <wchar.h> -MODULE_ID("$Id: lib_cchar.c,v 1.33 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_cchar.c,v 1.37 2021/06/17 21:11:08 tom Exp $") -/* +/* * The SuSv2 description leaves some room for interpretation. We'll assume wch * points to a string which is L'\0' terminated, contains at least one * character with strictly positive width, which must be the first, and @@ -55,7 +56,7 @@ setcchar(cchar_t *wcval, int color_pair = pair_arg; unsigned len; - TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,%lu,%d,%p)"), + TR(TRACE_CCALLS, (T_CALLED("setcchar(%p,%s,attrs=%lu,pair=%d,%p)"), (void *) wcval, _nc_viswbuf(wch), (unsigned long) attrs, color_pair, opts)); @@ -104,7 +105,6 @@ getcchar(const cchar_t *wcval, void *opts) { int code = ERR; - int color_pair; TR(TRACE_CCALLS, (T_CALLED("getcchar(%p,%p,%p,%p,%p)"), (const void *) wcval, @@ -113,7 +113,12 @@ getcchar(const cchar_t *wcval, (void *) pair_arg, opts)); - if (opts == NULL && wcval != NULL) { +#if !NCURSES_EXT_COLORS + if (opts != NULL) { + ; /* empty */ + } else +#endif + if (wcval != NULL) { wchar_t *wp; int len; @@ -130,6 +135,10 @@ getcchar(const cchar_t *wcval, } else if (attrs == 0 || pair_arg == 0) { code = ERR; } else if (len >= 0) { + int color_pair; + + TR(TRACE_CCALLS, ("copy %d wchars, first is %s", len, + _tracecchar_t(wcval))); *attrs = AttrOf(*wcval) & A_ATTRIBUTES; color_pair = GetPair(*wcval); get_extended_pair(opts, color_pair); diff --git a/ncurses/widechar/lib_erasewchar.c b/ncurses/widechar/lib_erasewchar.c index f49d641..197f80b 100644 --- a/ncurses/widechar/lib_erasewchar.c +++ b/ncurses/widechar/lib_erasewchar.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 2002-2010,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -33,46 +33,64 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_erasewchar.c,v 1.4 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_erasewchar.c,v 1.5 2021/05/22 23:51:14 tom Exp $") /* * erasewchar() * * Return erase character as given in cur_term->Ottyb. - * */ NCURSES_EXPORT(int) -erasewchar(wchar_t *wch) +NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch); +NCURSES_EXPORT(int) +NCURSES_SP_NAME(erasewchar) (NCURSES_SP_DCLx wchar_t *wch) { int value; int result = ERR; T((T_CALLED("erasewchar()"))); - if ((value = erasechar()) != ERR) { + if ((value = NCURSES_SP_NAME(erasechar) (NCURSES_SP_ARG)) != ERR) { *wch = (wchar_t) value; result = OK; } returnCode(result); } +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +erasewchar(wchar_t *wch) +{ + return NCURSES_SP_NAME(erasewchar) (CURRENT_SCREEN, wch); +} +#endif + /* * killwchar() * * Return kill character as given in cur_term->Ottyb. - * */ NCURSES_EXPORT(int) -killwchar(wchar_t *wch) +NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch); +NCURSES_EXPORT(int) +NCURSES_SP_NAME(killwchar) (NCURSES_SP_DCLx wchar_t *wch) { int value; int result = ERR; T((T_CALLED("killwchar()"))); - if ((value = killchar()) != ERR) { + if ((value = NCURSES_SP_NAME(killchar) (NCURSES_SP_ARG)) != ERR) { *wch = (wchar_t) value; result = OK; } returnCode(result); } + +#if NCURSES_SP_FUNCS +NCURSES_EXPORT(int) +killwchar(wchar_t *wch) +{ + return NCURSES_SP_NAME(killwchar) (CURRENT_SCREEN, wch); +} +#endif diff --git a/ncurses/widechar/lib_get_wch.c b/ncurses/widechar/lib_get_wch.c index 2bd4918..9f10d3b 100644 --- a/ncurses/widechar/lib_get_wch.c +++ b/ncurses/widechar/lib_get_wch.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020 Thomas E. Dickey * + * Copyright 2020,2021 Thomas E. Dickey * * Copyright 2002-2011,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -41,7 +41,7 @@ #include <curses.priv.h> #include <ctype.h> -MODULE_ID("$Id: lib_get_wch.c,v 1.25 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_get_wch.c,v 1.26 2021/04/17 16:12:54 tom Exp $") NCURSES_EXPORT(int) wget_wch(WINDOW *win, wint_t *result) @@ -49,7 +49,6 @@ wget_wch(WINDOW *win, wint_t *result) SCREEN *sp; int code; int value = 0; - wchar_t wch; #ifndef state_unused mbstate_t state; #endif @@ -98,6 +97,7 @@ wget_wch(WINDOW *win, wint_t *result) reset_mbytes(state); status = count_mbytes(buffer, count, state); if (status >= 0) { + wchar_t wch; reset_mbytes(state); if (check_mbytes(wch, buffer, count, state) != status) { code = ERR; /* the two calls should match */ diff --git a/ncurses/widechar/lib_get_wstr.c b/ncurses/widechar/lib_get_wstr.c index 695b526..83baaed 100644 --- a/ncurses/widechar/lib_get_wstr.c +++ b/ncurses/widechar/lib_get_wstr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018,2020 Thomas E. Dickey * + * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 2002-2009,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -40,7 +40,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_get_wstr.c,v 1.16 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_get_wstr.c,v 1.19 2021/09/04 10:29:59 tom Exp $") static int wadd_wint(WINDOW *win, wint_t *src) @@ -89,8 +89,8 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) SCREEN *sp = _nc_screen_of(win); TTY buf; bool oldnl, oldecho, oldraw, oldcbreak; - wint_t erasec; - wint_t killc; + wchar_t erasec = 0; + wchar_t killc = 0; wint_t *oldstr = str; wint_t *tmpstr = str; wint_t ch; @@ -109,13 +109,12 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) oldecho = sp->_echo; oldraw = sp->_raw; oldcbreak = sp->_cbreak; - nl(); - noecho(); - noraw(); - cbreak(); + NCURSES_SP_NAME(nl) (NCURSES_SP_ARG); + NCURSES_SP_NAME(noecho) (NCURSES_SP_ARG); + NCURSES_SP_NAME(raw) (NCURSES_SP_ARG); - erasec = (wint_t) erasechar(); - killc = (wint_t) killchar(); + NCURSES_SP_NAME(erasewchar) (NCURSES_SP_ARGx &erasec); + NCURSES_SP_NAME(killwchar) (NCURSES_SP_ARGx &killc); getyx(win, y, x); @@ -132,12 +131,12 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) code = KEY_CODE_YES; ch = KEY_ENTER; } - if (ch < KEY_MIN) { - if (ch == erasec) { + if (ch != 0 && ch < KEY_MIN) { + if (ch == (wint_t) erasec) { ch = KEY_BACKSPACE; code = KEY_CODE_YES; } - if (ch == killc) { + if (ch == (wint_t) killc) { ch = KEY_EOL; code = KEY_CODE_YES; } @@ -145,7 +144,7 @@ wgetn_wstr(WINDOW *win, wint_t *str, int maxlen) if (code == KEY_CODE_YES) { /* * Some terminals (the Wyse-50 is the most common) generate a \n - * from the down-arrow key. With this logic, it's the user's + * from the down-arrow key. With this logic, it is the user's * choice whether to set kcud=\n for wget_wch(); terminating * *getn_wstr() with \n should work either way. */ diff --git a/ncurses/widechar/lib_ins_wch.c b/ncurses/widechar/lib_ins_wch.c index a744f5b..f753610 100644 --- a/ncurses/widechar/lib_ins_wch.c +++ b/ncurses/widechar/lib_ins_wch.c @@ -40,7 +40,7 @@ #include <curses.priv.h> -MODULE_ID("$Id: lib_ins_wch.c,v 1.24 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_ins_wch.c,v 1.25 2020/12/05 20:04:59 tom Exp $") /* * Insert the given character, updating the current location to simplify @@ -111,7 +111,7 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n) if (win != 0 && wstr != 0) { if (n < 1) - n = (int) wcslen(wstr); + n = INT_MAX; code = OK; if (n > 0) { @@ -120,7 +120,7 @@ wins_nwstr(WINDOW *win, const wchar_t *wstr, int n) NCURSES_SIZE_T oy = win->_cury; NCURSES_SIZE_T ox = win->_curx; - for (cp = wstr; ((cp - wstr) < n) && *cp; cp++) { + for (cp = wstr; (*cp != L'\0') && ((cp - wstr) < n); cp++) { int len = _nc_wacs_width(*cp); if ((len >= 0 && len != 1) || !is7bits(*cp)) { diff --git a/ncurses/widechar/lib_vid_attr.c b/ncurses/widechar/lib_vid_attr.c index e167beb..2d9531f 100644 --- a/ncurses/widechar/lib_vid_attr.c +++ b/ncurses/widechar/lib_vid_attr.c @@ -37,7 +37,7 @@ #define CUR SP_TERMTYPE #endif -MODULE_ID("$Id: lib_vid_attr.c,v 1.28 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: lib_vid_attr.c,v 1.30 2020/05/27 23:54:31 tom Exp $") #define doPut(mode) \ TPUTS_TRACE(#mode); \ @@ -191,16 +191,16 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx if (turn_on || turn_off) { TPUTS_TRACE("set_attributes"); NCURSES_SP_NAME(tputs) (NCURSES_SP_ARGx - TPARM_9(set_attributes, - (newmode & A_STANDOUT) != 0, - (newmode & A_UNDERLINE) != 0, - (newmode & A_REVERSE) != 0, - (newmode & A_BLINK) != 0, - (newmode & A_DIM) != 0, - (newmode & A_BOLD) != 0, - (newmode & A_INVIS) != 0, - (newmode & A_PROTECT) != 0, - (newmode & A_ALTCHARSET) != 0), + TIPARM_9(set_attributes, + (newmode & A_STANDOUT) != 0, + (newmode & A_UNDERLINE) != 0, + (newmode & A_REVERSE) != 0, + (newmode & A_BLINK) != 0, + (newmode & A_DIM) != 0, + (newmode & A_BOLD) != 0, + (newmode & A_INVIS) != 0, + (newmode & A_PROTECT) != 0, + (newmode & A_ALTCHARSET) != 0), 1, outc); previous_attr &= ALL_BUT_COLOR; previous_pair = 0; @@ -264,7 +264,6 @@ NCURSES_SP_NAME(vid_puts) (NCURSES_SP_DCLx TurnOn(A_VERTICAL, enter_vertical_hl_mode); #endif /* *INDENT-ON* */ - } if (reverse) diff --git a/ncurses/widechar/widechars.c b/ncurses/widechar/widechars.c index 3577479..d05ba98 100644 --- a/ncurses/widechar/widechars.c +++ b/ncurses/widechar/widechars.c @@ -31,9 +31,9 @@ #if USE_WIDEC_SUPPORT -MODULE_ID("$Id: widechars.c,v 1.7 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: widechars.c,v 1.9 2020/08/29 16:22:03 juergen Exp $") -#if defined(_WIN32) +#if (defined(_NC_WINDOWS)) && !defined(_NC_MSC) /* * MinGW has wide-character functions, but they do not work correctly. */ @@ -148,6 +148,6 @@ _nc_wctomb(char *s, wchar_t wc) return result; } -#endif /* _WIN32 */ +#endif /* _NC_WINDOWS */ #endif /* USE_WIDEC_SUPPORT */ |