NetBSD Problem Report #47398
From www@NetBSD.org Thu Jan 3 21:47:37 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 CC81463E615
for <gnats-bugs@gnats.NetBSD.org>; Thu, 3 Jan 2013 21:47:37 +0000 (UTC)
Message-Id: <20130103214736.AA58A63E615@www.NetBSD.org>
Date: Thu, 3 Jan 2013 21:47:36 +0000 (UTC)
From: gnrp@komkon2.de
Reply-To: gnrp@komkon2.de
To: gnats-bugs@NetBSD.org
Subject: Cursor positioning in a curses form depends on the last refreshed window
X-Send-Pr-Version: www-1.0
>Number: 47398
>Category: lib
>Synopsis: Cursor positioning in a curses form depends on the last refreshed window
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: blymn
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 03 21:50:00 +0000 2013
>Closed-Date: Thu Oct 28 02:47:15 +0000 2021
>Last-Modified: Thu Oct 28 02:47:15 +0000 2021
>Originator: Julian Fagir
>Release: NetBSD 6.0-RELEASE
>Organization:
>Environment:
>Description:
When you have a form, ncurses will set the cursor automatically to the selected field, no matter what window you last refreshed.
When you have a form in nbcurses, it will set the cursor only to this field when you refresh the subwindow it is in last.
Is this a bug or just an intended difference between nbcurses and ncurses?
>How-To-Repeat:
Compile this piece of code with -lform, run it on a ncurses and a nbcurses machine. See how the cursor position is always somewhere. Then, recompile it with the one comment commented out, and see how the cursor position is on the field.
#include <form.h>
#include <form.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;
FIELD *fields[2];
FORM *form;
char buf[512];
initscr();
keypad(stdscr, TRUE);
noecho();
cbreak();
mainwin = newwin(20, 70, 2, 2);
box(mainwin, 0, 0);
mvwprintw(mainwin, 1, 1, "Creating window...");
wrefresh(mainwin);
fields[0] = new_field(1, 20, 2, 1, 0, 0);
fields[1] = NULL;
form = new_form(fields);
set_form_win(form, mainwin);
subwin = derwin(mainwin, 15, 60, 2, 2);
set_form_sub(form, subwin);
set_field_back(fields[0], A_UNDERLINE);
refresh();
post_form(form);
wrefresh(mainwin);
buf[0] = '\0';
while ((ch = getch()) != '\n') {
switch (ch) {
case KEY_LEFT:
form_driver(form, REQ_LEFT_CHAR);
i--;
break;
case KEY_RIGHT:
if (buf[i] != '\0') {
form_driver(form, REQ_RIGHT_CHAR);
i++;
}
break;
case KEY_END:
form_driver(form, REQ_END_LINE);
i = strlen(buf);
break;
case KEY_HOME:
form_driver(form, REQ_BEG_LINE);
i = 0;
break;
case '\b':
case KEY_BACKSPACE:
form_driver(form, REQ_DEL_PREV);
buf[i] = '\0';
i--;
break;
default:
if (i < sizeof(buf) - 2) {
form_driver(form, ch);
for (j = strlen(buf); j >= i; j--)
buf[j+1] = buf[j];
buf[i] = ch;
i++;
}
break;
}
refresh();
wrefresh(mainwin);
// wrefresh(subwin);
}
free_field(fields[1]);
unpost_form(form);
free_form(form);
endwin();
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: lib-bug-people->blymn
Responsible-Changed-By: blymn@NetBSD.org
Responsible-Changed-When: Mon, 25 Oct 2021 06:27:25 +0000
Responsible-Changed-Why:
I will claim this since I have committed a fix.
State-Changed-From-To: open->feedback
State-Changed-By: blymn@NetBSD.org
State-Changed-When: Mon, 25 Oct 2021 06:27:25 +0000
State-Changed-Why:
Fix committed for this bug.
From: "Brett Lymn" <blymn@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/47398 CVS commit: src/lib/libform
Date: Mon, 25 Oct 2021 06:25:19 +0000
Module Name: src
Committed By: blymn
Date: Mon Oct 25 06:25:19 UTC 2021
Modified Files:
src/lib/libform: internals.c
Log Message:
Fix for PR lib/47398
Move cursor to end of the currently active field and sync the cursor
location so the cursor get positioned correctly when the form window
is refreshed.
To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libform/internals.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: feedback->closed
State-Changed-By: blymn@NetBSD.org
State-Changed-When: Thu, 28 Oct 2021 02:47:15 +0000
State-Changed-Why:
Closing PR, reporter can no longer test fix but sample code works
so I am confident the bug is fixed.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.