Mercurial > vim
comparison src/gui_x11.c @ 13244:ac42c4b11dbc v8.0.1496
patch 8.0.1496: clearing a pointer takes two lines
commit https://github.com/vim/vim/commit/d23a823669d93fb2a570a039173eefe4856ac806
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 10 18:45:26 2018 +0100
patch 8.0.1496: clearing a pointer takes two lines
Problem: Clearing a pointer takes two lines.
Solution: Add VIM_CLEAR() and replace vim_clear(). (Hirohito Higashi,
closes #2629)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 10 Feb 2018 19:00:07 +0100 |
parents | f4c3a7f410f4 |
children | 245c053021d3 |
comparison
equal
deleted
inserted
replaced
13243:899b19739188 | 13244:ac42c4b11dbc |
---|---|
824 # ifdef USE_UTF8LOOKUP | 824 # ifdef USE_UTF8LOOKUP |
825 && !enc_utf8 | 825 && !enc_utf8 |
826 # endif | 826 # endif |
827 ) | 827 ) |
828 { | 828 { |
829 int maxlen = len * 4 + 40; /* guessed */ | 829 int maxlen = len * 4 + 40; /* guessed */ |
830 char_u *p = (char_u *)XtMalloc(maxlen); | 830 char_u *p = (char_u *)XtMalloc(maxlen); |
831 | 831 |
832 mch_memmove(p, string, len); | 832 mch_memmove(p, string, len); |
833 if (string_alloced) | 833 if (string_alloced) |
834 XtFree((char *)string); | 834 XtFree((char *)string); |
1565 { | 1565 { |
1566 gui_x11_destroy_widgets(); | 1566 gui_x11_destroy_widgets(); |
1567 XtCloseDisplay(gui.dpy); | 1567 XtCloseDisplay(gui.dpy); |
1568 gui.dpy = NULL; | 1568 gui.dpy = NULL; |
1569 vimShell = (Widget)0; | 1569 vimShell = (Widget)0; |
1570 vim_free(gui_argv); | 1570 VIM_CLEAR(gui_argv); |
1571 gui_argv = NULL; | |
1572 } | 1571 } |
1573 | 1572 |
1574 /* | 1573 /* |
1575 * Called when the foreground or background color has been changed. | 1574 * Called when the foreground or background color has been changed. |
1576 */ | 1575 */ |
1739 #if 0 | 1738 #if 0 |
1740 /* Lesstif gives an error message here, and so does Solaris. The man page | 1739 /* Lesstif gives an error message here, and so does Solaris. The man page |
1741 * says that this isn't needed when exiting, so just skip it. */ | 1740 * says that this isn't needed when exiting, so just skip it. */ |
1742 XtCloseDisplay(gui.dpy); | 1741 XtCloseDisplay(gui.dpy); |
1743 #endif | 1742 #endif |
1744 vim_free(gui_argv); | 1743 VIM_CLEAR(gui_argv); |
1745 gui_argv = NULL; | |
1746 } | 1744 } |
1747 | 1745 |
1748 /* | 1746 /* |
1749 * Get the position of the top left corner of the window. | 1747 * Get the position of the top left corner of the window. |
1750 */ | 1748 */ |
1954 GuiFont | 1952 GuiFont |
1955 gui_mch_get_font(char_u *name, int giveErrorIfMissing) | 1953 gui_mch_get_font(char_u *name, int giveErrorIfMissing) |
1956 { | 1954 { |
1957 XFontStruct *font; | 1955 XFontStruct *font; |
1958 | 1956 |
1959 if (!gui.in_use || name == NULL) /* can't do this when GUI not running */ | 1957 if (!gui.in_use || name == NULL) /* can't do this when GUI not running */ |
1960 return NOFONT; | 1958 return NOFONT; |
1961 | 1959 |
1962 font = XLoadQueryFont(gui.dpy, (char *)name); | 1960 font = XLoadQueryFont(gui.dpy, (char *)name); |
1963 | 1961 |
1964 if (font == NULL) | 1962 if (font == NULL) |
2273 * Return INVALCOLOR for error. | 2271 * Return INVALCOLOR for error. |
2274 */ | 2272 */ |
2275 guicolor_T | 2273 guicolor_T |
2276 gui_mch_get_color(char_u *name) | 2274 gui_mch_get_color(char_u *name) |
2277 { | 2275 { |
2278 guicolor_T requested; | 2276 guicolor_T requested; |
2279 | 2277 |
2280 /* can't do this when GUI not running */ | 2278 /* can't do this when GUI not running */ |
2281 if (!gui.in_use || name == NULL || *name == NUL) | 2279 if (!gui.in_use || name == NULL || *name == NUL) |
2282 return INVALCOLOR; | 2280 return INVALCOLOR; |
2283 | 2281 |
2296 * Return INVALCOLOR for error. | 2294 * Return INVALCOLOR for error. |
2297 */ | 2295 */ |
2298 guicolor_T | 2296 guicolor_T |
2299 gui_mch_get_rgb_color(int r, int g, int b) | 2297 gui_mch_get_rgb_color(int r, int g, int b) |
2300 { | 2298 { |
2301 char spec[8]; /* space enough to hold "#RRGGBB" */ | 2299 char spec[8]; /* space enough to hold "#RRGGBB" */ |
2302 XColor available; | 2300 XColor available; |
2303 Colormap colormap; | 2301 Colormap colormap; |
2304 | 2302 |
2305 vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b); | 2303 vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b); |
2306 colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy)); | 2304 colormap = DefaultColormap(gui.dpy, DefaultScreen(gui.dpy)); |
2307 if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0 | 2305 if (XParseColor(gui.dpy, colormap, (char *)spec, &available) != 0 |