Lines Matching +full:middle +full:- +full:button

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
50 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON3DOWN /* right button */
53 #define SC_MOUSE_PASTEBUTTON MOUSE_BUTTON2DOWN /* middle button */
54 #define SC_MOUSE_EXTENDBUTTON MOUSE_BUTTON3DOWN /* right button */
105 || (cut_buffer_size < scp->xsize * scp->ysize + 1)) { in sc_alloc_cut_buffer()
110 cut_buffer_size = scp->xsize * scp->ysize + 1; in sc_alloc_cut_buffer()
121 sc_mouse_input_button(scr_stat *scp, int button) in sc_mouse_input_button() argument
125 mouseb[3] = ' ' + button; in sc_mouse_input_button()
126 mouseb[4] = '!' + scp->mouse_pos % scp->xsize; in sc_mouse_input_button()
127 mouseb[5] = '!' + scp->mouse_pos / scp->xsize; in sc_mouse_input_button()
135 switch (mouse->operation) { in sc_mouse_input()
137 if (mouse->u.event.value > 0) { in sc_mouse_input()
138 /* Mouse button pressed. */ in sc_mouse_input()
139 if (mouse->u.event.id & MOUSE_BUTTON1DOWN) in sc_mouse_input()
141 if (mouse->u.event.id & MOUSE_BUTTON2DOWN) in sc_mouse_input()
143 if (mouse->u.event.id & MOUSE_BUTTON3DOWN) in sc_mouse_input()
146 /* Mouse button released. */ in sc_mouse_input()
151 if (mouse->u.data.z < 0) { in sc_mouse_input()
154 } else if (mouse->u.data.z > 0) { in sc_mouse_input()
169 scp->mouse_xpos = scp->mouse_oldxpos = x; in sc_mouse_move()
170 scp->mouse_ypos = scp->mouse_oldypos = y; in sc_mouse_move()
171 if (scp->font_size <= 0 || scp->font_width <= 0) in sc_mouse_move()
172 scp->mouse_pos = scp->mouse_oldpos = 0; in sc_mouse_move()
174 scp->mouse_pos = scp->mouse_oldpos = in sc_mouse_move()
175 (y/scp->font_size - scp->yoff)*scp->xsize + x/scp->font_width - in sc_mouse_move()
176 scp->xoff; in sc_mouse_move()
177 scp->status |= MOUSE_MOVED; in sc_mouse_move()
185 if (scp->mouse_xpos < scp->xoff*scp->font_width) in set_mouse_pos()
186 scp->mouse_xpos = scp->xoff*scp->font_width; in set_mouse_pos()
187 if (scp->mouse_ypos < scp->yoff*scp->font_size) in set_mouse_pos()
188 scp->mouse_ypos = scp->yoff*scp->font_size; in set_mouse_pos()
190 if (scp->mouse_xpos > scp->xpixel-1) in set_mouse_pos()
191 scp->mouse_xpos = scp->xpixel-1; in set_mouse_pos()
192 if (scp->mouse_ypos > scp->ypixel-1) in set_mouse_pos()
193 scp->mouse_ypos = scp->ypixel-1; in set_mouse_pos()
196 if (scp->mouse_xpos > (scp->xsize + scp->xoff)*scp->font_width - 1) in set_mouse_pos()
197 scp->mouse_xpos = (scp->xsize + scp->xoff)*scp->font_width - 1; in set_mouse_pos()
198 if (scp->mouse_ypos > (scp->ysize + scp->yoff)*scp->font_size - 1) in set_mouse_pos()
199 scp->mouse_ypos = (scp->ysize + scp->yoff)*scp->font_size - 1; in set_mouse_pos()
202 if ((scp->mouse_xpos != scp->mouse_oldxpos || scp->mouse_ypos != scp->mouse_oldypos) in set_mouse_pos()
203 && (scp->font_size != 0 && scp->font_width != 0)) { in set_mouse_pos()
204 scp->status |= MOUSE_MOVED; in set_mouse_pos()
205 scp->mouse_pos = in set_mouse_pos()
206 (scp->mouse_ypos/scp->font_size - scp->yoff)*scp->xsize in set_mouse_pos()
207 + scp->mouse_xpos/scp->font_width - scp->xoff; in set_mouse_pos()
209 if ((scp->status & MOUSE_VISIBLE) && (scp->status & MOUSE_CUTTING)) in set_mouse_pos()
223 SC_VIDEO_LOCK(scp->sc); in sc_draw_mouse_image()
224 (*scp->rndr->draw_mouse)(scp, scp->mouse_xpos, scp->mouse_ypos, TRUE); in sc_draw_mouse_image()
225 scp->mouse_oldpos = scp->mouse_pos; in sc_draw_mouse_image()
226 scp->mouse_oldxpos = scp->mouse_xpos; in sc_draw_mouse_image()
227 scp->mouse_oldypos = scp->mouse_ypos; in sc_draw_mouse_image()
228 scp->status |= MOUSE_VISIBLE; in sc_draw_mouse_image()
229 SC_VIDEO_UNLOCK(scp->sc); in sc_draw_mouse_image()
240 SC_VIDEO_LOCK(scp->sc); in sc_remove_mouse_image()
241 (*scp->rndr->draw_mouse)(scp, scp->mouse_oldxpos, scp->mouse_oldypos, in sc_remove_mouse_image()
252 i = scp->mouse_oldpos; in sc_remove_mouse_image()
255 cols = 1 + howmany(10 - 1, scp->font_width); /* up to VGA cursor width 9 */ in sc_remove_mouse_image()
257 cols = imin(cols, scp->xsize - i % scp->xsize); in sc_remove_mouse_image()
258 rows = 1 + howmany(16 - 1, scp->font_size); /* up to VGA cursor height 16 */ in sc_remove_mouse_image()
260 rows = imin(rows, scp->ysize - i / scp->xsize); in sc_remove_mouse_image()
261 mark_for_update(scp, i + (rows - 1) * scp->xsize + cols - 1); in sc_remove_mouse_image()
262 scp->status &= ~MOUSE_VISIBLE; in sc_remove_mouse_image()
263 SC_VIDEO_UNLOCK(scp->sc); in sc_remove_mouse_image()
272 if (scp->mouse_cut_end < 0) in sc_inside_cutmark()
274 if (scp->mouse_cut_start <= scp->mouse_cut_end) { in sc_inside_cutmark()
275 start = scp->mouse_cut_start; in sc_inside_cutmark()
276 end = scp->mouse_cut_end; in sc_inside_cutmark()
278 start = scp->mouse_cut_end; in sc_inside_cutmark()
279 end = scp->mouse_cut_start - 1; in sc_inside_cutmark()
290 if (scp->mouse_cut_end >= 0) { in sc_remove_cutmarking()
291 mark_for_update(scp, scp->mouse_cut_start); in sc_remove_cutmarking()
292 mark_for_update(scp, scp->mouse_cut_end); in sc_remove_cutmarking()
294 scp->mouse_cut_start = scp->xsize*scp->ysize; in sc_remove_cutmarking()
295 scp->mouse_cut_end = -1; in sc_remove_cutmarking()
297 scp->status &= ~MOUSE_CUTTING; in sc_remove_cutmarking()
307 for (i = 0; i < sc->vtys; ++i) { in sc_remove_all_cutmarkings()
308 scp = SC_STAT(sc->dev[i]); in sc_remove_all_cutmarkings()
321 for (i = 0; i < sc->vtys; ++i) { in sc_remove_all_mouse()
322 scp = SC_STAT(sc->dev[i]); in sc_remove_all_mouse()
325 if (scp->status & MOUSE_VISIBLE) { in sc_remove_all_mouse()
326 scp->status &= ~MOUSE_VISIBLE; in sc_remove_all_mouse()
353 for (i = p % scp->xsize; i < scp->xsize; ++i) { in skip_spc_right()
354 c = sc_vtb_getc(&scp->vtb, p); in skip_spc_right()
369 for (i = p-- % scp->xsize - 1; i >= 0; --i) { in skip_spc_left()
370 c = sc_vtb_getc(&scp->vtb, p); in skip_spc_left()
373 --p; in skip_spc_left()
388 cut_buffer[i] = sc_vtb_getc(&scp->vtb, p); in mouse_do_cut()
393 if (leadspaces != -1) { in mouse_do_cut()
397 if ((p % scp->xsize) % 8 == 7) { in mouse_do_cut()
398 i -= leadspaces - 1; in mouse_do_cut()
403 leadspaces = -1; in mouse_do_cut()
407 /* remember the position of the last non-space char */ in mouse_do_cut()
409 blank = i + 1; /* the first space after the last non-space */ in mouse_do_cut()
412 if ((p % scp->xsize) == (scp->xsize - 1)) { in mouse_do_cut()
422 if (scp->mouse_cut_start <= scp->mouse_cut_end) { in mouse_do_cut()
423 mark_for_update(scp, scp->mouse_cut_start); in mouse_do_cut()
424 mark_for_update(scp, scp->mouse_cut_end); in mouse_do_cut()
425 } else if (scp->mouse_cut_end >= 0) { in mouse_do_cut()
426 mark_for_update(scp, scp->mouse_cut_end); in mouse_do_cut()
427 mark_for_update(scp, scp->mouse_cut_start); in mouse_do_cut()
431 scp->mouse_cut_start = from; in mouse_do_cut()
432 scp->mouse_cut_end = to; in mouse_do_cut()
451 start = scp->mouse_cut_start; in mouse_cut()
452 end = scp->mouse_cut_end; in mouse_cut()
453 if (scp->mouse_pos >= start) { in mouse_cut()
455 to = end = scp->mouse_pos; in mouse_cut()
457 from = end = scp->mouse_pos; in mouse_cut()
458 to = start - 1; in mouse_cut()
461 for (i = p % scp->xsize; i < scp->xsize; ++i) { in mouse_cut()
462 c = sc_vtb_getc(&scp->vtb, p); in mouse_cut()
468 if (i == scp->xsize) { in mouse_cut()
470 to = end = p - 1; in mouse_cut()
476 scp->mouse_cut_start = start; in mouse_cut()
477 scp->mouse_cut_end = end; in mouse_cut()
481 /* a mouse button is pressed, start cut operation */
488 if (scp->status & MOUSE_VISIBLE) { in mouse_cut_start()
489 sc_remove_all_cutmarkings(scp->sc); in mouse_cut_start()
490 if ((scp->mouse_pos == scp->mouse_cut_start) && in mouse_cut_start()
491 (scp->mouse_pos == scp->mouse_cut_end)) { in mouse_cut_start()
494 } else if (skip_spc_right(scp, scp->mouse_pos) >= scp->xsize) { in mouse_cut_start()
496 i = skip_spc_left(scp, scp->mouse_pos) + 1; in mouse_cut_start()
498 scp->mouse_cut_start = in mouse_cut_start()
499 rounddown(scp->mouse_pos, scp->xsize) + i; in mouse_cut_start()
500 scp->mouse_cut_end = in mouse_cut_start()
501 (scp->mouse_pos / scp->xsize + 1) * scp->xsize - 1; in mouse_cut_start()
506 scp->mouse_cut_start = scp->mouse_pos; in mouse_cut_start()
507 scp->mouse_cut_end = scp->mouse_cut_start; in mouse_cut_start()
509 cut_buffer[0] = sc_vtb_getc(&scp->vtb, scp->mouse_cut_start); in mouse_cut_start()
512 scp->status |= MOUSE_CUTTING; in mouse_cut_start()
521 if (scp->status & MOUSE_VISIBLE) in mouse_cut_end()
522 scp->status &= ~MOUSE_CUTTING; in mouse_cut_end()
539 * we only distinguish space char and non-space chars. Punctuation in mouse_cut_word()
543 if (scp->status & MOUSE_VISIBLE) { in mouse_cut_word()
544 sol = rounddown(scp->mouse_pos, scp->xsize); in mouse_cut_word()
545 eol = sol + scp->xsize; in mouse_cut_word()
546 c = sc_vtb_getc(&scp->vtb, scp->mouse_pos); in mouse_cut_word()
549 for (j = scp->mouse_pos; j >= sol; --j) { in mouse_cut_word()
550 c = sc_vtb_getc(&scp->vtb, j); in mouse_cut_word()
555 for (j = scp->mouse_pos; j < eol; ++j) { in mouse_cut_word()
556 c = sc_vtb_getc(&scp->vtb, j); in mouse_cut_word()
560 end = j - 1; in mouse_cut_word()
562 /* non-space word */ in mouse_cut_word()
563 for (j = scp->mouse_pos; j >= sol; --j) { in mouse_cut_word()
564 c = sc_vtb_getc(&scp->vtb, j); in mouse_cut_word()
569 for (j = scp->mouse_pos; j < eol; ++j) { in mouse_cut_word()
570 c = sc_vtb_getc(&scp->vtb, j); in mouse_cut_word()
574 end = j - 1; in mouse_cut_word()
580 if (cut_buffer[len - 1] == '\r') in mouse_cut_word()
581 cut_buffer[len - 1] = '\0'; in mouse_cut_word()
592 if (scp->status & MOUSE_VISIBLE) { in mouse_cut_line()
593 from = rounddown(scp->mouse_pos, scp->xsize); in mouse_cut_line()
594 mouse_do_cut(scp, from, from + scp->xsize - 1); in mouse_cut_line()
596 if (cut_buffer[len - 1] == '\r') in mouse_cut_line()
597 cut_buffer[len - 1] = '\0'; in mouse_cut_line()
598 scp->status |= MOUSE_CUTTING; in mouse_cut_line()
610 if ((scp->status & MOUSE_VISIBLE) && !(scp->status & MOUSE_CUTTING) in mouse_cut_extend()
611 && (scp->mouse_cut_end >= 0)) { in mouse_cut_extend()
612 if (scp->mouse_cut_start <= scp->mouse_cut_end) { in mouse_cut_extend()
613 start = scp->mouse_cut_start; in mouse_cut_extend()
614 end = scp->mouse_cut_end; in mouse_cut_extend()
616 start = scp->mouse_cut_end; in mouse_cut_extend()
617 end = scp->mouse_cut_start - 1; in mouse_cut_extend()
620 if (scp->mouse_pos > end) { in mouse_cut_extend()
621 scp->mouse_cut_start = start; in mouse_cut_extend()
622 scp->mouse_cut_end = end; in mouse_cut_extend()
623 } else if (scp->mouse_pos < start) { in mouse_cut_extend()
624 scp->mouse_cut_start = end + 1; in mouse_cut_extend()
625 scp->mouse_cut_end = start; in mouse_cut_extend()
627 if (scp->mouse_pos - start > end + 1 - scp->mouse_pos) { in mouse_cut_extend()
628 scp->mouse_cut_start = start; in mouse_cut_extend()
629 scp->mouse_cut_end = end; in mouse_cut_extend()
631 scp->mouse_cut_start = end + 1; in mouse_cut_extend()
632 scp->mouse_cut_end = start; in mouse_cut_extend()
637 scp->status |= MOUSE_CUTTING; in mouse_cut_extend()
676 mouse->operation = old_mouse->operation; in sc_mouse_ioctl()
677 switch (mouse->operation) { in sc_mouse_ioctl()
679 mouse->u.mode = old_mouse->u.mode; in sc_mouse_ioctl()
687 mouse->u.data.x = old_mouse->u.data.x; in sc_mouse_ioctl()
688 mouse->u.data.y = old_mouse->u.data.y; in sc_mouse_ioctl()
689 mouse->u.data.z = 0; in sc_mouse_ioctl()
690 mouse->u.data.buttons = swapb[old_mouse->u.data.buttons & 0x7]; in sc_mouse_ioctl()
693 old_mouse->u.data.x = scp->mouse_xpos; in sc_mouse_ioctl()
694 old_mouse->u.data.y = scp->mouse_ypos; in sc_mouse_ioctl()
695 old_mouse->u.data.buttons = swapb[scp->mouse_buttons & 0x7]; in sc_mouse_ioctl()
702 cur_scp = scp->sc->cur_scp; in sc_mouse_ioctl()
704 switch (mouse->operation) { in sc_mouse_ioctl()
706 if (ISSIGVALID(mouse->u.mode.signal)) { in sc_mouse_ioctl()
707 scp->mouse_signal = mouse->u.mode.signal; in sc_mouse_ioctl()
708 scp->mouse_proc = td->td_proc; in sc_mouse_ioctl()
709 scp->mouse_pid = td->td_proc->p_pid; in sc_mouse_ioctl()
712 scp->mouse_signal = 0; in sc_mouse_ioctl()
713 scp->mouse_proc = NULL; in sc_mouse_ioctl()
714 scp->mouse_pid = 0; in sc_mouse_ioctl()
720 if (!(scp->sc->flags & SC_MOUSE_ENABLED)) { in sc_mouse_ioctl()
721 scp->sc->flags |= SC_MOUSE_ENABLED; in sc_mouse_ioctl()
722 cur_scp->status &= ~MOUSE_HIDDEN; in sc_mouse_ioctl()
732 if (scp->sc->flags & SC_MOUSE_ENABLED) { in sc_mouse_ioctl()
733 scp->sc->flags &= ~SC_MOUSE_ENABLED; in sc_mouse_ioctl()
734 sc_remove_all_mouse(scp->sc); in sc_mouse_ioctl()
742 scp->mouse_xpos = mouse->u.data.x; in sc_mouse_ioctl()
743 scp->mouse_ypos = mouse->u.data.y; in sc_mouse_ioctl()
750 scp->mouse_xpos += mouse->u.data.x; in sc_mouse_ioctl()
751 scp->mouse_ypos += mouse->u.data.y; in sc_mouse_ioctl()
757 mouse->u.data.x = scp->mouse_xpos; in sc_mouse_ioctl()
758 mouse->u.data.y = scp->mouse_ypos; in sc_mouse_ioctl()
759 mouse->u.data.z = 0; in sc_mouse_ioctl()
760 mouse->u.data.buttons = scp->mouse_buttons; in sc_mouse_ioctl()
768 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL) in sc_mouse_ioctl()
772 if (mouse->u.data.x != 0 || mouse->u.data.y != 0) { in sc_mouse_ioctl()
773 cur_scp->mouse_xpos += mouse->u.data.x; in sc_mouse_ioctl()
774 cur_scp->mouse_ypos += mouse->u.data.y; in sc_mouse_ioctl()
778 if (mouse->operation == MOUSE_ACTION) { in sc_mouse_ioctl()
779 f = cur_scp->mouse_buttons ^ mouse->u.data.buttons; in sc_mouse_ioctl()
780 cur_scp->mouse_buttons = mouse->u.data.buttons; in sc_mouse_ioctl()
791 if (((mouse->operation == MOUSE_ACTION) && mouse->u.data.buttons) in sc_mouse_ioctl()
792 || (mouse->u.data.x*mouse->u.data.x in sc_mouse_ioctl()
793 + mouse->u.data.y*mouse->u.data.y in sc_mouse_ioctl()
798 cur_scp->status &= ~MOUSE_HIDDEN; in sc_mouse_ioctl()
800 if (cur_scp->mouse_level > 0) { in sc_mouse_ioctl()
805 if (cur_scp->mouse_signal && cur_scp->mouse_proc) { in sc_mouse_ioctl()
807 if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))) { in sc_mouse_ioctl()
808 cur_scp->mouse_signal = 0; in sc_mouse_ioctl()
809 cur_scp->mouse_proc = NULL; in sc_mouse_ioctl()
810 cur_scp->mouse_pid = 0; in sc_mouse_ioctl()
814 kern_psignal(cur_scp->mouse_proc, cur_scp->mouse_signal); in sc_mouse_ioctl()
815 PROC_UNLOCK(cur_scp->mouse_proc); in sc_mouse_ioctl()
824 if ((mouse->operation == MOUSE_ACTION) && f) { in sc_mouse_ioctl()
825 /* process button presses */ in sc_mouse_ioctl()
826 if (cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN) in sc_mouse_ioctl()
830 if (cur_scp->mouse_buttons & MOUSE_BUTTON2DOWN || in sc_mouse_ioctl()
831 cur_scp->mouse_buttons & MOUSE_BUTTON3DOWN) in sc_mouse_ioctl()
838 if ((mouse->u.event.id & MOUSE_BUTTONS) == 0) in sc_mouse_ioctl()
840 if (mouse->u.event.value < 0) in sc_mouse_ioctl()
844 if (SC_VTY(tp->t_dev) != SC_CONSOLECTL) in sc_mouse_ioctl()
847 if (mouse->u.event.value > 0) in sc_mouse_ioctl()
848 cur_scp->mouse_buttons |= mouse->u.event.id; in sc_mouse_ioctl()
850 cur_scp->mouse_buttons &= ~mouse->u.event.id; in sc_mouse_ioctl()
855 /* if a button is held down, stop the screen saver */ in sc_mouse_ioctl()
856 if (mouse->u.event.value > 0) in sc_mouse_ioctl()
859 cur_scp->status &= ~MOUSE_HIDDEN; in sc_mouse_ioctl()
861 if (cur_scp->mouse_level > 0) { in sc_mouse_ioctl()
866 if (cur_scp->mouse_signal && cur_scp->mouse_proc) { in sc_mouse_ioctl()
867 if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))){ in sc_mouse_ioctl()
868 cur_scp->mouse_signal = 0; in sc_mouse_ioctl()
869 cur_scp->mouse_proc = NULL; in sc_mouse_ioctl()
870 cur_scp->mouse_pid = 0; in sc_mouse_ioctl()
874 kern_psignal(cur_scp->mouse_proc, cur_scp->mouse_signal); in sc_mouse_ioctl()
875 PROC_UNLOCK(cur_scp->mouse_proc); in sc_mouse_ioctl()
884 switch (mouse->u.event.id) { in sc_mouse_ioctl()
886 switch (mouse->u.event.value % 4) { in sc_mouse_ioctl()
904 switch (mouse->u.event.value) { in sc_mouse_ioctl()
913 switch (mouse->u.event.value) { in sc_mouse_ioctl()
915 if (!(cur_scp->mouse_buttons & MOUSE_BUTTON1DOWN)) in sc_mouse_ioctl()
928 if (mouse->u.mouse_char < 0) { in sc_mouse_ioctl()
929 mouse->u.mouse_char = scp->sc->mouse_char; in sc_mouse_ioctl()
931 if (mouse->u.mouse_char > UCHAR_MAX - 3) in sc_mouse_ioctl()
934 sc_remove_all_mouse(scp->sc); in sc_mouse_ioctl()
936 if (ISTEXTSC(cur_scp) && (cur_scp->font != NULL)) in sc_mouse_ioctl()
937 sc_load_font(cur_scp, 0, cur_scp->font_size, in sc_mouse_ioctl()
938 cur_scp->font_width, in sc_mouse_ioctl()
939 cur_scp->font + cur_scp->font_size in sc_mouse_ioctl()
940 * cur_scp->sc->mouse_char, in sc_mouse_ioctl()
941 cur_scp->sc->mouse_char, 4); in sc_mouse_ioctl()
943 scp->sc->mouse_char = mouse->u.mouse_char; in sc_mouse_ioctl()