#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_screen.c,v 1.101 2021/06/26 20:43:19 tom Exp $")
+MODULE_ID("$Id: lib_screen.c,v 1.103 2021/10/18 22:40:48 tom Exp $")
#define MAX_SIZE 0x3fff /* 16k is big enough for a window or pad */
if (ch == '\n') {
result[--used] = '\0';
- T(("READ:%s", result));
+ TR(TRACE_IEVENT, ("READ:%s", result));
} else if (used == 0) {
free(result);
result = 0;
{
bool found = FALSE;
- T(("decode_attr '%s'", source));
+ TR(TRACE_IEVENT, ("decode_attr '%s'", source));
while (*source) {
if (source[0] == MARKER && source[1] == L_CURL) {
int base = 16;
const char digits[] = "0123456789abcdef";
- T(("decode_char '%s'", source));
+ TR(TRACE_IEVENT, ("decode_char '%s'", source));
*target = ' ';
switch (*source) {
case MARKER:
int color = PAIR_NUMBER((int) attr);
int value;
- T(("decode_chtype '%s'", source));
+ TR(TRACE_IEVENT, ("decode_chtype '%s'", source));
source = decode_attr(source, &attr, &color);
source = decode_char(source, &value);
*target = (ChCharOf(value) | attr | (chtype) COLOR_PAIR(color));
int append = 0;
int value = 0;
- T(("decode_cchar '%s'", source));
+ TR(TRACE_IEVENT, ("decode_cchar '%s'", source));
*target = blank;
#if NCURSES_EXT_COLORS
color = fillin->ext_color;
returnCode(code);
}
+/*
+ * Replace a window covering the whole screen, i.e., newscr or curscr.
+ */
+static WINDOW *
+replace_window(WINDOW *target, FILE *source)
+{
+ WINDOW *result = getwin(source);
+#if NCURSES_EXT_FUNCS
+ if (result != NULL) {
+ if (getmaxx(result) != getmaxx(target)
+ || getmaxy(result) != getmaxy(target)) {
+ int code = wresize(result,
+ 1 + getmaxy(target),
+ 1 + getmaxx(target));
+ if (code != OK) {
+ delwin(result);
+ result = NULL;
+ }
+ }
+ }
+#endif
+ delwin(target);
+ return result;
+}
+
NCURSES_EXPORT(int)
NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
{
if (_nc_access(file, R_OK) >= 0
&& (fp = safe_fopen(file, BIN_R)) != 0) {
- delwin(NewScreen(SP_PARM));
- NewScreen(SP_PARM) = getwin(fp);
+ NewScreen(SP_PARM) = replace_window(NewScreen(SP_PARM), fp);
#if !USE_REENTRANT
newscr = NewScreen(SP_PARM);
#endif
if (_nc_access(file, R_OK) >= 0
&& (fp = safe_fopen(file, BIN_R)) != 0) {
- delwin(CurScreen(SP_PARM));
- CurScreen(SP_PARM) = getwin(fp);
+ CurScreen(SP_PARM) = replace_window(CurScreen(SP_PARM), fp);
#if !USE_REENTRANT
curscr = CurScreen(SP_PARM);
#endif