bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-ncurses] export _mouse_fd for select(2)


From: Dr. Werner Fink
Subject: Re: [bug-ncurses] export _mouse_fd for select(2)
Date: Fri, 28 Jun 2019 09:06:33 +0200
User-agent: Mutt/1.11.3 (2019-02-01)

On 2019/06/27 13:03:19 +0000, address@hidden wrote:
> > Currently, one can include STDIN_FILENO in a select(2), and then call 
> > getch() if input is available on stdin. This allows for a main loop that 
> > also wait on other file descriptors, signals and a timeout. Unfortunataly, 
> > the mouse cannot be included  in this select because the _mouse_fd field of 
> > the SCREEN structure is private. 
> 
> > A workaroud is to have a thread call getch() in blocking mode and then 
> > serve the result on a pipe whose other end goes in the select. But this 
> > solution seems awkward to me, especially considering that STDIN_FILENO is 
> > instead always available to the application, and compared with having a 
> > function like getmousefd() that returns _mouse_fd. 
> 
> > This function would be similar to ConnectionNumber(Display *) in XWindow: 
> > it returns a file descriptor to be used in a select, so that the 
> > application may then call XNextEvent() or similar if something can be read 
> > there. I believe it is not supposed to be used in any other way. 
> Here is a patch for doing this:
> --- ncurses-6.1/include/curses.tail 2016-02-13 17:37:45.000000000 +0100+++ 
> ncurses-6.1-withmousefd/include/curses.tail 2019-06-26 10:57:05.755049847 
> +0200@@ -95,6 +95,7 @@ MEVENT;  extern NCURSES_EXPORT(bool)    
> has_mouse(void);+extern NCURSES_EXPORT(int)     getmousefd(void); extern 
> NCURSES_EXPORT(int)     getmouse (MEVENT *); extern NCURSES_EXPORT(int)     
> ungetmouse (MEVENT *); extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, 
> mmask_t *);@@ -105,6 +106,7 @@  #if NCURSES_SP_FUNCS extern 
> NCURSES_EXPORT(bool)    NCURSES_SP_NAME(has_mouse) (SCREEN*);+extern 
> NCURSES_EXPORT(int)     NCURSES_SP_NAME(getmousefd) (SCREEN*); extern 
> NCURSES_EXPORT(int)     NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); extern 
> NCURSES_EXPORT(int)     NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); 
> extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, 
> mmask_t *);--- ncurses-6.1/ncurses/base/lib_mouse.c 2017-11-18 
> 23:12:06.000000000 +0100+++ ncurses-6.1-withmousefd/ncurses/base/lib_mouse.c 
> 2019-06-26 10:56:53.138048893 +0200@@ -2005,3 +2005,17 @@     }     
> returnBool(result); }++NCURSES_EXPORT(int)+_nc_getmousefd(SCREEN *scr) {+ 
> return scr->_mouse_fd;+}++#if 
> NCURSES_SP_FUNCS+NCURSES_EXPORT(int)+getmousefd(void)+{+    return 
> _nc_getmousefd(CURRENT_SCREEN);+}+#endif+

Please attach patches as separate text file instead of including them within 
HTML
text container of your e-mail ;)

Even if readed the HTML part of your mail with an HTML viewer with correct word
wrap and line break, the spaces and tabulators do also survive in a real text
file of mime type text/x-patch or text/plain

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]