Skip to content

Commit 7e94ef5

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 1cfc3ae + c71053c commit 7e94ef5

8 files changed

Lines changed: 247 additions & 17 deletions

File tree

src/channel.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ ch_log_active(void)
140140
}
141141

142142
static void
143-
ch_log_lead(char *what, channel_T *ch)
143+
ch_log_lead(const char *what, channel_T *ch)
144144
{
145145
if (log_fd != NULL)
146146
{
@@ -1834,12 +1834,11 @@ channel_save(channel_T *channel, ch_part_T part, char_u *buf, int len,
18341834
head->rq_prev = node;
18351835
}
18361836

1837-
if (log_fd != NULL && lead != NULL)
1837+
if (ch_log_active() && lead != NULL)
18381838
{
18391839
ch_log_lead(lead, channel);
18401840
fprintf(log_fd, "'");
1841-
if (fwrite(buf, len, 1, log_fd) != 1)
1842-
return FAIL;
1841+
ignored = (int)fwrite(buf, len, 1, log_fd);
18431842
fprintf(log_fd, "'\n");
18441843
}
18451844
return OK;
@@ -3410,7 +3409,7 @@ channel_read_block(channel_T *channel, ch_part_T part, int timeout)
34103409
channel_consume(channel, part, (int)(nl - buf) + 1);
34113410
}
34123411
}
3413-
if (log_fd != NULL)
3412+
if (ch_log_active())
34143413
ch_log(channel, "Returning %d bytes", (int)STRLEN(msg));
34153414
return msg;
34163415
}
@@ -3695,7 +3694,7 @@ channel_send(
36953694
return FAIL;
36963695
}
36973696

3698-
if (log_fd != NULL)
3697+
if (ch_log_active())
36993698
{
37003699
ch_log_lead("SEND ", channel);
37013700
fprintf(log_fd, "'");

src/mbyte.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,19 +4907,92 @@ im_preedit_window_set_position(void)
49074907
im_preedit_window_open()
49084908
{
49094909
char *preedit_string;
4910+
#if !GTK_CHECK_VERSION(3,16,0)
49104911
char buf[8];
4912+
#endif
49114913
PangoAttrList *attr_list;
49124914
PangoLayout *layout;
4915+
#if GTK_CHECK_VERSION(3,0,0)
4916+
# if !GTK_CHECK_VERSION(3,16,0)
4917+
GdkRGBA color;
4918+
# endif
4919+
#else
49134920
GdkColor color;
4921+
#endif
49144922
gint w, h;
49154923

49164924
if (preedit_window == NULL)
49174925
{
49184926
preedit_window = gtk_window_new(GTK_WINDOW_POPUP);
4927+
gtk_window_set_transient_for(GTK_WINDOW(preedit_window),
4928+
GTK_WINDOW(gui.mainwin));
49194929
preedit_label = gtk_label_new("");
4930+
gtk_widget_set_name(preedit_label, "vim-gui-preedit-area");
49204931
gtk_container_add(GTK_CONTAINER(preedit_window), preedit_label);
49214932
}
49224933

4934+
#if GTK_CHECK_VERSION(3,16,0)
4935+
{
4936+
GtkStyleContext * const context
4937+
= gtk_widget_get_style_context(gui.drawarea);
4938+
GtkCssProvider * const provider = gtk_css_provider_new();
4939+
gchar *css = NULL;
4940+
const char * const fontname
4941+
= pango_font_description_get_family(gui.norm_font);
4942+
gint fontsize
4943+
= pango_font_description_get_size(gui.norm_font) / PANGO_SCALE;
4944+
gchar *fontsize_propval = NULL;
4945+
4946+
if (!pango_font_description_get_size_is_absolute(gui.norm_font))
4947+
{
4948+
/* fontsize was given in points. Convert it into that in pixels
4949+
* to use with CSS. */
4950+
GdkScreen * const screen
4951+
= gdk_window_get_screen(gtk_widget_get_window(gui.mainwin));
4952+
const gdouble dpi = gdk_screen_get_resolution(screen);
4953+
fontsize = dpi * fontsize / 72;
4954+
}
4955+
if (fontsize > 0)
4956+
fontsize_propval = g_strdup_printf("%dpx", fontsize);
4957+
else
4958+
fontsize_propval = g_strdup_printf("inherit");
4959+
4960+
css = g_strdup_printf(
4961+
"widget#vim-gui-preedit-area {\n"
4962+
" font-family: %s,monospace;\n"
4963+
" font-size: %s;\n"
4964+
" color: #%.2lx%.2lx%.2lx;\n"
4965+
" background-color: #%.2lx%.2lx%.2lx;\n"
4966+
"}\n",
4967+
fontname != NULL ? fontname : "inherit",
4968+
fontsize_propval,
4969+
(gui.norm_pixel >> 16) & 0xff,
4970+
(gui.norm_pixel >> 8) & 0xff,
4971+
gui.norm_pixel & 0xff,
4972+
(gui.back_pixel >> 16) & 0xff,
4973+
(gui.back_pixel >> 8) & 0xff,
4974+
gui.back_pixel & 0xff);
4975+
4976+
gtk_css_provider_load_from_data(provider, css, -1, NULL);
4977+
gtk_style_context_add_provider(context,
4978+
GTK_STYLE_PROVIDER(provider), G_MAXUINT);
4979+
4980+
g_free(css);
4981+
g_free(fontsize_propval);
4982+
g_object_unref(provider);
4983+
}
4984+
#elif GTK_CHECK_VERSION(3,0,0)
4985+
gtk_widget_override_font(preedit_label, gui.norm_font);
4986+
4987+
vim_snprintf(buf, sizeof(buf), "#%06X", gui.norm_pixel);
4988+
gdk_rgba_parse(&color, buf);
4989+
gtk_widget_override_color(preedit_label, GTK_STATE_FLAG_NORMAL, &color);
4990+
4991+
vim_snprintf(buf, sizeof(buf), "#%06X", gui.back_pixel);
4992+
gdk_rgba_parse(&color, buf);
4993+
gtk_widget_override_background_color(preedit_label, GTK_STATE_FLAG_NORMAL,
4994+
&color);
4995+
#else
49234996
gtk_widget_modify_font(preedit_label, gui.norm_font);
49244997

49254998
vim_snprintf(buf, sizeof(buf), "#%06X", gui.norm_pixel);
@@ -4929,6 +5002,7 @@ im_preedit_window_open()
49295002
vim_snprintf(buf, sizeof(buf), "#%06X", gui.back_pixel);
49305003
gdk_color_parse(buf, &color);
49315004
gtk_widget_modify_bg(preedit_window, GTK_STATE_NORMAL, &color);
5005+
#endif
49325006

49335007
gtk_im_context_get_preedit_string(xic, &preedit_string, &attr_list, NULL);
49345008

src/proto/screen.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int redraw_asap(int type);
1010
void redraw_after_callback(int call_update_screen);
1111
void redrawWinline(linenr_T lnum, int invalid);
1212
void update_curbuf(int type);
13-
void update_screen(int type_arg);
13+
int update_screen(int type_arg);
1414
int conceal_cursor_line(win_T *wp);
1515
void conceal_check_cursur_line(void);
1616
void update_single_line(win_T *wp, linenr_T lnum);

src/proto/syntax.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ int syn_namen2id(char_u *linep, int len);
5252
int syn_check_group(char_u *pp, int len);
5353
int syn_id2attr(int hl_id);
5454
int syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp);
55+
void syn_id2cterm_bg(int hl_id, int *fgp, int *bgp);
5556
int syn_get_final_id(int hl_id);
5657
void highlight_gui_started(void);
5758
int highlight_changed(void);

src/screen.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,8 +538,9 @@ update_curbuf(int type)
538538
/*
539539
* Based on the current value of curwin->w_topline, transfer a screenfull
540540
* of stuff from Filemem to ScreenLines[], and update curwin->w_botline.
541+
* Return OK when the screen was updated, FAIL if it was not done.
541542
*/
542-
void
543+
int
543544
update_screen(int type_arg)
544545
{
545546
int type = type_arg;
@@ -557,7 +558,7 @@ update_screen(int type_arg)
557558

558559
/* Don't do anything if the screen structures are (not yet) valid. */
559560
if (!screen_valid(TRUE))
560-
return;
561+
return FAIL;
561562

562563
if (type == VALID_NO_UPDATE)
563564
{
@@ -589,7 +590,7 @@ update_screen(int type_arg)
589590
must_redraw = type;
590591
if (type > INVERTED_ALL)
591592
curwin->w_lines_valid = 0; /* don't use w_lines[].wl_size now */
592-
return;
593+
return FAIL;
593594
}
594595

595596
updating_screen = TRUE;
@@ -842,6 +843,7 @@ update_screen(int type_arg)
842843
gui_update_scrollbars(FALSE);
843844
}
844845
#endif
846+
return OK;
845847
}
846848

847849
#if defined(FEAT_SIGNS) || defined(FEAT_GUI) || defined(FEAT_CONCEAL)

src/syntax.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9710,7 +9710,7 @@ syn_id2attr(int hl_id)
97109710
return attr;
97119711
}
97129712

9713-
#ifdef FEAT_GUI
9713+
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
97149714
/*
97159715
* Get the GUI colors and attributes for a group ID.
97169716
* NOTE: the colors will be INVALCOLOR when not set, the color otherwise.
@@ -9729,6 +9729,19 @@ syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp)
97299729
}
97309730
#endif
97319731

9732+
#if defined(FEAT_TERMINAL) || defined(PROT)
9733+
void
9734+
syn_id2cterm_bg(int hl_id, int *fgp, int *bgp)
9735+
{
9736+
struct hl_group *sgp;
9737+
9738+
hl_id = syn_get_final_id(hl_id);
9739+
sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */
9740+
*fgp = sgp->sg_cterm_fg - 1;
9741+
*bgp = sgp->sg_cterm_bg - 1;
9742+
}
9743+
#endif
9744+
97329745
/*
97339746
* Translate a group ID to the final group ID (following links).
97349747
*/

0 commit comments

Comments
 (0)