diff options
| author | Eli Zaretskii | 2012-08-11 17:34:55 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2012-08-11 17:34:55 +0300 |
| commit | 141f1ff7a40cda10f0558e891dd196a943a5082e (patch) | |
| tree | 4a1fced77628527d37258b7dfb1970db9a91653c /src | |
| parent | b5e9cbb6fdce4b7e8c5cd6ad1addf6e4af35da67 (diff) | |
| download | emacs-141f1ff7a40cda10f0558e891dd196a943a5082e.tar.gz emacs-141f1ff7a40cda10f0558e891dd196a943a5082e.zip | |
Second commit; does not compile yet.
Finalized saving of current_matrix and restoring into desired_matrix.
Added margin areas, when non-empty, to save/restore.
Replaced ScreenRetreive and ScreenUpdate with the new functions based on
saving and restoring glyph matrices.
Started work on reading input via read_char while inside menu display.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispextern.h | 1 | ||||
| -rw-r--r-- | src/dispnew.c | 42 | ||||
| -rw-r--r-- | src/keyboard.c | 5 | ||||
| -rw-r--r-- | src/term.c | 193 | ||||
| -rw-r--r-- | src/xdisp.c | 4 |
5 files changed, 209 insertions, 36 deletions
diff --git a/src/dispextern.h b/src/dispextern.h index 65df553c831..9ffb1e5a67a 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -3302,6 +3302,7 @@ extern void adjust_glyphs (struct frame *); | |||
| 3302 | extern void free_glyphs (struct frame *); | 3302 | extern void free_glyphs (struct frame *); |
| 3303 | extern void free_window_matrices (struct window *); | 3303 | extern void free_window_matrices (struct window *); |
| 3304 | extern void check_glyph_memory (void); | 3304 | extern void check_glyph_memory (void); |
| 3305 | extern struct glyph_matrix *save_current_matrix (struct frame *); | ||
| 3305 | extern void mirrored_line_dance (struct glyph_matrix *, int, int, int *, | 3306 | extern void mirrored_line_dance (struct glyph_matrix *, int, int, int *, |
| 3306 | char *); | 3307 | char *); |
| 3307 | extern void clear_glyph_matrix (struct glyph_matrix *); | 3308 | extern void clear_glyph_matrix (struct glyph_matrix *); |
diff --git a/src/dispnew.c b/src/dispnew.c index 0c975124479..1cb30b84d6f 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -2040,7 +2040,7 @@ fake_current_matrices (Lisp_Object window) | |||
| 2040 | /* Save away the contents of frame F's current frame matrix. Value is | 2040 | /* Save away the contents of frame F's current frame matrix. Value is |
| 2041 | a glyph matrix holding the contents of F's current frame matrix. */ | 2041 | a glyph matrix holding the contents of F's current frame matrix. */ |
| 2042 | 2042 | ||
| 2043 | static struct glyph_matrix * | 2043 | struct glyph_matrix * |
| 2044 | save_current_matrix (struct frame *f) | 2044 | save_current_matrix (struct frame *f) |
| 2045 | { | 2045 | { |
| 2046 | int i; | 2046 | int i; |
| @@ -2058,9 +2058,26 @@ save_current_matrix (struct frame *f) | |||
| 2058 | struct glyph_row *from = f->current_matrix->rows + i; | 2058 | struct glyph_row *from = f->current_matrix->rows + i; |
| 2059 | struct glyph_row *to = saved->rows + i; | 2059 | struct glyph_row *to = saved->rows + i; |
| 2060 | ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); | 2060 | ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); |
| 2061 | |||
| 2061 | to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes); | 2062 | to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes); |
| 2062 | memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); | 2063 | memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); |
| 2063 | to->used[TEXT_AREA] = from->used[TEXT_AREA]; | 2064 | to->used[TEXT_AREA] = from->used[TEXT_AREA]; |
| 2065 | if (from->used[LEFT_MARGIN_AREA]) | ||
| 2066 | { | ||
| 2067 | nbytes = from->used[LEFT_MARGIN_AREA] * sizeof (struct glyph); | ||
| 2068 | to->glyphs[LEFT_MARGIN_AREA] = (struct glyph *) xmalloc (nbytes); | ||
| 2069 | memcpy (to->glyphs[LEFT_MARGIN_AREA], | ||
| 2070 | from->glyphs[LEFT_MARGIN_AREA], nbytes); | ||
| 2071 | to->used[LEFT_MARGIN_AREA] = from->used[LEFT_MARGIN_AREA]; | ||
| 2072 | } | ||
| 2073 | if (from->used[RIGHT_MARGIN_AREA]) | ||
| 2074 | { | ||
| 2075 | nbytes = from->used[RIGHT_MARGIN_AREA] * sizeof (struct glyph); | ||
| 2076 | to->glyphs[RIGHT_MARGIN_AREA] = (struct glyph *) xmalloc (nbytes); | ||
| 2077 | memcpy (to->glyphs[RIGHT_MARGIN_AREA], | ||
| 2078 | from->glyphs[RIGHT_MARGIN_AREA], nbytes); | ||
| 2079 | to->used[RIGHT_MARGIN_AREA] = from->used[RIGHT_MARGIN_AREA]; | ||
| 2080 | } | ||
| 2064 | } | 2081 | } |
| 2065 | 2082 | ||
| 2066 | return saved; | 2083 | return saved; |
| @@ -2080,9 +2097,30 @@ restore_current_matrix (struct frame *f, struct glyph_matrix *saved) | |||
| 2080 | struct glyph_row *from = saved->rows + i; | 2097 | struct glyph_row *from = saved->rows + i; |
| 2081 | struct glyph_row *to = f->current_matrix->rows + i; | 2098 | struct glyph_row *to = f->current_matrix->rows + i; |
| 2082 | ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); | 2099 | ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); |
| 2100 | |||
| 2083 | memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); | 2101 | memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); |
| 2084 | to->used[TEXT_AREA] = from->used[TEXT_AREA]; | 2102 | to->used[TEXT_AREA] = from->used[TEXT_AREA]; |
| 2085 | xfree (from->glyphs[TEXT_AREA]); | 2103 | xfree (from->glyphs[TEXT_AREA]); |
| 2104 | nbytes = from->used[LEFT_MARGIN_AREA]; | ||
| 2105 | if (nbytes) | ||
| 2106 | { | ||
| 2107 | memcpy (to->glyphs[LEFT_MARGIN_AREA], | ||
| 2108 | from->glyphs[LEFT_MARGIN_AREA], nbytes); | ||
| 2109 | to->used[LEFT_MARGIN_AREA] = from->used[LEFT_MARGIN_AREA]; | ||
| 2110 | xfree (from->glyphs[LEFT_MARGIN_AREA]); | ||
| 2111 | } | ||
| 2112 | else | ||
| 2113 | to->used[LEFT_MARGIN_AREA] = 0; | ||
| 2114 | nbytes = from->used[RIGHT_MARGIN_AREA]; | ||
| 2115 | if (nbytes) | ||
| 2116 | { | ||
| 2117 | memcpy (to->glyphs[RIGHT_MARGIN_AREA], | ||
| 2118 | from->glyphs[RIGHT_MARGIN_AREA], nbytes); | ||
| 2119 | to->used[RIGHT_MARGIN_AREA] = from->used[RIGHT_MARGIN_AREA]; | ||
| 2120 | xfree (from->glyphs[RIGHT_MARGIN_AREA]); | ||
| 2121 | } | ||
| 2122 | else | ||
| 2123 | to->used[RIGHT_MARGIN_AREA] = 0; | ||
| 2086 | } | 2124 | } |
| 2087 | 2125 | ||
| 2088 | xfree (saved->rows); | 2126 | xfree (saved->rows); |
| @@ -3355,6 +3393,8 @@ update_frame_with_menu (struct frame *f) | |||
| 3355 | 3393 | ||
| 3356 | /* Update the display */ | 3394 | /* Update the display */ |
| 3357 | update_begin (f); | 3395 | update_begin (f); |
| 3396 | /* Force update_frame_1 not to stop due to pending input, and not | ||
| 3397 | try scrolling. */ | ||
| 3358 | paused_p = update_frame_1 (f, 1, 1); | 3398 | paused_p = update_frame_1 (f, 1, 1); |
| 3359 | update_end (f); | 3399 | update_end (f); |
| 3360 | 3400 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 2642ad7734b..8df0006eeb8 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2249,6 +2249,7 @@ do { if (polling_stopped_here) start_polling (); \ | |||
| 2249 | /* read a character from the keyboard; call the redisplay if needed */ | 2249 | /* read a character from the keyboard; call the redisplay if needed */ |
| 2250 | /* commandflag 0 means do not autosave, but do redisplay. | 2250 | /* commandflag 0 means do not autosave, but do redisplay. |
| 2251 | -1 means do not redisplay, but do autosave. | 2251 | -1 means do not redisplay, but do autosave. |
| 2252 | -2 means do neither. | ||
| 2252 | 1 means do both. */ | 2253 | 1 means do both. */ |
| 2253 | 2254 | ||
| 2254 | /* The arguments MAPS and NMAPS are for menu prompting. | 2255 | /* The arguments MAPS and NMAPS are for menu prompting. |
| @@ -2630,7 +2631,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2630 | 2631 | ||
| 2631 | /* Maybe auto save due to number of keystrokes. */ | 2632 | /* Maybe auto save due to number of keystrokes. */ |
| 2632 | 2633 | ||
| 2633 | if (commandflag != 0 | 2634 | if (commandflag != 0 && commandflag != -2 |
| 2634 | && auto_save_interval > 0 | 2635 | && auto_save_interval > 0 |
| 2635 | && num_nonmacro_input_events - last_auto_save > max (auto_save_interval, 20) | 2636 | && num_nonmacro_input_events - last_auto_save > max (auto_save_interval, 20) |
| 2636 | && !detect_input_pending_run_timers (0)) | 2637 | && !detect_input_pending_run_timers (0)) |
| @@ -2683,7 +2684,7 @@ read_char (int commandflag, ptrdiff_t nmaps, Lisp_Object *maps, | |||
| 2683 | 9 at 200k, 11 at 300k, and 12 at 500k. It is 15 at 1 meg. */ | 2684 | 9 at 200k, 11 at 300k, and 12 at 500k. It is 15 at 1 meg. */ |
| 2684 | 2685 | ||
| 2685 | /* Auto save if enough time goes by without input. */ | 2686 | /* Auto save if enough time goes by without input. */ |
| 2686 | if (commandflag != 0 | 2687 | if (commandflag != 0 && commandflag != -2 |
| 2687 | && num_nonmacro_input_events > last_auto_save | 2688 | && num_nonmacro_input_events > last_auto_save |
| 2688 | && INTEGERP (Vauto_save_timeout) | 2689 | && INTEGERP (Vauto_save_timeout) |
| 2689 | && XINT (Vauto_save_timeout) > 0) | 2690 | && XINT (Vauto_save_timeout) > 0) |
diff --git a/src/term.c b/src/term.c index 188c476961b..bed0e8b4d1f 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2855,7 +2855,7 @@ DEFUN ("gpm-mouse-stop", Fgpm_mouse_stop, Sgpm_mouse_stop, | |||
| 2855 | contents when the menu selection changes or when the final | 2855 | contents when the menu selection changes or when the final |
| 2856 | selection is made and the menu should be popped down. | 2856 | selection is made and the menu should be popped down. |
| 2857 | 2857 | ||
| 2858 | The idea of this implementation was suggested by Gerd Moellmann. */ | 2858 | The idea of this implementation was suggested by Gerd Moellmann. */ |
| 2859 | 2859 | ||
| 2860 | #define TTYM_FAILURE -1 | 2860 | #define TTYM_FAILURE -1 |
| 2861 | #define TTYM_SUCCESS 1 | 2861 | #define TTYM_SUCCESS 1 |
| @@ -2963,15 +2963,6 @@ tty_menu_calc_size (tty_menu *menu, int *width, int *height) | |||
| 2963 | 2963 | ||
| 2964 | /* Display MENU at (X,Y) using FACES. */ | 2964 | /* Display MENU at (X,Y) using FACES. */ |
| 2965 | 2965 | ||
| 2966 | #define BUILD_CHAR_GLYPH(GLYPH, CODE, FACE_ID, PADDING_P) \ | ||
| 2967 | do \ | ||
| 2968 | { \ | ||
| 2969 | (GLYPH).type = CHAR_GLYPH; \ | ||
| 2970 | SET_CHAR_GLYPH ((GLYPH), CODE, FACE_ID, PADDING_P); \ | ||
| 2971 | (GLYPH).charpos = -1; \ | ||
| 2972 | } \ | ||
| 2973 | while (0) | ||
| 2974 | |||
| 2975 | static void | 2966 | static void |
| 2976 | tty_menu_display (tty_menu *menu, int y, int x, int pn, int *faces, | 2967 | tty_menu_display (tty_menu *menu, int y, int x, int pn, int *faces, |
| 2977 | int disp_help) | 2968 | int disp_help) |
| @@ -3125,15 +3116,143 @@ tty_menu_locate (tty_menu *menu, int x, int y, | |||
| 3125 | 3116 | ||
| 3126 | struct tty_menu_state | 3117 | struct tty_menu_state |
| 3127 | { | 3118 | { |
| 3128 | void *screen_behind; | 3119 | struct glyph_matrix *screen_behind; |
| 3129 | tty_menu *menu; | 3120 | tty_menu *menu; |
| 3130 | int pane; | 3121 | int pane; |
| 3131 | int x, y; | 3122 | int x, y; |
| 3132 | }; | 3123 | }; |
| 3133 | 3124 | ||
| 3125 | /* Restore the contents of frame F's desired frame matrix from SAVED, | ||
| 3126 | and free memory associated with SAVED. */ | ||
| 3134 | 3127 | ||
| 3135 | /* Display menu, wait for user's response, and return that response. */ | 3128 | static void |
| 3129 | restore_desired_matrix (struct frame *f, struct glyph_matrix *saved) | ||
| 3130 | { | ||
| 3131 | int i; | ||
| 3132 | |||
| 3133 | for (i = 0; i < saved->nrows; ++i) | ||
| 3134 | { | ||
| 3135 | struct glyph_row *from = saved->rows + i; | ||
| 3136 | struct glyph_row *to = f->desired_matrix->rows + i; | ||
| 3137 | ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); | ||
| 3138 | |||
| 3139 | memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); | ||
| 3140 | to->used[TEXT_AREA] = from->used[TEXT_AREA]; | ||
| 3141 | xfree (from->glyphs[TEXT_AREA]); | ||
| 3142 | nbytes = from->used[LEFT_MARGIN_AREA]; | ||
| 3143 | if (nbytes) | ||
| 3144 | { | ||
| 3145 | memcpy (to->glyphs[LEFT_MARGIN_AREA], | ||
| 3146 | from->glyphs[LEFT_MARGIN_AREA], nbytes); | ||
| 3147 | to->used[LEFT_MARGIN_AREA] = from->used[LEFT_MARGIN_AREA]; | ||
| 3148 | xfree (from->glyphs[LEFT_MARGIN_AREA]); | ||
| 3149 | } | ||
| 3150 | else | ||
| 3151 | to->used[LEFT_MARGIN_AREA] = 0; | ||
| 3152 | nbytes = from->used[RIGHT_MARGIN_AREA]; | ||
| 3153 | if (nbytes) | ||
| 3154 | { | ||
| 3155 | memcpy (to->glyphs[RIGHT_MARGIN_AREA], | ||
| 3156 | from->glyphs[RIGHT_MARGIN_AREA], nbytes); | ||
| 3157 | to->used[RIGHT_MARGIN_AREA] = from->used[RIGHT_MARGIN_AREA]; | ||
| 3158 | xfree (from->glyphs[RIGHT_MARGIN_AREA]); | ||
| 3159 | } | ||
| 3160 | else | ||
| 3161 | to->used[RIGHT_MARGIN_AREA] = 0; | ||
| 3162 | } | ||
| 3163 | |||
| 3164 | xfree (saved->rows); | ||
| 3165 | xfree (saved); | ||
| 3166 | } | ||
| 3167 | |||
| 3168 | static void | ||
| 3169 | free_saved_screen (struct glyph_matrix *saved) | ||
| 3170 | { | ||
| 3171 | int i; | ||
| 3172 | |||
| 3173 | if (!saved) | ||
| 3174 | return; /* already freed */ | ||
| 3175 | |||
| 3176 | for (i = 0; i < saved->nrows; ++i) | ||
| 3177 | { | ||
| 3178 | struct glyph_row *from = saved->rows + i; | ||
| 3179 | |||
| 3180 | xfree (from->glyphs[TEXT_AREA]); | ||
| 3181 | nbytes = from->used[LEFT_MARGIN_AREA]; | ||
| 3182 | if (nbytes) | ||
| 3183 | xfree (from->glyphs[LEFT_MARGIN_AREA]); | ||
| 3184 | nbytes = from->used[RIGHT_MARGIN_AREA]; | ||
| 3185 | if (nbytes) | ||
| 3186 | xfree (from->glyphs[RIGHT_MARGIN_AREA]); | ||
| 3187 | } | ||
| 3188 | |||
| 3189 | xfree (saved->rows); | ||
| 3190 | xfree (saved); | ||
| 3191 | } | ||
| 3192 | |||
| 3193 | /* Update the display of frame F from its saved contents. */ | ||
| 3194 | static void | ||
| 3195 | screen_update (struct frame *f, struct glyph_matrix *mtx) | ||
| 3196 | { | ||
| 3197 | restore_desired_matrix (f, mtx); | ||
| 3198 | update_frame_with_menu (f); | ||
| 3199 | } | ||
| 3136 | 3200 | ||
| 3201 | /* Read user input and return X and Y coordinates where that input | ||
| 3202 | puts us. We only consider mouse movement and click events and | ||
| 3203 | keyboard movement commands; the rest are ignored. */ | ||
| 3204 | static void | ||
| 3205 | read_menu_input (int *x, int *y) | ||
| 3206 | { | ||
| 3207 | Lisp_Object c; | ||
| 3208 | |||
| 3209 | while (1) | ||
| 3210 | { | ||
| 3211 | do { | ||
| 3212 | c = read_char (-2, 0, NULL, Qnil, NULL, NULL); | ||
| 3213 | } while (BUFFERP (c) || (INTEGERP (c) && XINT (c) == -2)); | ||
| 3214 | |||
| 3215 | if (INTEGERP (c)) | ||
| 3216 | { | ||
| 3217 | int ch = XINT (c); | ||
| 3218 | int usable_input = 1; | ||
| 3219 | |||
| 3220 | /* FIXME: Exceedingly primitive! Can we support arrow keys? */ | ||
| 3221 | switch (ch && ~CHAR_MODIFIER_MASK) | ||
| 3222 | { | ||
| 3223 | case 6: /* ^F */ | ||
| 3224 | *x += 1; | ||
| 3225 | break; | ||
| 3226 | case 2: /* ^B */ | ||
| 3227 | *x -= 1; | ||
| 3228 | break; | ||
| 3229 | case 14: /* ^N */ | ||
| 3230 | *y += 1; | ||
| 3231 | break; | ||
| 3232 | case 16: /* ^P */ | ||
| 3233 | *y -= 1; | ||
| 3234 | break; | ||
| 3235 | default: | ||
| 3236 | usable_input = 0; | ||
| 3237 | break; | ||
| 3238 | } | ||
| 3239 | if (usable_input) | ||
| 3240 | return; | ||
| 3241 | } | ||
| 3242 | |||
| 3243 | else if (EVENT_HAS_PARAMETERS (c)) | ||
| 3244 | { | ||
| 3245 | if (EQ (EVENT_HEAD (c), Qmouse_movement)) | ||
| 3246 | { | ||
| 3247 | } | ||
| 3248 | else if (EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_click)) | ||
| 3249 | { | ||
| 3250 | } | ||
| 3251 | } | ||
| 3252 | } | ||
| 3253 | } | ||
| 3254 | |||
| 3255 | /* Display menu, wait for user's response, and return that response. */ | ||
| 3137 | int | 3256 | int |
| 3138 | tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | 3257 | tty_menu_activate (tty_menu *menu, int *pane, int *selidx, |
| 3139 | int x0, int y0, char **txt, | 3258 | int x0, int y0, char **txt, |
| @@ -3153,11 +3272,11 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3153 | if (y0 <= 0) | 3272 | if (y0 <= 0) |
| 3154 | y0 = 1; | 3273 | y0 = 1; |
| 3155 | 3274 | ||
| 3156 | /* We will process all the mouse events directly, so we had | 3275 | /* We will process all the mouse events directly. */ |
| 3157 | better prevent dos_rawgetc from stealing them from us. */ | ||
| 3158 | mouse_preempted++; | 3276 | mouse_preempted++; |
| 3159 | 3277 | ||
| 3160 | state = alloca (menu->panecount * sizeof (struct tty_menu_state)); | 3278 | state = alloca (menu->panecount * sizeof (struct tty_menu_state)); |
| 3279 | memset (state, 0, sizeof (*state)); | ||
| 3161 | screensize = screen_size * 2; | 3280 | screensize = screen_size * 2; |
| 3162 | faces[0] | 3281 | faces[0] |
| 3163 | = lookup_derived_face (sf, intern ("tty-menu-disabled-face"), | 3282 | = lookup_derived_face (sf, intern ("tty-menu-disabled-face"), |
| @@ -3196,13 +3315,18 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3196 | before the call to message_with_string. */ | 3315 | before the call to message_with_string. */ |
| 3197 | saved_echo_area_message = Fcurrent_message (); | 3316 | saved_echo_area_message = Fcurrent_message (); |
| 3198 | #endif | 3317 | #endif |
| 3318 | /* Force update of the current frame, so that the desired and the | ||
| 3319 | current matrices are identical. */ | ||
| 3320 | update_frame_with_menu (sf); | ||
| 3199 | state[0].menu = menu; | 3321 | state[0].menu = menu; |
| 3200 | mouse_off (); /* FIXME */ | 3322 | mouse_off (); /* FIXME */ |
| 3201 | ScreenRetrieve (state[0].screen_behind = xmalloc (screensize)); /* FIXME */ | 3323 | state[0].screen_behind = save_current_matrix (sf); |
| 3202 | 3324 | ||
| 3203 | /* Turn off the cursor. Otherwise it shows through the menu | 3325 | /* Turn off the cursor. Otherwise it shows through the menu |
| 3204 | panes, which is ugly. */ | 3326 | panes, which is ugly. */ |
| 3205 | show_cursor (0); /* FIXME: need a new hook. */ | 3327 | #if 0 |
| 3328 | show_cursor (0); /* FIXME: need a new hook, for w32console. */ | ||
| 3329 | #endif | ||
| 3206 | 3330 | ||
| 3207 | /* Display the menu title. */ | 3331 | /* Display the menu title. */ |
| 3208 | tty_menu_display (menu, y0 - 1, x0 - 1, 1, title_faces, 0); | 3332 | tty_menu_display (menu, y0 - 1, x0 - 1, 1, title_faces, 0); |
| @@ -3221,17 +3345,18 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3221 | state[0].y = y0; | 3345 | state[0].y = y0; |
| 3222 | state[0].pane = onepane; | 3346 | state[0].pane = onepane; |
| 3223 | 3347 | ||
| 3224 | mouse_last_x = -1; /* A hack that forces display. */ | 3348 | x = state[0].x; |
| 3349 | y = state[0].y; | ||
| 3350 | |||
| 3225 | leave = 0; | 3351 | leave = 0; |
| 3226 | while (!leave) | 3352 | while (!leave) |
| 3227 | { | 3353 | { |
| 3228 | if (!mouse_visible) mouse_on (); | 3354 | if (!mouse_visible) mouse_on (); |
| 3229 | mouse_check_moved (); | 3355 | read_menu_input (&x, &y); |
| 3230 | if (sf->mouse_moved) | 3356 | if (sf->mouse_moved) |
| 3231 | { | 3357 | { |
| 3232 | sf->mouse_moved = 0; | 3358 | sf->mouse_moved = 0; |
| 3233 | result = TTYM_IA_SELECT; | 3359 | result = TTYM_IA_SELECT; |
| 3234 | mouse_get_xy (&x, &y); | ||
| 3235 | for (i = 0; i < statecount; i++) | 3360 | for (i = 0; i < statecount; i++) |
| 3236 | if (state[i].x <= x && x < state[i].x + state[i].menu->width + 2) | 3361 | if (state[i].x <= x && x < state[i].x + state[i].menu->width + 2) |
| 3237 | { | 3362 | { |
| @@ -3255,9 +3380,9 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3255 | while (i != statecount - 1) | 3380 | while (i != statecount - 1) |
| 3256 | { | 3381 | { |
| 3257 | statecount--; | 3382 | statecount--; |
| 3258 | mouse_off (); | 3383 | mouse_off (); /* FIXME */ |
| 3259 | ScreenUpdate (state[statecount].screen_behind); | 3384 | screen_update (state[statecount].screen_behind); |
| 3260 | xfree (state[statecount].screen_behind); | 3385 | state[statecount].screen_behind = NULL; |
| 3261 | } | 3386 | } |
| 3262 | if (i == statecount - 1 && state[i].menu->submenu[dy]) | 3387 | if (i == statecount - 1 && state[i].menu->submenu[dy]) |
| 3263 | { | 3388 | { |
| @@ -3268,9 +3393,9 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3268 | faces, 1); | 3393 | faces, 1); |
| 3269 | state[statecount].menu = state[i].menu->submenu[dy]; | 3394 | state[statecount].menu = state[i].menu->submenu[dy]; |
| 3270 | state[statecount].pane = state[i].menu->panenumber[dy]; | 3395 | state[statecount].pane = state[i].menu->panenumber[dy]; |
| 3271 | mouse_off (); | 3396 | mouse_off (); /* FIXME */ |
| 3272 | ScreenRetrieve (state[statecount].screen_behind | 3397 | state[statecount].screen_behind |
| 3273 | = xmalloc (screensize)); | 3398 | = save_current_matrix (sf); |
| 3274 | state[statecount].x | 3399 | state[statecount].x |
| 3275 | = state[i].x + state[i].menu->width + 2; | 3400 | = state[i].x + state[i].menu->width + 2; |
| 3276 | state[statecount].y = y; | 3401 | state[statecount].y = y; |
| @@ -3291,12 +3416,14 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3291 | { | 3416 | { |
| 3292 | help_callback (menu_help_message, | 3417 | help_callback (menu_help_message, |
| 3293 | menu_help_paneno, menu_help_itemno); | 3418 | menu_help_paneno, menu_help_itemno); |
| 3294 | show_cursor (0); | 3419 | #if 0 |
| 3420 | show_cursor (0); /* FIXME */ | ||
| 3421 | #endif | ||
| 3295 | prev_menu_help_message = menu_help_message; | 3422 | prev_menu_help_message = menu_help_message; |
| 3296 | } | 3423 | } |
| 3297 | /* We are busy-waiting for the mouse to move, so let's be nice | 3424 | /* We are busy-waiting for the mouse to move, so let's be nice |
| 3298 | to other Windows applications by releasing our time slice. */ | 3425 | to other Windows applications by releasing our time slice. */ |
| 3299 | __dpmi_yield (); | 3426 | Sleep (20); /* FIXME */ |
| 3300 | } | 3427 | } |
| 3301 | for (b = 0; b < mouse_button_count && !leave; b++) | 3428 | for (b = 0; b < mouse_button_count && !leave; b++) |
| 3302 | { | 3429 | { |
| @@ -3306,16 +3433,16 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3306 | if (mouse_pressed (b, &x, &y)) | 3433 | if (mouse_pressed (b, &x, &y)) |
| 3307 | { | 3434 | { |
| 3308 | while (mouse_button_depressed (b, &x, &y)) | 3435 | while (mouse_button_depressed (b, &x, &y)) |
| 3309 | __dpmi_yield (); | 3436 | Sleep (20); /* FIXME */ |
| 3310 | leave = 1; | 3437 | leave = 1; |
| 3311 | } | 3438 | } |
| 3312 | (void) mouse_released (b, &x, &y); | 3439 | (void) mouse_released (b, &x, &y); |
| 3313 | } | 3440 | } |
| 3314 | } | 3441 | } |
| 3315 | 3442 | ||
| 3316 | mouse_off (); | 3443 | mouse_off (); /* FIXME */ |
| 3317 | ScreenUpdate (state[0].screen_behind); | 3444 | screen_update (sf, state[0].screen_behind); |
| 3318 | 3445 | state[0].screen_behind = NULL; | |
| 3319 | #if 0 | 3446 | #if 0 |
| 3320 | /* We have a situation here. ScreenUpdate has just restored the | 3447 | /* We have a situation here. ScreenUpdate has just restored the |
| 3321 | screen contents as it was before we started drawing this menu. | 3448 | screen contents as it was before we started drawing this menu. |
| @@ -3339,8 +3466,10 @@ tty_menu_activate (tty_menu *menu, int *pane, int *selidx, | |||
| 3339 | message (0); | 3466 | message (0); |
| 3340 | #endif | 3467 | #endif |
| 3341 | while (statecount--) | 3468 | while (statecount--) |
| 3342 | xfree (state[statecount].screen_behind); | 3469 | free_saved_screen (state[statecount].screen_behind); |
| 3470 | #if 0 | ||
| 3343 | show_cursor (1); /* turn cursor back on */ | 3471 | show_cursor (1); /* turn cursor back on */ |
| 3472 | #endif | ||
| 3344 | /* Clean up any mouse events that are waiting inside Emacs event queue. | 3473 | /* Clean up any mouse events that are waiting inside Emacs event queue. |
| 3345 | These events are likely to be generated before the menu was even | 3474 | These events are likely to be generated before the menu was even |
| 3346 | displayed, probably because the user pressed and released the button | 3475 | displayed, probably because the user pressed and released the button |
diff --git a/src/xdisp.c b/src/xdisp.c index 52163db7456..e584a1c9b03 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -19988,7 +19988,7 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y, | |||
| 19988 | { | 19988 | { |
| 19989 | struct it it; | 19989 | struct it it; |
| 19990 | struct frame *f = SELECTED_FRAME (); | 19990 | struct frame *f = SELECTED_FRAME (); |
| 19991 | int saved_used, saved_truncated; | 19991 | int saved_used, saved_truncated, saved_width; |
| 19992 | struct glyph_row *row; | 19992 | struct glyph_row *row; |
| 19993 | 19993 | ||
| 19994 | xassert (FRAME_TERMCAP_P (f)); | 19994 | xassert (FRAME_TERMCAP_P (f)); |
| @@ -19997,6 +19997,7 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y, | |||
| 19997 | it.first_visible_x = 0; | 19997 | it.first_visible_x = 0; |
| 19998 | it.last_visible_x = FRAME_COLS (f); | 19998 | it.last_visible_x = FRAME_COLS (f); |
| 19999 | row = it.glyph_row; | 19999 | row = it.glyph_row; |
| 20000 | saved_width = row->full_width_p; | ||
| 20000 | row->full_width_p = 1; | 20001 | row->full_width_p = 1; |
| 20001 | 20002 | ||
| 20002 | /* Arrange for the menu item glyphs to start at X and have the | 20003 | /* Arrange for the menu item glyphs to start at X and have the |
| @@ -20031,6 +20032,7 @@ display_tty_menu_item (const char *item_text, int face_id, int x, int y, | |||
| 20031 | row->used[TEXT_AREA] = saved_used; | 20032 | row->used[TEXT_AREA] = saved_used; |
| 20032 | row->truncated_on_right_p = saved_truncated; | 20033 | row->truncated_on_right_p = saved_truncated; |
| 20033 | row->hash - row_hash (row); | 20034 | row->hash - row_hash (row); |
| 20035 | row->full_width_p = saved_width; | ||
| 20034 | } | 20036 | } |
| 20035 | #endif /* HAVE_MENUS */ | 20037 | #endif /* HAVE_MENUS */ |
| 20036 | 20038 | ||