comparison src/msdos.c @ 27462:a4cddf1245d7

(IT_clear_end_of_line): Print the extent of the cleared part of the line to the termscript file. (IT_clear_to_end): Clear the entire line, not just its beginning. (menu_help_message, prev_menu_help_message): New variables. (IT_menu_make_room): Make room for the help_text member. (IT_menu_display): New argument disp_help; all callers changed. If disp_help is non-zero, store the help text of the active menu item in menu_help_message. (XMenuAddPane): Initialize the help_text member to NULL. (XMenuAddSelection): New argument help_text. Store it in the XMenu structure. (XMenuActivate): New argument help_callback. If the value of menu_help_message has changed since the last time, display the menu help message text while waiting for the mouse to move. Clear the echo area before exiting. (XMenuDestroy): Free the help_text member.
author Eli Zaretskii <eliz@gnu.org>
date Thu, 27 Jan 2000 17:07:27 +0000
parents 4df4f3866b55
children 4ce3be69ca1f
comparison
equal deleted inserted replaced
27461:9de1087abd5a 27462:a4cddf1245d7
1511 1511
1512 if (new_pos_X >= first_unused || fatal_error_in_progress) 1512 if (new_pos_X >= first_unused || fatal_error_in_progress)
1513 return; 1513 return;
1514 1514
1515 IT_set_face (0); 1515 IT_set_face (0);
1516 i = (j = first_unused - new_pos_X) * 2;
1516 if (termscript) 1517 if (termscript)
1517 fprintf (termscript, "<CLR:EOL>"); 1518 fprintf (termscript, "<CLR:EOL[%d..%d)>", new_pos_X, first_unused);
1518 i = (j = first_unused - new_pos_X) * 2;
1519 spaces = sp = alloca (i); 1519 spaces = sp = alloca (i);
1520 1520
1521 while (--j >= 0) 1521 while (--j >= 0)
1522 { 1522 {
1523 *sp++ = ' '; 1523 *sp++ = ' ';
1553 if (termscript) 1553 if (termscript)
1554 fprintf (termscript, "<CLR:EOS>"); 1554 fprintf (termscript, "<CLR:EOS>");
1555 1555
1556 while (new_pos_Y < screen_size_Y) { 1556 while (new_pos_Y < screen_size_Y) {
1557 new_pos_X = 0; 1557 new_pos_X = 0;
1558 IT_clear_end_of_line (0); 1558 IT_clear_end_of_line (screen_size_X);
1559 new_pos_Y++; 1559 new_pos_Y++;
1560 } 1560 }
1561 } 1561 }
1562 1562
1563 static void 1563 static void
3170 Actually, I don't know the meaning of all the parameters of the functions 3170 Actually, I don't know the meaning of all the parameters of the functions
3171 here -- I only know how they are called by xmenu.c. I could of course 3171 here -- I only know how they are called by xmenu.c. I could of course
3172 grab the nearest Xlib manual (down the hall, second-to-last door on the 3172 grab the nearest Xlib manual (down the hall, second-to-last door on the
3173 left), but I don't think it's worth the effort. */ 3173 left), but I don't think it's worth the effort. */
3174 3174
3175 static char *menu_help_message, *prev_menu_help_message;
3176
3175 static XMenu * 3177 static XMenu *
3176 IT_menu_create () 3178 IT_menu_create ()
3177 { 3179 {
3178 XMenu *menu; 3180 XMenu *menu;
3179 3181
3192 { 3194 {
3193 int count = menu->allocated = 10; 3195 int count = menu->allocated = 10;
3194 menu->text = (char **) xmalloc (count * sizeof (char *)); 3196 menu->text = (char **) xmalloc (count * sizeof (char *));
3195 menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *)); 3197 menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *));
3196 menu->panenumber = (int *) xmalloc (count * sizeof (int)); 3198 menu->panenumber = (int *) xmalloc (count * sizeof (int));
3199 menu->help_text = (char **) xmalloc (count * sizeof (char *));
3197 } 3200 }
3198 else if (menu->allocated == menu->count) 3201 else if (menu->allocated == menu->count)
3199 { 3202 {
3200 int count = menu->allocated = menu->allocated + 10; 3203 int count = menu->allocated = menu->allocated + 10;
3201 menu->text 3204 menu->text
3202 = (char **) xrealloc (menu->text, count * sizeof (char *)); 3205 = (char **) xrealloc (menu->text, count * sizeof (char *));
3203 menu->submenu 3206 menu->submenu
3204 = (XMenu **) xrealloc (menu->submenu, count * sizeof (XMenu *)); 3207 = (XMenu **) xrealloc (menu->submenu, count * sizeof (XMenu *));
3205 menu->panenumber 3208 menu->panenumber
3206 = (int *) xrealloc (menu->panenumber, count * sizeof (int)); 3209 = (int *) xrealloc (menu->panenumber, count * sizeof (int));
3210 menu->help_text
3211 = (char **) xrealloc (menu->help_text, count * sizeof (char *));
3207 } 3212 }
3208 } 3213 }
3209 3214
3210 /* Search the given menu structure for a given pane number. */ 3215 /* Search the given menu structure for a given pane number. */
3211 3216
3249 } 3254 }
3250 3255
3251 /* Display MENU at (X,Y) using FACES. */ 3256 /* Display MENU at (X,Y) using FACES. */
3252 3257
3253 static void 3258 static void
3254 IT_menu_display (XMenu *menu, int y, int x, int *faces) 3259 IT_menu_display (XMenu *menu, int y, int x, int *faces, int disp_help)
3255 { 3260 {
3256 int i, j, face, width; 3261 int i, j, face, width;
3257 struct glyph *text, *p; 3262 struct glyph *text, *p;
3258 char *q; 3263 char *q;
3259 int mx, my; 3264 int mx, my;
3260 int enabled, mousehere; 3265 int enabled, mousehere;
3261 int row, col; 3266 int row, col;
3262 struct frame *sf = SELECTED_FRAME(); 3267 struct frame *sf = SELECTED_FRAME();
3263 3268
3269 menu_help_message = NULL;
3270
3264 width = menu->width; 3271 width = menu->width;
3265 text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph)); 3272 text = (struct glyph *) xmalloc ((width + 2) * sizeof (struct glyph));
3266 ScreenGetCursor (&row, &col); 3273 ScreenGetCursor (&row, &col);
3267 mouse_get_xy (&mx, &my); 3274 mouse_get_xy (&mx, &my);
3268 IT_update_begin (sf); 3275 IT_update_begin (sf);
3273 IT_cursor_to (y + i, x); 3280 IT_cursor_to (y + i, x);
3274 enabled 3281 enabled
3275 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]); 3282 = (!menu->submenu[i] && menu->panenumber[i]) || (menu->submenu[i]);
3276 mousehere = (y + i == my && x <= mx && mx < x + width + 2); 3283 mousehere = (y + i == my && x <= mx && mx < x + width + 2);
3277 face = faces[enabled + mousehere * 2]; 3284 face = faces[enabled + mousehere * 2];
3285 if (disp_help && enabled + mousehere * 2 >= 2)
3286 menu_help_message = menu->help_text[i];
3278 p = text; 3287 p = text;
3279 SET_CHAR_GLYPH (*p, ' ', face, 0); 3288 SET_CHAR_GLYPH (*p, ' ', face, 0);
3280 p++; 3289 p++;
3281 for (j = 0, q = menu->text[i]; *q; j++) 3290 for (j = 0, q = menu->text[i]; *q; j++)
3282 { 3291 {
3345 3354
3346 IT_menu_make_room (menu); 3355 IT_menu_make_room (menu);
3347 menu->submenu[menu->count] = IT_menu_create (); 3356 menu->submenu[menu->count] = IT_menu_create ();
3348 menu->text[menu->count] = txt; 3357 menu->text[menu->count] = txt;
3349 menu->panenumber[menu->count] = ++menu->panecount; 3358 menu->panenumber[menu->count] = ++menu->panecount;
3359 menu->help_text[menu->count] = NULL;
3350 menu->count++; 3360 menu->count++;
3351 3361
3352 /* Adjust length for possible control characters (which will 3362 /* Adjust length for possible control characters (which will
3353 be written as ^x). */ 3363 be written as ^x). */
3354 for (len = strlen (txt), p = txt; *p; p++) 3364 for (len = strlen (txt), p = txt; *p; p++)
3363 3373
3364 /* Create a new item in a menu pane. */ 3374 /* Create a new item in a menu pane. */
3365 3375
3366 int 3376 int
3367 XMenuAddSelection (Display *bar, XMenu *menu, int pane, 3377 XMenuAddSelection (Display *bar, XMenu *menu, int pane,
3368 int foo, char *txt, int enable) 3378 int foo, char *txt, int enable, char *help_text)
3369 { 3379 {
3370 int len; 3380 int len;
3371 char *p; 3381 char *p;
3372 3382
3373 if (pane) 3383 if (pane)
3375 return XM_FAILURE; 3385 return XM_FAILURE;
3376 IT_menu_make_room (menu); 3386 IT_menu_make_room (menu);
3377 menu->submenu[menu->count] = (XMenu *) 0; 3387 menu->submenu[menu->count] = (XMenu *) 0;
3378 menu->text[menu->count] = txt; 3388 menu->text[menu->count] = txt;
3379 menu->panenumber[menu->count] = enable; 3389 menu->panenumber[menu->count] = enable;
3390 menu->help_text[menu->count] = help_text;
3380 menu->count++; 3391 menu->count++;
3381 3392
3382 /* Adjust length for possible control characters (which will 3393 /* Adjust length for possible control characters (which will
3383 be written as ^x). */ 3394 be written as ^x). */
3384 for (len = strlen (txt), p = txt; *p; p++) 3395 for (len = strlen (txt), p = txt; *p; p++)
3414 3425
3415 /* Display menu, wait for user's response, and return that response. */ 3426 /* Display menu, wait for user's response, and return that response. */
3416 3427
3417 int 3428 int
3418 XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx, 3429 XMenuActivate (Display *foo, XMenu *menu, int *pane, int *selidx,
3419 int x0, int y0, unsigned ButtonMask, char **txt) 3430 int x0, int y0, unsigned ButtonMask, char **txt,
3431 void (*help_callback)(char *))
3420 { 3432 {
3421 struct IT_menu_state *state; 3433 struct IT_menu_state *state;
3422 int statecount; 3434 int statecount;
3423 int x, y, i, b; 3435 int x, y, i, b;
3424 int screensize; 3436 int screensize;
3481 3493
3482 /* Turn off the cursor. Otherwise it shows through the menu 3494 /* Turn off the cursor. Otherwise it shows through the menu
3483 panes, which is ugly. */ 3495 panes, which is ugly. */
3484 IT_display_cursor (0); 3496 IT_display_cursor (0);
3485 3497
3486 IT_menu_display (menu, y0 - 1, x0 - 1, title_faces); /* display menu title */ 3498 /* Display the menu title. */
3499 IT_menu_display (menu, y0 - 1, x0 - 1, title_faces, 0);
3487 if (buffers_num_deleted) 3500 if (buffers_num_deleted)
3488 menu->text[0][7] = ' '; 3501 menu->text[0][7] = ' ';
3489 if ((onepane = menu->count == 1 && menu->submenu[0])) 3502 if ((onepane = menu->count == 1 && menu->submenu[0]))
3490 { 3503 {
3491 menu->width = menu->submenu[0]->width; 3504 menu->width = menu->submenu[0]->width;
3540 if (i == statecount - 1 && state[i].menu->submenu[dy]) 3553 if (i == statecount - 1 && state[i].menu->submenu[dy])
3541 { 3554 {
3542 IT_menu_display (state[i].menu, 3555 IT_menu_display (state[i].menu,
3543 state[i].y, 3556 state[i].y,
3544 state[i].x, 3557 state[i].x,
3545 faces); 3558 faces, 1);
3546 state[statecount].menu = state[i].menu->submenu[dy]; 3559 state[statecount].menu = state[i].menu->submenu[dy];
3547 state[statecount].pane = state[i].menu->panenumber[dy]; 3560 state[statecount].pane = state[i].menu->panenumber[dy];
3548 mouse_off (); 3561 mouse_off ();
3549 ScreenRetrieve (state[statecount].screen_behind 3562 ScreenRetrieve (state[statecount].screen_behind
3550 = xmalloc (screensize)); 3563 = xmalloc (screensize));
3556 } 3569 }
3557 } 3570 }
3558 IT_menu_display (state[statecount - 1].menu, 3571 IT_menu_display (state[statecount - 1].menu,
3559 state[statecount - 1].y, 3572 state[statecount - 1].y,
3560 state[statecount - 1].x, 3573 state[statecount - 1].x,
3561 faces); 3574 faces, 1);
3562 } 3575 }
3563 else 3576 else
3564 /* We are busy-waiting for the mouse to move, so let's be nice 3577 {
3565 to other Windows applications by releasing our time slice. */ 3578 if ((menu_help_message || prev_menu_help_message)
3566 __dpmi_yield (); 3579 && menu_help_message != prev_menu_help_message)
3580 {
3581 help_callback (menu_help_message);
3582 prev_menu_help_message = menu_help_message;
3583 }
3584 /* We are busy-waiting for the mouse to move, so let's be nice
3585 to other Windows applications by releasing our time slice. */
3586 __dpmi_yield ();
3587 }
3567 for (b = 0; b < mouse_button_count && !leave; b++) 3588 for (b = 0; b < mouse_button_count && !leave; b++)
3568 { 3589 {
3569 /* Only leave if user both pressed and released the mouse, and in 3590 /* Only leave if user both pressed and released the mouse, and in
3570 that order. This avoids popping down the menu pane unless 3591 that order. This avoids popping down the menu pane unless
3571 the user is really done with it. */ 3592 the user is really done with it. */
3581 3602
3582 mouse_off (); 3603 mouse_off ();
3583 ScreenUpdate (state[0].screen_behind); 3604 ScreenUpdate (state[0].screen_behind);
3584 if (screen_virtual_segment) 3605 if (screen_virtual_segment)
3585 dosv_refresh_virtual_screen (0, screen_size); 3606 dosv_refresh_virtual_screen (0, screen_size);
3607 message (0);
3586 while (statecount--) 3608 while (statecount--)
3587 xfree (state[statecount].screen_behind); 3609 xfree (state[statecount].screen_behind);
3588 IT_display_cursor (1); /* turn cursor back on */ 3610 IT_display_cursor (1); /* turn cursor back on */
3589 /* Clean up any mouse events that are waiting inside Emacs event queue. 3611 /* Clean up any mouse events that are waiting inside Emacs event queue.
3590 These events are likely to be generated before the menu was even 3612 These events are likely to be generated before the menu was even
3609 if (menu->submenu[i]) 3631 if (menu->submenu[i])
3610 XMenuDestroy (foo, menu->submenu[i]); 3632 XMenuDestroy (foo, menu->submenu[i]);
3611 xfree (menu->text); 3633 xfree (menu->text);
3612 xfree (menu->submenu); 3634 xfree (menu->submenu);
3613 xfree (menu->panenumber); 3635 xfree (menu->panenumber);
3636 xfree (menu->help_text);
3614 } 3637 }
3615 xfree (menu); 3638 xfree (menu);
3639 menu_help_message = prev_menu_help_message = NULL;
3616 } 3640 }
3617 3641
3618 int 3642 int
3619 x_pixel_width (struct frame *f) 3643 x_pixel_width (struct frame *f)
3620 { 3644 {