comparison src/gui.c @ 2277:f42e0b5ff9e9 vim73

Change remaining HAVE_GTK2 to FEAT_GUI_GTK.
author Bram Moolenaar <bram@vim.org>
date Sat, 26 Jun 2010 05:38:18 +0200
parents e4d849f4df03
children a888ed7ba375
comparison
equal deleted inserted replaced
2276:ebabd8a8b714 2277:f42e0b5ff9e9
11 #include "vim.h" 11 #include "vim.h"
12 12
13 /* Structure containing all the GUI information */ 13 /* Structure containing all the GUI information */
14 gui_T gui; 14 gui_T gui;
15 15
16 #if defined(FEAT_MBYTE) && !defined(HAVE_GTK2) 16 #if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK)
17 static void set_guifontwide __ARGS((char_u *font_name)); 17 static void set_guifontwide __ARGS((char_u *font_name));
18 #endif 18 #endif
19 static void gui_check_pos __ARGS((void)); 19 static void gui_check_pos __ARGS((void));
20 static void gui_position_components __ARGS((int)); 20 static void gui_position_components __ARGS((int));
21 static void gui_outstr __ARGS((char_u *, int)); 21 static void gui_outstr __ARGS((char_u *, int));
22 static int gui_screenchar __ARGS((int off, int flags, guicolor_T fg, guicolor_T bg, int back)); 22 static int gui_screenchar __ARGS((int off, int flags, guicolor_T fg, guicolor_T bg, int back));
23 #ifdef HAVE_GTK2 23 #ifdef FEAT_GUI_GTK
24 static int gui_screenstr __ARGS((int off, int len, int flags, guicolor_T fg, guicolor_T bg, int back)); 24 static int gui_screenstr __ARGS((int off, int len, int flags, guicolor_T fg, guicolor_T bg, int back));
25 #endif 25 #endif
26 static void gui_delete_lines __ARGS((int row, int count)); 26 static void gui_delete_lines __ARGS((int row, int count));
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));
248 gui.char_height = 1; 248 gui.char_height = 1;
249 gui.char_ascent = 0; 249 gui.char_ascent = 0;
250 gui.border_width = 0; 250 gui.border_width = 0;
251 251
252 gui.norm_font = NOFONT; 252 gui.norm_font = NOFONT;
253 #ifndef HAVE_GTK2 253 #ifndef FEAT_GUI_GTK
254 gui.bold_font = NOFONT; 254 gui.bold_font = NOFONT;
255 gui.ital_font = NOFONT; 255 gui.ital_font = NOFONT;
256 gui.boldital_font = NOFONT; 256 gui.boldital_font = NOFONT;
257 # ifdef FEAT_XFONTSET 257 # ifdef FEAT_XFONTSET
258 gui.fontset = NOFONTSET; 258 gui.fontset = NOFONTSET;
259 # endif 259 # endif
260 #endif 260 #endif
261 261
262 #ifdef FEAT_MENU 262 #ifdef FEAT_MENU
263 # ifndef HAVE_GTK2 263 # ifndef FEAT_GUI_GTK
264 # ifdef FONTSET_ALWAYS 264 # ifdef FONTSET_ALWAYS
265 gui.menu_fontset = NOFONTSET; 265 gui.menu_fontset = NOFONTSET;
266 # else 266 # else
267 gui.menu_font = NOFONT; 267 gui.menu_font = NOFONT;
268 # endif 268 # endif
707 * name, which frees the old value. This makes font_list 707 * name, which frees the old value. This makes font_list
708 * invalid. Thus when OK is returned here, font_list must no 708 * invalid. Thus when OK is returned here, font_list must no
709 * longer be used! */ 709 * longer be used! */
710 if (gui_mch_init_font(font_name, FALSE) == OK) 710 if (gui_mch_init_font(font_name, FALSE) == OK)
711 { 711 {
712 #if defined(FEAT_MBYTE) && !defined(HAVE_GTK2) 712 #if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK)
713 /* If it's a Unicode font, try setting 'guifontwide' to a 713 /* If it's a Unicode font, try setting 'guifontwide' to a
714 * similar double-width font. */ 714 * similar double-width font. */
715 if ((p_guifontwide == NULL || *p_guifontwide == NUL) 715 if ((p_guifontwide == NULL || *p_guifontwide == NUL)
716 && strstr((char *)font_name, "10646") != NULL) 716 && strstr((char *)font_name, "10646") != NULL)
717 set_guifontwide(font_name); 717 set_guifontwide(font_name);
734 ret = gui_mch_init_font(NULL, FALSE); 734 ret = gui_mch_init_font(NULL, FALSE);
735 } 735 }
736 736
737 if (ret == OK) 737 if (ret == OK)
738 { 738 {
739 #ifndef HAVE_GTK2 739 #ifndef FEAT_GUI_GTK
740 /* Set normal font as current font */ 740 /* Set normal font as current font */
741 # ifdef FEAT_XFONTSET 741 # ifdef FEAT_XFONTSET
742 if (gui.fontset != NOFONTSET) 742 if (gui.fontset != NOFONTSET)
743 gui_mch_set_fontset(gui.fontset); 743 gui_mch_set_fontset(gui.fontset);
744 else 744 else
756 756
757 return ret; 757 return ret;
758 } 758 }
759 759
760 #if defined(FEAT_MBYTE) || defined(PROTO) 760 #if defined(FEAT_MBYTE) || defined(PROTO)
761 # ifndef HAVE_GTK2 761 # ifndef FEAT_GUI_GTK
762 /* 762 /*
763 * Try setting 'guifontwide' to a font twice as wide as "name". 763 * Try setting 'guifontwide' to a font twice as wide as "name".
764 */ 764 */
765 static void 765 static void
766 set_guifontwide(name) 766 set_guifontwide(name)
804 break; 804 break;
805 } 805 }
806 } 806 }
807 } 807 }
808 } 808 }
809 # endif /* !HAVE_GTK2 */ 809 # endif /* !FEAT_GUI_GTK */
810 810
811 /* 811 /*
812 * Get the font for 'guifontwide'. 812 * Get the font for 'guifontwide'.
813 * Return FAIL for an invalid font name. 813 * Return FAIL for an invalid font name.
814 */ 814 */
835 if (font == NOFONT) 835 if (font == NOFONT)
836 return FAIL; 836 return FAIL;
837 } 837 }
838 838
839 gui_mch_free_font(gui.wide_font); 839 gui_mch_free_font(gui.wide_font);
840 #ifdef HAVE_GTK2 840 #ifdef FEAT_GUI_GTK
841 /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */ 841 /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */
842 if (font != NOFONT && gui.norm_font != NOFONT 842 if (font != NOFONT && gui.norm_font != NOFONT
843 && pango_font_description_equal(font, gui.norm_font)) 843 && pango_font_description_equal(font, gui.norm_font))
844 { 844 {
845 gui.wide_font = NOFONT; 845 gui.wide_font = NOFONT;
952 { 952 {
953 static int iid; 953 static int iid;
954 guicolor_T fg, bg; 954 guicolor_T fg, bg;
955 955
956 if ( 956 if (
957 # if defined(HAVE_GTK2) && !defined(FEAT_HANGULIN) 957 # if defined(FEAT_GUI_GTK) && !defined(FEAT_HANGULIN)
958 preedit_get_status() 958 preedit_get_status()
959 # else 959 # else
960 im_get_status() 960 im_get_status()
961 # endif 961 # endif
962 ) 962 )
1181 1181
1182 gui_mch_set_text_area_pos(text_area_x, 1182 gui_mch_set_text_area_pos(text_area_x,
1183 text_area_y, 1183 text_area_y,
1184 text_area_width, 1184 text_area_width,
1185 text_area_height 1185 text_area_height
1186 #if defined(FEAT_XIM) && !defined(HAVE_GTK2) 1186 #if defined(FEAT_XIM) && !defined(FEAT_GUI_GTK)
1187 + xim_get_status_area_height() 1187 + xim_get_status_area_height()
1188 #endif 1188 #endif
1189 ); 1189 );
1190 #ifdef FEAT_MENU 1190 #ifdef FEAT_MENU
1191 gui_position_menu(); 1191 gui_position_menu();
1312 || gui.num_rows != Rows || gui.num_cols != Columns) 1312 || gui.num_rows != Rows || gui.num_cols != Columns)
1313 shell_resized(); 1313 shell_resized();
1314 1314
1315 gui_update_scrollbars(TRUE); 1315 gui_update_scrollbars(TRUE);
1316 gui_update_cursor(FALSE, TRUE); 1316 gui_update_cursor(FALSE, TRUE);
1317 #if defined(FEAT_XIM) && !defined(HAVE_GTK2) 1317 #if defined(FEAT_XIM) && !defined(FEAT_GUI_GTK)
1318 xim_set_status_area(); 1318 xim_set_status_area();
1319 #endif 1319 #endif
1320 1320
1321 busy = FALSE; 1321 busy = FALSE;
1322 1322
1379 int height; 1379 int height;
1380 int min_width; 1380 int min_width;
1381 int min_height; 1381 int min_height;
1382 int screen_w; 1382 int screen_w;
1383 int screen_h; 1383 int screen_h;
1384 #ifdef HAVE_GTK2 1384 #ifdef FEAT_GUI_GTK
1385 int un_maximize = mustset; 1385 int un_maximize = mustset;
1386 int did_adjust = 0; 1386 int did_adjust = 0;
1387 #endif 1387 #endif
1388 int x = -1, y = -1; 1388 int x = -1, y = -1;
1389 1389
1427 { 1427 {
1428 Columns = (screen_w - base_width) / gui.char_width; 1428 Columns = (screen_w - base_width) / gui.char_width;
1429 if (Columns < MIN_COLUMNS) 1429 if (Columns < MIN_COLUMNS)
1430 Columns = MIN_COLUMNS; 1430 Columns = MIN_COLUMNS;
1431 width = Columns * gui.char_width + base_width; 1431 width = Columns * gui.char_width + base_width;
1432 #ifdef HAVE_GTK2 1432 #ifdef FEAT_GUI_GTK
1433 ++did_adjust; 1433 ++did_adjust;
1434 #endif 1434 #endif
1435 } 1435 }
1436 if ((direction & RESIZE_VERT) && height > screen_h) 1436 if ((direction & RESIZE_VERT) && height > screen_h)
1437 { 1437 {
1438 Rows = (screen_h - base_height) / gui.char_height; 1438 Rows = (screen_h - base_height) / gui.char_height;
1439 check_shellsize(); 1439 check_shellsize();
1440 height = Rows * gui.char_height + base_height; 1440 height = Rows * gui.char_height + base_height;
1441 #ifdef HAVE_GTK2 1441 #ifdef FEAT_GUI_GTK
1442 ++did_adjust; 1442 ++did_adjust;
1443 #endif 1443 #endif
1444 } 1444 }
1445 #ifdef HAVE_GTK2 1445 #ifdef FEAT_GUI_GTK
1446 if (did_adjust == 2 || (width + gui.char_width >= screen_w 1446 if (did_adjust == 2 || (width + gui.char_width >= screen_w
1447 && height + gui.char_height >= screen_h)) 1447 && height + gui.char_height >= screen_h))
1448 /* don't unmaximize if at maximum size */ 1448 /* don't unmaximize if at maximum size */
1449 un_maximize = FALSE; 1449 un_maximize = FALSE;
1450 #endif 1450 #endif
1456 min_height = base_height + MIN_LINES * gui.char_height; 1456 min_height = base_height + MIN_LINES * gui.char_height;
1457 #ifdef FEAT_WINDOWS 1457 #ifdef FEAT_WINDOWS
1458 min_height += tabline_height() * gui.char_height; 1458 min_height += tabline_height() * gui.char_height;
1459 #endif 1459 #endif
1460 1460
1461 #ifdef HAVE_GTK2 1461 #ifdef FEAT_GUI_GTK
1462 if (un_maximize) 1462 if (un_maximize)
1463 { 1463 {
1464 /* If the window size is smaller than the screen unmaximize the 1464 /* If the window size is smaller than the screen unmaximize the
1465 * window, otherwise resizing won't work. */ 1465 * window, otherwise resizing won't work. */
1466 gui_mch_get_screen_dimensions(&screen_w, &screen_h); 1466 gui_mch_get_screen_dimensions(&screen_w, &screen_h);
1916 #else 1916 #else
1917 return gui_outstr_nowrap(ScreenLines + off, 1, flags, fg, bg, back); 1917 return gui_outstr_nowrap(ScreenLines + off, 1, flags, fg, bg, back);
1918 #endif 1918 #endif
1919 } 1919 }
1920 1920
1921 #ifdef HAVE_GTK2 1921 #ifdef FEAT_GUI_GTK
1922 /* 1922 /*
1923 * Output the string at the given screen position. This is used in place 1923 * Output the string at the given screen position. This is used in place
1924 * of gui_screenchar() where possible because Pango needs as much context 1924 * of gui_screenchar() where possible because Pango needs as much context
1925 * as possible to work nicely. It's a lot faster as well. 1925 * as possible to work nicely. It's a lot faster as well.
1926 */ 1926 */
1990 { 1990 {
1991 return gui_outstr_nowrap(&ScreenLines[off], len, 1991 return gui_outstr_nowrap(&ScreenLines[off], len,
1992 flags, fg, bg, back); 1992 flags, fg, bg, back);
1993 } 1993 }
1994 } 1994 }
1995 #endif /* HAVE_GTK2 */ 1995 #endif /* FEAT_GUI_GTK */
1996 1996
1997 /* 1997 /*
1998 * Output the given string at the current cursor position. If the string is 1998 * Output the given string at the current cursor position. If the string is
1999 * too long to fit on the line, then it is truncated. 1999 * too long to fit on the line, then it is truncated.
2000 * "flags": 2000 * "flags":
2018 long_u highlight_mask; 2018 long_u highlight_mask;
2019 long_u hl_mask_todo; 2019 long_u hl_mask_todo;
2020 guicolor_T fg_color; 2020 guicolor_T fg_color;
2021 guicolor_T bg_color; 2021 guicolor_T bg_color;
2022 guicolor_T sp_color; 2022 guicolor_T sp_color;
2023 #if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2) 2023 #if !defined(MSWIN16_FASTTEXT) && !defined(FEAT_GUI_GTK)
2024 GuiFont font = NOFONT; 2024 GuiFont font = NOFONT;
2025 # ifdef FEAT_XFONTSET 2025 # ifdef FEAT_XFONTSET
2026 GuiFontset fontset = NOFONTSET; 2026 GuiFontset fontset = NOFONTSET;
2027 # endif 2027 # endif
2028 #endif 2028 #endif
2072 } 2072 }
2073 else 2073 else
2074 highlight_mask = gui.highlight_mask; 2074 highlight_mask = gui.highlight_mask;
2075 hl_mask_todo = highlight_mask; 2075 hl_mask_todo = highlight_mask;
2076 2076
2077 #if !defined(MSWIN16_FASTTEXT) && !defined(HAVE_GTK2) 2077 #if !defined(MSWIN16_FASTTEXT) && !defined(FEAT_GUI_GTK)
2078 /* Set the font */ 2078 /* Set the font */
2079 if (aep != NULL && aep->ae_u.gui.font != NOFONT) 2079 if (aep != NULL && aep->ae_u.gui.font != NOFONT)
2080 font = aep->ae_u.gui.font; 2080 font = aep->ae_u.gui.font;
2081 # ifdef FEAT_XFONTSET 2081 # ifdef FEAT_XFONTSET
2082 else if (aep != NULL && aep->ae_u.gui.fontset != NOFONTSET) 2082 else if (aep != NULL && aep->ae_u.gui.fontset != NOFONTSET)
2186 * just after a blank. 2186 * just after a blank.
2187 */ 2187 */
2188 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC))) 2188 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC)))
2189 return FAIL; 2189 return FAIL;
2190 2190
2191 #if defined(RISCOS) || defined(HAVE_GTK2) 2191 #if defined(RISCOS) || defined(FEAT_GUI_GTK)
2192 /* If there's no italic font, then fake it. 2192 /* If there's no italic font, then fake it.
2193 * For GTK2, we don't need a different font for italic style. */ 2193 * For GTK2, we don't need a different font for italic style. */
2194 if (hl_mask_todo & HL_ITALIC) 2194 if (hl_mask_todo & HL_ITALIC)
2195 draw_flags |= DRAW_ITALIC; 2195 draw_flags |= DRAW_ITALIC;
2196 2196
2215 draw_flags |= DRAW_TRANSP; 2215 draw_flags |= DRAW_TRANSP;
2216 2216
2217 /* 2217 /*
2218 * Draw the text. 2218 * Draw the text.
2219 */ 2219 */
2220 #ifdef HAVE_GTK2 2220 #ifdef FEAT_GUI_GTK
2221 /* The value returned is the length in display cells */ 2221 /* The value returned is the length in display cells */
2222 len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags); 2222 len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags);
2223 #else 2223 #else
2224 # ifdef FEAT_MBYTE 2224 # ifdef FEAT_MBYTE
2225 if (enc_utf8) 2225 if (enc_utf8)
2338 clen += (*mb_ptr2cells)(s + i); 2338 clen += (*mb_ptr2cells)(s + i);
2339 len = clen; 2339 len = clen;
2340 } 2340 }
2341 # endif 2341 # endif
2342 } 2342 }
2343 #endif /* !HAVE_GTK2 */ 2343 #endif /* !FEAT_GUI_GTK */
2344 2344
2345 if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR))) 2345 if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR)))
2346 gui.col = col + len; 2346 gui.col = col + len;
2347 2347
2348 /* May need to invert it when it's part of the selection. */ 2348 /* May need to invert it when it's part of the selection. */
2497 } 2497 }
2498 else if (enc_utf8) 2498 else if (enc_utf8)
2499 { 2499 {
2500 if (ScreenLines[off + col1] == 0) 2500 if (ScreenLines[off + col1] == 0)
2501 --col1; 2501 --col1;
2502 # ifdef HAVE_GTK2 2502 # ifdef FEAT_GUI_GTK
2503 if (col2 + 1 < Columns && ScreenLines[off + col2 + 1] == 0) 2503 if (col2 + 1 < Columns && ScreenLines[off + col2 + 1] == 0)
2504 ++col2; 2504 ++col2;
2505 # endif 2505 # endif
2506 } 2506 }
2507 #endif 2507 #endif
2522 /* Print UTF-8 characters individually. */ 2522 /* Print UTF-8 characters individually. */
2523 while (len > 0) 2523 while (len > 0)
2524 { 2524 {
2525 first_attr = ScreenAttrs[off]; 2525 first_attr = ScreenAttrs[off];
2526 gui.highlight_mask = first_attr; 2526 gui.highlight_mask = first_attr;
2527 #if defined(FEAT_MBYTE) && !defined(HAVE_GTK2) 2527 #if defined(FEAT_MBYTE) && !defined(FEAT_GUI_GTK)
2528 if (enc_utf8 && ScreenLinesUC[off] != 0) 2528 if (enc_utf8 && ScreenLinesUC[off] != 0)
2529 { 2529 {
2530 /* output multi-byte character separately */ 2530 /* output multi-byte character separately */
2531 nback = gui_screenchar(off, flags, 2531 nback = gui_screenchar(off, flags,
2532 (guicolor_T)0, (guicolor_T)0, back); 2532 (guicolor_T)0, (guicolor_T)0, back);
2543 idx = 1; 2543 idx = 1;
2544 } 2544 }
2545 else 2545 else
2546 #endif 2546 #endif
2547 { 2547 {
2548 #ifdef HAVE_GTK2 2548 #ifdef FEAT_GUI_GTK
2549 for (idx = 0; idx < len; ++idx) 2549 for (idx = 0; idx < len; ++idx)
2550 { 2550 {
2551 if (enc_utf8 && ScreenLines[off + idx] == 0) 2551 if (enc_utf8 && ScreenLines[off + idx] == 0)
2552 continue; /* skip second half of double-width char */ 2552 continue; /* skip second half of double-width char */
2553 if (ScreenAttrs[off + idx] != first_attr) 2553 if (ScreenAttrs[off + idx] != first_attr)
3087 3087
3088 /* 3088 /*
3089 * We need to make sure this is cleared since Athena doesn't tell us when 3089 * We need to make sure this is cleared since Athena doesn't tell us when
3090 * he is done dragging. Neither does GTK+ 2 -- at least for now. 3090 * he is done dragging. Neither does GTK+ 2 -- at least for now.
3091 */ 3091 */
3092 #if defined(FEAT_GUI_ATHENA) || defined(HAVE_GTK2) 3092 #if defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_GTK)
3093 gui.dragged_sb = SBAR_NONE; 3093 gui.dragged_sb = SBAR_NONE;
3094 #endif 3094 #endif
3095 } 3095 }
3096 3096
3097 /* 3097 /*
3737 gui.dragged_wp = sb->wp; 3737 gui.dragged_wp = sb->wp;
3738 } 3738 }
3739 else 3739 else
3740 { 3740 {
3741 gui.dragged_sb = SBAR_NONE; 3741 gui.dragged_sb = SBAR_NONE;
3742 #ifdef HAVE_GTK2 3742 #ifdef FEAT_GUI_GTK
3743 /* Keep the "dragged_wp" value until after the scrolling, for when the 3743 /* Keep the "dragged_wp" value until after the scrolling, for when the
3744 * moust button is released. GTK2 doesn't send the button-up event. */ 3744 * moust button is released. GTK2 doesn't send the button-up event. */
3745 gui.dragged_wp = NULL; 3745 gui.dragged_wp = NULL;
3746 #endif 3746 #endif
3747 } 3747 }
4830 || *buffer == NUL) 4830 || *buffer == NUL)
4831 return FAIL; 4831 return FAIL;
4832 return OK; 4832 return OK;
4833 } 4833 }
4834 4834
4835 # if !defined(HAVE_GTK2) || defined(PROTO) 4835 # if !defined(FEAT_GUI_GTK) || defined(PROTO)
4836 /* 4836 /*
4837 * Given the name of the "icon=" argument, try finding the bitmap file for the 4837 * Given the name of the "icon=" argument, try finding the bitmap file for the
4838 * icon. If it is an absolute path name, use it as it is. Otherwise append 4838 * icon. If it is an absolute path name, use it as it is. Otherwise append
4839 * "ext" and search for it in 'runtimepath'. 4839 * "ext" and search for it in 'runtimepath'.
4840 * The result is put in "buffer[MAXPATHL]". If something fails "buffer" 4840 * The result is put in "buffer[MAXPATHL]". If something fails "buffer"