[PATCH 0/2] Improve compatibility with NetBSD libcurses

[PATCH 0/2] Improve compatibility with NetBSD libcurses

From: Michael Forney
Here are a couple of patches I needed to get catgirl working well
with NetBSD libcurses.

Other issues fixed in NetBSD trunk are:
PR 55457 (libcurses: when passed a pad, wget_wch/wgetch calls wrefresh on the pad)
PR 56224 (libcurses: adding character to last line of non-scrolling window wraps instead of truncates)

The last remaining issue I'm aware of is that vid_attr is not
implemented for the M-l listing. However, since it is just styling
for a non-critical feature, it seems acceptable for people who want
to use NetBSD libcurses to just patch those calls out themselves.

Michael Forney (2):
  Break out of input loop when UI is hidden
  Resize status window explicitly during resize()

 ui.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.31.1

4 replies

[PATCH 1/2] Break out of input loop when UI is hidden

From: Michael Forney
Otherwise, wget_wch() is called immediately after hiding the UI
with M-l, which restores curses mode when using NetBSD's libcurses.
---
 ui.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui.c b/ui.c
index 8f8de1e..8d1f089 100644
--- a/ui.c
+++ b/ui.c
@@ -1075,7 +1075,7 @@ void uiRead(void) {
 
 	wint_t ch;
 	static bool paste, style, literal;
-	for (int ret; ERR != (ret = wget_wch(input, &ch));) {
+	for (int ret; !hidden && ERR != (ret = wget_wch(input, &ch));) {
 		if (ret == KEY_CODE_YES && ch == KeyPasteOn) {
 			paste = true;
 		} else if (ret == KEY_CODE_YES && ch == KeyPasteOff) {
-- 
2.31.1

Re: [PATCH 1/2] Break out of input loop when UI is hidden

From: june
On Thu, Jun 17, 2021, at 14:21, Michael Forney wrote:
> Otherwise, wget_wch() is called immediately after hiding the UI
> with M-l, which restores curses mode when using NetBSD's libcurses.

This seems to cause some weird behaviour on ncurses: pressing M-l
gets partway through printing the lines then stops in the middle
of a line. Pressing enter restores the UI, and on pressing M-l
again, scrolling up reveals the rest of the lines were printed at
*some* point. Very strange.

Re: [PATCH 1/2] Break out of input loop when UI is hidden

From: Michael Forney
To: june
On 2021-06-17, june <june@causal.agency> wrote:
> This seems to cause some weird behaviour on ncurses: pressing M-l
> gets partway through printing the lines then stops in the middle
> of a line. Pressing enter restores the UI, and on pressing M-l
> again, scrolling up reveals the rest of the lines were printed at
> *some* point. Very strange.

Interesting. Sorry, I should have tested that it didn't break ncurses.
I'll do some investigation to see if I can figure out what's going on,
then hopefully get back to you with a v2.

Re: [PATCH 1/2] Break out of input loop when UI is hidden

From: june
> On Jun 17, 2021, at 15:19, Michael Forney <mforney@mforney.org> wrote:
> 
> On 2021-06-17, june <june@causal.agency> wrote:
>> This seems to cause some weird behaviour on ncurses: pressing M-l
>> gets partway through printing the lines then stops in the middle
>> of a line. Pressing enter restores the UI, and on pressing M-l
>> again, scrolling up reveals the rest of the lines were printed at
>> *some* point. Very strange.
> 
> Interesting. Sorry, I should have tested that it didn't break ncurses.
> I'll do some investigation to see if I can figure out what's going on,
> then hopefully get back to you with a v2.

Just updating/confirming that this only seems to be a problem in
xterm on OpenBSD (6.9, unconfirmed on -current, but xterm doesn’t
seem to have been changed since 6.9). The plot thicken.

1 reply

[PATCH 2/2] Resize status window explicitly during resize()

From: Michael Forney
Although ncurses automatically resizes windows that extend to the
previous screen limits, NetBSD's libcurses does not, so resize the
status window explicitly.
---
 ui.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui.c b/ui.c
index 8d1f089..b7e7337 100644
--- a/ui.c
+++ b/ui.c
@@ -648,6 +648,7 @@ static void windowReflow(struct Window *window) {
 
 static void resize(void) {
 	wclear(main);
+	wresize(status, 1, COLS);
 	wresize(main, MAIN_LINES, COLS);
 	for (uint num = 0; num < windows.len; ++num) {
 		windowReflow(windows.ptrs[num]);
-- 
2.31.1