bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Minor corrections


From: philippe blain
Subject: Minor corrections
Date: Tue, 21 Aug 2001 07:14:29 +0200

>From Philippe Blain, Bordeaux, FRANCE
My (old) computer : P133 - 8,4Go - 32 Mo       Red Hat Linux 7.0

To the maintainers of 'ncurses'. (and to Mr Dickey)
Subject : Corrections for ncurses-5.2-20010811

Here are some problems I found :

--------------------------------------------------------------------------------
File : ncurses/tty/lib_vidattr.c

Function : vidputs(...)

The boolean 'used_ncv' (present in 5.0 but useless) is no longer used and
can be suppressed.

--------------------------------------------------------------------------------
File : ncurses/base/lib_newwin.c

In the structure '_win_st', the boolean '_notimeout' is not set when creating
a new window, but used then in 'lib_getch.c' for setting or not a timer.
That boolean is modified by the 'notimeout()' function in tinfo/lib_options.c
(See also the timeout functions in 'curs_inopts' manual)

--------------------------------------------------------------------------------
File : ncurses/ncurses.priv.h

Suggestion :   Replace the structure WINDOWLIST

    typedef struct _win_list {
        struct _win_list *next;
        WINDOW *win;
    } WINDOWLIST;

with a doubly linked list directly in the WINDOW structure accessed
by SP->_nc_sp_window. No need to allocate memory for a WINDOWLIST
each time a window is created by that way.

struct _win_st
{
    NCURSES_SIZE_T _cury, _curx; /* current cursor position */
    ................................
    WINDOW *next_win, *prev_win; /* linked list of created windows */
};

Then modify and simplify related functions :
_nc_free_win(), _nc_makenew(), cannot_delete(), resizeterm()

WINDOW *_nc_makenew(....)
{
    ................................
    win->next_win = _nc_window;
    win->prev_win = (WINDOW *) NULL;
    _nc_window = win;
    ................................
};

int *_nc_freewin(....)
{
    ................................
    if (win->prev_win) win->prev_win->next_win = win->next_win;
    else _nc_window = win->next;
    if (win->next_win) win->next_win->prev_win = win->prev_win;
    ................................
};

static bool cannot_delete(WINDOW *win)
{
    WINDOW *w;
    bool result = TRUE;

    for (w = _nc_windows; w != 0; w = w->next_win) {
        if (w == win) { result = FALSE; }
        else if ((w->_flags & _SUBWIN) != 0 && w->_parent == win) {
            result = TRUE;
            break;
        }
    }
    return result;
}

NCURSES_EXPORT(void) _nc_freeall(void)
{
    WINDOW *p, *q;

    ................................
    while (_nc_windows != 0) {
        /* Delete only windows that're not a parent */
        for (p = _nc_windows; p != 0; p = p->next) {
            bool found = FALSE;

            for (q = _nc_windows; q != 0; q = q->next) {
                if ((p != q)
                    && (q->_flags & _SUBWIN)
                    && (p == q->_parent)) {
                found = TRUE;
                break;
                }
            }

            if (!found) {
                delwin(p);
                break;
            }
        }
    }
    ................................
}

--------------------------------------------------------------------------------
------ Philippe.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]