Mercurial > vim
comparison src/gui.c @ 7821:81794242a275 v7.4.1207
commit https://github.com/vim/vim/commit/66f948e928d5e0cd3123af902aa8ac1613534c94
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 30 16:39:25 2016 +0100
patch 7.4.1207
Problem: Using old style function declarations.
Solution: Change to new style function declarations. (script by Hirohito
Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Jan 2016 16:45:04 +0100 |
parents | a1e71a01dbd6 |
children | 563c923b1584 |
comparison
equal
deleted
inserted
replaced
7820:38d22ab3d9a0 | 7821:81794242a275 |
---|---|
71 * Careful: This function can be called recursively when there is a ":gui" | 71 * Careful: This function can be called recursively when there is a ":gui" |
72 * command in the .gvimrc file. Only the first call should fork, not the | 72 * command in the .gvimrc file. Only the first call should fork, not the |
73 * recursive call. | 73 * recursive call. |
74 */ | 74 */ |
75 void | 75 void |
76 gui_start() | 76 gui_start(void) |
77 { | 77 { |
78 char_u *old_term; | 78 char_u *old_term; |
79 static int recursive = 0; | 79 static int recursive = 0; |
80 | 80 |
81 old_term = vim_strsave(T_NAME); | 81 old_term = vim_strsave(T_NAME); |
150 * what size the shell should be. So if there are errors in the .gvimrc | 150 * what size the shell should be. So if there are errors in the .gvimrc |
151 * file, they will have to go to the terminal: Set full_screen to FALSE. | 151 * file, they will have to go to the terminal: Set full_screen to FALSE. |
152 * full_screen will be set to TRUE again by a successful termcapinit(). | 152 * full_screen will be set to TRUE again by a successful termcapinit(). |
153 */ | 153 */ |
154 static void | 154 static void |
155 gui_attempt_start() | 155 gui_attempt_start(void) |
156 { | 156 { |
157 static int recursive = 0; | 157 static int recursive = 0; |
158 | 158 |
159 ++recursive; | 159 ++recursive; |
160 gui.starting = TRUE; | 160 gui.starting = TRUE; |
202 * If the child fails to start the GUI, then the child will exit and the | 202 * If the child fails to start the GUI, then the child will exit and the |
203 * parent will return. If the child succeeds, then the parent will exit | 203 * parent will return. If the child succeeds, then the parent will exit |
204 * and the child will return. | 204 * and the child will return. |
205 */ | 205 */ |
206 static void | 206 static void |
207 gui_do_fork() | 207 gui_do_fork(void) |
208 { | 208 { |
209 int pipefd[2]; /* pipe between parent and child */ | 209 int pipefd[2]; /* pipe between parent and child */ |
210 int pipe_error; | 210 int pipe_error; |
211 int status; | 211 int status; |
212 int exit_status; | 212 int exit_status; |
343 | 343 |
344 /* | 344 /* |
345 * Call this when vim starts up, whether or not the GUI is started | 345 * Call this when vim starts up, whether or not the GUI is started |
346 */ | 346 */ |
347 void | 347 void |
348 gui_prepare(argc, argv) | 348 gui_prepare(int *argc, char **argv) |
349 int *argc; | |
350 char **argv; | |
351 { | 349 { |
352 gui.in_use = FALSE; /* No GUI yet (maybe later) */ | 350 gui.in_use = FALSE; /* No GUI yet (maybe later) */ |
353 gui.starting = FALSE; /* No GUI yet (maybe later) */ | 351 gui.starting = FALSE; /* No GUI yet (maybe later) */ |
354 gui_mch_prepare(argc, argv); | 352 gui_mch_prepare(argc, argv); |
355 } | 353 } |
359 * Used from main() to check early if "vim -g" can start the GUI. | 357 * Used from main() to check early if "vim -g" can start the GUI. |
360 * Used from gui_init() to prepare for starting the GUI. | 358 * Used from gui_init() to prepare for starting the GUI. |
361 * Returns FAIL or OK. | 359 * Returns FAIL or OK. |
362 */ | 360 */ |
363 int | 361 int |
364 gui_init_check() | 362 gui_init_check(void) |
365 { | 363 { |
366 static int result = MAYBE; | 364 static int result = MAYBE; |
367 | 365 |
368 if (result != MAYBE) | 366 if (result != MAYBE) |
369 { | 367 { |
459 | 457 |
460 /* | 458 /* |
461 * This is the call which starts the GUI. | 459 * This is the call which starts the GUI. |
462 */ | 460 */ |
463 void | 461 void |
464 gui_init() | 462 gui_init(void) |
465 { | 463 { |
466 win_T *wp; | 464 win_T *wp; |
467 static int recursive = 0; | 465 static int recursive = 0; |
468 | 466 |
469 /* | 467 /* |
787 clip_init(FALSE); | 785 clip_init(FALSE); |
788 } | 786 } |
789 | 787 |
790 | 788 |
791 void | 789 void |
792 gui_exit(rc) | 790 gui_exit(int rc) |
793 int rc; | |
794 { | 791 { |
795 /* don't free the fonts, it leads to a BUS error | 792 /* don't free the fonts, it leads to a BUS error |
796 * richard@whitequeen.com Jul 99 */ | 793 * richard@whitequeen.com Jul 99 */ |
797 free_highlight_fonts(); | 794 free_highlight_fonts(); |
798 gui.in_use = FALSE; | 795 gui.in_use = FALSE; |
807 * files Vim exits, otherwise there will be a dialog to ask the user what to | 804 * files Vim exits, otherwise there will be a dialog to ask the user what to |
808 * do. | 805 * do. |
809 * When this function returns, Vim should NOT exit! | 806 * When this function returns, Vim should NOT exit! |
810 */ | 807 */ |
811 void | 808 void |
812 gui_shell_closed() | 809 gui_shell_closed(void) |
813 { | 810 { |
814 cmdmod_T save_cmdmod; | 811 cmdmod_T save_cmdmod; |
815 | 812 |
816 save_cmdmod = cmdmod; | 813 save_cmdmod = cmdmod; |
817 | 814 |
841 * If "fontset" is TRUE, the "font_list" is used as one name for the fontset. | 838 * If "fontset" is TRUE, the "font_list" is used as one name for the fontset. |
842 * Return OK when able to set the font. When it failed FAIL is returned and | 839 * Return OK when able to set the font. When it failed FAIL is returned and |
843 * the fonts are unchanged. | 840 * the fonts are unchanged. |
844 */ | 841 */ |
845 int | 842 int |
846 gui_init_font(font_list, fontset) | 843 gui_init_font(char_u *font_list, int fontset UNUSED) |
847 char_u *font_list; | |
848 int fontset UNUSED; | |
849 { | 844 { |
850 #define FONTLEN 320 | 845 #define FONTLEN 320 |
851 char_u font_name[FONTLEN]; | 846 char_u font_name[FONTLEN]; |
852 int font_list_empty = FALSE; | 847 int font_list_empty = FALSE; |
853 int ret = FAIL; | 848 int ret = FAIL; |
924 # ifndef FEAT_GUI_GTK | 919 # ifndef FEAT_GUI_GTK |
925 /* | 920 /* |
926 * Try setting 'guifontwide' to a font twice as wide as "name". | 921 * Try setting 'guifontwide' to a font twice as wide as "name". |
927 */ | 922 */ |
928 static void | 923 static void |
929 set_guifontwide(name) | 924 set_guifontwide(char_u *name) |
930 char_u *name; | |
931 { | 925 { |
932 int i = 0; | 926 int i = 0; |
933 char_u wide_name[FONTLEN + 10]; /* room for 2 * width and '*' */ | 927 char_u wide_name[FONTLEN + 10]; /* room for 2 * width and '*' */ |
934 char_u *wp = NULL; | 928 char_u *wp = NULL; |
935 char_u *p; | 929 char_u *p; |
974 /* | 968 /* |
975 * Get the font for 'guifontwide'. | 969 * Get the font for 'guifontwide'. |
976 * Return FAIL for an invalid font name. | 970 * Return FAIL for an invalid font name. |
977 */ | 971 */ |
978 int | 972 int |
979 gui_get_wide_font() | 973 gui_get_wide_font(void) |
980 { | 974 { |
981 GuiFont font = NOFONT; | 975 GuiFont font = NOFONT; |
982 char_u font_name[FONTLEN]; | 976 char_u font_name[FONTLEN]; |
983 char_u *p; | 977 char_u *p; |
984 | 978 |
1022 return OK; | 1016 return OK; |
1023 } | 1017 } |
1024 #endif | 1018 #endif |
1025 | 1019 |
1026 void | 1020 void |
1027 gui_set_cursor(row, col) | 1021 gui_set_cursor(int row, int col) |
1028 int row; | |
1029 int col; | |
1030 { | 1022 { |
1031 gui.row = row; | 1023 gui.row = row; |
1032 gui.col = col; | 1024 gui.col = col; |
1033 } | 1025 } |
1034 | 1026 |
1035 /* | 1027 /* |
1036 * gui_check_pos - check if the cursor is on the screen. | 1028 * gui_check_pos - check if the cursor is on the screen. |
1037 */ | 1029 */ |
1038 static void | 1030 static void |
1039 gui_check_pos() | 1031 gui_check_pos(void) |
1040 { | 1032 { |
1041 if (gui.row >= screen_Rows) | 1033 if (gui.row >= screen_Rows) |
1042 gui.row = screen_Rows - 1; | 1034 gui.row = screen_Rows - 1; |
1043 if (gui.col >= screen_Columns) | 1035 if (gui.col >= screen_Columns) |
1044 gui.col = screen_Columns - 1; | 1036 gui.col = screen_Columns - 1; |
1050 * Redraw the cursor if necessary or when forced. | 1042 * Redraw the cursor if necessary or when forced. |
1051 * Careful: The contents of ScreenLines[] must match what is on the screen, | 1043 * Careful: The contents of ScreenLines[] must match what is on the screen, |
1052 * otherwise this goes wrong. May need to call out_flush() first. | 1044 * otherwise this goes wrong. May need to call out_flush() first. |
1053 */ | 1045 */ |
1054 void | 1046 void |
1055 gui_update_cursor(force, clear_selection) | 1047 gui_update_cursor( |
1056 int force; /* when TRUE, update even when not moved */ | 1048 int force, /* when TRUE, update even when not moved */ |
1057 int clear_selection;/* clear selection under cursor */ | 1049 int clear_selection)/* clear selection under cursor */ |
1058 { | 1050 { |
1059 int cur_width = 0; | 1051 int cur_width = 0; |
1060 int cur_height = 0; | 1052 int cur_height = 0; |
1061 int old_hl_mask; | 1053 int old_hl_mask; |
1062 int idx; | 1054 int idx; |
1299 } | 1291 } |
1300 } | 1292 } |
1301 | 1293 |
1302 #if defined(FEAT_MENU) || defined(PROTO) | 1294 #if defined(FEAT_MENU) || defined(PROTO) |
1303 void | 1295 void |
1304 gui_position_menu() | 1296 gui_position_menu(void) |
1305 { | 1297 { |
1306 # if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) | 1298 # if !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) |
1307 if (gui.menu_is_active && gui.in_use) | 1299 if (gui.menu_is_active && gui.in_use) |
1308 gui_mch_set_menu_pos(0, 0, gui.menu_width, gui.menu_height); | 1300 gui_mch_set_menu_pos(0, 0, gui.menu_width, gui.menu_height); |
1309 # endif | 1301 # endif |
1313 /* | 1305 /* |
1314 * Position the various GUI components (text area, menu). The vertical | 1306 * Position the various GUI components (text area, menu). The vertical |
1315 * scrollbars are NOT handled here. See gui_update_scrollbars(). | 1307 * scrollbars are NOT handled here. See gui_update_scrollbars(). |
1316 */ | 1308 */ |
1317 static void | 1309 static void |
1318 gui_position_components(total_width) | 1310 gui_position_components(int total_width UNUSED) |
1319 int total_width UNUSED; | |
1320 { | 1311 { |
1321 int text_area_x; | 1312 int text_area_x; |
1322 int text_area_y; | 1313 int text_area_y; |
1323 int text_area_width; | 1314 int text_area_width; |
1324 int text_area_height; | 1315 int text_area_height; |
1386 | 1377 |
1387 /* | 1378 /* |
1388 * Get the width of the widgets and decorations to the side of the text area. | 1379 * Get the width of the widgets and decorations to the side of the text area. |
1389 */ | 1380 */ |
1390 int | 1381 int |
1391 gui_get_base_width() | 1382 gui_get_base_width(void) |
1392 { | 1383 { |
1393 int base_width; | 1384 int base_width; |
1394 | 1385 |
1395 base_width = 2 * gui.border_offset; | 1386 base_width = 2 * gui.border_offset; |
1396 if (gui.which_scrollbars[SBAR_LEFT]) | 1387 if (gui.which_scrollbars[SBAR_LEFT]) |
1402 | 1393 |
1403 /* | 1394 /* |
1404 * Get the height of the widgets and decorations above and below the text area. | 1395 * Get the height of the widgets and decorations above and below the text area. |
1405 */ | 1396 */ |
1406 int | 1397 int |
1407 gui_get_base_height() | 1398 gui_get_base_height(void) |
1408 { | 1399 { |
1409 int base_height; | 1400 int base_height; |
1410 | 1401 |
1411 base_height = 2 * gui.border_offset; | 1402 base_height = 2 * gui.border_offset; |
1412 if (gui.which_scrollbars[SBAR_BOTTOM]) | 1403 if (gui.which_scrollbars[SBAR_BOTTOM]) |
1447 /* | 1438 /* |
1448 * Should be called after the GUI shell has been resized. Its arguments are | 1439 * Should be called after the GUI shell has been resized. Its arguments are |
1449 * the new width and height of the shell in pixels. | 1440 * the new width and height of the shell in pixels. |
1450 */ | 1441 */ |
1451 void | 1442 void |
1452 gui_resize_shell(pixel_width, pixel_height) | 1443 gui_resize_shell(int pixel_width, int pixel_height) |
1453 int pixel_width; | |
1454 int pixel_height; | |
1455 { | 1444 { |
1456 static int busy = FALSE; | 1445 static int busy = FALSE; |
1457 | 1446 |
1458 if (!gui.shell_created) /* ignore when still initializing */ | 1447 if (!gui.shell_created) /* ignore when still initializing */ |
1459 return; | 1448 return; |
1518 | 1507 |
1519 /* | 1508 /* |
1520 * Check if gui_resize_shell() must be called. | 1509 * Check if gui_resize_shell() must be called. |
1521 */ | 1510 */ |
1522 void | 1511 void |
1523 gui_may_resize_shell() | 1512 gui_may_resize_shell(void) |
1524 { | 1513 { |
1525 int h, w; | 1514 int h, w; |
1526 | 1515 |
1527 if (new_pixel_height) | 1516 if (new_pixel_height) |
1528 { | 1517 { |
1535 gui_resize_shell(w, h); | 1524 gui_resize_shell(w, h); |
1536 } | 1525 } |
1537 } | 1526 } |
1538 | 1527 |
1539 int | 1528 int |
1540 gui_get_shellsize() | 1529 gui_get_shellsize(void) |
1541 { | 1530 { |
1542 Rows = gui.num_rows; | 1531 Rows = gui.num_rows; |
1543 Columns = gui.num_cols; | 1532 Columns = gui.num_cols; |
1544 return OK; | 1533 return OK; |
1545 } | 1534 } |
1548 * Set the size of the Vim shell according to Rows and Columns. | 1537 * Set the size of the Vim shell according to Rows and Columns. |
1549 * If "fit_to_display" is TRUE then the size may be reduced to fit the window | 1538 * If "fit_to_display" is TRUE then the size may be reduced to fit the window |
1550 * on the screen. | 1539 * on the screen. |
1551 */ | 1540 */ |
1552 void | 1541 void |
1553 gui_set_shellsize(mustset, fit_to_display, direction) | 1542 gui_set_shellsize( |
1554 int mustset UNUSED; /* set by the user */ | 1543 int mustset UNUSED, /* set by the user */ |
1555 int fit_to_display; | 1544 int fit_to_display, |
1556 int direction; /* RESIZE_HOR, RESIZE_VER */ | 1545 int direction) /* RESIZE_HOR, RESIZE_VER */ |
1557 { | 1546 { |
1558 int base_width; | 1547 int base_width; |
1559 int base_height; | 1548 int base_height; |
1560 int width; | 1549 int width; |
1561 int height; | 1550 int height; |
1674 | 1663 |
1675 /* | 1664 /* |
1676 * Called when Rows and/or Columns has changed. | 1665 * Called when Rows and/or Columns has changed. |
1677 */ | 1666 */ |
1678 void | 1667 void |
1679 gui_new_shellsize() | 1668 gui_new_shellsize(void) |
1680 { | 1669 { |
1681 gui_reset_scroll_region(); | 1670 gui_reset_scroll_region(); |
1682 } | 1671 } |
1683 | 1672 |
1684 /* | 1673 /* |
1685 * Make scroll region cover whole screen. | 1674 * Make scroll region cover whole screen. |
1686 */ | 1675 */ |
1687 void | 1676 void |
1688 gui_reset_scroll_region() | 1677 gui_reset_scroll_region(void) |
1689 { | 1678 { |
1690 gui.scroll_region_top = 0; | 1679 gui.scroll_region_top = 0; |
1691 gui.scroll_region_bot = gui.num_rows - 1; | 1680 gui.scroll_region_bot = gui.num_rows - 1; |
1692 gui.scroll_region_left = 0; | 1681 gui.scroll_region_left = 0; |
1693 gui.scroll_region_right = gui.num_cols - 1; | 1682 gui.scroll_region_right = gui.num_cols - 1; |
1694 } | 1683 } |
1695 | 1684 |
1696 void | 1685 void |
1697 gui_start_highlight(mask) | 1686 gui_start_highlight(int mask) |
1698 int mask; | |
1699 { | 1687 { |
1700 if (mask > HL_ALL) /* highlight code */ | 1688 if (mask > HL_ALL) /* highlight code */ |
1701 gui.highlight_mask = mask; | 1689 gui.highlight_mask = mask; |
1702 else /* mask */ | 1690 else /* mask */ |
1703 gui.highlight_mask |= mask; | 1691 gui.highlight_mask |= mask; |
1704 } | 1692 } |
1705 | 1693 |
1706 void | 1694 void |
1707 gui_stop_highlight(mask) | 1695 gui_stop_highlight(int mask) |
1708 int mask; | |
1709 { | 1696 { |
1710 if (mask > HL_ALL) /* highlight code */ | 1697 if (mask > HL_ALL) /* highlight code */ |
1711 gui.highlight_mask = HL_NORMAL; | 1698 gui.highlight_mask = HL_NORMAL; |
1712 else /* mask */ | 1699 else /* mask */ |
1713 gui.highlight_mask &= ~mask; | 1700 gui.highlight_mask &= ~mask; |
1716 /* | 1703 /* |
1717 * Clear a rectangular region of the screen from text pos (row1, col1) to | 1704 * Clear a rectangular region of the screen from text pos (row1, col1) to |
1718 * (row2, col2) inclusive. | 1705 * (row2, col2) inclusive. |
1719 */ | 1706 */ |
1720 void | 1707 void |
1721 gui_clear_block(row1, col1, row2, col2) | 1708 gui_clear_block( |
1722 int row1; | 1709 int row1, |
1723 int col1; | 1710 int col1, |
1724 int row2; | 1711 int row2, |
1725 int col2; | 1712 int col2) |
1726 { | 1713 { |
1727 /* Clear the selection if we are about to write over it */ | 1714 /* Clear the selection if we are about to write over it */ |
1728 clip_may_clear_selection(row1, row2); | 1715 clip_may_clear_selection(row1, row2); |
1729 | 1716 |
1730 gui_mch_clear_block(row1, col1, row2, col2); | 1717 gui_mch_clear_block(row1, col1, row2, col2); |
1738 /* | 1725 /* |
1739 * Write code to update the cursor later. This avoids the need to flush the | 1726 * Write code to update the cursor later. This avoids the need to flush the |
1740 * output buffer before calling gui_update_cursor(). | 1727 * output buffer before calling gui_update_cursor(). |
1741 */ | 1728 */ |
1742 void | 1729 void |
1743 gui_update_cursor_later() | 1730 gui_update_cursor_later(void) |
1744 { | 1731 { |
1745 OUT_STR(IF_EB("\033|s", ESC_STR "|s")); | 1732 OUT_STR(IF_EB("\033|s", ESC_STR "|s")); |
1746 } | 1733 } |
1747 | 1734 |
1748 void | 1735 void |
1749 gui_write(s, len) | 1736 gui_write( |
1750 char_u *s; | 1737 char_u *s, |
1751 int len; | 1738 int len) |
1752 { | 1739 { |
1753 char_u *p; | 1740 char_u *p; |
1754 int arg1 = 0, arg2 = 0; | 1741 int arg1 = 0, arg2 = 0; |
1755 int force_cursor = FALSE; /* force cursor update */ | 1742 int force_cursor = FALSE; /* force cursor update */ |
1756 int force_scrollbar = FALSE; | 1743 int force_scrollbar = FALSE; |
1975 * When ScreenLines[] is invalid, updating the cursor should not be done, it | 1962 * When ScreenLines[] is invalid, updating the cursor should not be done, it |
1976 * produces wrong results. Call gui_dont_update_cursor() before that code and | 1963 * produces wrong results. Call gui_dont_update_cursor() before that code and |
1977 * gui_can_update_cursor() afterwards. | 1964 * gui_can_update_cursor() afterwards. |
1978 */ | 1965 */ |
1979 void | 1966 void |
1980 gui_dont_update_cursor() | 1967 gui_dont_update_cursor(void) |
1981 { | 1968 { |
1982 if (gui.in_use) | 1969 if (gui.in_use) |
1983 { | 1970 { |
1984 /* Undraw the cursor now, we probably can't do it after the change. */ | 1971 /* Undraw the cursor now, we probably can't do it after the change. */ |
1985 gui_undraw_cursor(); | 1972 gui_undraw_cursor(); |
1986 can_update_cursor = FALSE; | 1973 can_update_cursor = FALSE; |
1987 } | 1974 } |
1988 } | 1975 } |
1989 | 1976 |
1990 void | 1977 void |
1991 gui_can_update_cursor() | 1978 gui_can_update_cursor(void) |
1992 { | 1979 { |
1993 can_update_cursor = TRUE; | 1980 can_update_cursor = TRUE; |
1994 /* No need to update the cursor right now, there is always more output | 1981 /* No need to update the cursor right now, there is always more output |
1995 * after scrolling. */ | 1982 * after scrolling. */ |
1996 } | 1983 } |
1997 | 1984 |
1998 static void | 1985 static void |
1999 gui_outstr(s, len) | 1986 gui_outstr(char_u *s, int len) |
2000 char_u *s; | |
2001 int len; | |
2002 { | 1987 { |
2003 int this_len; | 1988 int this_len; |
2004 #ifdef FEAT_MBYTE | 1989 #ifdef FEAT_MBYTE |
2005 int cells; | 1990 int cells; |
2006 #endif | 1991 #endif |
2058 * Output one character (may be one or two display cells). | 2043 * Output one character (may be one or two display cells). |
2059 * Caller must check for valid "off". | 2044 * Caller must check for valid "off". |
2060 * Returns FAIL or OK, just like gui_outstr_nowrap(). | 2045 * Returns FAIL or OK, just like gui_outstr_nowrap(). |
2061 */ | 2046 */ |
2062 static int | 2047 static int |
2063 gui_screenchar(off, flags, fg, bg, back) | 2048 gui_screenchar( |
2064 int off; /* Offset from start of screen */ | 2049 int off, /* Offset from start of screen */ |
2065 int flags; | 2050 int flags, |
2066 guicolor_T fg, bg; /* colors for cursor */ | 2051 guicolor_T fg, /* colors for cursor */ |
2067 int back; /* backup this many chars when using bold trick */ | 2052 guicolor_T bg, /* colors for cursor */ |
2053 int back) /* backup this many chars when using bold trick */ | |
2068 { | 2054 { |
2069 #ifdef FEAT_MBYTE | 2055 #ifdef FEAT_MBYTE |
2070 char_u buf[MB_MAXBYTES + 1]; | 2056 char_u buf[MB_MAXBYTES + 1]; |
2071 | 2057 |
2072 /* Don't draw right halve of a double-width UTF-8 char. "cannot happen" */ | 2058 /* Don't draw right halve of a double-width UTF-8 char. "cannot happen" */ |
2099 * Output the string at the given screen position. This is used in place | 2085 * Output the string at the given screen position. This is used in place |
2100 * of gui_screenchar() where possible because Pango needs as much context | 2086 * of gui_screenchar() where possible because Pango needs as much context |
2101 * as possible to work nicely. It's a lot faster as well. | 2087 * as possible to work nicely. It's a lot faster as well. |
2102 */ | 2088 */ |
2103 static int | 2089 static int |
2104 gui_screenstr(off, len, flags, fg, bg, back) | 2090 gui_screenstr( |
2105 int off; /* Offset from start of screen */ | 2091 int off, /* Offset from start of screen */ |
2106 int len; /* string length in screen cells */ | 2092 int len, /* string length in screen cells */ |
2107 int flags; | 2093 int flags, |
2108 guicolor_T fg, bg; /* colors for cursor */ | 2094 guicolor_T fg, /* colors for cursor */ |
2109 int back; /* backup this many chars when using bold trick */ | 2095 guicolor_T bg, /* colors for cursor */ |
2096 int back) /* backup this many chars when using bold trick */ | |
2110 { | 2097 { |
2111 char_u *buf; | 2098 char_u *buf; |
2112 int outlen = 0; | 2099 int outlen = 0; |
2113 int i; | 2100 int i; |
2114 int retval; | 2101 int retval; |
2182 * it. | 2169 * it. |
2183 * Returns OK, unless "back" is non-zero and using the bold trick, then return | 2170 * Returns OK, unless "back" is non-zero and using the bold trick, then return |
2184 * FAIL (the caller should start drawing "back" chars back). | 2171 * FAIL (the caller should start drawing "back" chars back). |
2185 */ | 2172 */ |
2186 int | 2173 int |
2187 gui_outstr_nowrap(s, len, flags, fg, bg, back) | 2174 gui_outstr_nowrap( |
2188 char_u *s; | 2175 char_u *s, |
2189 int len; | 2176 int len, |
2190 int flags; | 2177 int flags, |
2191 guicolor_T fg, bg; /* colors for cursor */ | 2178 guicolor_T fg, /* colors for cursor */ |
2192 int back; /* backup this many chars when using bold trick */ | 2179 guicolor_T bg, /* colors for cursor */ |
2180 int back) /* backup this many chars when using bold trick */ | |
2193 { | 2181 { |
2194 long_u highlight_mask; | 2182 long_u highlight_mask; |
2195 long_u hl_mask_todo; | 2183 long_u hl_mask_todo; |
2196 guicolor_T fg_color; | 2184 guicolor_T fg_color; |
2197 guicolor_T bg_color; | 2185 guicolor_T bg_color; |
2574 /* | 2562 /* |
2575 * Un-draw the cursor. Actually this just redraws the character at the given | 2563 * Un-draw the cursor. Actually this just redraws the character at the given |
2576 * position. The character just before it too, for when it was in bold. | 2564 * position. The character just before it too, for when it was in bold. |
2577 */ | 2565 */ |
2578 void | 2566 void |
2579 gui_undraw_cursor() | 2567 gui_undraw_cursor(void) |
2580 { | 2568 { |
2581 if (gui.cursor_is_valid) | 2569 if (gui.cursor_is_valid) |
2582 { | 2570 { |
2583 #ifdef FEAT_HANGULIN | 2571 #ifdef FEAT_HANGULIN |
2584 if (composing_hangul | 2572 if (composing_hangul |
2615 gui.cursor_is_valid = FALSE; | 2603 gui.cursor_is_valid = FALSE; |
2616 } | 2604 } |
2617 } | 2605 } |
2618 | 2606 |
2619 void | 2607 void |
2620 gui_redraw(x, y, w, h) | 2608 gui_redraw( |
2621 int x; | 2609 int x, |
2622 int y; | 2610 int y, |
2623 int w; | 2611 int w, |
2624 int h; | 2612 int h) |
2625 { | 2613 { |
2626 int row1, col1, row2, col2; | 2614 int row1, col1, row2, col2; |
2627 | 2615 |
2628 row1 = Y_2_ROW(y); | 2616 row1 = Y_2_ROW(y); |
2629 col1 = X_2_COL(x); | 2617 col1 = X_2_COL(x); |
2648 * from col1 to col2 (inclusive). | 2636 * from col1 to col2 (inclusive). |
2649 * Return TRUE when the character before the first drawn character has | 2637 * Return TRUE when the character before the first drawn character has |
2650 * different attributes (may have to be redrawn too). | 2638 * different attributes (may have to be redrawn too). |
2651 */ | 2639 */ |
2652 int | 2640 int |
2653 gui_redraw_block(row1, col1, row2, col2, flags) | 2641 gui_redraw_block( |
2654 int row1; | 2642 int row1, |
2655 int col1; | 2643 int col1, |
2656 int row2; | 2644 int row2, |
2657 int col2; | 2645 int col2, |
2658 int flags; /* flags for gui_outstr_nowrap() */ | 2646 int flags) /* flags for gui_outstr_nowrap() */ |
2659 { | 2647 { |
2660 int old_row, old_col; | 2648 int old_row, old_col; |
2661 long_u old_hl_mask; | 2649 long_u old_hl_mask; |
2662 int off; | 2650 int off; |
2663 sattr_T first_attr; | 2651 sattr_T first_attr; |
2812 | 2800 |
2813 return retval; | 2801 return retval; |
2814 } | 2802 } |
2815 | 2803 |
2816 static void | 2804 static void |
2817 gui_delete_lines(row, count) | 2805 gui_delete_lines(int row, int count) |
2818 int row; | |
2819 int count; | |
2820 { | 2806 { |
2821 if (count <= 0) | 2807 if (count <= 0) |
2822 return; | 2808 return; |
2823 | 2809 |
2824 if (row + count > gui.scroll_region_bot) | 2810 if (row + count > gui.scroll_region_bot) |
2842 } | 2828 } |
2843 } | 2829 } |
2844 } | 2830 } |
2845 | 2831 |
2846 static void | 2832 static void |
2847 gui_insert_lines(row, count) | 2833 gui_insert_lines(int row, int count) |
2848 int row; | |
2849 int count; | |
2850 { | 2834 { |
2851 if (count <= 0) | 2835 if (count <= 0) |
2852 return; | 2836 return; |
2853 | 2837 |
2854 if (row + count > gui.scroll_region_bot) | 2838 if (row + count > gui.scroll_region_bot) |
2878 * wtime > 0 Wait wtime milliseconds for a character. | 2862 * wtime > 0 Wait wtime milliseconds for a character. |
2879 * Returns OK if a character was found to be available within the given time, | 2863 * Returns OK if a character was found to be available within the given time, |
2880 * or FAIL otherwise. | 2864 * or FAIL otherwise. |
2881 */ | 2865 */ |
2882 int | 2866 int |
2883 gui_wait_for_chars(wtime) | 2867 gui_wait_for_chars(long wtime) |
2884 long wtime; | |
2885 { | 2868 { |
2886 int retval; | 2869 int retval; |
2887 | 2870 |
2888 #ifdef FEAT_MENU | 2871 #ifdef FEAT_MENU |
2889 /* | 2872 /* |
2954 | 2937 |
2955 /* | 2938 /* |
2956 * Fill p[4] with mouse coordinates encoded for check_termcode(). | 2939 * Fill p[4] with mouse coordinates encoded for check_termcode(). |
2957 */ | 2940 */ |
2958 static void | 2941 static void |
2959 fill_mouse_coord(p, col, row) | 2942 fill_mouse_coord(char_u *p, int col, int row) |
2960 char_u *p; | |
2961 int col; | |
2962 int row; | |
2963 { | 2943 { |
2964 p[0] = (char_u)(col / 128 + ' ' + 1); | 2944 p[0] = (char_u)(col / 128 + ' ' + 1); |
2965 p[1] = (char_u)(col % 128 + ' ' + 1); | 2945 p[1] = (char_u)(col % 128 + ' ' + 1); |
2966 p[2] = (char_u)(row / 128 + ' ' + 1); | 2946 p[2] = (char_u)(row / 128 + ' ' + 1); |
2967 p[3] = (char_u)(row % 128 + ' ' + 1); | 2947 p[3] = (char_u)(row % 128 + ' ' + 1); |
2982 * or'ed together: MOUSE_SHIFT | MOUSE_CTRL | MOUSE_ALT. | 2962 * or'ed together: MOUSE_SHIFT | MOUSE_CTRL | MOUSE_ALT. |
2983 * This function will ignore drag events where the mouse has not moved to a new | 2963 * This function will ignore drag events where the mouse has not moved to a new |
2984 * character. | 2964 * character. |
2985 */ | 2965 */ |
2986 void | 2966 void |
2987 gui_send_mouse_event(button, x, y, repeated_click, modifiers) | 2967 gui_send_mouse_event( |
2988 int button; | 2968 int button, |
2989 int x; | 2969 int x, |
2990 int y; | 2970 int y, |
2991 int repeated_click; | 2971 int repeated_click, |
2992 int_u modifiers; | 2972 int_u modifiers) |
2993 { | 2973 { |
2994 static int prev_row = 0, prev_col = 0; | 2974 static int prev_row = 0, prev_col = 0; |
2995 static int prev_button = -1; | 2975 static int prev_button = -1; |
2996 static int num_clicks = 1; | 2976 static int num_clicks = 1; |
2997 char_u string[10]; | 2977 char_u string[10]; |
3297 * Convert x and y coordinate to column and row in text window. | 3277 * Convert x and y coordinate to column and row in text window. |
3298 * Corrects for multi-byte character. | 3278 * Corrects for multi-byte character. |
3299 * returns column in "*colp" and row as return value; | 3279 * returns column in "*colp" and row as return value; |
3300 */ | 3280 */ |
3301 int | 3281 int |
3302 gui_xy2colrow(x, y, colp) | 3282 gui_xy2colrow(int x, int y, int *colp) |
3303 int x; | |
3304 int y; | |
3305 int *colp; | |
3306 { | 3283 { |
3307 int col = check_col(X_2_COL(x)); | 3284 int col = check_col(X_2_COL(x)); |
3308 int row = check_row(Y_2_ROW(y)); | 3285 int row = check_row(Y_2_ROW(y)); |
3309 | 3286 |
3310 #ifdef FEAT_MBYTE | 3287 #ifdef FEAT_MBYTE |
3318 #if defined(FEAT_MENU) || defined(PROTO) | 3295 #if defined(FEAT_MENU) || defined(PROTO) |
3319 /* | 3296 /* |
3320 * Callback function for when a menu entry has been selected. | 3297 * Callback function for when a menu entry has been selected. |
3321 */ | 3298 */ |
3322 void | 3299 void |
3323 gui_menu_cb(menu) | 3300 gui_menu_cb(vimmenu_T *menu) |
3324 vimmenu_T *menu; | |
3325 { | 3301 { |
3326 char_u bytes[sizeof(long_u)]; | 3302 char_u bytes[sizeof(long_u)]; |
3327 | 3303 |
3328 /* Don't put events in the input queue now. */ | 3304 /* Don't put events in the input queue now. */ |
3329 if (hold_gui_events) | 3305 if (hold_gui_events) |
3344 * Set which components are present. | 3320 * Set which components are present. |
3345 * If "oldval" is not NULL, "oldval" is the previous value, the new value is | 3321 * If "oldval" is not NULL, "oldval" is the previous value, the new value is |
3346 * in p_go. | 3322 * in p_go. |
3347 */ | 3323 */ |
3348 void | 3324 void |
3349 gui_init_which_components(oldval) | 3325 gui_init_which_components(char_u *oldval UNUSED) |
3350 char_u *oldval UNUSED; | |
3351 { | 3326 { |
3352 #ifdef FEAT_MENU | 3327 #ifdef FEAT_MENU |
3353 static int prev_menu_is_active = -1; | 3328 static int prev_menu_is_active = -1; |
3354 #endif | 3329 #endif |
3355 #ifdef FEAT_TOOLBAR | 3330 #ifdef FEAT_TOOLBAR |
3597 /* | 3572 /* |
3598 * Return TRUE if the GUI is taking care of the tabline. | 3573 * Return TRUE if the GUI is taking care of the tabline. |
3599 * It may still be hidden if 'showtabline' is zero. | 3574 * It may still be hidden if 'showtabline' is zero. |
3600 */ | 3575 */ |
3601 int | 3576 int |
3602 gui_use_tabline() | 3577 gui_use_tabline(void) |
3603 { | 3578 { |
3604 return gui.in_use && vim_strchr(p_go, GO_TABLINE) != NULL; | 3579 return gui.in_use && vim_strchr(p_go, GO_TABLINE) != NULL; |
3605 } | 3580 } |
3606 | 3581 |
3607 /* | 3582 /* |
3608 * Return TRUE if the GUI is showing the tabline. | 3583 * Return TRUE if the GUI is showing the tabline. |
3609 * This uses 'showtabline'. | 3584 * This uses 'showtabline'. |
3610 */ | 3585 */ |
3611 static int | 3586 static int |
3612 gui_has_tabline() | 3587 gui_has_tabline(void) |
3613 { | 3588 { |
3614 if (!gui_use_tabline() | 3589 if (!gui_use_tabline() |
3615 || p_stal == 0 | 3590 || p_stal == 0 |
3616 || (p_stal == 1 && first_tabpage->tp_next == NULL)) | 3591 || (p_stal == 1 && first_tabpage->tp_next == NULL)) |
3617 return FALSE; | 3592 return FALSE; |
3621 /* | 3596 /* |
3622 * Update the tabline. | 3597 * Update the tabline. |
3623 * This may display/undisplay the tabline and update the labels. | 3598 * This may display/undisplay the tabline and update the labels. |
3624 */ | 3599 */ |
3625 void | 3600 void |
3626 gui_update_tabline() | 3601 gui_update_tabline(void) |
3627 { | 3602 { |
3628 int showit = gui_has_tabline(); | 3603 int showit = gui_has_tabline(); |
3629 int shown = gui_mch_showing_tabline(); | 3604 int shown = gui_mch_showing_tabline(); |
3630 | 3605 |
3631 if (!gui.starting && starting == 0) | 3606 if (!gui.starting && starting == 0) |
3649 | 3624 |
3650 /* | 3625 /* |
3651 * Get the label or tooltip for tab page "tp" into NameBuff[]. | 3626 * Get the label or tooltip for tab page "tp" into NameBuff[]. |
3652 */ | 3627 */ |
3653 void | 3628 void |
3654 get_tabline_label(tp, tooltip) | 3629 get_tabline_label( |
3655 tabpage_T *tp; | 3630 tabpage_T *tp, |
3656 int tooltip; /* TRUE: get tooltip */ | 3631 int tooltip) /* TRUE: get tooltip */ |
3657 { | 3632 { |
3658 int modified = FALSE; | 3633 int modified = FALSE; |
3659 char_u buf[40]; | 3634 char_u buf[40]; |
3660 int wincount; | 3635 int wincount; |
3661 win_T *wp; | 3636 win_T *wp; |
3742 * Send the event for clicking to select tab page "nr". | 3717 * Send the event for clicking to select tab page "nr". |
3743 * Returns TRUE if it was done, FALSE when skipped because we are already at | 3718 * Returns TRUE if it was done, FALSE when skipped because we are already at |
3744 * that tab page or the cmdline window is open. | 3719 * that tab page or the cmdline window is open. |
3745 */ | 3720 */ |
3746 int | 3721 int |
3747 send_tabline_event(nr) | 3722 send_tabline_event(int nr) |
3748 int nr; | |
3749 { | 3723 { |
3750 char_u string[3]; | 3724 char_u string[3]; |
3751 | 3725 |
3752 if (nr == tabpage_index(curtab)) | 3726 if (nr == tabpage_index(curtab)) |
3753 return FALSE; | 3727 return FALSE; |
3775 | 3749 |
3776 /* | 3750 /* |
3777 * Send a tabline menu event | 3751 * Send a tabline menu event |
3778 */ | 3752 */ |
3779 void | 3753 void |
3780 send_tabline_menu_event(tabidx, event) | 3754 send_tabline_menu_event(int tabidx, int event) |
3781 int tabidx; | |
3782 int event; | |
3783 { | 3755 { |
3784 char_u string[3]; | 3756 char_u string[3]; |
3785 | 3757 |
3786 /* Don't put events in the input queue now. */ | 3758 /* Don't put events in the input queue now. */ |
3787 if (hold_gui_events) | 3759 if (hold_gui_events) |
3805 #if defined(FEAT_WINDOWS) || defined(PROTO) | 3777 #if defined(FEAT_WINDOWS) || defined(PROTO) |
3806 /* | 3778 /* |
3807 * Remove all scrollbars. Used before switching to another tab page. | 3779 * Remove all scrollbars. Used before switching to another tab page. |
3808 */ | 3780 */ |
3809 void | 3781 void |
3810 gui_remove_scrollbars() | 3782 gui_remove_scrollbars(void) |
3811 { | 3783 { |
3812 int i; | 3784 int i; |
3813 win_T *wp; | 3785 win_T *wp; |
3814 | 3786 |
3815 for (i = 0; i < 3; i++) | 3787 for (i = 0; i < 3; i++) |
3827 } | 3799 } |
3828 } | 3800 } |
3829 #endif | 3801 #endif |
3830 | 3802 |
3831 void | 3803 void |
3832 gui_create_scrollbar(sb, type, wp) | 3804 gui_create_scrollbar(scrollbar_T *sb, int type, win_T *wp) |
3833 scrollbar_T *sb; | |
3834 int type; | |
3835 win_T *wp; | |
3836 { | 3805 { |
3837 static int sbar_ident = 0; | 3806 static int sbar_ident = 0; |
3838 | 3807 |
3839 sb->ident = sbar_ident++; /* No check for too big, but would it happen? */ | 3808 sb->ident = sbar_ident++; /* No check for too big, but would it happen? */ |
3840 sb->wp = wp; | 3809 sb->wp = wp; |
3856 | 3825 |
3857 /* | 3826 /* |
3858 * Find the scrollbar with the given index. | 3827 * Find the scrollbar with the given index. |
3859 */ | 3828 */ |
3860 scrollbar_T * | 3829 scrollbar_T * |
3861 gui_find_scrollbar(ident) | 3830 gui_find_scrollbar(long ident) |
3862 long ident; | |
3863 { | 3831 { |
3864 win_T *wp; | 3832 win_T *wp; |
3865 | 3833 |
3866 if (gui.bottom_sbar.ident == ident) | 3834 if (gui.bottom_sbar.ident == ident) |
3867 return &gui.bottom_sbar; | 3835 return &gui.bottom_sbar; |
3889 * Solution: Do the scrolling right here. But only when allowed. | 3857 * Solution: Do the scrolling right here. But only when allowed. |
3890 * Ignore the scrollbars while executing an external command or when there | 3858 * Ignore the scrollbars while executing an external command or when there |
3891 * are still characters to be processed. | 3859 * are still characters to be processed. |
3892 */ | 3860 */ |
3893 void | 3861 void |
3894 gui_drag_scrollbar(sb, value, still_dragging) | 3862 gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging) |
3895 scrollbar_T *sb; | |
3896 long value; | |
3897 int still_dragging; | |
3898 { | 3863 { |
3899 #ifdef FEAT_WINDOWS | 3864 #ifdef FEAT_WINDOWS |
3900 win_T *wp; | 3865 win_T *wp; |
3901 #endif | 3866 #endif |
3902 int sb_num; | 3867 int sb_num; |
4110 #if defined(FEAT_AUTOCMD) || defined(FEAT_WINDOWS) || defined(PROTO) | 4075 #if defined(FEAT_AUTOCMD) || defined(FEAT_WINDOWS) || defined(PROTO) |
4111 /* | 4076 /* |
4112 * Called when something in the window layout has changed. | 4077 * Called when something in the window layout has changed. |
4113 */ | 4078 */ |
4114 void | 4079 void |
4115 gui_may_update_scrollbars() | 4080 gui_may_update_scrollbars(void) |
4116 { | 4081 { |
4117 if (gui.in_use && starting == 0) | 4082 if (gui.in_use && starting == 0) |
4118 { | 4083 { |
4119 out_flush(); | 4084 out_flush(); |
4120 gui_init_which_components(NULL); | 4085 gui_init_which_components(NULL); |
4123 need_mouse_correct = TRUE; | 4088 need_mouse_correct = TRUE; |
4124 } | 4089 } |
4125 #endif | 4090 #endif |
4126 | 4091 |
4127 void | 4092 void |
4128 gui_update_scrollbars(force) | 4093 gui_update_scrollbars( |
4129 int force; /* Force all scrollbars to get updated */ | 4094 int force) /* Force all scrollbars to get updated */ |
4130 { | 4095 { |
4131 win_T *wp; | 4096 win_T *wp; |
4132 scrollbar_T *sb; | 4097 scrollbar_T *sb; |
4133 long val, size, max; /* need 32 bits here */ | 4098 long val, size, max; /* need 32 bits here */ |
4134 int which_sb; | 4099 int which_sb; |
4338 * Enable or disable a scrollbar. | 4303 * Enable or disable a scrollbar. |
4339 * Check for scrollbars for vertically split windows which are not enabled | 4304 * Check for scrollbars for vertically split windows which are not enabled |
4340 * sometimes. | 4305 * sometimes. |
4341 */ | 4306 */ |
4342 static void | 4307 static void |
4343 gui_do_scrollbar(wp, which, enable) | 4308 gui_do_scrollbar( |
4344 win_T *wp; | 4309 win_T *wp, |
4345 int which; /* SBAR_LEFT or SBAR_RIGHT */ | 4310 int which, /* SBAR_LEFT or SBAR_RIGHT */ |
4346 int enable; /* TRUE to enable scrollbar */ | 4311 int enable) /* TRUE to enable scrollbar */ |
4347 { | 4312 { |
4348 #ifdef FEAT_VERTSPLIT | 4313 #ifdef FEAT_VERTSPLIT |
4349 int midcol = curwin->w_wincol + curwin->w_width / 2; | 4314 int midcol = curwin->w_wincol + curwin->w_width / 2; |
4350 int has_midcol = (wp->w_wincol <= midcol | 4315 int has_midcol = (wp->w_wincol <= midcol |
4351 && wp->w_wincol + wp->w_width >= midcol); | 4316 && wp->w_wincol + wp->w_width >= midcol); |
4384 * Scroll a window according to the values set in the globals current_scrollbar | 4349 * Scroll a window according to the values set in the globals current_scrollbar |
4385 * and scrollbar_value. Return TRUE if the cursor in the current window moved | 4350 * and scrollbar_value. Return TRUE if the cursor in the current window moved |
4386 * or FALSE otherwise. | 4351 * or FALSE otherwise. |
4387 */ | 4352 */ |
4388 int | 4353 int |
4389 gui_do_scroll() | 4354 gui_do_scroll(void) |
4390 { | 4355 { |
4391 win_T *wp, *save_wp; | 4356 win_T *wp, *save_wp; |
4392 int i; | 4357 int i; |
4393 long nlines; | 4358 long nlines; |
4394 pos_T old_cursor; | 4359 pos_T old_cursor; |
4496 | 4461 |
4497 /* | 4462 /* |
4498 * Return length of line "lnum" for horizontal scrolling. | 4463 * Return length of line "lnum" for horizontal scrolling. |
4499 */ | 4464 */ |
4500 static colnr_T | 4465 static colnr_T |
4501 scroll_line_len(lnum) | 4466 scroll_line_len(linenr_T lnum) |
4502 linenr_T lnum; | |
4503 { | 4467 { |
4504 char_u *p; | 4468 char_u *p; |
4505 colnr_T col; | 4469 colnr_T col; |
4506 int w; | 4470 int w; |
4507 | 4471 |
4526 /* | 4490 /* |
4527 * Find longest visible line number. If this is not possible (or not desired, | 4491 * Find longest visible line number. If this is not possible (or not desired, |
4528 * by setting 'h' in "guioptions") then the current line number is returned. | 4492 * by setting 'h' in "guioptions") then the current line number is returned. |
4529 */ | 4493 */ |
4530 static linenr_T | 4494 static linenr_T |
4531 gui_find_longest_lnum() | 4495 gui_find_longest_lnum(void) |
4532 { | 4496 { |
4533 linenr_T ret = 0; | 4497 linenr_T ret = 0; |
4534 | 4498 |
4535 /* Calculate maximum for horizontal scrollbar. Check for reasonable | 4499 /* Calculate maximum for horizontal scrollbar. Check for reasonable |
4536 * line numbers, topline and botline can be invalid when displaying is | 4500 * line numbers, topline and botline can be invalid when displaying is |
4567 | 4531 |
4568 return ret; | 4532 return ret; |
4569 } | 4533 } |
4570 | 4534 |
4571 static void | 4535 static void |
4572 gui_update_horiz_scrollbar(force) | 4536 gui_update_horiz_scrollbar(int force) |
4573 int force; | |
4574 { | 4537 { |
4575 long value, size, max; /* need 32 bit ints here */ | 4538 long value, size, max; /* need 32 bit ints here */ |
4576 | 4539 |
4577 if (!gui.which_scrollbars[SBAR_BOTTOM]) | 4540 if (!gui.which_scrollbars[SBAR_BOTTOM]) |
4578 return; | 4541 return; |
4660 | 4623 |
4661 /* | 4624 /* |
4662 * Do a horizontal scroll. Return TRUE if the cursor moved, FALSE otherwise. | 4625 * Do a horizontal scroll. Return TRUE if the cursor moved, FALSE otherwise. |
4663 */ | 4626 */ |
4664 int | 4627 int |
4665 gui_do_horiz_scroll(leftcol, compute_longest_lnum) | 4628 gui_do_horiz_scroll(long_u leftcol, int compute_longest_lnum) |
4666 long_u leftcol; | |
4667 int compute_longest_lnum; | |
4668 { | 4629 { |
4669 /* no wrapping, no scrolling */ | 4630 /* no wrapping, no scrolling */ |
4670 if (curwin->w_p_wrap) | 4631 if (curwin->w_p_wrap) |
4671 return FALSE; | 4632 return FALSE; |
4672 | 4633 |
4700 | 4661 |
4701 /* | 4662 /* |
4702 * Check that none of the colors are the same as the background color | 4663 * Check that none of the colors are the same as the background color |
4703 */ | 4664 */ |
4704 void | 4665 void |
4705 gui_check_colors() | 4666 gui_check_colors(void) |
4706 { | 4667 { |
4707 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) | 4668 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) |
4708 { | 4669 { |
4709 gui_set_bg_color((char_u *)"White"); | 4670 gui_set_bg_color((char_u *)"White"); |
4710 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) | 4671 if (gui.norm_pixel == gui.back_pixel || gui.norm_pixel == INVALCOLOR) |
4711 gui_set_fg_color((char_u *)"Black"); | 4672 gui_set_fg_color((char_u *)"Black"); |
4712 } | 4673 } |
4713 } | 4674 } |
4714 | 4675 |
4715 static void | 4676 static void |
4716 gui_set_fg_color(name) | 4677 gui_set_fg_color(char_u *name) |
4717 char_u *name; | |
4718 { | 4678 { |
4719 gui.norm_pixel = gui_get_color(name); | 4679 gui.norm_pixel = gui_get_color(name); |
4720 hl_set_fg_color_name(vim_strsave(name)); | 4680 hl_set_fg_color_name(vim_strsave(name)); |
4721 } | 4681 } |
4722 | 4682 |
4723 static void | 4683 static void |
4724 gui_set_bg_color(name) | 4684 gui_set_bg_color(char_u *name) |
4725 char_u *name; | |
4726 { | 4685 { |
4727 gui.back_pixel = gui_get_color(name); | 4686 gui.back_pixel = gui_get_color(name); |
4728 hl_set_bg_color_name(vim_strsave(name)); | 4687 hl_set_bg_color_name(vim_strsave(name)); |
4729 } | 4688 } |
4730 | 4689 |
4731 /* | 4690 /* |
4732 * Allocate a color by name. | 4691 * Allocate a color by name. |
4733 * Returns INVALCOLOR and gives an error message when failed. | 4692 * Returns INVALCOLOR and gives an error message when failed. |
4734 */ | 4693 */ |
4735 guicolor_T | 4694 guicolor_T |
4736 gui_get_color(name) | 4695 gui_get_color(char_u *name) |
4737 char_u *name; | |
4738 { | 4696 { |
4739 guicolor_T t; | 4697 guicolor_T t; |
4740 | 4698 |
4741 if (*name == NUL) | 4699 if (*name == NUL) |
4742 return INVALCOLOR; | 4700 return INVALCOLOR; |
4753 | 4711 |
4754 /* | 4712 /* |
4755 * Return the grey value of a color (range 0-255). | 4713 * Return the grey value of a color (range 0-255). |
4756 */ | 4714 */ |
4757 int | 4715 int |
4758 gui_get_lightness(pixel) | 4716 gui_get_lightness(guicolor_T pixel) |
4759 guicolor_T pixel; | |
4760 { | 4717 { |
4761 long_u rgb = gui_mch_get_rgb(pixel); | 4718 long_u rgb = gui_mch_get_rgb(pixel); |
4762 | 4719 |
4763 return (int)( (((rgb >> 16) & 0xff) * 299) | 4720 return (int)( (((rgb >> 16) & 0xff) * 299) |
4764 + (((rgb >> 8) & 0xff) * 587) | 4721 + (((rgb >> 8) & 0xff) * 587) |
4765 + ((rgb & 0xff) * 114)) / 1000; | 4722 + ((rgb & 0xff) * 114)) / 1000; |
4766 } | 4723 } |
4767 | 4724 |
4768 #if defined(FEAT_GUI_X11) || defined(PROTO) | 4725 #if defined(FEAT_GUI_X11) || defined(PROTO) |
4769 void | 4726 void |
4770 gui_new_scrollbar_colors() | 4727 gui_new_scrollbar_colors(void) |
4771 { | 4728 { |
4772 win_T *wp; | 4729 win_T *wp; |
4773 | 4730 |
4774 /* Nothing to do if GUI hasn't started yet. */ | 4731 /* Nothing to do if GUI hasn't started yet. */ |
4775 if (!gui.in_use) | 4732 if (!gui.in_use) |
4786 | 4743 |
4787 /* | 4744 /* |
4788 * Call this when focus has changed. | 4745 * Call this when focus has changed. |
4789 */ | 4746 */ |
4790 void | 4747 void |
4791 gui_focus_change(in_focus) | 4748 gui_focus_change(int in_focus) |
4792 int in_focus; | |
4793 { | 4749 { |
4794 /* | 4750 /* |
4795 * Skip this code to avoid drawing the cursor when debugging and switching | 4751 * Skip this code to avoid drawing the cursor when debugging and switching |
4796 * between the debugger window and gvim. | 4752 * between the debugger window and gvim. |
4797 */ | 4753 */ |
4821 | 4777 |
4822 /* | 4778 /* |
4823 * Called when the mouse moved (but not when dragging). | 4779 * Called when the mouse moved (but not when dragging). |
4824 */ | 4780 */ |
4825 void | 4781 void |
4826 gui_mouse_moved(x, y) | 4782 gui_mouse_moved(int x, int y) |
4827 int x; | |
4828 int y; | |
4829 { | 4783 { |
4830 win_T *wp; | 4784 win_T *wp; |
4831 char_u st[8]; | 4785 char_u st[8]; |
4832 | 4786 |
4833 /* Ignore this while still starting up. */ | 4787 /* Ignore this while still starting up. */ |
4900 | 4854 |
4901 /* | 4855 /* |
4902 * Called when mouse should be moved to window with focus. | 4856 * Called when mouse should be moved to window with focus. |
4903 */ | 4857 */ |
4904 void | 4858 void |
4905 gui_mouse_correct() | 4859 gui_mouse_correct(void) |
4906 { | 4860 { |
4907 int x, y; | 4861 int x, y; |
4908 win_T *wp = NULL; | 4862 win_T *wp = NULL; |
4909 | 4863 |
4910 need_mouse_correct = FALSE; | 4864 need_mouse_correct = FALSE; |
4933 | 4887 |
4934 /* | 4888 /* |
4935 * Find window where the mouse pointer "y" coordinate is in. | 4889 * Find window where the mouse pointer "y" coordinate is in. |
4936 */ | 4890 */ |
4937 static win_T * | 4891 static win_T * |
4938 xy2win(x, y) | 4892 xy2win(int x UNUSED, int y UNUSED) |
4939 int x UNUSED; | |
4940 int y UNUSED; | |
4941 { | 4893 { |
4942 #ifdef FEAT_WINDOWS | 4894 #ifdef FEAT_WINDOWS |
4943 int row; | 4895 int row; |
4944 int col; | 4896 int col; |
4945 win_T *wp; | 4897 win_T *wp; |
4979 /* | 4931 /* |
4980 * ":gui" and ":gvim": Change from the terminal version to the GUI version. | 4932 * ":gui" and ":gvim": Change from the terminal version to the GUI version. |
4981 * File names may be given to redefine the args list. | 4933 * File names may be given to redefine the args list. |
4982 */ | 4934 */ |
4983 void | 4935 void |
4984 ex_gui(eap) | 4936 ex_gui(exarg_T *eap) |
4985 exarg_T *eap; | |
4986 { | 4937 { |
4987 char_u *arg = eap->arg; | 4938 char_u *arg = eap->arg; |
4988 | 4939 |
4989 /* | 4940 /* |
4990 * Check for "-f" argument: foreground, don't fork. | 4941 * Check for "-f" argument: foreground, don't fork. |
5021 | 4972 |
5022 /* | 4973 /* |
5023 * Callback function for do_in_runtimepath(). | 4974 * Callback function for do_in_runtimepath(). |
5024 */ | 4975 */ |
5025 static void | 4976 static void |
5026 gfp_setname(fname, cookie) | 4977 gfp_setname(char_u *fname, void *cookie) |
5027 char_u *fname; | |
5028 void *cookie; | |
5029 { | 4978 { |
5030 char_u *gfp_buffer = cookie; | 4979 char_u *gfp_buffer = cookie; |
5031 | 4980 |
5032 if (STRLEN(fname) >= MAXPATHL) | 4981 if (STRLEN(fname) >= MAXPATHL) |
5033 *gfp_buffer = NUL; | 4982 *gfp_buffer = NUL; |
5038 /* | 4987 /* |
5039 * Find the path of bitmap "name" with extension "ext" in 'runtimepath'. | 4988 * Find the path of bitmap "name" with extension "ext" in 'runtimepath'. |
5040 * Return FAIL for failure and OK if buffer[MAXPATHL] contains the result. | 4989 * Return FAIL for failure and OK if buffer[MAXPATHL] contains the result. |
5041 */ | 4990 */ |
5042 int | 4991 int |
5043 gui_find_bitmap(name, buffer, ext) | 4992 gui_find_bitmap(char_u *name, char_u *buffer, char *ext) |
5044 char_u *name; | |
5045 char_u *buffer; | |
5046 char *ext; | |
5047 { | 4993 { |
5048 if (STRLEN(name) > MAXPATHL - 14) | 4994 if (STRLEN(name) > MAXPATHL - 14) |
5049 return FAIL; | 4995 return FAIL; |
5050 vim_snprintf((char *)buffer, MAXPATHL, "bitmaps/%s.%s", name, ext); | 4996 vim_snprintf((char *)buffer, MAXPATHL, "bitmaps/%s.%s", name, ext); |
5051 if (do_in_runtimepath(buffer, FALSE, gfp_setname, buffer) == FAIL | 4997 if (do_in_runtimepath(buffer, FALSE, gfp_setname, buffer) == FAIL |
5061 * "ext" and search for it in 'runtimepath'. | 5007 * "ext" and search for it in 'runtimepath'. |
5062 * The result is put in "buffer[MAXPATHL]". If something fails "buffer" | 5008 * The result is put in "buffer[MAXPATHL]". If something fails "buffer" |
5063 * contains "name". | 5009 * contains "name". |
5064 */ | 5010 */ |
5065 void | 5011 void |
5066 gui_find_iconfile(name, buffer, ext) | 5012 gui_find_iconfile(char_u *name, char_u *buffer, char *ext) |
5067 char_u *name; | |
5068 char_u *buffer; | |
5069 char *ext; | |
5070 { | 5013 { |
5071 char_u buf[MAXPATHL + 1]; | 5014 char_u buf[MAXPATHL + 1]; |
5072 | 5015 |
5073 expand_env(name, buffer, MAXPATHL); | 5016 expand_env(name, buffer, MAXPATHL); |
5074 if (!mch_isFullName(buffer) && gui_find_bitmap(buffer, buf, ext) == OK) | 5017 if (!mch_isFullName(buffer) && gui_find_bitmap(buffer, buf, ext) == OK) |
5077 # endif | 5020 # endif |
5078 #endif | 5021 #endif |
5079 | 5022 |
5080 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(PROTO) | 5023 #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) || defined(PROTO) |
5081 void | 5024 void |
5082 display_errors() | 5025 display_errors(void) |
5083 { | 5026 { |
5084 char_u *p; | 5027 char_u *p; |
5085 | 5028 |
5086 if (isatty(2)) | 5029 if (isatty(2)) |
5087 fflush(stderr); | 5030 fflush(stderr); |
5109 * For GTK and X11 we check if stderr is not a tty, which means we were | 5052 * For GTK and X11 we check if stderr is not a tty, which means we were |
5110 * (probably) started from the desktop. Also check stdin, "vim >& file" does | 5053 * (probably) started from the desktop. Also check stdin, "vim >& file" does |
5111 * allow typing on stdin. | 5054 * allow typing on stdin. |
5112 */ | 5055 */ |
5113 int | 5056 int |
5114 no_console_input() | 5057 no_console_input(void) |
5115 { | 5058 { |
5116 return ((!gui.in_use || gui.starting) | 5059 return ((!gui.in_use || gui.starting) |
5117 # ifndef NO_CONSOLE | 5060 # ifndef NO_CONSOLE |
5118 && !isatty(0) && !isatty(2) | 5061 && !isatty(0) && !isatty(2) |
5119 # endif | 5062 # endif |
5126 || defined(PROTO) | 5069 || defined(PROTO) |
5127 /* | 5070 /* |
5128 * Update the current window and the screen. | 5071 * Update the current window and the screen. |
5129 */ | 5072 */ |
5130 void | 5073 void |
5131 gui_update_screen() | 5074 gui_update_screen(void) |
5132 { | 5075 { |
5133 #ifdef FEAT_CONCEAL | 5076 #ifdef FEAT_CONCEAL |
5134 linenr_T conceal_old_cursor_line = 0; | 5077 linenr_T conceal_old_cursor_line = 0; |
5135 linenr_T conceal_new_cursor_line = 0; | 5078 linenr_T conceal_new_cursor_line = 0; |
5136 int conceal_update_lines = FALSE; | 5079 int conceal_update_lines = FALSE; |
5197 * Get the text to use in a find/replace dialog. Uses the last search pattern | 5140 * Get the text to use in a find/replace dialog. Uses the last search pattern |
5198 * if the argument is empty. | 5141 * if the argument is empty. |
5199 * Returns an allocated string. | 5142 * Returns an allocated string. |
5200 */ | 5143 */ |
5201 char_u * | 5144 char_u * |
5202 get_find_dialog_text(arg, wwordp, mcasep) | 5145 get_find_dialog_text( |
5203 char_u *arg; | 5146 char_u *arg, |
5204 int *wwordp; /* return: TRUE if \< \> found */ | 5147 int *wwordp, /* return: TRUE if \< \> found */ |
5205 int *mcasep; /* return: TRUE if \C found */ | 5148 int *mcasep) /* return: TRUE if \C found */ |
5206 { | 5149 { |
5207 char_u *text; | 5150 char_u *text; |
5208 | 5151 |
5209 if (*arg == NUL) | 5152 if (*arg == NUL) |
5210 text = last_search_pat(); | 5153 text = last_search_pat(); |
5258 | 5201 |
5259 /* | 5202 /* |
5260 * Concatenate "text" to grow array "gap", escaping "what" with a backslash. | 5203 * Concatenate "text" to grow array "gap", escaping "what" with a backslash. |
5261 */ | 5204 */ |
5262 static void | 5205 static void |
5263 concat_esc(gap, text, what) | 5206 concat_esc(garray_T *gap, char_u *text, int what) |
5264 garray_T *gap; | |
5265 char_u *text; | |
5266 int what; | |
5267 { | 5207 { |
5268 while (*text != NUL) | 5208 while (*text != NUL) |
5269 { | 5209 { |
5270 #ifdef FEAT_MBYTE | 5210 #ifdef FEAT_MBYTE |
5271 int l = (*mb_ptr2len)(text); | 5211 int l = (*mb_ptr2len)(text); |
5287 /* | 5227 /* |
5288 * Handle the press of a button in the find-replace dialog. | 5228 * Handle the press of a button in the find-replace dialog. |
5289 * Return TRUE when something was added to the input buffer. | 5229 * Return TRUE when something was added to the input buffer. |
5290 */ | 5230 */ |
5291 int | 5231 int |
5292 gui_do_findrepl(flags, find_text, repl_text, down) | 5232 gui_do_findrepl( |
5293 int flags; /* one of FRD_REPLACE, FRD_FINDNEXT, etc. */ | 5233 int flags, /* one of FRD_REPLACE, FRD_FINDNEXT, etc. */ |
5294 char_u *find_text; | 5234 char_u *find_text, |
5295 char_u *repl_text; | 5235 char_u *repl_text, |
5296 int down; /* Search downwards. */ | 5236 int down) /* Search downwards. */ |
5297 { | 5237 { |
5298 garray_T ga; | 5238 garray_T ga; |
5299 int i; | 5239 int i; |
5300 int type = (flags & FRD_TYPE_MASK); | 5240 int type = (flags & FRD_TYPE_MASK); |
5301 char_u *p; | 5241 char_u *p; |
5420 | 5360 |
5421 /* | 5361 /* |
5422 * Jump to the window at specified point (x, y). | 5362 * Jump to the window at specified point (x, y). |
5423 */ | 5363 */ |
5424 static void | 5364 static void |
5425 gui_wingoto_xy(x, y) | 5365 gui_wingoto_xy(int x, int y) |
5426 int x; | |
5427 int y; | |
5428 { | 5366 { |
5429 int row = Y_2_ROW(y); | 5367 int row = Y_2_ROW(y); |
5430 int col = X_2_COL(x); | 5368 int col = X_2_COL(x); |
5431 win_T *wp; | 5369 win_T *wp; |
5432 | 5370 |
5444 * and count of files are given. Argument "fnames[count]" has full pathnames | 5382 * and count of files are given. Argument "fnames[count]" has full pathnames |
5445 * of dropped files, they will be freed in this function, and caller can't use | 5383 * of dropped files, they will be freed in this function, and caller can't use |
5446 * fnames after call this function. | 5384 * fnames after call this function. |
5447 */ | 5385 */ |
5448 void | 5386 void |
5449 gui_handle_drop(x, y, modifiers, fnames, count) | 5387 gui_handle_drop( |
5450 int x UNUSED; | 5388 int x UNUSED, |
5451 int y UNUSED; | 5389 int y UNUSED, |
5452 int_u modifiers; | 5390 int_u modifiers, |
5453 char_u **fnames; | 5391 char_u **fnames, |
5454 int count; | 5392 int count) |
5455 { | 5393 { |
5456 int i; | 5394 int i; |
5457 char_u *p; | 5395 char_u *p; |
5458 static int entered = FALSE; | 5396 static int entered = FALSE; |
5459 | 5397 |