summaryrefslogtreecommitdiff
path: root/sys/arch/i386/isa/pcvt
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/i386/isa/pcvt')
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_drv.c6
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_ext.c45
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_hdr.h20
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_ioctl.h3
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_kbd.c10
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_mouse.c457
-rw-r--r--sys/arch/i386/isa/pcvt/pcvt_mouse.h6
7 files changed, 425 insertions, 122 deletions
diff --git a/sys/arch/i386/isa/pcvt/pcvt_drv.c b/sys/arch/i386/isa/pcvt/pcvt_drv.c
index 12beb84f7c1..d5bf32eb623 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_drv.c
+++ b/sys/arch/i386/isa/pcvt/pcvt_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcvt_drv.c,v 1.34 2000/09/28 17:45:42 aaron Exp $ */
+/* $OpenBSD: pcvt_drv.c,v 1.35 2000/10/07 03:12:45 aaron Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
*
@@ -549,11 +549,9 @@ pcstart(register struct tty *tp)
if (vs[minor(tp->t_dev)].scrolling)
sgetc(31337);
if (vsp == &vs[minor(tp->t_dev)]) {
- if (IS_SEL_EXISTS(vsp)) {
+ if (IS_SEL_EXISTS(vsp))
/* hides a potential selection */
remove_selection();
- vsp->mouse_flags &= ~SEL_EXISTS;
- }
mouse_hide(); /* hides a potential mouse cursor */
}
sput(&buf[0], 0, len, minor(tp->t_dev));
diff --git a/sys/arch/i386/isa/pcvt/pcvt_ext.c b/sys/arch/i386/isa/pcvt/pcvt_ext.c
index d7e3ca381dd..babde2b9990 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_ext.c
+++ b/sys/arch/i386/isa/pcvt/pcvt_ext.c
@@ -1,5 +1,4 @@
-/* $OpenBSD: pcvt_ext.c,v 1.27 2000/09/01 05:46:01 aaron Exp $ */
-
+/* $OpenBSD: pcvt_ext.c,v 1.28 2000/10/07 03:12:45 aaron Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
*
@@ -2417,11 +2416,10 @@ vgapage(int new_screen)
{
int x;
- if (IS_SEL_EXISTS(vsp)) {
+ if (IS_SEL_EXISTS(vsp))
/* hides a potential selection */
remove_selection();
- vsp->mouse_flags &= ~SEL_EXISTS;
- }
+
mouse_hide(); /* hides a potential mouse cursor */
if(new_screen < 0 || new_screen >= totalscreens)
@@ -2630,7 +2628,7 @@ usl_vt_ioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
* if the new vt is also in process
* mode, we have to wait until its
* controlling process acknowledged
- * the switch
+ * the switch
*/
vsp->vt_status
|= VT_WAIT_ACK;
@@ -2643,6 +2641,14 @@ usl_vt_ioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
/* we are committed */
vt_switch_pending = 0;
}
+ /*
+ * We send here a USR2 signal to the mouse
+ * daemon (moused(8))
+ * to tell him he can reuse the mouse device.
+ */
+ if (moused_proc)
+ psignal(moused_proc, SIGUSR2);
+
return 0;
}
break;
@@ -2653,6 +2659,13 @@ usl_vt_ioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
{
vt_switch_pending = 0;
vsp->vt_status &= ~VT_WAIT_ACK;
+ /*
+ * We send a USR1 signal to the mouse
+ * daemon (moused(8))
+ * to ask him to free the mouse device.
+ */
+ if (moused_proc)
+ psignal(moused_proc, SIGUSR1);
return 0;
}
@@ -2769,8 +2782,17 @@ usl_vt_ioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
case KD_TEXT:
haschanged = (vsx->vt_status & VT_GRAFX) != 0;
vsx->vt_status &= ~VT_GRAFX;
- if(haschanged && vsx == vsp)
+ if (haschanged && vsx == vsp)
switch_screen(current_video_screen, 1, 0);
+
+ /*
+ * We send here a USR2 signal to the mouse
+ * daemon (moused(8))
+ * to tell him he can reuse the mouse device.
+ */
+ if (moused_proc)
+ psignal(moused_proc, SIGUSR2);
+
return 0;
case KD_GRAPHICS:
@@ -2781,6 +2803,15 @@ usl_vt_ioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
vsx->vt_status |= VT_GRAFX;
if(haschanged && vsx == vsp)
switch_screen(current_video_screen, 0, 1);
+
+ /*
+ * We send a USR1 signal to the mouse
+ * daemon (moused(8))
+ * to ask him to free the mouse device.
+ */
+ if (moused_proc)
+ psignal(moused_proc, SIGUSR1);
+
return 0;
}
diff --git a/sys/arch/i386/isa/pcvt/pcvt_hdr.h b/sys/arch/i386/isa/pcvt/pcvt_hdr.h
index 4f1f16f5f66..2f5e710010f 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_hdr.h
+++ b/sys/arch/i386/isa/pcvt/pcvt_hdr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcvt_hdr.h,v 1.40 2000/09/28 17:45:42 aaron Exp $ */
+/* $OpenBSD: pcvt_hdr.h,v 1.41 2000/10/07 03:12:46 aaron Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
@@ -705,21 +705,29 @@ typedef struct video_state {
int kbd_state; /* keyboard raw or translated */
unsigned short mouse; /* mouse cursor position */
+ unsigned short cursor; /* selection cursor position ( if
+ different from mouse cursor pos) */
unsigned short cpy_start; /* position of the copy start mark*/
unsigned short cpy_end; /* position of the copy end mark */
- unsigned short cpy_orig; /* original copy position */
+ unsigned short orig_start; /* position of the original sel. start*/
+ unsigned short orig_end; /* position of the original sel. end */
#define MOUSE_VISIBLE (1 << 0) /* flag, the mouse cursor is visible */
#define SEL_EXISTS (1 << 1) /* flag, a selection exists */
#define SEL_IN_PROGRESS (1 << 2) /* flag, a selection is in progress */
-#define BLANK_TO_EOL (1 << 3) /* flag, there are only blanks
+#define SEL_EXT_AFTER (1 << 3) /* flag, selection is extended after */
+#define BLANK_TO_EOL (1 << 4) /* flag, there are only blanks
characters to eol */
-#define IN_SELECTION (1 << 4) /* flag, the cursor is currently in
- the selection */
+#define SEL_BY_CHAR (1 << 5) /* flag, select character by character*/
+#define SEL_BY_WORD (1 << 6) /* flag, select word by word */
+#define SEL_BY_LINE (1 << 7) /* flag, select line by line */
#define IS_MOUSE_VISIBLE(vsp) ((vsp)->mouse_flags & MOUSE_VISIBLE)
#define IS_SEL_EXISTS(vsp) ((vsp)->mouse_flags & SEL_EXISTS)
#define IS_SEL_IN_PROGRESS(vsp) ((vsp)->mouse_flags & SEL_IN_PROGRESS)
+#define IS_SEL_EXT_AFTER(vsp) ((vsp)->mouse_flags & SEL_EXT_AFTER)
#define IS_BLANK_TO_EOL(vsp) ((vsp)->mouse_flags & BLANK_TO_EOL)
-#define IS_IN_SELECTION(vsp) ((vsp)->mouse_flags & IN_SELECTION)
+#define IS_SEL_BY_CHAR(vsp) ((vsp)->mouse_flags & SEL_BY_CHAR)
+#define IS_SEL_BY_WORD(vsp) ((vsp)->mouse_flags & SEL_BY_WORD)
+#define IS_SEL_BY_LINE(vsp) ((vsp)->mouse_flags & SEL_BY_LINE)
unsigned char mouse_flags; /* flags, status of the mouse */
} video_state;
diff --git a/sys/arch/i386/isa/pcvt/pcvt_ioctl.h b/sys/arch/i386/isa/pcvt/pcvt_ioctl.h
index 03b00f3e586..6ef47922372 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_ioctl.h
+++ b/sys/arch/i386/isa/pcvt/pcvt_ioctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcvt_ioctl.h,v 1.15 2000/09/01 05:46:02 aaron Exp $ */
+/* $OpenBSD: pcvt_ioctl.h,v 1.16 2000/10/07 03:12:46 aaron Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
@@ -592,5 +592,6 @@ typedef struct keymap keymap_t;
/* Ioctl for mouse console support */
#define PCVT_MOUSECTL _IOW('M',1,mouse_info_t)
+#define PCVT_MOUSED _IOW('M',2,char)
#endif /* ! _MACHINE_PCVT_IOCTL_H_ */
diff --git a/sys/arch/i386/isa/pcvt/pcvt_kbd.c b/sys/arch/i386/isa/pcvt/pcvt_kbd.c
index 2c0ec4e3764..c38299f89dc 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_kbd.c
+++ b/sys/arch/i386/isa/pcvt/pcvt_kbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcvt_kbd.c,v 1.36 2000/09/01 05:46:02 aaron Exp $ */
+/* $OpenBSD: pcvt_kbd.c,v 1.37 2000/10/07 03:12:46 aaron Exp $ */
/*
* Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch.
@@ -1107,11 +1107,9 @@ regular:
if ((key == 85) && shift_down &&
(kbd_lastkey != 85 || !kbd_status.breakseen)) {
/* removing of visual regions for mouse console support */
- if (IS_SEL_EXISTS(vsp)) {
+ if (IS_SEL_EXISTS(vsp))
remove_selection(); /* remove current selection before
leaving this screen */
- vsp->mouse_flags &= ~SEL_EXISTS;
- }
if (IS_MOUSE_VISIBLE(vsp)) {
mouse_hide();
vsp->mouse_flags &= ~MOUSE_VISIBLE;
@@ -1156,11 +1154,9 @@ regular:
(kbd_lastkey != 86 || !kbd_status.breakseen)) {
scroll_reset:
/* removing of visual regions for mouse console support */
- if (IS_SEL_EXISTS(vsp)) {
+ if (IS_SEL_EXISTS(vsp))
remove_selection(); /* remove current selection before
leaving this screen */
- vsp->mouse_flags &= ~SEL_EXISTS;
- }
if (IS_MOUSE_VISIBLE(vsp)) {
mouse_hide();
vsp->mouse_flags &= ~MOUSE_VISIBLE;
diff --git a/sys/arch/i386/isa/pcvt/pcvt_mouse.c b/sys/arch/i386/isa/pcvt/pcvt_mouse.c
index ee4c45aa23a..0785e10b5a7 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_mouse.c
+++ b/sys/arch/i386/isa/pcvt/pcvt_mouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcvt_mouse.c,v 1.4 2000/09/28 15:44:50 aaron Exp $ */
+/* $OpenBSD: pcvt_mouse.c,v 1.5 2000/10/07 03:12:47 aaron Exp $ */
/*
* Copyright (c) 2000 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
@@ -47,14 +47,19 @@ void inverse_region(unsigned short start, unsigned short end);
unsigned char skip_spc_right(char);
unsigned char skip_spc_left(void);
-unsigned char skip_char_right(void);
-unsigned char skip_char_left(void);
+unsigned char skip_char_right(unsigned short);
+unsigned char skip_char_left(unsigned short);
+unsigned char class_cmp(unsigned short, unsigned short);
void mouse_copy_start(void);
void mouse_copy_end(void);
void mouse_copy_word(void);
void mouse_copy_line(void);
void mouse_copy_extend(void);
+void mouse_copy_extend_char(void);
+void mouse_copy_extend_word(void);
+void mouse_copy_extend_line(void);
+void mouse_copy_extend_after(void);
void remove_selection(void);
void mouse_copy_selection(void);
void mouse_paste(void);
@@ -120,6 +125,21 @@ mouse_ioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
}
return 0;
}
+ if (device == PCVTCTL_MINOR && cmd == PCVT_MOUSED) {
+ char moused_flag = *(char *) data;
+ switch(moused_flag) {
+ case MOUSED_ON:
+ moused_proc = p;
+ break;
+ case MOUSED_OFF:
+ moused_proc = NULL;
+ break;
+ default:
+ return 0;
+ }
+ return 0;
+ }
+
return (-1); /* continue treatment in pcioctl */
}
@@ -181,7 +201,7 @@ mouse_moverel(char dx, char dy)
}
/*
- * function to video inverse a character of the display
+ * Function to video inverse a character of the display
*/
void
@@ -208,13 +228,15 @@ void
inverse_region(unsigned short start, unsigned short end)
{
unsigned short current_pos;
- unsigned char c = 0;
+ unsigned short abs_end;
+ /* sanity check, useful because 'end' can be (0 - 1) = 65535 */
+ abs_end = vsp->maxcol * vsp->screen_rows;
+ if (end > abs_end)
+ return ;
current_pos = start;
- while (current_pos <= end) {
+ while (current_pos <= end)
inverse_char(current_pos++);
- c++;
- }
}
/*
@@ -270,7 +292,7 @@ skip_spc_left(void)
res--;
return (res);
}
-
+
/*
* Class of characters
* Stolen from xterm sources of the Xfree project (see cvs tag below)
@@ -342,20 +364,21 @@ static int charClass[256] = {
48, 48, 48, 48, 48, 48, 48, 248,
/* o/ u` u' u^ u: y' P y: */
48, 48, 48, 48, 48, 48, 48, 48};
+
/*
* Function which find the first blank beginning after the current cursor
* position
*/
unsigned char
-skip_char_right(void)
+skip_char_right(unsigned short offset)
{
unsigned short *current;
unsigned short *limit;
unsigned char res = 0;
unsigned char class;
- current = vsp->Crtat + vsp->cpy_end;
+ current = vsp->Crtat + offset;
class = charClass[(*current & 0x00ff)];
limit = current + (vsp->maxcol - (vsp->mouse % vsp->maxcol) - 1);
while ((charClass[(*current & 0x00ff)] == class) && (current <= limit)){
@@ -372,14 +395,14 @@ skip_char_right(void)
*/
unsigned char
-skip_char_left(void)
+skip_char_left(unsigned short offset)
{
unsigned short *current;
unsigned short *limit;
unsigned char res = 0;
unsigned char class;
- current = vsp->Crtat + vsp->cpy_start;
+ current = vsp->Crtat + offset;
class = charClass[(*current & 0x00ff)];
limit = current - (vsp->mouse % vsp->maxcol);
while ((charClass[(*current & 0x00ff)] == class) && (current >= limit)){
@@ -391,6 +414,25 @@ skip_char_left(void)
return (res);
}
+/*
+ * Function to compare character classes
+ */
+
+unsigned char
+class_cmp(unsigned short first, unsigned short second)
+{
+ unsigned char first_class;
+ unsigned char second_class;
+
+ first_class = charClass[(*(vsp->Crtat + first) & 0x00ff)];
+ second_class = charClass[(*(vsp->Crtat + second) & 0x00ff)];
+
+ if (first_class != second_class)
+ return (1);
+ else
+ return (0);
+}
+
/*
* Function to handle beginning of a copy operation
*/
@@ -414,20 +456,23 @@ mouse_copy_start(void)
/* initial show of the cursor */
if (!IS_MOUSE_VISIBLE(vsp))
inverse_char(vsp->mouse);
-
- vsp->cpy_start = vsp->mouse;
+
+ vsp->cpy_start = vsp->mouse;
vsp->cpy_end = vsp->mouse;
- vsp->cpy_orig = vsp->cpy_start; /* for correct action in
- remove_selection() */
+ vsp->orig_start = vsp->cpy_start;
+ vsp->orig_end = vsp->cpy_end;
+ vsp->cursor = vsp->cpy_end + 1; /* init value */
+
right = skip_spc_right(BORDER); /* useful later, in mouse_copy_extend */
if (right)
vsp->mouse_flags |= BLANK_TO_EOL;
vsp->mouse_flags |= SEL_IN_PROGRESS;
vsp->mouse_flags |= SEL_EXISTS;
-
- /* mouse cursor hidden in the selection */
- vsp->mouse_flags &= ~MOUSE_VISIBLE;
+ vsp->mouse_flags |= SEL_BY_CHAR; /* select by char */
+ vsp->mouse_flags &= ~SEL_BY_WORD;
+ vsp->mouse_flags &= ~SEL_BY_LINE;
+ vsp->mouse_flags &= ~MOUSE_VISIBLE; /* cursor hidden in selection */
}
/*
@@ -449,8 +494,8 @@ mouse_copy_word()
vsp->cpy_end = vsp->mouse;
if (IS_ALPHANUM(vsp->mouse)) {
- right = skip_char_right();
- left = skip_char_left();
+ right = skip_char_right(vsp->cpy_end);
+ left = skip_char_left(vsp->cpy_start);
}
else {
right = skip_spc_right(NO_BORDER);
@@ -459,15 +504,16 @@ mouse_copy_word()
vsp->cpy_start -= left;
vsp->cpy_end += right;
- vsp->cpy_orig = vsp->cpy_start;
+ vsp->orig_start = vsp->cpy_start;
+ vsp->orig_end = vsp->cpy_end;
+ vsp->cursor = vsp->cpy_end + 1; /* init value, never happen */
inverse_region(vsp->cpy_start, vsp->cpy_end);
vsp->mouse_flags |= SEL_IN_PROGRESS;
vsp->mouse_flags |= SEL_EXISTS;
-
- /* mouse cursor is in the selection. Moving the cursor inside the
- selection won't modify (extend or reduce) it */
- vsp->mouse_flags |= IN_SELECTION;
+ vsp->mouse_flags &= ~SEL_BY_CHAR;
+ vsp->mouse_flags |= SEL_BY_WORD;
+ vsp->mouse_flags &= ~SEL_BY_LINE;
/* mouse cursor hidden in the selection */
vsp->mouse_flags &= ~BLANK_TO_EOL;
@@ -490,15 +536,16 @@ mouse_copy_line(void)
vsp->cpy_start = row * vsp->maxcol;
vsp->cpy_end = vsp->cpy_start + MAXCOL;
- vsp->cpy_orig = vsp->cpy_start;
+ vsp->orig_start = vsp->cpy_start;
+ vsp->orig_end = vsp->cpy_end;
+ vsp->cursor = vsp->cpy_end + 1;
inverse_region(vsp->cpy_start, vsp->cpy_end);
vsp->mouse_flags |= SEL_IN_PROGRESS;
vsp->mouse_flags |= SEL_EXISTS;
-
- /* mouse cursor is in the selection. Moving the cursor inside the
- selection won't modify (extend or reduce) it */
- vsp->mouse_flags |= IN_SELECTION;
+ vsp->mouse_flags &= ~SEL_BY_CHAR;
+ vsp->mouse_flags &= ~SEL_BY_WORD;
+ vsp->mouse_flags |= SEL_BY_LINE;
/* mouse cursor hidden in the selection */
vsp->mouse_flags &= ~BLANK_TO_EOL;
@@ -513,18 +560,41 @@ void
mouse_copy_end(void)
{
vsp->mouse_flags &= ~(SEL_IN_PROGRESS);
+ if (IS_SEL_BY_WORD(vsp) || IS_SEL_BY_LINE(vsp)) {
+ if (vsp->cursor != (vsp->cpy_end + 1))
+ inverse_char(vsp->cursor);
+ vsp->cursor = vsp->cpy_end + 1;
+ }
}
+/*
+ * Generic selection extend function
+ */
+
+void
+mouse_copy_extend(void)
+{
+ if (IS_SEL_BY_CHAR(vsp))
+ mouse_copy_extend_char();
+ if (IS_SEL_BY_WORD(vsp))
+ mouse_copy_extend_word();
+ if (IS_SEL_BY_LINE(vsp))
+ mouse_copy_extend_line();
+}
+
+
+
/*
- * Function to extend a previously selected region
+ * Function to extend a selected region, character by character
*/
void
-mouse_copy_extend()
+mouse_copy_extend_char()
{
unsigned char right;
+
+ if (!IS_SEL_EXT_AFTER(vsp)) {
- if (IS_SEL_EXISTS(vsp)) {
if (IS_BLANK_TO_EOL(vsp)) {
/*
* First extension of selection. We handle special
@@ -532,93 +602,295 @@ mouse_copy_extend()
*/
right = skip_spc_right(BORDER);
- if (vsp->mouse > vsp->cpy_orig) {
+ if (vsp->mouse > vsp->orig_start) {
/* the selection goes to the lower part of
the screen */
-
+
/* remove the previous cursor, start of
selection is now next line */
inverse_char(vsp->cpy_start);
vsp->cpy_start += (right + 1);
vsp->cpy_end = vsp->cpy_start;
- vsp->cpy_orig = vsp->cpy_start;
+ vsp->orig_start = vsp->cpy_start;
/* simulate the initial mark */
inverse_char(vsp->cpy_start);
}
else {
/* the selection goes to the upper part
of the screen */
- /* remove the previous cursorm, start of
+ /* remove the previous cursor, start of
selection is now at the eol */
inverse_char(vsp->cpy_start);
- vsp->cpy_orig += (right + 1);
- vsp->cpy_start = vsp->cpy_orig - 1;
- vsp->cpy_end = vsp->cpy_orig - 1;
+ vsp->orig_start += (right + 1);
+ vsp->cpy_start = vsp->orig_start - 1;
+ vsp->cpy_end = vsp->orig_start - 1;
/* simulate the initial mark */
inverse_char(vsp->cpy_start);
}
vsp->mouse_flags &= ~ BLANK_TO_EOL;
}
-
- if (vsp->mouse < vsp->cpy_orig
- && vsp->cpy_end >= vsp->cpy_orig) {
+
+ if (vsp->mouse < vsp->orig_start
+ && vsp->cpy_end >= vsp->orig_start) {
/* we go to the upper part of the screen */
-
+
/* reverse the old selection region */
remove_selection();
- vsp->cpy_end = vsp->cpy_orig - 1;
- vsp->cpy_start = vsp->cpy_orig;
+ vsp->cpy_end = vsp->orig_start - 1;
+ vsp->cpy_start = vsp->orig_start;
}
- if (vsp->cpy_start < vsp->cpy_orig
- && vsp->mouse >= vsp->cpy_orig) {
- /* we go back to the lower part of the screen */
+ if (vsp->cpy_start < vsp->orig_start
+ && vsp->mouse >= vsp->orig_start) {
+ /* we go to the lower part of the screen */
/* reverse the old selection region */
remove_selection();
+ vsp->cpy_start = vsp->orig_start;
+ vsp->cpy_end = vsp->orig_start - 1;
+ }
+ /* restore flags cleared in remove_selection() */
+ vsp->mouse_flags |= SEL_IN_PROGRESS;
+ vsp->mouse_flags |= SEL_EXISTS;
+ }
+ /* beginning of common part */
+
+ if (vsp->mouse >= vsp->orig_start) {
+
+ /* lower part of the screen */
+ if (vsp->mouse > vsp->cpy_end)
+ /* extending selection */
+ inverse_region(vsp->cpy_end + 1, vsp->mouse);
+ else
+ /* reducing selection */
+ inverse_region(vsp->mouse + 1, vsp->cpy_end);
+ vsp->cpy_end = vsp->mouse;
+ }
+ else {
+ /* upper part of the screen */
+ if (vsp->mouse < vsp->cpy_start)
+ /* extending selection */
+ inverse_region(vsp->mouse,vsp->cpy_start - 1);
+ else
+ /* reducing selection */
+ inverse_region(vsp->cpy_start,vsp->mouse - 1);
+ vsp->cpy_start = vsp->mouse;
+ }
+ /* end of common part */
+}
+
+/*
+ * Function to extend a selected region, word by word
+ */
+
+void
+mouse_copy_extend_word(void)
+{
+ unsigned short old_cpy_end;
+ unsigned short old_cpy_start;
+
+ if (!IS_SEL_EXT_AFTER(vsp)) {
+
+ /* remove cursor in selection (black one) */
+
+ if (vsp->cursor != (vsp->cpy_end + 1))
+ inverse_char(vsp->cursor);
- vsp->cpy_start = vsp->cpy_orig;
- vsp->cpy_end = vsp->cpy_orig - 1;
+ /* now, switch between lower and upper part of the screen */
+
+ if (vsp->mouse < vsp->orig_start
+ && vsp->cpy_end >= vsp->orig_start) {
+ /* going to the upper part of the screen */
+ inverse_region(vsp->orig_end + 1, vsp->cpy_end);
+ vsp->cpy_end = vsp->orig_end;
}
-
- if (vsp->mouse >= vsp->cpy_orig) {
- /* lower part of the screen */
- if (vsp->mouse > vsp->cpy_end) {
- /* extending selection */
- if (IS_IN_SELECTION(vsp))
- vsp->mouse_flags &= ~ IN_SELECTION;
- inverse_region(vsp->cpy_end + 1,vsp->mouse);
+ if (vsp->mouse > vsp->orig_end
+ && vsp->cpy_start <= vsp->orig_start) {
+ /* going to the lower part of the screen */
+ inverse_region(vsp->cpy_start, vsp->orig_start - 1);
+ vsp->cpy_start = vsp->orig_start;
+ }
+ }
+
+ if (vsp->mouse >= vsp->orig_start) {
+ /* lower part of the screen */
+
+ if (vsp->mouse > vsp->cpy_end) {
+ /* extending selection */
+
+ old_cpy_end = vsp->cpy_end;
+ vsp->cpy_end = vsp->mouse + skip_char_right(vsp->mouse);
+ inverse_region(old_cpy_end + 1, vsp->cpy_end);
+ }
+ else {
+ if (class_cmp(vsp->mouse, vsp->mouse + 1)) {
+ /* reducing selection (remove last word) */
+ old_cpy_end = vsp->cpy_end;
+ vsp->cpy_end = vsp->mouse;
+ inverse_region(vsp->cpy_end + 1, old_cpy_end);
}
else {
- /* reducing selection, if the cursor is not
- inside a word or line selection */
- if (!IS_IN_SELECTION(vsp))
- inverse_region(vsp->mouse + 1,vsp->cpy_end);
+ old_cpy_end = vsp->cpy_end;
+ vsp->cpy_end = vsp->mouse +
+ skip_char_right(vsp->mouse);
+ if (vsp->cpy_end != old_cpy_end) {
+ /* reducing selection, from the end of
+ * next word */
+ inverse_region(vsp->cpy_end + 1,
+ old_cpy_end);
+ }
}
- if (!IS_IN_SELECTION(vsp))
- vsp->cpy_end = vsp->mouse;
+ }
+ }
+ else {
+ /* upper part of the screen */
+ if (vsp->mouse < vsp->cpy_start) {
+ /* extending selection */
+ old_cpy_start = vsp->cpy_start;
+ vsp->cpy_start = vsp->mouse -skip_char_left(vsp->mouse);
+ inverse_region(vsp->cpy_start, old_cpy_start - 1);
}
else {
- /* upper part of the screen */
- if (vsp->mouse < vsp->cpy_start) {
- /* extending selection */
- if (IS_IN_SELECTION(vsp))
- vsp->mouse_flags &= ~ IN_SELECTION;
- inverse_region(vsp->mouse,vsp->cpy_start - 1);
+ if (class_cmp(vsp->mouse - 1, vsp->mouse)) {
+ /* reducing selection (remove last word) */
+ old_cpy_start = vsp->cpy_start;
+ vsp->cpy_start = vsp->mouse;
+ inverse_region(old_cpy_start,
+ vsp->cpy_start - 1);
}
else {
- /* reducing selection */
- inverse_region(vsp->cpy_start,vsp->mouse - 1);
+ old_cpy_start = vsp->cpy_start;
+ vsp->cpy_start = vsp->mouse -
+ skip_char_left(vsp->mouse);
+ if (vsp->cpy_start != old_cpy_start)
+ inverse_region(old_cpy_start,
+ vsp->cpy_start - 1);
}
- vsp->cpy_start = vsp->mouse;
}
}
- else {
+
+ if (!IS_SEL_EXT_AFTER(vsp)) {
+ /* display new cursor */
+ vsp->cursor = vsp->mouse;
+ inverse_char(vsp->cursor);
+ }
+}
+
+/*
+ * Function to extend a selected region, line by line
+ */
+
+void
+mouse_copy_extend_line(void)
+{
+ unsigned short old_row;
+ unsigned short new_row;
+ unsigned short old_cpy_start;
+ unsigned short old_cpy_end;
+
+ if (!IS_SEL_EXT_AFTER(vsp)) {
+ /* remove cursor in selection (black one) */
+
+ if (vsp->cursor != (vsp->cpy_end + 1))
+ inverse_char(vsp->cursor);
+
+ /* now, switch between lower and upper part of the screen */
+
+ if (vsp->mouse < vsp->orig_start
+ && vsp->cpy_end >= vsp->orig_start) {
+ /* going to the upper part of the screen */
+ inverse_region(vsp->orig_end + 1, vsp->cpy_end);
+ vsp->cpy_end = vsp->orig_end;
+ }
+
+ if (vsp->mouse > vsp->orig_end
+ && vsp->cpy_start <= vsp->orig_start) {
+ /* going to the lower part of the screen */
+ inverse_region(vsp->cpy_start, vsp->orig_start - 1);
+ vsp->cpy_start = vsp->orig_start;
+ }
+ }
+
+ if (vsp->mouse >= vsp->orig_start) {
+ /* lower part of the screen */
+ if (vsp->cursor == (vsp->cpy_end + 1))
+ vsp->cursor = vsp->cpy_end;
+ old_row = vsp->cursor / vsp->maxcol;
+ new_row = vsp->mouse / vsp->maxcol;
+ old_cpy_end = vsp->cpy_end;
+ vsp->cpy_end = (new_row * vsp->maxcol) + MAXCOL;
+ if (new_row > old_row)
+ inverse_region(old_cpy_end + 1, vsp->cpy_end);
+ else if (new_row < old_row)
+ inverse_region(vsp->cpy_end + 1, old_cpy_end);
+ }
+ else {
+ /* upper part of the screen */
+ old_row = vsp->cursor / vsp->maxcol;
+ new_row = vsp->mouse / vsp->maxcol;
+ old_cpy_start = vsp->cpy_start;
+ vsp->cpy_start = new_row * vsp->maxcol;
+ if (new_row < old_row)
+ inverse_region(vsp->cpy_start, old_cpy_start - 1);
+ else if (new_row > old_row)
+ inverse_region(old_cpy_start, vsp->cpy_start - 1);
+ }
+
+ if (!IS_SEL_EXT_AFTER(vsp)) {
+ /* display new cursor */
+ vsp->cursor = vsp->mouse;
+ inverse_char(vsp->cursor);
+ }
+}
+
+/*
+ * Function to add an extension to a selected region, word by word
+ */
+
+void
+mouse_copy_extend_after(void)
+{
+ unsigned short start_dist;
+ unsigned short end_dist;
+
+ if (IS_SEL_EXISTS(vsp)) {
+ vsp->mouse_flags |= SEL_EXT_AFTER;
+ mouse_hide(); /* hide current cursor */
+
+ if (vsp->cpy_start > vsp->mouse)
+ start_dist = vsp->cpy_start - vsp->mouse;
+ else
+ start_dist = vsp->mouse - vsp->cpy_start;
+ if (vsp->mouse > vsp->cpy_end)
+ end_dist = vsp->mouse - vsp->cpy_end;
+ else
+ end_dist = vsp->cpy_end - vsp->mouse;
+ if (start_dist < end_dist) {
+ /* upper part of the screen*/
+ vsp->orig_start = vsp->mouse + 1;
+ /* only used in mouse_copy_extend_line() */
+ vsp->cursor = vsp->cpy_start;
+ }
+ else {
+ /* lower part of the screen */
+ vsp->orig_start = vsp->mouse;
+ /* only used in mouse_copy_extend_line() */
+ vsp->cursor = vsp->cpy_end;
+ }
+ if (IS_SEL_BY_CHAR(vsp))
+ mouse_copy_extend_char();
+ if (IS_SEL_BY_WORD(vsp))
+ mouse_copy_extend_word();
+ if (IS_SEL_BY_LINE(vsp))
+ mouse_copy_extend_line();
+ mouse_copy_selection();
+ }
+ else
/* no selection yet! */
sysbeep(PCVT_SYSBEEPF / 1500, hz / 4);
- }
}
+
/*
* Function to remove a previously selected region
*/
@@ -626,12 +898,12 @@ mouse_copy_extend()
void
remove_selection()
{
- if (vsp->cpy_start < vsp->cpy_orig)
- /* backward selection */
- inverse_region(vsp->cpy_start, vsp->cpy_orig - 1);
- else
- /* forward selection */
- inverse_region(vsp->cpy_start, vsp->cpy_end);
+ if (IS_SEL_EXT_AFTER(vsp))
+ /* reset the flag indicating an extension of selection */
+ vsp->mouse_flags &= ~SEL_EXT_AFTER;
+ inverse_region(vsp->cpy_start, vsp->cpy_end);
+ vsp->mouse_flags &= ~SEL_IN_PROGRESS;
+ vsp->mouse_flags &= ~SEL_EXISTS;
}
/*
@@ -680,16 +952,9 @@ mouse_copy_selection(void)
unsigned short *sel_cur;
unsigned short *sel_end;
- if (vsp->cpy_start < vsp->cpy_orig) {
- /* backward selection */
- sel_cur = vsp->Crtat + vsp->cpy_end;
- sel_end = vsp->Crtat + vsp->cpy_orig - 1;
- }
- else {
- /* forward selection */
- sel_cur = vsp->Crtat + vsp->cpy_start;
- sel_end = vsp->Crtat + vsp->cpy_end;
- }
+ sel_cur = vsp->Crtat + vsp->cpy_start;
+ sel_end = vsp->Crtat + vsp->cpy_end;
+
while (sel_cur <= sel_end && current < buf_end - 1) {
Copybuffer[current] = ((*sel_cur) & 0x00ff);
if (!IS_SPACE(Copybuffer[current]))
@@ -708,6 +973,7 @@ mouse_copy_selection(void)
Copybuffer[current] = '\0';
Copyowner = current_uid();
}
+
/*
* Function to paste the current selection
*/
@@ -781,8 +1047,7 @@ mouse_button(int button, int clicks)
case 0: /* button is up */
break;
default: /* extend the selection */
- mouse_copy_extend();
- mouse_copy_selection();
+ mouse_copy_extend_after();
break;
}
break;
diff --git a/sys/arch/i386/isa/pcvt/pcvt_mouse.h b/sys/arch/i386/isa/pcvt/pcvt_mouse.h
index 985f2f512e5..2828382a33f 100644
--- a/sys/arch/i386/isa/pcvt/pcvt_mouse.h
+++ b/sys/arch/i386/isa/pcvt/pcvt_mouse.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcvt_mouse.h,v 1.1 2000/09/01 05:46:02 aaron Exp $ */
+/* $OpenBSD: pcvt_mouse.h,v 1.2 2000/10/07 03:12:47 aaron Exp $ */
/*
* Copyright (c) 2000 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
@@ -87,6 +87,8 @@ typedef struct mouse_info {
#define MOUSE_HIDE (1 << 1) /* Hide the cursor */
#define MOUSE_MOTION_EVENT (1 << 2) /* Motion event */
#define MOUSE_BUTTON_EVENT (1 << 3) /* Button event */
+#define MOUSED_ON 1
+#define MOUSED_OFF 0
union {
struct mouse_data data;
@@ -94,3 +96,5 @@ typedef struct mouse_info {
}u;
} mouse_info_t;
+struct proc *moused_proc;
+