comparison src/gui.c @ 203:80000fb16feb

updated for version 7.0060
author vimboss
date Tue, 15 Mar 2005 22:34:55 +0000
parents 3b32f6b507fa
children da182deebec7
comparison
equal deleted inserted replaced
202:b6450bf509d8 203:80000fb16feb
27 static void gui_insert_lines __ARGS((int row, int count)); 27 static void gui_insert_lines __ARGS((int row, int count));
28 static void fill_mouse_coord __ARGS((char_u *p, int col, int row)); 28 static void fill_mouse_coord __ARGS((char_u *p, int col, int row));
29 static void gui_do_scrollbar __ARGS((win_T *wp, int which, int enable)); 29 static void gui_do_scrollbar __ARGS((win_T *wp, int which, int enable));
30 static colnr_T scroll_line_len __ARGS((linenr_T lnum)); 30 static colnr_T scroll_line_len __ARGS((linenr_T lnum));
31 static void gui_update_horiz_scrollbar __ARGS((int)); 31 static void gui_update_horiz_scrollbar __ARGS((int));
32 static void gui_set_fg_color __ARGS((char_u *name));
33 static void gui_set_bg_color __ARGS((char_u *name));
32 static win_T *xy2win __ARGS((int x, int y)); 34 static win_T *xy2win __ARGS((int x, int y));
33 35
34 static int can_update_cursor = TRUE; /* can display the cursor */ 36 static int can_update_cursor = TRUE; /* can display the cursor */
35 37
36 /* 38 /*
1939 { 1941 {
1940 long_u highlight_mask; 1942 long_u highlight_mask;
1941 long_u hl_mask_todo; 1943 long_u hl_mask_todo;
1942 guicolor_T fg_color; 1944 guicolor_T fg_color;
1943 guicolor_T bg_color; 1945 guicolor_T bg_color;
1946 guicolor_T sp_color;
1944 #if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2) && !defined(FEAT_GUI_KDE) 1947 #if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2) && !defined(FEAT_GUI_KDE)
1945 GuiFont font = NOFONT; 1948 GuiFont font = NOFONT;
1946 # ifdef FEAT_XFONTSET 1949 # ifdef FEAT_XFONTSET
1947 GuiFontset fontset = NOFONTSET; 1950 GuiFontset fontset = NOFONTSET;
1948 # endif 1951 # endif
2048 if ((flags & GUI_MON_IS_CURSOR) && gui.in_focus) 2051 if ((flags & GUI_MON_IS_CURSOR) && gui.in_focus)
2049 { 2052 {
2050 draw_flags |= DRAW_CURSOR; 2053 draw_flags |= DRAW_CURSOR;
2051 fg_color = fg; 2054 fg_color = fg;
2052 bg_color = bg; 2055 bg_color = bg;
2056 sp_color = fg;
2053 } 2057 }
2054 else if (aep != NULL) 2058 else if (aep != NULL)
2055 { 2059 {
2056 fg_color = aep->ae_u.gui.fg_color; 2060 fg_color = aep->ae_u.gui.fg_color;
2057 if (fg_color == INVALCOLOR) 2061 if (fg_color == INVALCOLOR)
2058 fg_color = gui.norm_pixel; 2062 fg_color = gui.norm_pixel;
2059 bg_color = aep->ae_u.gui.bg_color; 2063 bg_color = aep->ae_u.gui.bg_color;
2060 if (bg_color == INVALCOLOR) 2064 if (bg_color == INVALCOLOR)
2061 bg_color = gui.back_pixel; 2065 bg_color = gui.back_pixel;
2066 sp_color = aep->ae_u.gui.sp_color;
2067 if (sp_color == INVALCOLOR)
2068 sp_color = fg_color;
2062 } 2069 }
2063 else 2070 else
2071 {
2064 fg_color = gui.norm_pixel; 2072 fg_color = gui.norm_pixel;
2073 sp_color = fg_color;
2074 }
2065 2075
2066 if (highlight_mask & (HL_INVERSE | HL_STANDOUT)) 2076 if (highlight_mask & (HL_INVERSE | HL_STANDOUT))
2067 { 2077 {
2068 #if defined(AMIGA) || defined(RISCOS) 2078 #if defined(AMIGA) || defined(RISCOS)
2069 gui_mch_set_colors(bg_color, fg_color); 2079 gui_mch_set_colors(bg_color, fg_color);
2079 #else 2089 #else
2080 gui_mch_set_fg_color(fg_color); 2090 gui_mch_set_fg_color(fg_color);
2081 gui_mch_set_bg_color(bg_color); 2091 gui_mch_set_bg_color(bg_color);
2082 #endif 2092 #endif
2083 } 2093 }
2094 gui_mch_set_sp_color(sp_color);
2084 2095
2085 /* Clear the selection if we are about to write over it */ 2096 /* Clear the selection if we are about to write over it */
2086 if (!(flags & GUI_MON_NOCLEAR)) 2097 if (!(flags & GUI_MON_NOCLEAR))
2087 clip_may_clear_selection(gui.row, gui.row); 2098 clip_may_clear_selection(gui.row, gui.row);
2088 2099
2117 || (hl_mask_todo & HL_ITALIC) 2128 || (hl_mask_todo & HL_ITALIC)
2118 # endif 2129 # endif
2119 ) 2130 )
2120 draw_flags |= DRAW_UNDERL; 2131 draw_flags |= DRAW_UNDERL;
2121 #endif 2132 #endif
2133 /* Do we undercurl the text? */
2134 if (hl_mask_todo & HL_UNDERCURL)
2135 draw_flags |= DRAW_UNDERC;
2122 2136
2123 /* Do we draw transparantly? */ 2137 /* Do we draw transparantly? */
2124 if (flags & GUI_MON_TRS_CURSOR) 2138 if (flags & GUI_MON_TRS_CURSOR)
2125 draw_flags |= DRAW_TRANSP; 2139 draw_flags |= DRAW_TRANSP;
2126 2140
2362 int flags; /* flags for gui_outstr_nowrap() */ 2376 int flags; /* flags for gui_outstr_nowrap() */
2363 { 2377 {
2364 int old_row, old_col; 2378 int old_row, old_col;
2365 long_u old_hl_mask; 2379 long_u old_hl_mask;
2366 int off; 2380 int off;
2367 char_u first_attr; 2381 sattr_T first_attr;
2368 int idx, len; 2382 int idx, len;
2369 int back, nback; 2383 int back, nback;
2370 int retval = FALSE; 2384 int retval = FALSE;
2371 #ifdef FEAT_MBYTE 2385 #ifdef FEAT_MBYTE
2372 int orig_col1, orig_col2; 2386 int orig_col1, orig_col2;
2586 int 2600 int
2587 gui_wait_for_chars(wtime) 2601 gui_wait_for_chars(wtime)
2588 long wtime; 2602 long wtime;
2589 { 2603 {
2590 int retval; 2604 int retval;
2591 #ifdef FEAT_AUTOCMD
2592 static int once_already = 0;
2593 #endif
2594 2605
2595 /* 2606 /*
2596 * If we're going to wait a bit, update the menus and mouse shape for the 2607 * If we're going to wait a bit, update the menus and mouse shape for the
2597 * current State. 2608 * current State.
2598 */ 2609 */
2603 #endif 2614 #endif
2604 } 2615 }
2605 2616
2606 gui_mch_update(); 2617 gui_mch_update();
2607 if (input_available()) /* Got char, return immediately */ 2618 if (input_available()) /* Got char, return immediately */
2608 {
2609 #ifdef FEAT_AUTOCMD
2610 once_already = 0;
2611 #endif
2612 return OK; 2619 return OK;
2613 }
2614 if (wtime == 0) /* Don't wait for char */ 2620 if (wtime == 0) /* Don't wait for char */
2615 {
2616 #ifdef FEAT_AUTOCMD
2617 once_already = 0;
2618 #endif
2619 return FAIL; 2621 return FAIL;
2620 }
2621 2622
2622 /* Before waiting, flush any output to the screen. */ 2623 /* Before waiting, flush any output to the screen. */
2623 gui_mch_flush(); 2624 gui_mch_flush();
2624 2625
2625 if (wtime > 0) 2626 if (wtime > 0)
2627 /* Blink when waiting for a character. Probably only does something 2628 /* Blink when waiting for a character. Probably only does something
2628 * for showmatch() */ 2629 * for showmatch() */
2629 gui_mch_start_blink(); 2630 gui_mch_start_blink();
2630 retval = gui_mch_wait_for_chars(wtime); 2631 retval = gui_mch_wait_for_chars(wtime);
2631 gui_mch_stop_blink(); 2632 gui_mch_stop_blink();
2632 #ifdef FEAT_AUTOCMD
2633 once_already = 0;
2634 #endif
2635 return retval; 2633 return retval;
2636 } 2634 }
2637 2635
2638 /* 2636 /*
2639 * While we are waiting indefenitely for a character, blink the cursor. 2637 * While we are waiting indefenitely for a character, blink the cursor.
2640 */ 2638 */
2641 gui_mch_start_blink(); 2639 gui_mch_start_blink();
2642 2640
2643 2641 retval = FAIL;
2642 /*
2643 * We may want to trigger the CursorHold event. First wait for
2644 * 'updatetime' and if nothing is typed within that time put the
2645 * K_CURSORHOLD key in the input buffer.
2646 */
2647 if (gui_mch_wait_for_chars(p_ut) == OK)
2648 retval = OK;
2644 #ifdef FEAT_AUTOCMD 2649 #ifdef FEAT_AUTOCMD
2645 /* If there is no character available within 2 seconds (default), 2650 else if (!did_cursorhold && has_cursorhold()
2646 * write the autoscript file to disk */ 2651 && get_real_state() == NORMAL_BUSY)
2647 if (once_already == 2) 2652 {
2648 { 2653 char_u buf[3];
2654
2655 /* Put K_CURSORHOLD in the input buffer. */
2656 buf[0] = CSI;
2657 buf[1] = KS_EXTRA;
2658 buf[2] = (int)KE_CURSORHOLD;
2659 add_to_input_buf(buf, 3);
2660
2661 retval = OK;
2662 }
2663 #endif
2664
2665 if (retval == FAIL)
2666 {
2667 /* Blocking wait. */
2649 updatescript(0); 2668 updatescript(0);
2650 retval = gui_mch_wait_for_chars(-1L); 2669 retval = gui_mch_wait_for_chars(-1L);
2651 once_already = 0; 2670 }
2652 }
2653 else if (once_already == 1)
2654 {
2655 setcursor();
2656 once_already = 2;
2657 retval = 0;
2658 }
2659 else
2660 #endif
2661 if (gui_mch_wait_for_chars(p_ut) != OK)
2662 {
2663 #ifdef FEAT_AUTOCMD
2664 if (has_cursorhold() && get_real_state() == NORMAL_BUSY)
2665 {
2666 apply_autocmds(EVENT_CURSORHOLD, NULL, NULL, FALSE, curbuf);
2667 update_screen(VALID);
2668 showruler(FALSE);
2669 setcursor();
2670 /* In case the commands moved the focus to another window
2671 * (temporarily). */
2672 if (need_mouse_correct)
2673 gui_mouse_correct();
2674
2675 once_already = 1;
2676 retval = 0;
2677 }
2678 else
2679 #endif
2680 {
2681 updatescript(0);
2682 retval = gui_mch_wait_for_chars(-1L);
2683 #ifdef FEAT_AUTOCMD
2684 once_already = 0;
2685 #endif
2686 }
2687 }
2688 else
2689 retval = OK;
2690 2671
2691 gui_mch_stop_blink(); 2672 gui_mch_stop_blink();
2692 return retval; 2673 return retval;
2693 } 2674 }
2694 2675
4065 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) 4046 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR)
4066 gui_set_fg_color((char_u *)"Black"); 4047 gui_set_fg_color((char_u *)"Black");
4067 } 4048 }
4068 } 4049 }
4069 4050
4070 void 4051 static void
4071 gui_set_fg_color(name) 4052 gui_set_fg_color(name)
4072 char_u *name; 4053 char_u *name;
4073 { 4054 {
4074 gui.norm_pixel = gui_get_color(name); 4055 gui.norm_pixel = gui_get_color(name);
4075 hl_set_fg_color_name(vim_strsave(name)); 4056 hl_set_fg_color_name(vim_strsave(name));
4076 } 4057 }
4077 4058
4078 void 4059 static void
4079 gui_set_bg_color(name) 4060 gui_set_bg_color(name)
4080 char_u *name; 4061 char_u *name;
4081 { 4062 {
4082 gui.back_pixel = gui_get_color(name); 4063 gui.back_pixel = gui_get_color(name);
4083 hl_set_bg_color_name(vim_strsave(name)); 4064 hl_set_bg_color_name(vim_strsave(name));