NetBSD Problem Report #57605
From rhialto@falu.nl Tue Sep 5 16:41:05 2023
Return-Path: <rhialto@falu.nl>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id D63F31A9239
for <gnats-bugs@gnats.NetBSD.org>; Tue, 5 Sep 2023 16:41:05 +0000 (UTC)
Message-Id: <202309051640.385GewpG027554@murthe.falu.nl>
Date: Tue, 5 Sep 2023 18:40:58 +0200 (CEST)
From: rhialto@falu.nl
Reply-To: rhialto@falu.nl
To: gnats-bugs@NetBSD.org
Subject: curses cursor does not move as expected
X-Send-Pr-Version: 3.95
>Number: 57605
>Category: lib
>Synopsis: curses cursor does not move as expected
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Sep 05 16:45:00 +0000 2023
>Originator: Rhialto
>Release: NetBSD 9.3
>Organization:
>Environment:
System: NetBSD murthe.falu.nl 9.3 NetBSD 9.3 (MAXLWP8192) #0: Sat Aug 6 22:25:06 CEST 2022 rhialto@murthe.falu.nl:/mnt/scratch/scratch/NetBSD/NetBSD-9.3/source/sets/x/usr/src/sys/arch/amd64/compile/MAXLWP8192 amd64
Architecture: x86_64
Machine: amd64
>Description:
The cursor is not always on the screen where it is expected. In
particular, in the package games/nethack-tty, the cursor remains
in the same location all the time. With ncurses, the cursor
moves around as expected.
Unfortunately I didn't succeed (yet?) in making a small
reproducer. I have attached my attempt at the end, to
illustrate that the issue is likely to be more subtle than I
could think of.
>How-To-Repeat:
Let's build a curses and an ncurses version of the nethack package.
Go to games/nethack-lib. In patches/patch-sys_unix_Makefile.src there
are 2 lines ":+#CFLAGS += -ggdb". Remove the '#' and do make mps.
Go to games/nethack-tty and add "INSTALL_UNSTRIPPED= yes" to the
Makefile. make package. Rename the package to include "ncurses" in the
name.
Now edit games/nethack-lib/Makefile.common and comment out
"PREFER.curses=pkgsrc". make clean && make package. Rename the
package to include "curses" in the name.
Create a file ~/.nethackrc with just "OPTIONS=windowtype:curses"
in it.
Install the ncurses package variant.
Run "nethack" in an xterm of at least 80x25. A dark (black)
background seems to work better.
You get some prompts; answer "y" to all of them.
Part of the screen will show a map, with something like this in it:
+---------+
|·········|
+@········|
|·d········
+---------+
(looking a bit nicer because of curses)
The cursor (I made mine red so I can see easily where it is) should be
on the @ symbol, which represents you, the hero.
Move around a bit with the hjkl keys like in vi. The cursor
should move with you.
Type a semicolon ";", this is a command which prompts you to
select a position on the map. It prompts "Pick an object.". Move
again with hjkl. The curor should move away from @, according
to your hjkl commands. End with Escape.
Quit with "#q<return>". Really quit? [yn] (n) -> y. You can
answer "n" to all following prompts. Hit return to the ">>"
prompt and the following "pop up window".
With NetBSD's builtin curses I see that the cursor either
remains in the home position, or even in some random location,
and doesn't move.
/usr/pkg/share/doc/nethack/Guidebook is a very extensive
explanation of how to play NetHack.
All the curses related source code in nethack should be in the
directory NetHack-3.6.7/win/curses.
The test program below does NOT exhibit the problem.
####
#
# Test program for curses vs ncurses.
#
all: curstest ncurstest
curstest: curstest.c
cc curstest.c -lcurses -o curstest
ncurstest: curstest.c
cc -I /usr/pkg/include -DN curstest.c -L /usr/pkg/lib -Wl,-R,/usr/pkg/lib -lncurses -o ncurstest
#include <unistd.h>
#ifdef N
# include <ncurses/curses.h>
#else
# include <curses.h>
#endif
WINDOW *
curses_create_window(int width, int height)
{
WINDOW *win;
static int startx = 10, starty = 10 ;
startx += 5;
starty += 5;
win = newwin(height, width, starty, startx);
box(win, 0, 0);
return win;
}
int orig_cursor;
int
main(int argc, char **argv)
{
WINDOW *mainwindow = initscr();
noecho();
raw();
nonl();
meta(stdscr, TRUE);
keypad(stdscr, TRUE);
border(0,0,0,0,0,0,0,0);
sleep(1); refresh();
move(10, 10);
sleep(1); refresh();
addch('@');
sleep(1); refresh();
move(10, 10);
sleep(1); refresh();
WINDOW *dummywind = curses_create_window(5, 5);
sleep(1); wrefresh(dummywind);
WINDOW *mapwind = curses_create_window(20, 20);
sleep(1); wrefresh(mapwind);
wmove(mapwind, 10, 10);
sleep(1); wrefresh(mapwind);
waddch(mapwind, '@');
sleep(1); wrefresh(mapwind);
wmove(mapwind, 10, 10);
sleep(1); wrefresh(mapwind);
sleep(5);
noraw();
echo();
nl();
return 0;
}
>Fix:
unknown to me
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.