/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* common mouse interface functions */
#include <stdio.h> /* NULL */
#include <stdlib.h> /* NULL */
#include <string.h> /* NULL */
#include <ctype.h> /* isdigit */
#include "global.h"
/* see if there is a mouse interface */
void
initmouse(void)
{
char *s, *term;
return;
}
/*
* the MOUSE enviroment variable is for 5620 terminal
* programs that have mouse support but the TERM environment
* variable is the same as a terminal without a mouse, such
* as myx
*/
}
changemenu = NO;
}
initmenu();
}
/* reinitialize the mouse in case curses changed the attributes */
void
reinitmouse(void)
{
/*
* enable the mouse click and sweep coordinate control
* sequence
*/
(void) printf("\033{2");
if (changemenu) {
}
}
}
/* restore any original mouse attributes not handled by terminfo */
void
cleanupmouse(void)
{
int i;
/* remove the mouse menu */
(void) printf("\033[6;0X\033[9;0X");
(void) printf("\033[0;0x");
}
loadedmenu = NULL;
}
}
/* download a mouse menu */
void
{
int i;
int len;
switch (mouse) {
case EMACSTERM:
reinitmouse();
if (changemenu) {
}
}
break;
case MYX:
if (changemenu) {
cleanupmouse();
(void) printf("\033[6;1X\033[9;1X");
}
loadedmenu = menu;
}
break;
case NONE:
case PC7300:
break;
}
}
/* draw the scroll bar */
void
{
if (p2 > 116) {
p2 = 116;
}
if (p1 < 16) {
p1 = 16;
}
/*
* don't send ^S or ^Q to avoid hanging a layer using
* cu(1)
*/
++p1;
}
++p2;
}
} else {
}
}
}
/* translate a mouse click or sweep to a selection */
int
{
int i;
if (i < 0) {
i = 0;
} else if (i >= maxselection) {
i = maxselection - 1;
}
return (i);
}
/* get the mouse event */
getmouseevent(void)
{
static MOUSEEVENT m;
switch (mygetch()) {
m.percent = getpercent();
} else {
m.x1 = getcoordinate();
m.y1 = getcoordinate();
}
break;
m.x1 = getcoordinate();
m.y1 = getcoordinate();
m.x2 = getcoordinate();
m.y2 = getcoordinate();
break;
default:
return (NULL);
}
return (&m);
}
return (NULL);
}
/* get a row or column coordinate from a mouse button click or sweep */
int
getcoordinate(void)
{
int c, next;
c = mygetch();
next = 0;
if (c == ctrl('A')) {
next = 95;
c = mygetch();
}
if (c < ' ') {
return (0);
}
return (next + c - ' ');
}
/* get a percentage */
int
getpercent(void)
{
int c;
c = mygetch();
if (c < 16) {
return (0);
}
if (c > 120) {
return (100);
}
return (c - 16);
}
/* update the window label area */
int
labelarea(char *s)
{
switch (mouse) {
case EMACSTERM:
}
(void) printf("\033L!%s!", s);
return (1);
case MYX:
return (1);
case NONE:
case PC7300:
default:
return (0); /* no label area */
}
}