X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Fbase%2Fresizeterm.c;h=8bea743a3d22552b0ea39441e6f2c37334291609;hp=062af604a1fde34a26efb535e6f44b5900554e25;hb=e0371a7943009d611a4dc080dcddfcdfba9f589b;hpb=f70db18a0c3c6a828d8a5999be37239f01c9d98a diff --git a/ncurses/base/resizeterm.c b/ncurses/base/resizeterm.c index 062af604..8bea743a 100644 --- a/ncurses/base/resizeterm.c +++ b/ncurses/base/resizeterm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2004,2006 Free Software Foundation, Inc. * + * Copyright (c) 1998-2006,2007 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 * @@ -41,14 +41,14 @@ #include #include -MODULE_ID("$Id: resizeterm.c,v 1.19 2006/12/30 17:12:29 tom Exp $") +MODULE_ID("$Id: resizeterm.c,v 1.24 2007/12/22 23:20:31 tom Exp $") #define stolen_lines (screen_lines - SP->_lines_avail) /* * If we're trying to be reentrant, do not want any local statics. */ -#ifdef _REENTRANT +#if USE_REENTRANT #define EXTRA_ARGS , CurLines, CurCols #define EXTRA_DCLS , int CurLines, int CurCols #else @@ -66,6 +66,7 @@ show_window_sizes(const char *name) { WINDOWLIST *wp; + _nc_lock_global(windowlist); _tracef("%s resizing: %2d x %2d (%2d x %2d)", name, LINES, COLS, screen_lines, screen_columns); for (wp = _nc_windows; wp != 0; wp = wp->next) { @@ -76,6 +77,7 @@ show_window_sizes(const char *name) (long) wp->win._begy, (long) wp->win._begx); } + _nc_unlock_global(windowlist); } #endif @@ -250,19 +252,28 @@ NCURSES_EXPORT(int) resize_term(int ToLines, int ToCols) { int result = OK EXTRA_ARGS; - int was_stolen = (screen_lines - SP->_lines_avail); + int was_stolen; T((T_CALLED("resize_term(%d,%d) old(%d,%d)"), ToLines, ToCols, screen_lines, screen_columns)); + if (SP == 0) { + returnCode(ERR); + } + + _nc_lock_global(windowlist); + + was_stolen = (screen_lines - SP->_lines_avail); if (is_term_resized(ToLines, ToCols)) { int myLines = CurLines = screen_lines; int myCols = CurCols = screen_columns; #ifdef TRACE - if (_nc_tracing & TRACE_UPDATE) + if (USE_TRACEF(TRACE_UPDATE)) { show_window_sizes("before"); + _nc_unlock_global(tracef); + } #endif if (ToLines > screen_lines) { increase_size(myLines = ToLines, myCols, was_stolen EXTRA_ARGS); @@ -293,10 +304,11 @@ resize_term(int ToLines, int ToCols) FreeAndNull(SP->newhash); } #ifdef TRACE - if (_nc_tracing & TRACE_UPDATE) { - LINES = ToLines - was_stolen; - COLS = ToCols; + if (USE_TRACEF(TRACE_UPDATE)) { + SET_LINES(ToLines - was_stolen); + SET_COLS(ToCols); show_window_sizes("after"); + _nc_unlock_global(tracef); } #endif } @@ -305,8 +317,10 @@ resize_term(int ToLines, int ToCols) * Always update LINES, to allow for call from lib_doupdate.c which * needs to have the count adjusted by the stolen (ripped off) lines. */ - LINES = ToLines - was_stolen; - COLS = ToCols; + SET_LINES(ToLines - was_stolen); + SET_COLS(ToCols); + + _nc_unlock_global(windowlist); returnCode(result); } @@ -322,22 +336,25 @@ resize_term(int ToLines, int ToCols) NCURSES_EXPORT(int) resizeterm(int ToLines, int ToCols) { - int result = OK; - - SP->_sig_winch = FALSE; + int result = ERR; T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"), ToLines, ToCols, screen_lines, screen_columns)); - if (is_term_resized(ToLines, ToCols)) { + if (SP != 0) { + result = OK; + SP->_sig_winch = FALSE; + + if (is_term_resized(ToLines, ToCols)) { #if USE_SIGWINCH - ungetch(KEY_RESIZE); /* so application can know this */ - clearok(curscr, TRUE); /* screen contents are unknown */ + ungetch(KEY_RESIZE); /* so application can know this */ + clearok(curscr, TRUE); /* screen contents are unknown */ #endif - result = resize_term(ToLines, ToCols); + result = resize_term(ToLines, ToCols); + } } returnCode(result);