X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fwidechar%2Flib_add_wch.c;h=b817647c607eb13a590df1b786427b530c2cdbca;hp=c1c565c13436b757fca7ea344365ad0f35087ac6;hb=643ec2bf782cd02efafe3ccdeaea8920a404645e;hpb=5b7f4de105080e2a715b0564ede4bb7eb6767659 diff --git a/ncurses/widechar/lib_add_wch.c b/ncurses/widechar/lib_add_wch.c index c1c565c1..b817647c 100644 --- a/ncurses/widechar/lib_add_wch.c +++ b/ncurses/widechar/lib_add_wch.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2004-2006,2009 Free Software Foundation, Inc. * + * 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 * * copy of this software and associated documentation files (the * @@ -39,7 +40,7 @@ #include #endif -MODULE_ID("$Id: lib_add_wch.c,v 1.7 2009/07/04 21:59:25 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); @@ -55,7 +56,7 @@ static const cchar_t blankchar = NewChar(BLANK_TEXT); */ /* Return bit mask for clearing color pair number if given ch has color */ -#define COLOR_MASK(ch) (~(attr_t)((ch) & A_COLOR ? A_COLOR : 0)) +#define COLOR_MASK(ch) (~(attr_t)(((ch) & A_COLOR) ? A_COLOR : 0)) static NCURSES_INLINE cchar_t render_char(WINDOW *win, cchar_t ch) @@ -81,12 +82,6 @@ render_char(WINDOW *win, cchar_t ch) if ((pair = GET_WINDOW_PAIR(win)) == 0) pair = GetPair(win->_nc_bkgd); } -#if 0 - if (pair > 255) { - cchar_t fixme = ch; - SetPair(fixme, pair); - } -#endif AddAttr(ch, (a & COLOR_MASK(AttrOf(ch)))); SetPair(ch, pair); } @@ -120,7 +115,7 @@ render_char(WINDOW *win, cchar_t ch) #endif static bool -newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos) +newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos) { bool result = FALSE; @@ -128,7 +123,7 @@ newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T * ypos) *ypos = win->_regbottom; result = TRUE; } else { - *ypos += 1; + *ypos = (NCURSES_SIZE_T) (*ypos + 1); } return result; } @@ -138,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). */ @@ -172,8 +167,8 @@ fill_cells(WINDOW *win, int count) if (wadd_wch_literal(win, blank) == ERR) break; } - win->_curx = save_x; - win->_cury = save_y; + win->_curx = (NCURSES_SIZE_T) save_x; + win->_cury = (NCURSES_SIZE_T) save_y; } static int @@ -201,7 +196,7 @@ wadd_wch_literal(WINDOW *win, cchar_t ch) * adjustments. */ { - int len = wcwidth(CharOf(ch)); + int len = _nc_wacs_width(CharOf(ch)); int i; int j; wchar_t *chars; @@ -297,7 +292,7 @@ wadd_wch_literal(WINDOW *win, cchar_t ch) if (x > win->_maxx) { return wrap_to_next_line(win); } - win->_curx = x; + win->_curx = (NCURSES_SIZE_T) x; return OK; } @@ -308,14 +303,17 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch) NCURSES_SIZE_T x, y; wchar_t *s; int tabsize = 8; +#if USE_REENTRANT + SCREEN *sp = _nc_screen_of(win); +#endif /* * If we are using the alternate character set, forget about locale. - * Otherwise, if the locale * claims the code is printable, treat it that + * Otherwise, if the locale claims the code is printable, treat it that * way. */ if ((AttrOf(ch) & A_ALTCHARSET) - || iswprint(CharOf(ch))) + || iswprint((wint_t) CharOf(ch))) return wadd_wch_literal(win, ch); /* @@ -328,11 +326,11 @@ wadd_wch_nosync(WINDOW *win, cchar_t ch) switch (CharOf(ch)) { case '\t': #if USE_REENTRANT - tabsize = sp->_TABSIZE; + tabsize = *ptrTabsize(sp); #else tabsize = TABSIZE; #endif - x += (tabsize - (x % tabsize)); + x = (NCURSES_SIZE_T) (x + (tabsize - (x % tabsize))); /* * Space-fill the tab on the bottom line so that we'll get the * "correct" cursor position. @@ -412,7 +410,8 @@ wadd_wch(WINDOW *win, const cchar_t *wch) { int code = ERR; - TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), win, + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), + (void *) win, _tracecchar_t(wch))); if (win && (wadd_wch_nosync(win, *wch) != ERR)) { @@ -429,7 +428,8 @@ wecho_wchar(WINDOW *win, const cchar_t *wch) { int code = ERR; - TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, + TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), + (void *) win, _tracecchar_t(wch))); if (win && (wadd_wch_nosync(win, *wch) != ERR)) {