fix asyncgetnstr() not being compatible with POSIX curses

Mon, 31 Aug 2026 17:51:32 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 31 Aug 2026 17:51:32 +0200
changeset 200
4913bc0ff3e5
parent 199
3d4d361ebb80
child 201
b61c2b90f19c

fix asyncgetnstr() not being compatible with POSIX curses

src/input.c file | annotate | diff | comparison | revisions
src/input.h file | annotate | diff | comparison | revisions
--- a/src/input.c	Mon Aug 31 17:44:06 2026 +0200
+++ b/src/input.c	Mon Aug 31 17:51:32 2026 +0200
@@ -29,6 +29,8 @@
 
 #include "input.h"
 #include <ctype.h>
+#include <stdbool.h> /* necessary to avoid errors with outdated curses.h */
+#include <curses.h>
 
 int prompt_yesno(char *msg) {
     printw("%s (y/n)? ", msg);
@@ -44,7 +46,10 @@
     return ch == 'y';
 }
 
-int mvwasyncgetnstr(WINDOW* w,int y,int x,char *str,size_t *pos,size_t len) {
+int asyncgetnstr(char *str, size_t *pos, size_t len) {
+    WINDOW* w = stdscr;
+    int y, x;
+    getyx(w, y, x);
     mvwaddnstr(w, y, x, str, *pos);
     wrefresh(w);
     int c = wgetch(w);
--- a/src/input.h	Mon Aug 31 17:44:06 2026 +0200
+++ b/src/input.h	Mon Aug 31 17:51:32 2026 +0200
@@ -31,8 +31,6 @@
 #define	INPUT_H
 
 #include <stdlib.h>
-#include <stdbool.h> /* necessary to avoid errors with outdated curses.h */
-#include <curses.h>
 
 #ifdef	__cplusplus
 extern "C" {
@@ -40,36 +38,6 @@
 
 int prompt_yesno(char *msg);
 
-
-/**
- * Asynchronous variant of mvwgetnstr().
- * 
- * Needs halfdelay mode enabled!
- * 
- * @param w the window
- * @param y the window y position
- * @param x the window x position
- * @param str the buffer for the read string
- * @param pos a pointer to the object containing the current buffer position
- * @param len the length of the buffer
- * @return 0 if reading is in progress and 1 when a complete line is read
- */
-int mvwasyncgetnstr(WINDOW* w,int y,int x,char *str,size_t *pos,size_t len);
-
-/**
- * Asynchronous variant of mvgetnstr().
- * 
- * Needs halfdelay mode enabled!
- * 
- * @param y the window y position
- * @param x the window x position
- * @param str the buffer for the read string
- * @param pos a pointer to the object containing the current buffer position
- * @param len the length of the buffer
- * @return 0 if reading is in progress and 1 when a complete line is read
- */
-#define mvasyncgetnstr(y,x,str,pos,len) mvwasyncgetnstr(stdscr,y,x,str,pos,len)
-
 /**
  * Asynchronous variant of getnstr().
  * 
@@ -80,8 +48,7 @@
  * @param len the length of the buffer
  * @return 0 if reading is in progress and 1 when a complete line is read
  */
-#define asyncgetnstr(str,pos,len) mvwasyncgetnstr(stdscr, getcury(stdscr), \
-    getcurx(stdscr), str, pos, len)
+int asyncgetnstr(char *str, size_t *pos, size_t len);
 
 
 #ifdef	__cplusplus

mercurial