/****************************************************************************
- * Copyright (c) 2004-2016,2019 Free Software Foundation, Inc. *
+ * Copyright 2019-2023,2024 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 *
#include <wctype.h>
#endif
-MODULE_ID("$Id: lib_add_wch.c,v 1.15 2019/05/04 20:31:31 tom Exp $")
+MODULE_ID("$Id: lib_add_wch.c,v 1.19 2024/07/27 19:22:23 tom Exp $")
/* clone/adapt lib_addch.c */
static const cchar_t blankchar = NewChar(BLANK_TEXT);
#endif
static bool
-newline_forces_scroll(WINDOW *win, NCURSES_SIZE_T *ypos)
+newline_forces_scroll(const WINDOW *win, NCURSES_SIZE_T *ypos)
{
bool result = FALSE;
* 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).
*/
if (len == 0) { /* non-spacing */
if ((x > 0 && y >= 0)
|| (win->_maxx >= 0 && win->_cury >= 1)) {
- if (x > 0 && y >= 0)
- chars = (win->_line[y].text[x - 1].chars);
- else
+ if (x > 0 && y >= 0) {
+ for (j = x - 1; j > 0; --j) {
+ if (!isWidecExt(win->_line[y].text[j])) {
+ break;
+ }
+ }
+ chars = (win->_line[y].text[j].chars);
+ } else {
chars = (win->_line[y - 1].text[win->_maxx].chars);
+ }
for (i = 0; i < CCHARW_MAX; ++i) {
if (chars[i] == 0) {
TR(TRACE_VIRTPUT,
/* the workhorse function -- add a character to the given window */
{
NCURSES_SIZE_T x, y;
- wchar_t *s;
+ const wchar_t *s;
int tabsize = 8;
#if USE_REENTRANT
SCREEN *sp = _nc_screen_of(win);