From a6aa61e9fb2569d8d97b6a4eb16516c04fd39685 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Sun, 24 Dec 2006 04:32:22 +0000 Subject: [PATCH] mouseinterval(), from ncurses. I'd already implemented the mechanism, so why not make it adjustable? Unlike ncurses, the max is 1000. Also, comment formatting. --- curses.h | 40 +++++++++++++++++++++------------------- dos/pdckbd.c | 4 ++-- dos/pdcscrn.c | 4 +++- os2/pdckbd.c | 4 ++-- os2/pdcscrn.c | 4 +++- pdcurses/mouse.c | 35 +++++++++++++++++++++++++++++------ win32/pdckbd.c | 4 ++-- win32/pdcscrn.c | 4 +++- x11/x11.c | 6 ++++-- 9 files changed, 69 insertions(+), 36 deletions(-) diff --git a/curses.h b/curses.h index d29ca707..6e7f9f7a 100644 --- a/curses.h +++ b/curses.h @@ -11,7 +11,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: curses.h,v 1.259 2006/12/23 17:54:13 wmcbrine Exp $ */ +/* $Id: curses.h,v 1.260 2006/12/24 04:32:21 wmcbrine Exp $ */ /*----------------------------------------------------------------------* * PDCurses * @@ -319,15 +319,12 @@ typedef unsigned short chtype; /* 8-bit attr + 8-bit char */ typedef chtype cchar_t; #endif -/*---------------------------------------------------------------------- - * This defines a new type for attributes. - * - */ - typedef chtype attr_t; /*---------------------------------------------------------------------- - * Define our mouse interface - same as SYSVR4 (with extensions) + * + * PDCurses Mouse Interface -- SYSVR4, with extensions + * */ typedef struct @@ -407,7 +404,7 @@ typedef struct /*---------------------------------------------------------------------- * - * PDCurses Structure Definitions: + * PDCurses Structure Definitions * */ @@ -468,20 +465,23 @@ typedef struct bool mono; /* TRUE if current screen is mono */ bool resized; /* TRUE if TERM has been resized */ bool orig_attr; /* TRUE if we have the original colors */ - short orig_fore; /* Original screen foreground color */ - short orig_back; /* Original screen foreground color */ + short orig_fore; /* original screen foreground color */ + short orig_back; /* original screen foreground color */ int cursrow; /* position of physical cursor */ int curscol; /* position of physical cursor */ - int visibility; /* Visibility of cursor */ - int orig_cursor; /* Original cursor size */ - int lines; /* New value for LINES */ - int cols; /* New value for COLS */ + int visibility; /* visibility of cursor */ + int orig_cursor; /* original cursor size */ + int lines; /* new value for LINES */ + int cols; /* new value for COLS */ unsigned long _trap_mbe; /* trap these mouse button events */ unsigned long _map_mbe_to_key; /* map mouse buttons to slk */ - int slklines; /* Lines in use by slk_init() */ + int mouse_wait; /* time to wait (in ms) for a + button release after a press, in + order to count it as a click */ + int slklines; /* lines in use by slk_init() */ WINDOW *slk_winptr; /* window for slk */ - int linesrippedoff; /* Lines ripped off via ripoffline() */ - int linesrippedoffontop; /* Lines ripped off on + int linesrippedoff; /* lines ripped off via ripoffline() */ + int linesrippedoffontop; /* lines ripped off on top via ripoffline() */ int delaytenths; /* 1/10ths second to wait block getch() for */ @@ -506,7 +506,7 @@ typedef struct int sb_cur_y; int sb_cur_x; #endif - short line_color; /* Color of line attributes - default white */ + short line_color; /* color of line attributes - default -1 */ } SCREEN; @@ -1052,7 +1052,7 @@ extern chtype acs_map[]; /*---------------------------------------------------------------------- * - * PDCurses function declarations + * PDCurses Function Declarations * */ @@ -1453,6 +1453,8 @@ bool has_key(int); int use_default_colors(void); int wresize(WINDOW *, int, int); +int mouseinterval(int); + /* PDCurses */ int addrawch(chtype); diff --git a/dos/pdckbd.c b/dos/pdckbd.c index 9ff0b230..32ed777e 100644 --- a/dos/pdckbd.c +++ b/dos/pdckbd.c @@ -26,7 +26,7 @@ #include "pdcdos.h" -RCSID("$Id: pdckbd.c,v 1.71 2006/12/13 20:40:50 wmcbrine Exp $"); +RCSID("$Id: pdckbd.c,v 1.72 2006/12/24 04:32:21 wmcbrine Exp $"); /************************************************************************ * Table for key code translation of function keys in keypad mode * @@ -309,7 +309,7 @@ static int _process_mouse_events(void) { PDCREGS regs; - napms(100); + napms(SP->mouse_wait); regs.W.ax = 6; regs.W.bx = button_map[i]; diff --git a/dos/pdcscrn.c b/dos/pdcscrn.c index 10f78c38..bfd5244b 100644 --- a/dos/pdcscrn.c +++ b/dos/pdcscrn.c @@ -19,7 +19,7 @@ # include #endif -RCSID("$Id: pdcscrn.c,v 1.71 2006/12/22 14:47:26 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.72 2006/12/24 04:32:21 wmcbrine Exp $"); int pdc_adapter; /* screen type */ int pdc_scrnmode; /* default screen mode */ @@ -561,6 +561,8 @@ int PDC_scr_open(int argc, char **argv) SP->lines = PDC_get_rows(); SP->cols = PDC_get_columns(); + SP->mouse_wait = 100; + /* If the environment variable PDCURSES_BIOS is set, the DOS int10() BIOS calls are used in place of direct video memory access. */ diff --git a/os2/pdckbd.c b/os2/pdckbd.c index 6a8154ef..444b41c1 100644 --- a/os2/pdckbd.c +++ b/os2/pdckbd.c @@ -35,7 +35,7 @@ static bool key_pressed = FALSE; static int mouse_events = 0; #endif -RCSID("$Id: pdckbd.c,v 1.73 2006/12/05 23:10:31 wmcbrine Exp $"); +RCSID("$Id: pdckbd.c,v 1.74 2006/12/24 04:32:22 wmcbrine Exp $"); /************************************************************************ * Table for key code translation of function keys in keypad mode * @@ -282,7 +282,7 @@ static int _process_mouse_events(void) { MOUQUEINFO queue; - napms(100); + napms(SP->mouse_wait); MouGetNumQueEl(&queue, mouse_handle); mouse_events = queue.cEvents; diff --git a/os2/pdcscrn.c b/os2/pdcscrn.c index e49cb21f..0f7aae57 100644 --- a/os2/pdcscrn.c +++ b/os2/pdcscrn.c @@ -13,7 +13,7 @@ #include "pdcos2.h" -RCSID("$Id: pdcscrn.c,v 1.61 2006/12/22 14:46:54 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.62 2006/12/24 04:32:22 wmcbrine Exp $"); int pdc_font; /* default font size */ @@ -208,6 +208,8 @@ int PDC_scr_open(int argc, char **argv) SP->lines = PDC_get_rows(); SP->cols = PDC_get_columns(); + SP->mouse_wait = 100; + /* This code for preserving the current screen */ if (getenv("PDC_RESTORE_SCREEN")) diff --git a/pdcurses/mouse.c b/pdcurses/mouse.c index e82cc79b..9ce859b4 100644 --- a/pdcurses/mouse.c +++ b/pdcurses/mouse.c @@ -14,7 +14,7 @@ #include #include -RCSID("$Id: mouse.c,v 1.29 2006/11/11 20:24:36 wmcbrine Exp $"); +RCSID("$Id: mouse.c,v 1.30 2006/12/24 04:32:22 wmcbrine Exp $"); /*man-start************************************************************** @@ -22,15 +22,17 @@ RCSID("$Id: mouse.c,v 1.29 2006/11/11 20:24:36 wmcbrine Exp $"); Synopsis: - int mouse_set(long); - int mouse_on(long); - int mouse_off(long); + int mouse_set(unsigned long mbe); + int mouse_on(unsigned long mbe); + int mouse_off(unsigned long mbe); int request_mouse_pos(void); - int map_button(unsigned long); - void wmouse_position(WINDOW *, int *, int *); + int map_button(unsigned long button); + void wmouse_position(WINDOW *win, int *y, int *x); unsigned long getmouse(void); unsigned long getbmap(void); + int mouseinterval(int wait); + PDCurses Description: These functions are intended to be based on Sys V mouse functions; however, those are undocumented. @@ -162,3 +164,24 @@ unsigned long getbmap(void) return SP->_map_mbe_to_key; } + +/* ncurses mouse interface */ + +int mouseinterval(int wait) +{ + int old_wait; + + PDC_LOG(("mouseinterval() - called: %d\n", wait)); + + if (SP) + { + old_wait = SP->mouse_wait; + + if (wait >= 0 && wait <= 1000) + SP->mouse_wait = wait; + } + else + old_wait = 100; + + return old_wait; +} diff --git a/win32/pdckbd.c b/win32/pdckbd.c index e193b35f..a8b0ec9a 100644 --- a/win32/pdckbd.c +++ b/win32/pdckbd.c @@ -13,7 +13,7 @@ #include "pdcwin.h" -RCSID("$Id: pdckbd.c,v 1.99 2006/12/05 23:46:46 wmcbrine Exp $"); +RCSID("$Id: pdckbd.c,v 1.100 2006/12/24 04:32:22 wmcbrine Exp $"); unsigned long pdc_key_modifiers = 0L; @@ -535,7 +535,7 @@ static int _process_mouse_event(void) if (!event_count) { - napms(100); + napms(SP->mouse_wait); GetNumberOfConsoleInputEvents(pdc_con_in, &event_count); diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c index f60dcaf2..391e494a 100644 --- a/win32/pdcscrn.c +++ b/win32/pdcscrn.c @@ -13,7 +13,7 @@ #include "pdcwin.h" -RCSID("$Id: pdcscrn.c,v 1.73 2006/12/20 02:35:48 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.74 2006/12/24 04:32:22 wmcbrine Exp $"); #define PDC_RESTORE_NONE 0 #define PDC_RESTORE_BUFFER 1 @@ -337,6 +337,8 @@ int PDC_scr_open(int argc, char **argv) SP->cols = ((str = getenv("COLS")) != NULL) ? atoi(str) : PDC_get_columns(); + SP->mouse_wait = 100; + if (SP->lines < 2 || SP->lines > csbi.dwMaximumWindowSize.Y) { fprintf(stderr, "LINES value must be >= 2 and <= %d: got %d\n", diff --git a/x11/x11.c b/x11/x11.c index cad2cbfd..1c77244c 100644 --- a/x11/x11.c +++ b/x11/x11.c @@ -32,7 +32,7 @@ #include #include -RCSID("$Id: x11.c,v 1.72 2006/12/20 03:27:10 wmcbrine Exp $"); +RCSID("$Id: x11.c,v 1.73 2006/12/24 04:32:22 wmcbrine Exp $"); #ifndef XPOINTER_TYPEDEFED typedef char * XPointer; @@ -2035,7 +2035,7 @@ static void XCursesButton(Widget w, XEvent *event, String *params, } else { - napms(xc_app_data.clickPeriod); + napms(SP->mouse_wait); event->type = ButtonRelease; XSendEvent(event->xbutton.display, event->xbutton.window, True, 0, event); @@ -3047,6 +3047,8 @@ int XCursesSetupX(int argc, char *argv[]) SP->lines = XCursesLINES; SP->cols = XCursesCOLS; + SP->mouse_wait = xc_app_data.clickPeriod; + PDC_LOG(("%s:SHM size for curscr %d\n", XCLOGMSG, SP->XcurscrSize)); if ((shmid_Xcurscr = shmget(shmkey_Xcurscr, SP->XcurscrSize +