2 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer as
10 * the first lines of this file unmodified.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/sys/dev/syscons/scmouse.c,v 1.12.2.3 2001/07/28 12:51:47 yokota Exp $
29 #include "opt_syscons.h"
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/kernel.h>
35 #include <sys/signalvar.h>
38 #include <sys/thread2.h>
40 #include <machine/console.h>
41 #include <sys/mouse.h>
45 #ifdef SC_TWOBUTTON_MOUSE
46 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON3DOWN /* right button */
47 #define SC_MOUSE_EXTENDBUTTON MOUSE_BUTTON2DOWN /* not really used */
49 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON2DOWN /* middle button */
50 #define SC_MOUSE_EXTENDBUTTON MOUSE_BUTTON3DOWN /* right button */
51 #endif /* SC_TWOBUTTON_MOUSE */
53 #define SC_WAKEUP_DELTA 20
55 #ifndef SC_NO_SYSMOUSE
57 static int cut_buffer_size;
58 static u_char *cut_buffer;
61 static void sc_mouse_init(void *);
62 static void sc_mouse_uninit(void *);
64 static void set_mouse_pos(scr_stat *scp);
65 #ifndef SC_NO_CUTPASTE
66 static int skip_spc_right(scr_stat *scp, int p);
67 static int skip_spc_left(scr_stat *scp, int p);
68 static void mouse_cut(scr_stat *scp);
69 static void mouse_cut_start(scr_stat *scp);
70 static void mouse_cut_end(scr_stat *scp);
71 static void mouse_cut_word(scr_stat *scp);
72 static void mouse_cut_line(scr_stat *scp);
73 static void mouse_cut_extend(scr_stat *scp);
74 static void mouse_paste(scr_stat *scp);
75 #endif /* SC_NO_CUTPASTE */
77 static struct lwkt_token scmouse_tok = LWKT_TOKEN_INITIALIZER(scmouse_tok);
79 #ifndef SC_NO_CUTPASTE
80 /* allocate a cut buffer */
82 sc_alloc_cut_buffer(scr_stat *scp, int wait)
86 if ((cut_buffer == NULL)
87 || (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
92 cut_buffer_size = scp->xsize * scp->ysize + 1;
93 p = kmalloc(cut_buffer_size, M_SYSCONS, (wait) ? M_WAITOK : M_NOWAIT);
99 #endif /* SC_NO_CUTPASTE */
103 sc_mouse_move(scr_stat *scp, int x, int y)
106 scp->mouse_xpos = scp->mouse_oldxpos = x;
107 scp->mouse_ypos = scp->mouse_oldypos = y;
108 if (scp->font_height <= 0)
109 scp->mouse_pos = scp->mouse_oldpos = 0;
111 scp->mouse_pos = scp->mouse_oldpos =
112 (y / scp->font_height - scp->yoff) * scp->xsize +
113 x / scp->font_width - scp->xoff;
114 scp->status |= MOUSE_MOVED;
118 /* adjust mouse position */
120 set_mouse_pos(scr_stat *scp)
122 if (scp->mouse_xpos < scp->xoff * scp->font_width)
123 scp->mouse_xpos = scp->xoff * scp->font_width;
124 if (scp->mouse_ypos < scp->yoff * scp->font_height)
125 scp->mouse_ypos = scp->yoff * scp->font_height;
126 if (ISGRAPHSC(scp)) {
127 if (scp->mouse_xpos > scp->xpixel - 1)
128 scp->mouse_xpos = scp->xpixel - 1;
129 if (scp->mouse_ypos > scp->ypixel - 1)
130 scp->mouse_ypos = scp->ypixel - 1;
133 if (scp->mouse_xpos > (scp->xsize + scp->xoff) * scp->font_width - 1)
134 scp->mouse_xpos = (scp->xsize + scp->xoff) * scp->font_width - 1;
135 if (scp->mouse_ypos > (scp->ysize + scp->yoff) * scp->font_height - 1)
136 scp->mouse_ypos = (scp->ysize + scp->yoff) * scp->font_height - 1;
139 if (scp->mouse_xpos != scp->mouse_oldxpos ||
140 scp->mouse_ypos != scp->mouse_oldypos) {
141 scp->status |= MOUSE_MOVED;
143 (scp->mouse_ypos / scp->font_height - scp->yoff) * scp->xsize +
144 scp->mouse_xpos / scp->font_width - scp->xoff;
145 #ifndef SC_NO_CUTPASTE
146 if ((scp->status & MOUSE_VISIBLE) && (scp->status & MOUSE_CUTTING))
152 #ifndef SC_NO_CUTPASTE
155 sc_draw_mouse_image(scr_stat *scp)
160 atomic_add_int(&scp->sc->videoio_in_progress, 1);
161 (*scp->rndr->draw_mouse)(scp, scp->mouse_xpos, scp->mouse_ypos, TRUE);
162 scp->mouse_oldpos = scp->mouse_pos;
163 scp->mouse_oldxpos = scp->mouse_xpos;
164 scp->mouse_oldypos = scp->mouse_ypos;
165 scp->status |= MOUSE_VISIBLE;
166 atomic_add_int(&scp->sc->videoio_in_progress, -1);
170 sc_remove_mouse_image(scr_stat *scp)
178 atomic_add_int(&scp->sc->videoio_in_progress, 1);
179 (*scp->rndr->draw_mouse)(scp,
180 (scp->mouse_oldpos%scp->xsize + scp->xoff) *
182 (scp->mouse_oldpos/scp->xsize + scp->yoff) *
185 size = scp->xsize * scp->ysize;
186 i = scp->mouse_oldpos;
187 mark_for_update(scp, i);
188 mark_for_update(scp, i);
189 if (i + scp->xsize + 1 < size) {
190 mark_for_update(scp, i + scp->xsize + 1);
191 } else if (i + scp->xsize < size) {
192 mark_for_update(scp, i + scp->xsize);
193 } else if (i + 1 < size) {
194 mark_for_update(scp, i + 1);
196 scp->status &= ~MOUSE_VISIBLE;
197 atomic_add_int(&scp->sc->videoio_in_progress, -1);
201 sc_inside_cutmark(scr_stat *scp, int pos)
206 if (scp->mouse_cut_end < 0)
208 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
209 start = scp->mouse_cut_start;
210 end = scp->mouse_cut_end;
212 start = scp->mouse_cut_end;
213 end = scp->mouse_cut_start - 1;
215 return ((start <= pos) && (pos <= end));
219 sc_remove_cutmarking(scr_stat *scp)
222 if (scp->mouse_cut_end >= 0) {
223 mark_for_update(scp, scp->mouse_cut_start);
224 mark_for_update(scp, scp->mouse_cut_end);
226 scp->mouse_cut_start = scp->xsize*scp->ysize;
227 scp->mouse_cut_end = -1;
229 scp->status &= ~MOUSE_CUTTING;
233 sc_remove_all_cutmarkings(sc_softc_t *sc)
238 /* delete cut markings in all vtys */
239 for (i = 0; i < sc->vtys; ++i) {
240 scp = SC_STAT(sc->dev[i]);
243 sc_remove_cutmarking(scp);
248 sc_remove_all_mouse(sc_softc_t *sc)
253 for (i = 0; i < sc->vtys; ++i) {
254 scp = SC_STAT(sc->dev[i]);
257 if (scp->status & MOUSE_VISIBLE) {
258 scp->status &= ~MOUSE_VISIBLE;
264 #define IS_SPACE_CHAR(c) (((c) & 0xff) == ' ')
266 /* skip spaces to right */
268 skip_spc_right(scr_stat *scp, int p)
273 for (i = p % scp->xsize; i < scp->xsize; ++i) {
274 c = sc_vtb_getc(&scp->vtb, p);
275 if (!IS_SPACE_CHAR(c))
282 /* skip spaces to left */
284 skip_spc_left(scr_stat *scp, int p)
289 for (i = p-- % scp->xsize - 1; i >= 0; --i) {
290 c = sc_vtb_getc(&scp->vtb, p);
291 if (!IS_SPACE_CHAR(c))
298 /* copy marked region to the cut buffer */
300 mouse_cut(scr_stat *scp)
311 start = scp->mouse_cut_start;
312 if (scp->mouse_pos >= start) {
314 to = end = scp->mouse_pos;
316 from = end = scp->mouse_pos;
319 for (p = from, i = blank = 0; p <= to; ++p) {
320 cut_buffer[i] = sc_vtb_getc(&scp->vtb, p);
321 /* remember the position of the last non-space char */
322 if (!IS_SPACE_CHAR(cut_buffer[i++]))
323 blank = i; /* the first space after the last non-space */
324 /* trim trailing blank when crossing lines */
325 if ((p % scp->xsize) == (scp->xsize - 1)) {
326 cut_buffer[blank] = '\r';
330 cut_buffer[i] = '\0';
332 /* scan towards the end of the last line */
334 for (i = p % scp->xsize; i < scp->xsize; ++i) {
335 c = sc_vtb_getc(&scp->vtb, p);
336 if (!IS_SPACE_CHAR(c))
340 /* if there is nothing but blank chars, trim them, but mark towards eol */
341 if (i >= scp->xsize) {
346 cut_buffer[blank++] = '\r';
347 cut_buffer[blank] = '\0';
350 /* remove the current marking */
352 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
353 mark_for_update(scp, scp->mouse_cut_start);
354 mark_for_update(scp, scp->mouse_cut_end);
355 } else if (scp->mouse_cut_end >= 0) {
356 mark_for_update(scp, scp->mouse_cut_end);
357 mark_for_update(scp, scp->mouse_cut_start);
360 /* mark the new region */
361 scp->mouse_cut_start = start;
362 scp->mouse_cut_end = end;
363 mark_for_update(scp, from);
364 mark_for_update(scp, to);
368 /* a mouse button is pressed, start cut operation */
370 mouse_cut_start(scr_stat *scp)
375 if (scp->status & MOUSE_VISIBLE) {
376 i = scp->mouse_cut_start;
377 j = scp->mouse_cut_end;
378 sc_remove_all_cutmarkings(scp->sc);
379 if (scp->mouse_pos == i && i == j) {
380 cut_buffer[0] = '\0';
381 } else if (skip_spc_right(scp, scp->mouse_pos) >= scp->xsize) {
382 /* if the pointer is on trailing blank chars, mark towards eol */
383 i = skip_spc_left(scp, scp->mouse_pos) + 1;
385 scp->mouse_cut_start = rounddown(scp->mouse_pos, scp->xsize) + i;
387 (scp->mouse_pos / scp->xsize + 1) * scp->xsize - 1;
389 cut_buffer[0] = '\r';
390 cut_buffer[1] = '\0';
391 scp->status |= MOUSE_CUTTING;
394 scp->mouse_cut_start = scp->mouse_pos;
395 scp->mouse_cut_end = scp->mouse_cut_start;
397 cut_buffer[0] = sc_vtb_getc(&scp->vtb, scp->mouse_cut_start);
398 cut_buffer[1] = '\0';
399 scp->status |= MOUSE_CUTTING;
401 mark_all(scp); /* this is probably overkill XXX */
405 /* end of cut operation */
407 mouse_cut_end(scr_stat *scp)
409 if (scp->status & MOUSE_VISIBLE)
410 scp->status &= ~MOUSE_CUTTING;
413 /* copy a word under the mouse pointer */
415 mouse_cut_word(scr_stat *scp)
426 * Because we don't have locale information in the kernel,
427 * we only distinguish space char and non-space chars. Punctuation
428 * chars, symbols and other regular chars are all treated alike.
430 if (scp->status & MOUSE_VISIBLE) {
431 /* remove the current cut mark */
433 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
434 mark_for_update(scp, scp->mouse_cut_start);
435 mark_for_update(scp, scp->mouse_cut_end);
436 } else if (scp->mouse_cut_end >= 0) {
437 mark_for_update(scp, scp->mouse_cut_end);
438 mark_for_update(scp, scp->mouse_cut_start);
440 scp->mouse_cut_start = scp->xsize*scp->ysize;
441 scp->mouse_cut_end = -1;
444 sol = rounddown(scp->mouse_pos, scp->xsize);
445 eol = sol + scp->xsize;
446 c = sc_vtb_getc(&scp->vtb, scp->mouse_pos);
447 if (IS_SPACE_CHAR(c)) {
449 for (j = scp->mouse_pos; j >= sol; --j) {
450 c = sc_vtb_getc(&scp->vtb, j);
451 if (!IS_SPACE_CHAR(c))
455 for (j = scp->mouse_pos; j < eol; ++j) {
456 c = sc_vtb_getc(&scp->vtb, j);
457 if (!IS_SPACE_CHAR(c))
463 for (j = scp->mouse_pos; j >= sol; --j) {
464 c = sc_vtb_getc(&scp->vtb, j);
465 if (IS_SPACE_CHAR(c))
469 for (j = scp->mouse_pos; j < eol; ++j) {
470 c = sc_vtb_getc(&scp->vtb, j);
471 if (IS_SPACE_CHAR(c))
477 /* copy the found word */
478 for (i = 0, j = start; j <= end; ++j)
479 cut_buffer[i++] = sc_vtb_getc(&scp->vtb, j);
480 cut_buffer[i] = '\0';
481 scp->status |= MOUSE_CUTTING;
483 /* mark the region */
485 scp->mouse_cut_start = start;
486 scp->mouse_cut_end = end;
487 mark_for_update(scp, start);
488 mark_for_update(scp, end);
493 /* copy a line under the mouse pointer */
495 mouse_cut_line(scr_stat *scp)
500 if (scp->status & MOUSE_VISIBLE) {
501 /* remove the current cut mark */
503 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
504 mark_for_update(scp, scp->mouse_cut_start);
505 mark_for_update(scp, scp->mouse_cut_end);
506 } else if (scp->mouse_cut_end >= 0) {
507 mark_for_update(scp, scp->mouse_cut_end);
508 mark_for_update(scp, scp->mouse_cut_start);
511 /* mark the entire line */
512 scp->mouse_cut_start = rounddown(scp->mouse_pos, scp->xsize);
513 scp->mouse_cut_end = scp->mouse_cut_start + scp->xsize - 1;
514 mark_for_update(scp, scp->mouse_cut_start);
515 mark_for_update(scp, scp->mouse_cut_end);
518 /* copy the line into the cut buffer */
519 for (i = 0, j = scp->mouse_cut_start; j <= scp->mouse_cut_end; ++j)
520 cut_buffer[i++] = sc_vtb_getc(&scp->vtb, j);
521 cut_buffer[i++] = '\r';
522 cut_buffer[i] = '\0';
523 scp->status |= MOUSE_CUTTING;
527 /* extend the marked region to the mouse pointer position */
529 mouse_cut_extend(scr_stat *scp)
534 if ((scp->status & MOUSE_VISIBLE) && !(scp->status & MOUSE_CUTTING)
535 && (scp->mouse_cut_end >= 0)) {
536 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
537 start = scp->mouse_cut_start;
538 end = scp->mouse_cut_end;
540 start = scp->mouse_cut_end;
541 end = scp->mouse_cut_start - 1;
544 if (scp->mouse_pos > end) {
545 scp->mouse_cut_start = start;
546 scp->mouse_cut_end = end;
547 } else if (scp->mouse_pos < start) {
548 scp->mouse_cut_start = end + 1;
549 scp->mouse_cut_end = start;
551 if (scp->mouse_pos - start > end + 1 - scp->mouse_pos) {
552 scp->mouse_cut_start = start;
553 scp->mouse_cut_end = end;
555 scp->mouse_cut_start = end + 1;
556 scp->mouse_cut_end = start;
561 scp->status |= MOUSE_CUTTING;
565 /* paste cut buffer contents into the current vty */
567 mouse_paste(scr_stat *scp)
569 if (scp->status & MOUSE_VISIBLE)
570 sc_paste(scp, cut_buffer, strlen(cut_buffer));
573 #endif /* SC_NO_CUTPASTE */
576 sc_mouse_exit1_proc(struct proc *p)
581 KKASSERT(scp != NULL);
583 lwkt_gettoken(&scmouse_tok);
584 KKASSERT(scp->mouse_proc == p);
585 KKASSERT(scp->mouse_pid == p->p_pid);
587 scp->mouse_signal = 0;
588 scp->mouse_proc = NULL;
590 lwkt_reltoken(&scmouse_tok);
593 p->p_flags &= ~P_SCMOUSE;
594 p->p_drv_priv = NULL;
600 * Handle exit1 for processes registered as MOUSE_MODE handlers.
601 * We must remove a process hold, established when MOUSE_MODE
605 sc_mouse_exit1(struct thread *td)
612 if ((p->p_flags & P_SCMOUSE) == 0)
616 sc_mouse_exit1_proc(p);
620 sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag)
627 scp = SC_STAT(tp->t_dev);
631 case CONS_MOUSECTL: /* control mouse arrow */
632 mouse = (mouse_info_t*) data;
633 cur_scp = scp->sc->cur_scp;
635 switch (mouse->operation) {
637 * Setup a process to receive signals on mouse events.
640 lwkt_gettoken(&scmouse_tok);
642 if (!ISSIGVALID(mouse->u.mode.signal)) {
643 /* Setting MOUSE_MODE w/ an invalid signal is used to disarm */
644 if (scp->mouse_proc == curproc) {
645 sc_mouse_exit1_proc(curproc);
646 lwkt_reltoken(&scmouse_tok);
649 lwkt_reltoken(&scmouse_tok);
653 /* Only one mouse process per syscons */
654 if (scp->mouse_proc) {
655 lwkt_reltoken(&scmouse_tok);
659 /* Only one syscons signal source per process */
660 if (curproc->p_flags & P_SCMOUSE) {
661 lwkt_reltoken(&scmouse_tok);
666 * Process is stabilized by a hold, which is removed from
667 * sc_mouse_exit1. scp's mouse_{signal,proc,pid} fields
668 * are synchronized by the MP Lock.
670 scp->mouse_signal = mouse->u.mode.signal;
671 scp->mouse_proc = curproc;
672 scp->mouse_pid = curproc->p_pid;
673 curproc->p_flags |= P_SCMOUSE;
674 KKASSERT(curproc->p_drv_priv == NULL);
675 curproc->p_drv_priv = scp;
678 lwkt_reltoken(&scmouse_tok);
686 if (!(scp->sc->flags & SC_MOUSE_ENABLED)) {
687 scp->sc->flags |= SC_MOUSE_ENABLED;
688 cur_scp->status &= ~MOUSE_HIDDEN;
689 if (!ISGRAPHSC(cur_scp))
701 if (scp->sc->flags & SC_MOUSE_ENABLED) {
702 scp->sc->flags &= ~SC_MOUSE_ENABLED;
703 sc_remove_all_mouse(scp->sc);
714 scp->mouse_xpos = mouse->u.data.x;
715 scp->mouse_ypos = mouse->u.data.y;
722 scp->mouse_xpos += mouse->u.data.x;
723 scp->mouse_ypos += mouse->u.data.y;
729 mouse->u.data.x = scp->mouse_xpos;
730 mouse->u.data.y = scp->mouse_ypos;
732 mouse->u.data.buttons = scp->mouse_buttons;
736 case MOUSE_MOTION_EVENT:
737 /* send out mouse event on /dev/sysmouse */
739 /* this should maybe only be settable from /dev/consolectl SOS */
740 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL)
744 if (mouse->u.data.x != 0 || mouse->u.data.y != 0) {
745 cur_scp->mouse_xpos += mouse->u.data.x;
746 cur_scp->mouse_ypos += mouse->u.data.y;
747 set_mouse_pos(cur_scp);
750 if (mouse->operation == MOUSE_ACTION) {
751 f = cur_scp->mouse_buttons ^ mouse->u.data.buttons;
752 cur_scp->mouse_buttons = mouse->u.data.buttons;
756 if (sysmouse_event(mouse) == 0)
760 * If any buttons are down or the mouse has moved a lot,
761 * stop the screen saver.
763 if (((mouse->operation == MOUSE_ACTION) && mouse->u.data.buttons)
764 || (mouse->u.data.x*mouse->u.data.x
765 + mouse->u.data.y*mouse->u.data.y
766 >= SC_WAKEUP_DELTA*SC_WAKEUP_DELTA)) {
767 sc_touch_scrn_saver();
770 cur_scp->status &= ~MOUSE_HIDDEN;
772 lwkt_gettoken(&scmouse_tok);
773 if (cur_scp->mouse_signal) {
774 KKASSERT(cur_scp->mouse_proc != NULL);
775 ksignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
776 lwkt_reltoken(&scmouse_tok);
779 lwkt_reltoken(&scmouse_tok);
781 if (ISGRAPHSC(cur_scp) || (cut_buffer == NULL))
784 #ifndef SC_NO_CUTPASTE
785 if ((mouse->operation == MOUSE_ACTION) && f) {
786 /* process button presses */
787 if (cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN)
788 mouse_cut_start(cur_scp);
790 mouse_cut_end(cur_scp);
791 if (cur_scp->mouse_buttons & MOUSE_BUTTON2DOWN ||
792 cur_scp->mouse_buttons & MOUSE_BUTTON3DOWN)
793 mouse_paste(cur_scp);
795 #endif /* SC_NO_CUTPASTE */
798 case MOUSE_BUTTON_EVENT:
799 if ((mouse->u.event.id & MOUSE_BUTTONS) == 0)
801 if (mouse->u.event.value < 0)
804 /* this should maybe only be settable from /dev/consolectl SOS */
805 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL)
808 if (mouse->u.event.value > 0)
809 cur_scp->mouse_buttons |= mouse->u.event.id;
811 cur_scp->mouse_buttons &= ~mouse->u.event.id;
813 if (sysmouse_event(mouse) == 0)
816 /* if a button is held down, stop the screen saver */
817 if (mouse->u.event.value > 0)
818 sc_touch_scrn_saver();
820 cur_scp->status &= ~MOUSE_HIDDEN;
822 lwkt_gettoken(&scmouse_tok);
823 if (cur_scp->mouse_signal) {
824 KKASSERT(cur_scp->mouse_proc != NULL);
825 ksignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
826 lwkt_reltoken(&scmouse_tok);
829 lwkt_reltoken(&scmouse_tok);
831 if (ISGRAPHSC(cur_scp) || (cut_buffer == NULL))
834 #ifndef SC_NO_CUTPASTE
835 switch (mouse->u.event.id) {
836 case MOUSE_BUTTON1DOWN:
837 switch (mouse->u.event.value % 4) {
839 mouse_cut_end(cur_scp);
841 case 1: /* single click: start cut operation */
842 mouse_cut_start(cur_scp);
844 case 2: /* double click: cut a word */
845 mouse_cut_word(cur_scp);
846 mouse_cut_end(cur_scp);
848 case 3: /* triple click: cut a line */
849 mouse_cut_line(cur_scp);
850 mouse_cut_end(cur_scp);
854 case SC_MOUSE_PASTEBUTTON:
855 switch (mouse->u.event.value) {
859 mouse_paste(cur_scp);
863 case SC_MOUSE_EXTENDBUTTON:
864 switch (mouse->u.event.value) {
866 if (!(cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN))
867 mouse_cut_end(cur_scp);
870 mouse_cut_extend(cur_scp);
875 #endif /* SC_NO_CUTPASTE */
878 case MOUSE_MOUSECHAR:
879 if (mouse->u.mouse_char < 0) {
880 mouse->u.mouse_char = scp->sc->mouse_char;
882 if (mouse->u.mouse_char >= (unsigned char)-1 - 4)
885 sc_remove_all_mouse(scp->sc);
886 #ifndef SC_NO_FONT_LOADING
887 if (ISTEXTSC(cur_scp) && (cur_scp->font != NULL))
888 sc_load_font(cur_scp, 0, cur_scp->font_height,
890 cur_scp->sc->mouse_char, 4);
892 scp->sc->mouse_char = mouse->u.mouse_char;
908 sc_mouse_init(void *unused)
910 at_exit(sc_mouse_exit1);
914 sc_mouse_uninit(void *unused)
918 SYSINIT(sc_mouse_init, SI_SUB_DRIVERS, SI_ORDER_ANY, sc_mouse_init, NULL);
919 SYSUNINIT(sc_mouse_uninit, SI_SUB_DRIVERS, SI_ORDER_ANY, sc_mouse_uninit, NULL);
921 #endif /* SC_NO_SYSMOUSE */