Exemplo n.º 1
0
/*
add_menu(winid wid, int glyph, const anything identifier,
                                char accelerator, char groupacc,
                                int attr, char *str, boolean preselected)
                -- Add a text line str to the given menu window.  If identifier
                   is 0, then the line cannot be selected (e.g. a title).
                   Otherwise, identifier is the value returned if the line is
                   selected.  Accelerator is a keyboard key that can be used
                   to select the line.  If the accelerator of a selectable
                   item is 0, the window system is free to select its own
                   accelerator.  It is up to the window-port to make the
                   accelerator visible to the user (e.g. put "a - " in front
                   of str).  The value attr is the same as in putstr().
                   Glyph is an optional glyph to accompany the line.  If
                   window port cannot or does not want to display it, this
                   is OK.  If there is no glyph applicable, then this
                   value will be NO_GLYPH.
                -- All accelerators should be in the range [A-Za-z].
                -- It is expected that callers do not mix accelerator
                   choices.  Either all selectable items have an accelerator
                   or let the window system pick them.  Don't do both.
                -- Groupacc is a group accelerator.  It may be any character
                   outside of the standard accelerator (see above) or a
                   number.  If 0, the item is unaffected by any group
                   accelerator.  If this accelerator conflicts with
                   the menu command (or their user defined alises), it loses.
                   The menu commands and aliases take care not to interfere
                   with the default object class symbols.
                -- If you want this choice to be preselected when the
                   menu is displayed, set preselected to TRUE.
*/
void curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
		char accelerator, char group_accel, int attr, 
		const char *str, boolean presel)
{
    int curses_attr = curses_convert_attr(attr);

    curses_add_nhmenu_item(wid, identifier, accelerator, group_accel,
     curses_attr, str, presel);
}
Exemplo n.º 2
0
void curses_puts(winid wid, int attr, const char *text)
{
    anything *identifier;
    WINDOW *win = NULL;
    
    if (is_main_window(wid))
    {
        win = curses_get_nhwin(wid);
    }
        
    if (wid == MESSAGE_WIN)
    {
        curses_message_win_puts(text, FALSE);
        return;
    }
    
    if (wid == STATUS_WIN)
    {
        curses_update_stats(FALSE);  /* We will do the write ourselves */
        return;
    }
    
    if (curses_is_menu(wid) || curses_is_text(wid))
    {
        if (!curses_menu_exists(wid))
        {
            panic("curses_puts: Attempted write to nonexistant window!"); 
        }
        identifier = malloc(sizeof(anything));
        identifier->a_void = NULL;
        curses_add_nhmenu_item(wid, identifier, 0, 0, attr, text,
         FALSE);
    }
    else
    {
        waddstr(win, text);
        wrefresh(win);
    }
}