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.
29 #include "opt_syscons.h"
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <sys/consio.h>
38 #include <sys/malloc.h>
39 #include <sys/mouse.h>
40 #include <sys/mutex.h>
42 #include <sys/random.h>
43 #include <sys/signalvar.h>
46 #include <dev/syscons/syscons.h>
48 #ifdef SC_TWOBUTTON_MOUSE
49 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON3DOWN /* right button */
50 #define SC_MOUSE_EXTENDBUTTON MOUSE_BUTTON2DOWN /* not really used */
52 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON2DOWN /* middle button */
53 #define SC_MOUSE_EXTENDBUTTON MOUSE_BUTTON3DOWN /* right button */
54 #endif /* SC_TWOBUTTON_MOUSE */
56 #define SC_WAKEUP_DELTA 20
58 /* for backward compatibility */
59 #define OLD_CONS_MOUSECTL _IOWR('c', 10, old_mouse_info_t)
61 typedef struct old_mouse_data {
67 typedef struct old_mouse_info {
70 struct old_mouse_data data;
71 struct mouse_mode mode;
75 #ifndef SC_NO_SYSMOUSE
78 static int cut_buffer_size;
79 static u_char *cut_buffer;
82 static void set_mouse_pos(scr_stat *scp);
83 #ifndef SC_NO_CUTPASTE
84 static int skip_spc_right(scr_stat *scp, int p);
85 static int skip_spc_left(scr_stat *scp, int p);
86 static void mouse_cut(scr_stat *scp);
87 static void mouse_cut_start(scr_stat *scp);
88 static void mouse_cut_end(scr_stat *scp);
89 static void mouse_cut_word(scr_stat *scp);
90 static void mouse_cut_line(scr_stat *scp);
91 static void mouse_cut_extend(scr_stat *scp);
92 #endif /* SC_NO_CUTPASTE */
94 #ifndef SC_NO_CUTPASTE
95 /* allocate a cut buffer */
97 sc_alloc_cut_buffer(scr_stat *scp, int wait)
101 if ((cut_buffer == NULL)
102 || (cut_buffer_size < scp->xsize * scp->ysize + 1)) {
107 cut_buffer_size = scp->xsize * scp->ysize + 1;
108 p = (u_char *)malloc(cut_buffer_size,
109 M_DEVBUF, (wait) ? M_WAITOK : M_NOWAIT);
115 #endif /* SC_NO_CUTPASTE */
119 sc_mouse_move(scr_stat *scp, int x, int y)
124 scp->mouse_xpos = scp->mouse_oldxpos = x;
125 scp->mouse_ypos = scp->mouse_oldypos = y;
126 if (scp->font_size <= 0)
127 scp->mouse_pos = scp->mouse_oldpos = 0;
129 scp->mouse_pos = scp->mouse_oldpos =
130 (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
131 scp->status |= MOUSE_MOVED;
135 /* adjust mouse position */
137 set_mouse_pos(scr_stat *scp)
139 if (scp->mouse_xpos < scp->xoff*8)
140 scp->mouse_xpos = scp->xoff*8;
141 if (scp->mouse_ypos < scp->yoff*scp->font_size)
142 scp->mouse_ypos = scp->yoff*scp->font_size;
143 if (ISGRAPHSC(scp)) {
144 if (scp->mouse_xpos > scp->xpixel-1)
145 scp->mouse_xpos = scp->xpixel-1;
146 if (scp->mouse_ypos > scp->ypixel-1)
147 scp->mouse_ypos = scp->ypixel-1;
150 if (scp->mouse_xpos > (scp->xsize + scp->xoff)*8 - 1)
151 scp->mouse_xpos = (scp->xsize + scp->xoff)*8 - 1;
152 if (scp->mouse_ypos > (scp->ysize + scp->yoff)*scp->font_size - 1)
153 scp->mouse_ypos = (scp->ysize + scp->yoff)*scp->font_size - 1;
156 if (scp->mouse_xpos != scp->mouse_oldxpos || scp->mouse_ypos != scp->mouse_oldypos) {
157 scp->status |= MOUSE_MOVED;
159 (scp->mouse_ypos/scp->font_size - scp->yoff)*scp->xsize
160 + scp->mouse_xpos/8 - scp->xoff;
161 #ifndef SC_NO_CUTPASTE
162 if ((scp->status & MOUSE_VISIBLE) && (scp->status & MOUSE_CUTTING))
168 #ifndef SC_NO_CUTPASTE
171 sc_draw_mouse_image(scr_stat *scp)
176 ++scp->sc->videoio_in_progress;
177 (*scp->rndr->draw_mouse)(scp, scp->mouse_xpos, scp->mouse_ypos, TRUE);
178 scp->mouse_oldpos = scp->mouse_pos;
179 scp->mouse_oldxpos = scp->mouse_xpos;
180 scp->mouse_oldypos = scp->mouse_ypos;
181 scp->status |= MOUSE_VISIBLE;
182 --scp->sc->videoio_in_progress;
186 sc_remove_mouse_image(scr_stat *scp)
194 ++scp->sc->videoio_in_progress;
195 (*scp->rndr->draw_mouse)(scp,
196 (scp->mouse_oldpos%scp->xsize + scp->xoff)*8,
197 (scp->mouse_oldpos/scp->xsize + scp->yoff)
200 size = scp->xsize*scp->ysize;
201 i = scp->mouse_oldpos;
202 mark_for_update(scp, i);
203 mark_for_update(scp, i);
205 if (i + scp->xsize + 1 < size) {
206 mark_for_update(scp, i + scp->xsize + 1);
207 } else if (i + scp->xsize < size) {
208 mark_for_update(scp, i + scp->xsize);
209 } else if (i + 1 < size) {
210 mark_for_update(scp, i + 1);
213 scp->status &= ~MOUSE_VISIBLE;
214 --scp->sc->videoio_in_progress;
218 sc_inside_cutmark(scr_stat *scp, int pos)
223 if (scp->mouse_cut_end < 0)
225 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
226 start = scp->mouse_cut_start;
227 end = scp->mouse_cut_end;
229 start = scp->mouse_cut_end;
230 end = scp->mouse_cut_start - 1;
232 return ((start <= pos) && (pos <= end));
236 sc_remove_cutmarking(scr_stat *scp)
241 if (scp->mouse_cut_end >= 0) {
242 mark_for_update(scp, scp->mouse_cut_start);
243 mark_for_update(scp, scp->mouse_cut_end);
245 scp->mouse_cut_start = scp->xsize*scp->ysize;
246 scp->mouse_cut_end = -1;
248 scp->status &= ~MOUSE_CUTTING;
252 sc_remove_all_cutmarkings(sc_softc_t *sc)
257 /* delete cut markings in all vtys */
258 for (i = 0; i < sc->vtys; ++i) {
259 scp = SC_STAT(sc->dev[i]);
262 sc_remove_cutmarking(scp);
267 sc_remove_all_mouse(sc_softc_t *sc)
272 for (i = 0; i < sc->vtys; ++i) {
273 scp = SC_STAT(sc->dev[i]);
276 if (scp->status & MOUSE_VISIBLE) {
277 scp->status &= ~MOUSE_VISIBLE;
283 #define IS_SPACE_CHAR(c) (((c) & 0xff) == ' ')
285 #ifdef SC_CUT_SPACES2TABS
286 #define IS_BLANK_CHAR(c) (((c) & 0xff) == ' ' || ((c) & 0xff) == '\t')
288 #define IS_BLANK_CHAR(c) IS_SPACE_CHAR(c)
289 #endif /* SC_CUT_SPACES2TABS */
291 #ifdef SC_CUT_SEPCHARS
292 #define IS_SEP_CHAR(c) (index(SC_CUT_SEPCHARS, (c) & 0xff) != NULL)
294 #define IS_SEP_CHAR(c) IS_SPACE_CHAR(c)
295 #endif /* SC_CUT_SEPCHARS */
297 /* skip spaces to right */
299 skip_spc_right(scr_stat *scp, int p)
304 for (i = p % scp->xsize; i < scp->xsize; ++i) {
305 c = sc_vtb_getc(&scp->vtb, p);
306 if (!IS_SPACE_CHAR(c))
313 /* skip spaces to left */
315 skip_spc_left(scr_stat *scp, int p)
320 for (i = p-- % scp->xsize - 1; i >= 0; --i) {
321 c = sc_vtb_getc(&scp->vtb, p);
322 if (!IS_SPACE_CHAR(c))
330 mouse_do_cut(scr_stat *scp, int from, int to)
338 for (p = from, i = blank = leadspaces = 0; p <= to; ++p) {
339 cut_buffer[i] = sc_vtb_getc(&scp->vtb, p);
340 /* Be prepared that sc_vtb_getc() can return '\0' */
341 if (cut_buffer[i] == '\0')
343 #ifdef SC_CUT_SPACES2TABS
344 if (leadspaces != -1) {
345 if (IS_SPACE_CHAR(cut_buffer[i])) {
347 /* Check that we are at tabstop position */
348 if ((p % scp->xsize) % 8 == 7) {
350 cut_buffer[i] = '\t';
357 #endif /* SC_CUT_SPACES2TABS */
358 /* remember the position of the last non-space char */
359 if (!IS_BLANK_CHAR(cut_buffer[i]))
360 blank = i + 1; /* the first space after the last non-space */
362 /* trim trailing blank when crossing lines */
363 if ((p % scp->xsize) == (scp->xsize - 1)) {
364 cut_buffer[blank++] = '\r';
369 cut_buffer[i] = '\0';
371 /* remove the current marking */
373 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
374 mark_for_update(scp, scp->mouse_cut_start);
375 mark_for_update(scp, scp->mouse_cut_end);
376 } else if (scp->mouse_cut_end >= 0) {
377 mark_for_update(scp, scp->mouse_cut_end);
378 mark_for_update(scp, scp->mouse_cut_start);
381 /* mark the new region */
382 scp->mouse_cut_start = from;
383 scp->mouse_cut_end = to;
384 mark_for_update(scp, from);
385 mark_for_update(scp, to);
389 /* copy marked region to the cut buffer */
391 mouse_cut(scr_stat *scp)
402 start = scp->mouse_cut_start;
403 end = scp->mouse_cut_end;
404 if (scp->mouse_pos >= start) {
406 to = end = scp->mouse_pos;
408 from = end = scp->mouse_pos;
412 for (i = p % scp->xsize; i < scp->xsize; ++i) {
413 c = sc_vtb_getc(&scp->vtb, p);
414 if (!IS_SPACE_CHAR(c))
418 /* if there is nothing but blank chars, trim them, but mark towards eol */
419 if (i == scp->xsize) {
425 mouse_do_cut(scp, from, to);
427 scp->mouse_cut_start = start;
428 scp->mouse_cut_end = end;
432 /* a mouse button is pressed, start cut operation */
434 mouse_cut_start(scr_stat *scp)
439 if (scp->status & MOUSE_VISIBLE) {
440 sc_remove_all_cutmarkings(scp->sc);
441 if (scp->mouse_pos == scp->mouse_cut_start == scp->mouse_cut_end) {
442 cut_buffer[0] = '\0';
444 } else if (skip_spc_right(scp, scp->mouse_pos) >= scp->xsize) {
445 /* if the pointer is on trailing blank chars, mark towards eol */
446 i = skip_spc_left(scp, scp->mouse_pos) + 1;
448 scp->mouse_cut_start =
449 (scp->mouse_pos / scp->xsize) * scp->xsize + i;
451 (scp->mouse_pos / scp->xsize + 1) * scp->xsize - 1;
453 cut_buffer[0] = '\r';
456 scp->mouse_cut_start = scp->mouse_pos;
457 scp->mouse_cut_end = scp->mouse_cut_start;
459 cut_buffer[0] = sc_vtb_getc(&scp->vtb, scp->mouse_cut_start);
461 cut_buffer[1] = '\0';
462 scp->status |= MOUSE_CUTTING;
463 mark_all(scp); /* this is probably overkill XXX */
467 /* end of cut operation */
469 mouse_cut_end(scr_stat *scp)
471 if (scp->status & MOUSE_VISIBLE)
472 scp->status &= ~MOUSE_CUTTING;
475 /* copy a word under the mouse pointer */
477 mouse_cut_word(scr_stat *scp)
488 * Because we don't have locale information in the kernel,
489 * we only distinguish space char and non-space chars. Punctuation
490 * chars, symbols and other regular chars are all treated alike
491 * unless user specified SC_CUT_SEPCHARS in his kernel config file.
493 if (scp->status & MOUSE_VISIBLE) {
494 sol = (scp->mouse_pos / scp->xsize) * scp->xsize;
495 eol = sol + scp->xsize;
496 c = sc_vtb_getc(&scp->vtb, scp->mouse_pos);
497 if (IS_SEP_CHAR(c)) {
499 for (j = scp->mouse_pos; j >= sol; --j) {
500 c = sc_vtb_getc(&scp->vtb, j);
505 for (j = scp->mouse_pos; j < eol; ++j) {
506 c = sc_vtb_getc(&scp->vtb, j);
513 for (j = scp->mouse_pos; j >= sol; --j) {
514 c = sc_vtb_getc(&scp->vtb, j);
519 for (j = scp->mouse_pos; j < eol; ++j) {
520 c = sc_vtb_getc(&scp->vtb, j);
527 /* copy the found word */
528 mouse_do_cut(scp, start, end);
529 len = strlen(cut_buffer);
530 if (cut_buffer[len - 1] == '\r')
531 cut_buffer[len - 1] = '\0';
535 /* copy a line under the mouse pointer */
537 mouse_cut_line(scr_stat *scp)
542 if (scp->status & MOUSE_VISIBLE) {
543 from = (scp->mouse_pos / scp->xsize) * scp->xsize;
544 mouse_do_cut(scp, from, from + scp->xsize - 1);
545 len = strlen(cut_buffer);
546 if (cut_buffer[len - 1] == '\r')
547 cut_buffer[len - 1] = '\0';
548 scp->status |= MOUSE_CUTTING;
552 /* extend the marked region to the mouse pointer position */
554 mouse_cut_extend(scr_stat *scp)
560 if ((scp->status & MOUSE_VISIBLE) && !(scp->status & MOUSE_CUTTING)
561 && (scp->mouse_cut_end >= 0)) {
562 if (scp->mouse_cut_start <= scp->mouse_cut_end) {
563 start = scp->mouse_cut_start;
564 end = scp->mouse_cut_end;
566 start = scp->mouse_cut_end;
567 end = scp->mouse_cut_start - 1;
570 if (scp->mouse_pos > end) {
571 scp->mouse_cut_start = start;
572 scp->mouse_cut_end = end;
573 } else if (scp->mouse_pos < start) {
574 scp->mouse_cut_start = end + 1;
575 scp->mouse_cut_end = start;
577 if (scp->mouse_pos - start > end + 1 - scp->mouse_pos) {
578 scp->mouse_cut_start = start;
579 scp->mouse_cut_end = end;
581 scp->mouse_cut_start = end + 1;
582 scp->mouse_cut_end = start;
587 scp->status |= MOUSE_CUTTING;
591 /* paste cut buffer contents into the current vty */
593 sc_mouse_paste(scr_stat *scp)
595 sc_paste(scp, cut_buffer, strlen(cut_buffer));
598 #endif /* SC_NO_CUTPASTE */
601 sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
612 scp = SC_STAT(tp->t_dev);
616 case CONS_MOUSECTL: /* control mouse arrow */
617 case OLD_CONS_MOUSECTL:
619 mouse = (mouse_info_t*)data;
621 random_harvest(mouse, sizeof(mouse_info_t), 2, 0, RANDOM_MOUSE);
623 if (cmd == OLD_CONS_MOUSECTL) {
624 static u_char swapb[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
625 old_mouse_info_t *old_mouse = (old_mouse_info_t *)data;
628 mouse->operation = old_mouse->operation;
629 switch (mouse->operation) {
631 mouse->u.mode = old_mouse->u.mode;
639 mouse->u.data.x = old_mouse->u.data.x;
640 mouse->u.data.y = old_mouse->u.data.y;
642 mouse->u.data.buttons = swapb[old_mouse->u.data.buttons & 0x7];
645 old_mouse->u.data.x = scp->mouse_xpos;
646 old_mouse->u.data.y = scp->mouse_ypos;
647 old_mouse->u.data.buttons = swapb[scp->mouse_buttons & 0x7];
654 cur_scp = scp->sc->cur_scp;
656 switch (mouse->operation) {
658 if (ISSIGVALID(mouse->u.mode.signal)) {
659 scp->mouse_signal = mouse->u.mode.signal;
660 scp->mouse_proc = td->td_proc;
661 scp->mouse_pid = td->td_proc->p_pid;
664 scp->mouse_signal = 0;
665 scp->mouse_proc = NULL;
672 if (!(scp->sc->flags & SC_MOUSE_ENABLED)) {
673 scp->sc->flags |= SC_MOUSE_ENABLED;
674 cur_scp->status &= ~MOUSE_HIDDEN;
675 if (!ISGRAPHSC(cur_scp))
687 if (scp->sc->flags & SC_MOUSE_ENABLED) {
688 scp->sc->flags &= ~SC_MOUSE_ENABLED;
689 sc_remove_all_mouse(scp->sc);
700 scp->mouse_xpos = mouse->u.data.x;
701 scp->mouse_ypos = mouse->u.data.y;
708 scp->mouse_xpos += mouse->u.data.x;
709 scp->mouse_ypos += mouse->u.data.y;
715 mouse->u.data.x = scp->mouse_xpos;
716 mouse->u.data.y = scp->mouse_ypos;
718 mouse->u.data.buttons = scp->mouse_buttons;
722 case MOUSE_MOTION_EVENT:
723 /* send out mouse event on /dev/sysmouse */
725 /* this should maybe only be settable from /dev/consolectl SOS */
726 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL)
730 if (mouse->u.data.x != 0 || mouse->u.data.y != 0) {
731 cur_scp->mouse_xpos += mouse->u.data.x;
732 cur_scp->mouse_ypos += mouse->u.data.y;
733 set_mouse_pos(cur_scp);
736 if (mouse->operation == MOUSE_ACTION) {
737 f = cur_scp->mouse_buttons ^ mouse->u.data.buttons;
738 cur_scp->mouse_buttons = mouse->u.data.buttons;
742 if (sysmouse_event(mouse) == 0)
746 * If any buttons are down or the mouse has moved a lot,
747 * stop the screen saver.
749 if (((mouse->operation == MOUSE_ACTION) && mouse->u.data.buttons)
750 || (mouse->u.data.x*mouse->u.data.x
751 + mouse->u.data.y*mouse->u.data.y
752 >= SC_WAKEUP_DELTA*SC_WAKEUP_DELTA)) {
753 sc_touch_scrn_saver();
756 cur_scp->status &= ~MOUSE_HIDDEN;
758 if (cur_scp->mouse_signal && cur_scp->mouse_proc) {
759 /* has controlling process died? */
760 if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))) {
761 cur_scp->mouse_signal = 0;
762 cur_scp->mouse_proc = NULL;
763 cur_scp->mouse_pid = 0;
767 psignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
768 PROC_UNLOCK(cur_scp->mouse_proc);
773 if (ISGRAPHSC(cur_scp) || (cut_buffer == NULL))
776 #ifndef SC_NO_CUTPASTE
777 if ((mouse->operation == MOUSE_ACTION) && f) {
778 /* process button presses */
779 if (cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN)
780 mouse_cut_start(cur_scp);
782 mouse_cut_end(cur_scp);
783 if (cur_scp->mouse_buttons & MOUSE_BUTTON2DOWN ||
784 cur_scp->mouse_buttons & MOUSE_BUTTON3DOWN)
785 sc_mouse_paste(cur_scp);
787 #endif /* SC_NO_CUTPASTE */
790 case MOUSE_BUTTON_EVENT:
791 if ((mouse->u.event.id & MOUSE_BUTTONS) == 0)
793 if (mouse->u.event.value < 0)
796 /* this should maybe only be settable from /dev/consolectl SOS */
797 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL)
800 if (mouse->u.event.value > 0)
801 cur_scp->mouse_buttons |= mouse->u.event.id;
803 cur_scp->mouse_buttons &= ~mouse->u.event.id;
805 if (sysmouse_event(mouse) == 0)
808 /* if a button is held down, stop the screen saver */
809 if (mouse->u.event.value > 0)
810 sc_touch_scrn_saver();
812 cur_scp->status &= ~MOUSE_HIDDEN;
814 if (cur_scp->mouse_signal && cur_scp->mouse_proc) {
815 if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))){
816 cur_scp->mouse_signal = 0;
817 cur_scp->mouse_proc = NULL;
818 cur_scp->mouse_pid = 0;
822 psignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
823 PROC_UNLOCK(cur_scp->mouse_proc);
828 if (ISGRAPHSC(cur_scp) || (cut_buffer == NULL))
831 #ifndef SC_NO_CUTPASTE
832 switch (mouse->u.event.id) {
833 case MOUSE_BUTTON1DOWN:
834 switch (mouse->u.event.value % 4) {
836 mouse_cut_end(cur_scp);
838 case 1: /* single click: start cut operation */
839 mouse_cut_start(cur_scp);
841 case 2: /* double click: cut a word */
842 mouse_cut_word(cur_scp);
843 mouse_cut_end(cur_scp);
845 case 3: /* triple click: cut a line */
846 mouse_cut_line(cur_scp);
847 mouse_cut_end(cur_scp);
851 case SC_MOUSE_PASTEBUTTON:
852 switch (mouse->u.event.value) {
856 sc_mouse_paste(cur_scp);
860 case SC_MOUSE_EXTENDBUTTON:
861 switch (mouse->u.event.value) {
863 if (!(cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN))
864 mouse_cut_end(cur_scp);
867 mouse_cut_extend(cur_scp);
872 #endif /* SC_NO_CUTPASTE */
875 case MOUSE_MOUSECHAR:
876 if (mouse->u.mouse_char < 0) {
877 mouse->u.mouse_char = scp->sc->mouse_char;
879 if (mouse->u.mouse_char > UCHAR_MAX - 3)
882 sc_remove_all_mouse(scp->sc);
883 #ifndef SC_NO_FONT_LOADING
884 if (ISTEXTSC(cur_scp) && (cur_scp->font != NULL))
885 sc_load_font(cur_scp, 0, cur_scp->font_size,
886 cur_scp->font + cur_scp->font_size
887 * cur_scp->sc->mouse_char,
888 cur_scp->sc->mouse_char, 4);
890 scp->sc->mouse_char = mouse->u.mouse_char;
905 #endif /* SC_NO_SYSMOUSE */