NetBSD Problem Report #47399

From www@NetBSD.org  Thu Jan  3 22:45:06 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id DEA5F63E615
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  3 Jan 2013 22:45:05 +0000 (UTC)
Message-Id: <20130103224504.A742C63E615@www.NetBSD.org>
Date: Thu,  3 Jan 2013 22:45:04 +0000 (UTC)
From: gnrp@komkon2.de
Reply-To: gnrp@komkon2.de
To: gnats-bugs@NetBSD.org
Subject: menu(3) positions the cursor strange when menu is larger than item array
X-Send-Pr-Version: www-1.0

>Number:         47399
>Category:       lib
>Synopsis:       menu(3) positions the cursor strange when menu is larger than item array
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 03 22:50:00 +0000 2013
>Originator:     Julian Fagir
>Release:        6.0-RELEASE
>Organization:
>Environment:
>Description:
When you make the menu format larger than the number of options, the cursor positioning is in the beginning *somewhere*, but not on the options.
If you make the menu format smaller or equal to the number of options, then the cursor is on the options right from the beginning on.
>How-To-Repeat:
Compile the following program, see how it works with ncurses (everything is fine), and that when you use it with nbcurses, it will position the cursor on the right below the last option.
If you change the line
    set_menu_format(menu, 3, 1);
to
    set_menu_format(menu, 2, 1);
the positioning will be right.



#include <menu.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

int
main(int arg, char *argv[])
{
        int ch, j, i = 0;
        WINDOW *mainwin, *subwin;
        ITEM *items[3];
        MENU *menu;

        initscr();
        keypad(stdscr, TRUE);
        noecho();
        cbreak();

        mainwin = newwin(20, 70, 2, 2);
        subwin = derwin(mainwin, 15, 60, 2, 2);
        keypad(mainwin, TRUE);
        box(mainwin, 0, 0);
        mvwprintw(mainwin, 1, 1, "Creating window...");

        items[0] = new_item("Bl1", NULL);
        set_item_userptr(items[0], (void *)5);
        items[1] = new_item("Bl2", NULL);
        set_item_userptr(items[0], (void *)6);
        items[2] = NULL;

        menu = new_menu(items);
        set_menu_win(menu, mainwin);
        set_menu_sub(menu, subwin);
        set_menu_format(menu, 3, 1);

        post_menu(menu);
        refresh();
        wrefresh(mainwin);
        wrefresh(subwin);

        while ((ch = getch()) != '\n') {
                switch (ch) {
                        case KEY_DOWN:
                                menu_driver(menu, REQ_NEXT_ITEM);
                                break;
                        case KEY_UP:
                                menu_driver(menu, REQ_PREV_ITEM);
                                break;
                }
                wrefresh(mainwin);
                wrefresh(subwin);
        }

        free_item(items[0]);
        unpost_menu(menu);
        free_menu(menu);
        endwin();

        return 0;
}

>Fix:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.