Lines Matching defs:scr
130 #define IS_MOUSE_VISIBLE(scr) ((scr)->mouse_flags & MOUSE_VISIBLE)
131 #define IS_SEL_EXISTS(scr) ((scr)->mouse_flags & SEL_EXISTS)
132 #define IS_SEL_IN_PROGRESS(scr) ((scr)->mouse_flags & SEL_IN_PROGRESS)
133 #define IS_SEL_EXT_AFTER(scr) ((scr)->mouse_flags & SEL_EXT_AFTER)
134 #define IS_BLANK_TO_EOL(scr) ((scr)->mouse_flags & BLANK_TO_EOL)
135 #define IS_SEL_BY_CHAR(scr) ((scr)->mouse_flags & SEL_BY_CHAR)
136 #define IS_SEL_BY_WORD(scr) ((scr)->mouse_flags & SEL_BY_WORD)
137 #define IS_SEL_BY_LINE(scr) ((scr)->mouse_flags & SEL_BY_LINE)
232 #define WSSCREEN_HAS_TTY(scr) ((scr)->scr_tty != NULL)
280 struct wsscreen *scr;
282 scr = malloc(sizeof(*scr), M_DEVBUF, M_ZERO | M_NOWAIT);
283 if (!scr)
292 (void)(*dconf->wsemul->attach)(1, 0, 0, 0, 0, scr, 0);
303 ccol, crow, scr, defattr);
309 task_set(&scr->scr_emulbell_task, wsdisplay_emulbell_task, scr);
310 scr->scr_dconf = dconf;
311 scr->scr_tty = ttymalloc(0);
312 scr->sc = sc;
313 return (scr);
318 free(scr, M_DEVBUF, sizeof(*scr));
323 wsscreen_detach(struct wsscreen *scr)
327 if (WSSCREEN_HAS_TTY(scr)) {
328 timeout_del(&scr->scr_tty->t_rstrt_to);
329 ttyfree(scr->scr_tty);
331 (*scr->scr_dconf->wsemul->detach)(scr->scr_dconf->wsemulcookie,
333 taskq_del_barrier(scr->sc->sc_taskq, &scr->scr_emulbell_task);
334 free(scr->scr_dconf, M_DEVBUF, sizeof(*scr->scr_dconf));
335 free(scr, M_DEVBUF, sizeof(*scr));
342 const struct wsscreen_descr *scr;
350 scr = scrdata->screens[i];
351 if (!strncmp(name, scr->name, WSSCREEN_NAME_SIZE))
352 return (scr);
381 struct wsscreen *scr;
397 scr = wsscreen_attach(sc, 0, emul, scrdesc,
399 if (scr == NULL) {
404 sc->sc_scr[idx] = scr;
410 scr->scr_dconf->emulcookie, 0, 0, 0);
412 sc->sc_focus = scr;
426 struct wsscreen *scr;
434 scr = sc->sc_scr[sd->idx];
435 if (scr == NULL)
438 strlcpy(sd->screentype, scr->scr_dconf->scrdata->name,
440 strlcpy(sd->emul, scr->scr_dconf->wsemul->name, WSEMUL_NAME_SIZE);
446 wsdisplay_closescreen(struct wsdisplay_softc *sc, struct wsscreen *scr)
451 if (WSSCREEN_HAS_TTY(scr)) {
452 struct tty *tp = scr->scr_tty;
462 if (scr == sc->sc_scr[idx])
477 struct wsscreen *scr;
483 if ((scr = sc->sc_scr[idx]) == NULL)
486 if (scr->scr_dconf == &wsdisplay_console_conf ||
488 scr->scr_syncops ||
490 ((scr->scr_flags & SCR_OPEN) && !(flags & WSDISPLAY_DELSCR_FORCE)))
493 wsdisplay_closescreen(sc, scr);
500 if (sc->sc_focus == scr) {
514 if (scr->scr_flags & SCR_WAITACTIVE)
515 wakeup(scr);
518 cookie = scr->scr_dconf->emulcookie;
520 wsscreen_detach(scr);
850 struct wsscreen *scr;
862 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
865 if (WSSCREEN_HAS_TTY(scr)) {
866 tp = scr->scr_tty;
892 tp->t_winsize.ws_row = scr->scr_dconf->scrdata->nrows;
893 tp->t_winsize.ws_col = scr->scr_dconf->scrdata->ncols;
897 scr->scr_flags |= SCR_OPEN;
907 struct wsscreen *scr;
915 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
918 if (WSSCREEN_HAS_TTY(scr)) {
919 if (scr->scr_hold_screen) {
924 wsdisplay_kbdholdscr(scr, 0);
927 tp = scr->scr_tty;
933 if (scr->scr_syncops)
934 (*scr->scr_syncops->destroy)(scr->scr_synccookie);
937 scr->scr_flags &= ~SCR_GRAPHICS;
938 (*scr->scr_dconf->wsemul->reset)(scr->scr_dconf->wsemulcookie,
941 (*scr->scr_dconf->wsemul->reset)
942 (scr->scr_dconf->wsemulcookie, WSEMUL_CLEARSCREEN);
945 if (scr->scr_rawkbd) {
947 (void) wsdisplay_internal_ioctl(sc, scr, WSKBDIO_SETMODE,
952 scr->scr_flags &= ~SCR_OPEN;
970 struct wsscreen *scr;
978 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
981 if (!WSSCREEN_HAS_TTY(scr))
984 tp = scr->scr_tty;
994 struct wsscreen *scr;
1002 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
1005 if (!WSSCREEN_HAS_TTY(scr))
1008 tp = scr->scr_tty;
1017 struct wsscreen *scr;
1025 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
1028 return (scr->scr_tty);
1037 struct wsscreen *scr;
1063 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
1066 if (WSSCREEN_HAS_TTY(scr)) {
1067 tp = scr->scr_tty;
1083 error = wsdisplay_usl_ioctl2(sc, scr, cmd, data, flag, p);
1088 error = wsdisplay_internal_ioctl(sc, scr, cmd, data, flag, p);
1100 wsdisplay_internal_ioctl(struct wsdisplay_softc *sc, struct wsscreen *scr,
1113 scr->scr_rawkbd = (*(int *)data == WSKBD_RAW);
1114 return (wsdisplay_update_rawkbd(sc, scr));
1116 *(int *)data = (scr->scr_rawkbd ?
1143 if (scr->scr_flags & SCR_GRAPHICS) {
1144 if (scr->scr_flags & SCR_DUMBFB)
1159 scr->scr_flags &= ~SCR_GRAPHICS;
1162 scr->scr_flags |= SCR_GRAPHICS |
1166 (*scr->scr_dconf->wsemul->reset)
1167 (scr->scr_dconf->wsemulcookie, WSEMUL_CLEARCURSOR);
1171 wsdisplay_burner_setup(sc, scr);
1186 scr->scr_dconf->emulcookie, d);
1188 (*scr->scr_dconf->wsemul->reset)
1189 (scr->scr_dconf->wsemulcookie, WSEMUL_SYNCFONT);
1234 active = scr;
1407 struct wsscreen *scr;
1412 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
1415 if (!(scr->scr_flags & SCR_GRAPHICS))
1426 struct wsscreen *scr;
1431 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(dev)]) == NULL)
1434 if (!WSSCREEN_HAS_TTY(scr))
1444 struct wsscreen *scr;
1461 if ((scr = sc->sc_scr[WSDISPLAYSCREEN(tp->t_dev)]) == NULL) {
1465 if (scr->scr_hold_screen) {
1485 if (!(scr->scr_flags & SCR_GRAPHICS)) {
1490 if (scr == sc->sc_focus)
1491 mouse_remove(scr);
1493 done = (*scr->scr_dconf->wsemul->output)
1494 (scr->scr_dconf->wsemulcookie, buf, n, 0);
1503 if (!(scr->scr_flags & SCR_GRAPHICS)) {
1504 done = (*scr->scr_dconf->wsemul->output)
1505 (scr->scr_dconf->wsemulcookie, buf, n, 0);
1555 struct wsscreen *scr = v;
1557 if (scr == NULL) /* console, before real attach */
1560 if (scr->scr_flags & SCR_GRAPHICS) /* can this happen? */
1563 task_add(scr->sc->sc_taskq, &scr->scr_emulbell_task);
1569 struct wsscreen *scr = v;
1571 (void)wsdisplay_internal_ioctl(scr->sc, scr, WSKBDIO_BELL, NULL,
1579 struct wsscreen *scr = v;
1585 if (scr->scr_flags & SCR_GRAPHICS) /* XXX can't happen */
1587 if (!WSSCREEN_HAS_TTY(scr))
1590 tp = scr->scr_tty;
1603 struct wsscreen *scr;
1608 scr = sc->sc_focus;
1609 if (!scr || !WSSCREEN_HAS_TTY(scr))
1613 tp = scr->scr_tty;
1615 count = (*scr->scr_dconf->wsemul->translate)
1616 (scr->scr_dconf->wsemulcookie, layout, *ks++, &dp);
1627 struct wsscreen *scr;
1630 scr = sc->sc_focus;
1631 if (!scr || !WSSCREEN_HAS_TTY(scr))
1634 tp = scr->scr_tty;
1639 wsdisplay_update_rawkbd(struct wsdisplay_softc *sc, struct wsscreen *scr)
1647 raw = (scr ? scr->scr_rawkbd : 0);
1649 if (scr != sc->sc_focus || sc->sc_rawkbd == raw) {
1676 struct wsscreen *scr;
1687 scr = sc->sc_scr[no];
1688 if (!scr) {
1717 scr = sc->sc_scr[no];
1724 wsdisplay_burner_setup(sc, scr);
1727 if (!error && (scr->scr_flags & SCR_WAITACTIVE))
1728 wakeup(scr);
1737 struct wsscreen *scr;
1747 scr = sc->sc_scr[no];
1748 if (!scr) {
1769 sc->sc_focus = scr;
1772 (void) wsdisplay_update_rawkbd(sc, scr);
1778 if (scr->scr_syncops) {
1779 error = (*scr->scr_syncops->attach)(scr->scr_synccookie, waitok,
1797 struct wsscreen *scr;
1815 scr = sc->sc_scr[no];
1816 if (!scr) {
1828 scr->scr_dconf->emulcookie, waitok,
1843 struct wsscreen *scr;
1878 scr = sc->sc_focus;
1879 if (!scr) {
1887 if (scr->scr_syncops) {
1888 res = (*scr->scr_syncops->detach)(scr->scr_synccookie, waitok,
1895 } else if (scr->scr_flags & SCR_GRAPHICS) {
1902 mouse_remove(scr);
1912 struct wsscreen *scr;
1914 scr = sc->sc_focus;
1916 if (!scr)
1921 (*scr->scr_dconf->wsemul->reset)(scr->scr_dconf->wsemulcookie,
1925 wsdisplay_closescreen(sc, scr);
1935 wsscreen_attach_sync(struct wsscreen *scr, const struct wscons_syncops *ops,
1938 if (scr->scr_syncops) {
1943 if ((*scr->scr_syncops->check)(scr->scr_synccookie))
1946 scr->scr_syncops = ops;
1947 scr->scr_synccookie = cookie;
1952 wsscreen_detach_sync(struct wsscreen *scr)
1954 if (!scr->scr_syncops)
1956 scr->scr_syncops = NULL;
1961 wsscreen_lookup_sync(struct wsscreen *scr,
1965 if (!scr->scr_syncops || ops != scr->scr_syncops)
1967 *cookiep = scr->scr_synccookie;
2000 struct wsscreen *scr;
2014 scr = sc->sc_scr[no];
2015 if (!scr)
2019 if (scr != sc->sc_focus) {
2020 scr->scr_flags |= SCR_WAITACTIVE;
2021 res = tsleep_nsec(scr, PCATCH, "wswait2", INFSLP);
2022 if (scr != sc->sc_scr[no])
2025 scr->scr_flags &= ~SCR_WAITACTIVE;
2032 wsdisplay_kbdholdscr(struct wsscreen *scr, int hold)
2035 scr->scr_hold_screen = 1;
2037 scr->scr_hold_screen = 0;
2038 timeout_add(&scr->scr_tty->t_rstrt_to, 0); /* "immediate" */
2046 struct wsscreen *scr;
2048 scr = sc->sc_focus;
2049 if (scr != NULL && WSSCREEN_HAS_TTY(scr))
2050 wsdisplay_kbdholdscr(scr, hold);
2162 struct wsscreen *scr;
2166 if ((scr = sc->sc_scr[0]) == NULL)
2169 scr->scr_dconf->emulcookie, 0, NULL, NULL);
2181 struct wsscreen *scr;
2185 if ((scr = sc->sc_scr[0]) == NULL)
2189 scr->scr_dconf->emulcookie);
2192 scr->scr_dconf->emulcookie, 0, NULL, NULL);
2219 struct wsscreen *scr;
2225 scr = sc->sc_scr[active];
2231 if (scr->scr_flags & SCR_GRAPHICS) {
2233 if (sc->sc_scr[idx] == NULL || sc->sc_scr[idx] == scr)
2327 wsdisplay_burner_setup(struct wsdisplay_softc *sc, struct wsscreen *scr)
2329 if (scr->scr_flags & SCR_GRAPHICS) {
2539 motion_event(struct wsscreen *scr, u_int type, int value)
2543 mouse_moverel(scr, value, 0);
2546 mouse_moverel(scr, 0, -value);
2550 mouse_zaxis(scr, value);
2562 button_event(struct wsscreen *scr, int button, int clicks)
2568 mouse_copy_end(scr);
2569 mouse_copy_selection(scr);
2572 mouse_copy_start(scr);
2573 mouse_copy_selection(scr);
2576 mouse_copy_word(scr);
2577 mouse_copy_selection(scr);
2580 mouse_copy_line(scr);
2581 mouse_copy_selection(scr);
2587 mouse_paste(scr);
2591 mouse_copy_extend_after(scr);
2604 struct wsscreen *scr;
2619 if ((scr = sc->sc_scr[i]) != NULL) {
2620 scr->mouse =
2621 (WS_NCOLS(scr) * WS_NROWS(scr)) / 2;
2622 scr->cursor = scr->mouse;
2623 scr->cpy_start = 0;
2624 scr->cpy_end = 0;
2625 scr->orig_start = 0;
2626 scr->orig_end = 0;
2627 scr->mouse_flags = 0;
2636 mouse_moverel(struct wsscreen *scr, int dx, int dy)
2638 struct wsscreen_internal *dconf = scr->scr_dconf;
2639 u_int old_mouse = scr->mouse;
2640 int mouse_col = scr->mouse % N_COLS(dconf);
2641 int mouse_row = scr->mouse / N_COLS(dconf);
2660 scr->mouse = mouse_row * N_COLS(dconf) + mouse_col;
2663 if (old_mouse != scr->mouse) {
2665 if (ISSET(scr->mouse_flags, SEL_IN_PROGRESS)) {
2667 mouse_copy_extend(scr);
2669 inverse_char(scr, scr->mouse);
2670 if (ISSET(scr->mouse_flags, MOUSE_VISIBLE))
2671 inverse_char(scr, old_mouse);
2673 SET(scr->mouse_flags, MOUSE_VISIBLE);
2679 inverse_char(struct wsscreen *scr, u_int pos)
2681 struct wsscreen_internal *dconf = scr->scr_dconf;
2688 GETCHAR(scr, pos, &cell);
2715 inverse_region(struct wsscreen *scr, u_int start, u_int end)
2717 struct wsscreen_internal *dconf = scr->scr_dconf;
2727 inverse_char(scr, current_pos++);
2736 skip_spc_right(struct wsscreen *scr, int border)
2738 struct wsscreen_internal *dconf = scr->scr_dconf;
2740 u_int current = scr->cpy_end;
2741 u_int mouse_col = scr->cpy_end % N_COLS(dconf);
2745 while (GETCHAR(scr, current, &cell) == 0 && cell.uc == ' ' &&
2768 skip_spc_left(struct wsscreen *scr)
2770 struct wsscreen_internal *dconf = scr->scr_dconf;
2772 u_int current = scr->cpy_start;
2773 u_int mouse_col = scr->mouse % N_COLS(dconf);
2777 while (GETCHAR(scr, current, &cell) == 0 && cell.uc == ' ' &&
2863 skip_char_right(struct wsscreen *scr, u_int offset)
2865 struct wsscreen_internal *dconf = scr->scr_dconf;
2869 (N_COLS(dconf) - (scr->mouse % N_COLS(dconf)) - 1);
2873 GETCHAR(scr, current, &cell);
2875 while (GETCHAR(scr, current, &cell) == 0 &&
2889 skip_char_left(struct wsscreen *scr, u_int offset)
2891 struct wsscreen_internal *dconf = scr->scr_dconf;
2894 u_int limit = current - (scr->mouse % N_COLS(dconf));
2898 GETCHAR(scr, current, &cell);
2900 while (GETCHAR(scr, current, &cell) == 0 &&
2914 class_cmp(struct wsscreen *scr, u_int first, u_int second)
2920 if (GETCHAR(scr, first, &cell) != 0)
2923 if (GETCHAR(scr, second, &cell) != 0)
2937 mouse_copy_start(struct wsscreen *scr)
2942 SET(scr->sc->sc_flags, SC_PASTE_AVAIL);
2945 if (ISSET(scr->mouse_flags, SEL_EXISTS))
2946 remove_selection(scr);
2949 if (!ISSET(scr->mouse_flags, MOUSE_VISIBLE))
2950 inverse_char(scr, scr->mouse);
2952 scr->cpy_start = scr->cpy_end = scr->mouse;
2953 scr->orig_start = scr->cpy_start;
2954 scr->orig_end = scr->cpy_end;
2955 scr->cursor = scr->cpy_end + 1; /* init value */
2958 right = skip_spc_right(scr, BORDER);
2960 SET(scr->mouse_flags, BLANK_TO_EOL);
2962 SET(scr->mouse_flags, SEL_IN_PROGRESS | SEL_EXISTS | SEL_BY_CHAR);
2963 CLR(scr->mouse_flags, SEL_BY_WORD | SEL_BY_LINE);
2964 CLR(scr->mouse_flags, MOUSE_VISIBLE); /* cursor hidden in selection */
2971 mouse_copy_word(struct wsscreen *scr)
2977 if (ISSET(scr->mouse_flags, SEL_EXISTS))
2978 remove_selection(scr);
2980 if (ISSET(scr->mouse_flags, MOUSE_VISIBLE))
2981 inverse_char(scr, scr->mouse);
2983 scr->cpy_start = scr->cpy_end = scr->mouse;
2985 if (GETCHAR(scr, scr->mouse, &cell) == 0 &&
2987 right = skip_char_right(scr, scr->cpy_end);
2988 left = skip_char_left(scr, scr->cpy_start);
2990 right = skip_spc_right(scr, NO_BORDER);
2991 left = skip_spc_left(scr);
2994 scr->cpy_start -= left;
2995 scr->cpy_end += right;
2996 scr->orig_start = scr->cpy_start;
2997 scr->orig_end = scr->cpy_end;
2998 scr->cursor = scr->cpy_end + 1; /* init value, never happen */
2999 inverse_region(scr, scr->cpy_start, scr->cpy_end);
3001 SET(scr->mouse_flags, SEL_IN_PROGRESS | SEL_EXISTS | SEL_BY_WORD);
3002 CLR(scr->mouse_flags, SEL_BY_CHAR | SEL_BY_LINE);
3004 CLR(scr->mouse_flags, BLANK_TO_EOL | MOUSE_VISIBLE);
3011 mouse_copy_line(struct wsscreen *scr)
3013 struct wsscreen_internal *dconf = scr->scr_dconf;
3014 u_int row = scr->mouse / N_COLS(dconf);
3016 if (ISSET(scr->mouse_flags, SEL_EXISTS))
3017 remove_selection(scr);
3019 if (ISSET(scr->mouse_flags, MOUSE_VISIBLE))
3020 inverse_char(scr, scr->mouse);
3022 scr->cpy_start = row * N_COLS(dconf);
3023 scr->cpy_end = scr->cpy_start + (N_COLS(dconf) - 1);
3024 scr->orig_start = scr->cpy_start;
3025 scr->orig_end = scr->cpy_end;
3026 scr->cursor = scr->cpy_end + 1;
3027 inverse_region(scr, scr->cpy_start, scr->cpy_end);
3029 SET(scr->mouse_flags, SEL_IN_PROGRESS | SEL_EXISTS | SEL_BY_LINE);
3030 CLR(scr->mouse_flags, SEL_BY_CHAR | SEL_BY_WORD);
3032 CLR(scr->mouse_flags, BLANK_TO_EOL | MOUSE_VISIBLE);
3039 mouse_copy_end(struct wsscreen *scr)
3041 CLR(scr->mouse_flags, SEL_IN_PROGRESS);
3042 if (ISSET(scr->mouse_flags, SEL_BY_WORD) ||
3043 ISSET(scr->mouse_flags, SEL_BY_LINE)) {
3044 if (scr->cursor != scr->cpy_end + 1)
3045 inverse_char(scr, scr->cursor);
3046 scr->cursor = scr->cpy_end + 1;
3055 mouse_copy_extend(struct wsscreen *scr)
3057 if (ISSET(scr->mouse_flags, SEL_BY_CHAR))
3058 mouse_copy_extend_char(scr);
3059 if (ISSET(scr->mouse_flags, SEL_BY_WORD))
3060 mouse_copy_extend_word(scr);
3061 if (ISSET(scr->mouse_flags, SEL_BY_LINE))
3062 mouse_copy_extend_line(scr);
3069 mouse_copy_extend_char(struct wsscreen *scr)
3073 if (!ISSET(scr->mouse_flags, SEL_EXT_AFTER)) {
3074 if (ISSET(scr->mouse_flags, BLANK_TO_EOL)) {
3080 right = skip_spc_right(scr, BORDER);
3081 if (scr->mouse > scr->orig_start) {
3087 inverse_char(scr, scr->cpy_start);
3088 scr->cpy_start += (right + 1);
3089 scr->cpy_end = scr->cpy_start;
3090 scr->orig_start = scr->cpy_start;
3092 inverse_char(scr, scr->cpy_start);
3098 inverse_char(scr, scr->cpy_start);
3099 scr->orig_start += (right + 1);
3100 scr->cpy_start = scr->orig_start - 1;
3101 scr->cpy_end = scr->orig_start - 1;
3103 inverse_char(scr, scr->cpy_start);
3105 CLR(scr->mouse_flags, BLANK_TO_EOL);
3108 if (scr->mouse < scr->orig_start &&
3109 scr->cpy_end >= scr->orig_start) {
3113 remove_selection(scr);
3114 scr->cpy_end = scr->orig_start - 1;
3115 scr->cpy_start = scr->orig_start;
3117 if (scr->cpy_start < scr->orig_start &&
3118 scr->mouse >= scr->orig_start) {
3123 remove_selection(scr);
3124 scr->cpy_start = scr->orig_start;
3125 scr->cpy_end = scr->orig_start - 1;
3128 SET(scr->mouse_flags, SEL_IN_PROGRESS | SEL_EXISTS);
3131 if (scr->mouse >= scr->orig_start) {
3133 if (scr->mouse > scr->cpy_end) {
3135 inverse_region(scr, scr->cpy_end + 1, scr->mouse);
3138 inverse_region(scr, scr->mouse + 1, scr->cpy_end);
3140 scr->cpy_end = scr->mouse;
3143 if (scr->mouse < scr->cpy_start) {
3145 inverse_region(scr, scr->mouse, scr->cpy_start - 1);
3148 inverse_region(scr, scr->cpy_start, scr->mouse - 1);
3150 scr->cpy_start = scr->mouse;
3158 mouse_copy_extend_word(struct wsscreen *scr)
3163 if (!ISSET(scr->mouse_flags, SEL_EXT_AFTER)) {
3165 if (scr->cursor != scr->cpy_end + 1)
3166 inverse_char(scr, scr->cursor);
3169 if (scr->mouse < scr->orig_start &&
3170 scr->cpy_end >= scr->orig_start) {
3172 inverse_region(scr, scr->orig_end + 1, scr->cpy_end);
3173 scr->cpy_end = scr->orig_end;
3176 if (scr->mouse > scr->orig_end &&
3177 scr->cpy_start <= scr->orig_start) {
3179 inverse_region(scr, scr->cpy_start,
3180 scr->orig_start - 1);
3181 scr->cpy_start = scr->orig_start;
3185 if (scr->mouse >= scr->orig_start) {
3187 if (scr->mouse > scr->cpy_end) {
3189 old_cpy_end = scr->cpy_end;
3190 scr->cpy_end = scr->mouse +
3191 skip_char_right(scr, scr->mouse);
3192 inverse_region(scr, old_cpy_end + 1, scr->cpy_end);
3194 if (class_cmp(scr, scr->mouse, scr->mouse + 1)) {
3196 old_cpy_end = scr->cpy_end;
3197 scr->cpy_end = scr->mouse;
3198 inverse_region(scr, scr->cpy_end + 1,
3201 old_cpy_end = scr->cpy_end;
3202 scr->cpy_end = scr->mouse +
3203 skip_char_right(scr, scr->mouse);
3204 if (scr->cpy_end != old_cpy_end) {
3207 inverse_region(scr, scr->cpy_end + 1,
3214 if (scr->mouse < scr->cpy_start) {
3216 old_cpy_start = scr->cpy_start;
3217 scr->cpy_start = scr->mouse -
3218 skip_char_left(scr, scr->mouse);
3219 inverse_region(scr, scr->cpy_start, old_cpy_start - 1);
3221 if (class_cmp(scr, scr->mouse - 1, scr->mouse)) {
3223 old_cpy_start = scr->cpy_start;
3224 scr->cpy_start = scr->mouse;
3225 inverse_region(scr, old_cpy_start,
3226 scr->cpy_start - 1);
3228 old_cpy_start = scr->cpy_start;
3229 scr->cpy_start = scr->mouse -
3230 skip_char_left(scr, scr->mouse);
3231 if (scr->cpy_start != old_cpy_start) {
3232 inverse_region(scr, old_cpy_start,
3233 scr->cpy_start - 1);
3239 if (!ISSET(scr->mouse_flags, SEL_EXT_AFTER)) {
3241 scr->cursor = scr->mouse;
3242 inverse_char(scr, scr->cursor);
3250 mouse_copy_extend_line(struct wsscreen *scr)
3252 struct wsscreen_internal *dconf = scr->scr_dconf;
3258 if (!ISSET(scr->mouse_flags, SEL_EXT_AFTER)) {
3260 if (scr->cursor != scr->cpy_end + 1)
3261 inverse_char(scr, scr->cursor);
3264 if (scr->mouse < scr->orig_start &&
3265 scr->cpy_end >= scr->orig_start) {
3267 inverse_region(scr, scr->orig_end + 1, scr->cpy_end);
3268 scr->cpy_end = scr->orig_end;
3271 if (scr->mouse > scr->orig_end &&
3272 scr->cpy_start <= scr->orig_start) {
3274 inverse_region(scr, scr->cpy_start,
3275 scr->orig_start - 1);
3276 scr->cpy_start = scr->orig_start;
3280 if (scr->mouse >= scr->orig_start) {
3282 if (scr->cursor == scr->cpy_end + 1)
3283 scr->cursor = scr->cpy_end;
3284 old_row = scr->cursor / N_COLS(dconf);
3285 new_row = scr->mouse / N_COLS(dconf);
3286 old_cpy_end = scr->cpy_end;
3287 scr->cpy_end = new_row * N_COLS(dconf) + MAXCOL(dconf);
3289 inverse_region(scr, old_cpy_end + 1, scr->cpy_end);
3291 inverse_region(scr, scr->cpy_end + 1, old_cpy_end);
3294 old_row = scr->cursor / N_COLS(dconf);
3295 new_row = scr->mouse / N_COLS(dconf);
3296 old_cpy_start = scr->cpy_start;
3297 scr->cpy_start = new_row * N_COLS(dconf);
3299 inverse_region(scr, scr->cpy_start, old_cpy_start - 1);
3301 inverse_region(scr, old_cpy_start, scr->cpy_start - 1);
3304 if (!ISSET(scr->mouse_flags, SEL_EXT_AFTER)) {
3306 scr->cursor = scr->mouse;
3307 inverse_char(scr, scr->cursor);
3315 mouse_copy_extend_after(struct wsscreen *scr)
3320 if (ISSET(scr->mouse_flags, SEL_EXISTS)) {
3321 SET(scr->mouse_flags, SEL_EXT_AFTER);
3322 mouse_hide(scr); /* hide current cursor */
3324 if (scr->cpy_start > scr->mouse)
3325 start_dist = scr->cpy_start - scr->mouse;
3327 start_dist = scr->mouse - scr->cpy_start;
3328 if (scr->mouse > scr->cpy_end)
3329 end_dist = scr->mouse - scr->cpy_end;
3331 end_dist = scr->cpy_end - scr->mouse;
3334 scr->orig_start = scr->mouse + 1;
3336 scr->cursor = scr->cpy_start;
3339 scr->orig_start = scr->mouse;
3341 scr->cursor = scr->cpy_end;
3343 if (ISSET(scr->mouse_flags, SEL_BY_CHAR))
3344 mouse_copy_extend_char(scr);
3345 if (ISSET(scr->mouse_flags, SEL_BY_WORD))
3346 mouse_copy_extend_word(scr);
3347 if (ISSET(scr->mouse_flags, SEL_BY_LINE))
3348 mouse_copy_extend_line(scr);
3349 mouse_copy_selection(scr);
3354 mouse_hide(struct wsscreen *scr)
3356 if (ISSET(scr->mouse_flags, MOUSE_VISIBLE)) {
3357 inverse_char(scr, scr->mouse);
3358 CLR(scr->mouse_flags, MOUSE_VISIBLE);
3366 remove_selection(struct wsscreen *scr)
3368 if (ISSET(scr->mouse_flags, SEL_EXT_AFTER)) {
3370 CLR(scr->mouse_flags, SEL_EXT_AFTER);
3372 inverse_region(scr, scr->cpy_start, scr->cpy_end);
3373 CLR(scr->mouse_flags, SEL_IN_PROGRESS | SEL_EXISTS);
3380 mouse_copy_selection(struct wsscreen *scr)
3382 struct wsscreen_internal *dconf = scr->scr_dconf;
3390 sel_cur = scr->cpy_start;
3391 sel_end = scr->cpy_end;
3394 if (GETCHAR(scr, sel_cur, &cell) != 0)
3396 scr->sc->sc_copybuffer[current] = cell.uc;
3405 scr->sc->sc_copybuffer[blank] = '\r';
3411 scr->sc->sc_copybuffer[current] = '\0';
3418 mouse_paste(struct wsscreen *scr)
3420 char *current = scr->sc->sc_copybuffer;
3424 if (ISSET(scr->sc->sc_flags, SC_PASTE_AVAIL)) {
3425 if (!WSSCREEN_HAS_TTY(scr))
3428 tp = scr->scr_tty;
3429 for (len = strlen(scr->sc->sc_copybuffer); len != 0; len--)
3440 mouse_zaxis(struct wsscreen *scr, int z)
3443 wsscrollback(scr->sc, WSDISPLAY_SCROLL_BACKWARD);
3445 wsscrollback(scr->sc, WSDISPLAY_SCROLL_FORWARD);
3487 mouse_remove(struct wsscreen *scr)
3489 if (ISSET(scr->mouse_flags, SEL_EXISTS))
3490 remove_selection(scr);
3492 mouse_hide(scr);