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.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include "opt_syscons.h"
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <sys/consio.h>
37 #include <sys/limits.h>
39 #include <sys/malloc.h>
40 #include <sys/mouse.h>
41 #include <sys/mutex.h>
43 #include <sys/random.h>
44 #include <sys/signalvar.h>
47 #include <dev/syscons/syscons.h>
49 #ifdef SC_TWOBUTTON_MOUSE
50 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON3DOWN /* right button */
51 #define SC_MOUSE_EXTENDBUTTON MOUSE_BUTTON2DOWN /* not really used */
53 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON2DOWN /* middle button */
54 #define SC_MOUSE_EXTENDBUTTON MOUSE_BUTTON3DOWN /* right button */
55 #endif /* SC_TWOBUTTON_MOUSE */
57 #define SC_WAKEUP_DELTA 20
59 /* for backward compatibility */
60 #define OLD_CONS_MOUSECTL _IOWR('c', 10, old_mouse_info_t)
62 typedef struct old_mouse_data {
68 typedef struct old_mouse_info {
71 struct old_mouse_data data;
72 struct mouse_mode mode;
76 #ifndef SC_NO_SYSMOUSE
79 #ifndef SC_NO_CUTPASTE
80 static int cut_buffer_size;
81 static u_char *cut_buffer;
85 static void set_mouse_pos(scr_stat *scp);
86 #ifndef SC_NO_CUTPASTE
87 static int skip_spc_right(scr_stat *scp, int p);
88 static int skip_spc_left(scr_stat *scp, int p);
89 static void mouse_cut(scr_stat *scp);
90 static void mouse_cut_start(scr_stat *scp);
91 static void mouse_cut_end(scr_stat *scp);
92 static void mouse_cut_word(scr_stat *scp);
93 static void mouse_cut_line(scr_stat *scp);
94 static void mouse_cut_extend(scr_stat *scp);
95 #endif /* SC_NO_CUTPASTE */
97 #ifndef SC_NO_CUTPASTE
98 /* allocate a cut buffer */
100 sc_alloc_cut_buffer(scr_stat *scp, int wait)
104 if ((cut_buffer == NULL)
105 || (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
110 cut_buffer_size = scp->xsize * scp->ysize + 1;
111 p = (u_char *)malloc(cut_buffer_size,
112 M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT);
118 #endif /* SC_NO_CUTPASTE */
122 sc_mouse_move(scr_stat *scp, int x, int y)
127 scp->mouse_xpos = scp->mouse_oldxpos = x;
128 scp->mouse_ypos = scp->mouse_oldypos = y;
129 if (scp->font_size <= 0 || scp->font_width <= 0)
130 scp->mouse_pos = scp->mouse_oldpos = 0;
132 scp->mouse_pos = scp->mouse_oldpos =
133 (y/scp->font_size - scp->yoff)*scp->xsize + x/scp->font_width -
135 scp->status |= MOUSE_MOVED;
139 /* adjust mouse position */
141 set_mouse_pos(scr_stat *scp)
143 if (scp->mouse_xpos < scp->xoff*scp->font_width)
144 scp->mouse_xpos = scp->xoff*scp->font_width;
145 if (scp->mouse_ypos < scp->yoff*scp->font_size)
146 scp->mouse_ypos = scp->yoff*scp->font_size;
147 if (ISGRAPHSC(scp)) {
148 if (scp->mouse_xpos > scp->xpixel-1)
149 scp->mouse_xpos = scp->xpixel-1;
150 if (scp->mouse_ypos > scp->ypixel-1)
151 scp->mouse_ypos = scp->ypixel-1;
154 if (scp->mouse_xpos > (scp->xsize + scp->xoff)*scp->font_width - 1)
155 scp->mouse_xpos = (scp->xsize + scp->xoff)*scp->font_width - 1;
156 if (scp->mouse_ypos > (scp->ysize + scp->yoff)*scp->font_size - 1)
157 scp->mouse_ypos = (scp->ysize + scp->yoff)*scp->font_size - 1;
160 if ((scp->mouse_xpos != scp->mouse_oldxpos || scp->mouse_ypos != scp->mouse_oldypos)
161 && (scp->font_size != 0 && scp->font_width != 0)) {
162 scp->status |= MOUSE_MOVED;
164 (scp->mouse_ypos/scp->font_size - scp->yoff)*scp->xsize
165 + scp->mouse_xpos/scp->font_width - scp->xoff;
166 #ifndef SC_NO_CUTPASTE
167 if ((scp->status & MOUSE_VISIBLE) && (scp->status & MOUSE_CUTTING))
173 #ifndef SC_NO_CUTPASTE
176 sc_draw_mouse_image(scr_stat *scp)
181 SC_VIDEO_LOCK(scp->sc);
182 (*scp->rndr->draw_mouse)(scp, scp->mouse_xpos, scp->mouse_ypos, TRUE);
183 scp->mouse_oldpos = scp->mouse_pos;
184 scp->mouse_oldxpos = scp->mouse_xpos;
185 scp->mouse_oldypos = scp->mouse_ypos;
186 scp->status |= MOUSE_VISIBLE;
187 SC_VIDEO_UNLOCK(scp->sc);
191 sc_remove_mouse_image(scr_stat *scp)
199 SC_VIDEO_LOCK(scp->sc);
200 (*scp->rndr->draw_mouse)(scp,
201 (scp->mouse_oldpos%scp->xsize + scp->xoff)
203 (scp->mouse_oldpos/scp->xsize + scp->yoff)
206 size = scp->xsize*scp->ysize;
207 i = scp->mouse_oldpos;
208 mark_for_update(scp, i);
209 mark_for_update(scp, i);
211 if (i + scp->xsize + 1 < size) {
212 mark_for_update(scp, i + scp->xsize + 1);
213 } else if (i + scp->xsize < size) {
214 mark_for_update(scp, i + scp->xsize);
215 } else if (i + 1 < size) {
216 mark_for_update(scp, i + 1);
219 scp->status &= ~MOUSE_VISIBLE;
220 SC_VIDEO_UNLOCK(scp->sc);
224 sc_inside_cutmark(scr_stat *scp, int pos)
229 if (scp->mouse_cut_end < 0)
231 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
232 start = scp->mouse_cut_start;
233 end = scp->mouse_cut_end;
235 start = scp->mouse_cut_end;
236 end = scp->mouse_cut_start - 1;
238 return ((start <= pos) && (pos <= end));
242 sc_remove_cutmarking(scr_stat *scp)
247 if (scp->mouse_cut_end >= 0) {
248 mark_for_update(scp, scp->mouse_cut_start);
249 mark_for_update(scp, scp->mouse_cut_end);
251 scp->mouse_cut_start = scp->xsize*scp->ysize;
252 scp->mouse_cut_end = -1;
254 scp->status &= ~MOUSE_CUTTING;
258 sc_remove_all_cutmarkings(sc_softc_t *sc)
263 /* delete cut markings in all vtys */
264 for (i = 0; i < sc->vtys; ++i) {
265 scp = SC_STAT(sc->dev[i]);
268 sc_remove_cutmarking(scp);
273 sc_remove_all_mouse(sc_softc_t *sc)
278 for (i = 0; i < sc->vtys; ++i) {
279 scp = SC_STAT(sc->dev[i]);
282 if (scp->status & MOUSE_VISIBLE) {
283 scp->status &= ~MOUSE_VISIBLE;
289 #define IS_SPACE_CHAR(c) (((c) & 0xff) == ' ')
291 #ifdef SC_CUT_SPACES2TABS
292 #define IS_BLANK_CHAR(c) (((c) & 0xff) == ' ' || ((c) & 0xff) == '\t')
294 #define IS_BLANK_CHAR(c) IS_SPACE_CHAR(c)
295 #endif /* SC_CUT_SPACES2TABS */
297 #ifdef SC_CUT_SEPCHARS
298 #define IS_SEP_CHAR(c) (index(SC_CUT_SEPCHARS, (c) & 0xff) != NULL)
300 #define IS_SEP_CHAR(c) IS_SPACE_CHAR(c)
301 #endif /* SC_CUT_SEPCHARS */
303 /* skip spaces to right */
305 skip_spc_right(scr_stat *scp, int p)
310 for (i = p % scp->xsize; i < scp->xsize; ++i) {
311 c = sc_vtb_getc(&scp->vtb, p);
312 if (!IS_SPACE_CHAR(c))
319 /* skip spaces to left */
321 skip_spc_left(scr_stat *scp, int p)
326 for (i = p-- % scp->xsize - 1; i >= 0; --i) {
327 c = sc_vtb_getc(&scp->vtb, p);
328 if (!IS_SPACE_CHAR(c))
336 mouse_do_cut(scr_stat *scp, int from, int to)
344 for (p = from, i = blank = leadspaces = 0; p <= to; ++p) {
345 cut_buffer[i] = sc_vtb_getc(&scp->vtb, p);
346 /* Be prepared that sc_vtb_getc() can return '\0' */
347 if (cut_buffer[i] == '\0')
349 #ifdef SC_CUT_SPACES2TABS
350 if (leadspaces != -1) {
351 if (IS_SPACE_CHAR(cut_buffer[i])) {
353 /* Check that we are at tabstop position */
354 if ((p % scp->xsize) % 8 == 7) {
356 cut_buffer[i] = '\t';
363 #endif /* SC_CUT_SPACES2TABS */
364 /* remember the position of the last non-space char */
365 if (!IS_BLANK_CHAR(cut_buffer[i]))
366 blank = i + 1; /* the first space after the last non-space */
368 /* trim trailing blank when crossing lines */
369 if ((p % scp->xsize) == (scp->xsize - 1)) {
370 cut_buffer[blank++] = '\r';
375 cut_buffer[i] = '\0';
377 /* remove the current marking */
379 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
380 mark_for_update(scp, scp->mouse_cut_start);
381 mark_for_update(scp, scp->mouse_cut_end);
382 } else if (scp->mouse_cut_end >= 0) {
383 mark_for_update(scp, scp->mouse_cut_end);
384 mark_for_update(scp, scp->mouse_cut_start);
387 /* mark the new region */
388 scp->mouse_cut_start = from;
389 scp->mouse_cut_end = to;
390 mark_for_update(scp, from);
391 mark_for_update(scp, to);
395 /* copy marked region to the cut buffer */
397 mouse_cut(scr_stat *scp)
408 start = scp->mouse_cut_start;
409 end = scp->mouse_cut_end;
410 if (scp->mouse_pos >= start) {
412 to = end = scp->mouse_pos;
414 from = end = scp->mouse_pos;
418 for (i = p % scp->xsize; i < scp->xsize; ++i) {
419 c = sc_vtb_getc(&scp->vtb, p);
420 if (!IS_SPACE_CHAR(c))
424 /* if there is nothing but blank chars, trim them, but mark towards eol */
425 if (i == scp->xsize) {
431 mouse_do_cut(scp, from, to);
433 scp->mouse_cut_start = start;
434 scp->mouse_cut_end = end;
438 /* a mouse button is pressed, start cut operation */
440 mouse_cut_start(scr_stat *scp)
445 if (scp->status & MOUSE_VISIBLE) {
446 sc_remove_all_cutmarkings(scp->sc);
447 if ((scp->mouse_pos == scp->mouse_cut_start) &&
448 (scp->mouse_pos == scp->mouse_cut_end)) {
449 cut_buffer[0] = '\0';
451 } else if (skip_spc_right(scp, scp->mouse_pos) >= scp->xsize) {
452 /* if the pointer is on trailing blank chars, mark towards eol */
453 i = skip_spc_left(scp, scp->mouse_pos) + 1;
455 scp->mouse_cut_start =
456 (scp->mouse_pos / scp->xsize) * scp->xsize + i;
458 (scp->mouse_pos / scp->xsize + 1) * scp->xsize - 1;
460 cut_buffer[0] = '\r';
463 scp->mouse_cut_start = scp->mouse_pos;
464 scp->mouse_cut_end = scp->mouse_cut_start;
466 cut_buffer[0] = sc_vtb_getc(&scp->vtb, scp->mouse_cut_start);
468 cut_buffer[1] = '\0';
469 scp->status |= MOUSE_CUTTING;
470 mark_all(scp); /* this is probably overkill XXX */
474 /* end of cut operation */
476 mouse_cut_end(scr_stat *scp)
478 if (scp->status & MOUSE_VISIBLE)
479 scp->status &= ~MOUSE_CUTTING;
482 /* copy a word under the mouse pointer */
484 mouse_cut_word(scr_stat *scp)
495 * Because we don't have locale information in the kernel,
496 * we only distinguish space char and non-space chars. Punctuation
497 * chars, symbols and other regular chars are all treated alike
498 * unless user specified SC_CUT_SEPCHARS in his kernel config file.
500 if (scp->status & MOUSE_VISIBLE) {
501 sol = (scp->mouse_pos / scp->xsize) * scp->xsize;
502 eol = sol + scp->xsize;
503 c = sc_vtb_getc(&scp->vtb, scp->mouse_pos);
504 if (IS_SEP_CHAR(c)) {
506 for (j = scp->mouse_pos; j >= sol; --j) {
507 c = sc_vtb_getc(&scp->vtb, j);
512 for (j = scp->mouse_pos; j < eol; ++j) {
513 c = sc_vtb_getc(&scp->vtb, j);
520 for (j = scp->mouse_pos; j >= sol; --j) {
521 c = sc_vtb_getc(&scp->vtb, j);
526 for (j = scp->mouse_pos; j < eol; ++j) {
527 c = sc_vtb_getc(&scp->vtb, j);
534 /* copy the found word */
535 mouse_do_cut(scp, start, end);
536 len = strlen(cut_buffer);
537 if (cut_buffer[len - 1] == '\r')
538 cut_buffer[len - 1] = '\0';
542 /* copy a line under the mouse pointer */
544 mouse_cut_line(scr_stat *scp)
549 if (scp->status & MOUSE_VISIBLE) {
550 from = (scp->mouse_pos / scp->xsize) * scp->xsize;
551 mouse_do_cut(scp, from, from + scp->xsize - 1);
552 len = strlen(cut_buffer);
553 if (cut_buffer[len - 1] == '\r')
554 cut_buffer[len - 1] = '\0';
555 scp->status |= MOUSE_CUTTING;
559 /* extend the marked region to the mouse pointer position */
561 mouse_cut_extend(scr_stat *scp)
567 if ((scp->status & MOUSE_VISIBLE) && !(scp->status & MOUSE_CUTTING)
568 && (scp->mouse_cut_end >= 0)) {
569 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
570 start = scp->mouse_cut_start;
571 end = scp->mouse_cut_end;
573 start = scp->mouse_cut_end;
574 end = scp->mouse_cut_start - 1;
577 if (scp->mouse_pos > end) {
578 scp->mouse_cut_start = start;
579 scp->mouse_cut_end = end;
580 } else if (scp->mouse_pos < start) {
581 scp->mouse_cut_start = end + 1;
582 scp->mouse_cut_end = start;
584 if (scp->mouse_pos - start > end + 1 - scp->mouse_pos) {
585 scp->mouse_cut_start = start;
586 scp->mouse_cut_end = end;
588 scp->mouse_cut_start = end + 1;
589 scp->mouse_cut_end = start;
594 scp->status |= MOUSE_CUTTING;
598 /* paste cut buffer contents into the current vty */
600 sc_mouse_paste(scr_stat *scp)
602 sc_paste(scp, cut_buffer, strlen(cut_buffer));
605 #endif /* SC_NO_CUTPASTE */
608 sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
619 scp = SC_STAT(tp->t_dev);
623 case CONS_MOUSECTL: /* control mouse arrow */
624 case OLD_CONS_MOUSECTL:
626 mouse = (mouse_info_t*)data;
628 random_harvest(mouse, sizeof(mouse_info_t), 2, 0, RANDOM_MOUSE);
630 if (cmd == OLD_CONS_MOUSECTL) {
631 static u_char swapb[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
632 old_mouse_info_t *old_mouse = (old_mouse_info_t *)data;
635 mouse->operation = old_mouse->operation;
636 switch (mouse->operation) {
638 mouse->u.mode = old_mouse->u.mode;
646 mouse->u.data.x = old_mouse->u.data.x;
647 mouse->u.data.y = old_mouse->u.data.y;
649 mouse->u.data.buttons = swapb[old_mouse->u.data.buttons & 0x7];
652 old_mouse->u.data.x = scp->mouse_xpos;
653 old_mouse->u.data.y = scp->mouse_ypos;
654 old_mouse->u.data.buttons = swapb[scp->mouse_buttons & 0x7];
661 cur_scp = scp->sc->cur_scp;
663 switch (mouse->operation) {
665 if (ISSIGVALID(mouse->u.mode.signal)) {
666 scp->mouse_signal = mouse->u.mode.signal;
667 scp->mouse_proc = td->td_proc;
668 scp->mouse_pid = td->td_proc->p_pid;
671 scp->mouse_signal = 0;
672 scp->mouse_proc = NULL;
679 if (!(scp->sc->flags & SC_MOUSE_ENABLED)) {
680 scp->sc->flags |= SC_MOUSE_ENABLED;
681 cur_scp->status &= ~MOUSE_HIDDEN;
682 if (!ISGRAPHSC(cur_scp))
691 if (scp->sc->flags & SC_MOUSE_ENABLED) {
692 scp->sc->flags &= ~SC_MOUSE_ENABLED;
693 sc_remove_all_mouse(scp->sc);
701 scp->mouse_xpos = mouse->u.data.x;
702 scp->mouse_ypos = mouse->u.data.y;
709 scp->mouse_xpos += mouse->u.data.x;
710 scp->mouse_ypos += mouse->u.data.y;
716 mouse->u.data.x = scp->mouse_xpos;
717 mouse->u.data.y = scp->mouse_ypos;
719 mouse->u.data.buttons = scp->mouse_buttons;
723 case MOUSE_MOTION_EVENT:
724 /* send out mouse event on /dev/sysmouse */
726 /* this should maybe only be settable from /dev/consolectl SOS */
727 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL)
731 if (mouse->u.data.x != 0 || mouse->u.data.y != 0) {
732 cur_scp->mouse_xpos += mouse->u.data.x;
733 cur_scp->mouse_ypos += mouse->u.data.y;
734 set_mouse_pos(cur_scp);
737 if (mouse->operation == MOUSE_ACTION) {
738 f = cur_scp->mouse_buttons ^ mouse->u.data.buttons;
739 cur_scp->mouse_buttons = mouse->u.data.buttons;
743 if (sysmouse_event(mouse) == 0)
747 * If any buttons are down or the mouse has moved a lot,
748 * stop the screen saver.
750 if (((mouse->operation == MOUSE_ACTION) && mouse->u.data.buttons)
751 || (mouse->u.data.x*mouse->u.data.x
752 + mouse->u.data.y*mouse->u.data.y
753 >= SC_WAKEUP_DELTA*SC_WAKEUP_DELTA)) {
754 sc_touch_scrn_saver();
757 cur_scp->status &= ~MOUSE_HIDDEN;
759 if (cur_scp->mouse_signal && cur_scp->mouse_proc) {
760 /* has controlling process died? */
761 if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))) {
762 cur_scp->mouse_signal = 0;
763 cur_scp->mouse_proc = NULL;
764 cur_scp->mouse_pid = 0;
768 psignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
769 PROC_UNLOCK(cur_scp->mouse_proc);
774 #ifndef SC_NO_CUTPASTE
775 if (ISGRAPHSC(cur_scp) || (cut_buffer == NULL))
778 if ((mouse->operation == MOUSE_ACTION) && f) {
779 /* process button presses */
780 if (cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN)
781 mouse_cut_start(cur_scp);
783 mouse_cut_end(cur_scp);
784 if (cur_scp->mouse_buttons & MOUSE_BUTTON2DOWN ||
785 cur_scp->mouse_buttons & MOUSE_BUTTON3DOWN)
786 sc_mouse_paste(cur_scp);
788 #endif /* SC_NO_CUTPASTE */
791 case MOUSE_BUTTON_EVENT:
792 if ((mouse->u.event.id & MOUSE_BUTTONS) == 0)
794 if (mouse->u.event.value < 0)
797 /* this should maybe only be settable from /dev/consolectl SOS */
798 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL)
801 if (mouse->u.event.value > 0)
802 cur_scp->mouse_buttons |= mouse->u.event.id;
804 cur_scp->mouse_buttons &= ~mouse->u.event.id;
806 if (sysmouse_event(mouse) == 0)
809 /* if a button is held down, stop the screen saver */
810 if (mouse->u.event.value > 0)
811 sc_touch_scrn_saver();
813 cur_scp->status &= ~MOUSE_HIDDEN;
815 if (cur_scp->mouse_signal && cur_scp->mouse_proc) {
816 if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))){
817 cur_scp->mouse_signal = 0;
818 cur_scp->mouse_proc = NULL;
819 cur_scp->mouse_pid = 0;
823 psignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
824 PROC_UNLOCK(cur_scp->mouse_proc);
829 #ifndef SC_NO_CUTPASTE
830 if (ISGRAPHSC(cur_scp) || (cut_buffer == NULL))
833 switch (mouse->u.event.id) {
834 case MOUSE_BUTTON1DOWN:
835 switch (mouse->u.event.value % 4) {
837 mouse_cut_end(cur_scp);
839 case 1: /* single click: start cut operation */
840 mouse_cut_start(cur_scp);
842 case 2: /* double click: cut a word */
843 mouse_cut_word(cur_scp);
844 mouse_cut_end(cur_scp);
846 case 3: /* triple click: cut a line */
847 mouse_cut_line(cur_scp);
848 mouse_cut_end(cur_scp);
852 case SC_MOUSE_PASTEBUTTON:
853 switch (mouse->u.event.value) {
857 sc_mouse_paste(cur_scp);
861 case SC_MOUSE_EXTENDBUTTON:
862 switch (mouse->u.event.value) {
864 if (!(cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN))
865 mouse_cut_end(cur_scp);
868 mouse_cut_extend(cur_scp);
873 #endif /* SC_NO_CUTPASTE */
876 case MOUSE_MOUSECHAR:
877 if (mouse->u.mouse_char < 0) {
878 mouse->u.mouse_char = scp->sc->mouse_char;
880 if (mouse->u.mouse_char > UCHAR_MAX - 3)
883 sc_remove_all_mouse(scp->sc);
884 #ifndef SC_NO_FONT_LOADING
885 if (ISTEXTSC(cur_scp) && (cur_scp->font != NULL))
886 sc_load_font(cur_scp, 0, cur_scp->font_size,
888 cur_scp->font + cur_scp->font_size
889 * cur_scp->sc->mouse_char,
890 cur_scp->sc->mouse_char, 4);
892 scp->sc->mouse_char = mouse->u.mouse_char;
907 #endif /* SC_NO_SYSMOUSE */