mouseinterval(), from ncurses. I'd already implemented the mechanism, so

why not make it adjustable? Unlike ncurses, the max is 1000. Also,
comment formatting.
This commit is contained in:
William McBrine
2006-12-24 04:32:22 +00:00
parent b52bcb5e80
commit a6aa61e9fb
9 changed files with 69 additions and 36 deletions

View File

@@ -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);

View File

@@ -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];

View File

@@ -19,7 +19,7 @@
# include <sys/movedata.h>
#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. */

View File

@@ -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;

View File

@@ -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"))

View File

@@ -14,7 +14,7 @@
#include <curspriv.h>
#include <string.h>
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;
}

View File

@@ -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);

View File

@@ -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",

View File

@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <string.h>
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 +