Mercurial > vim
comparison src/terminal.c @ 28998:983ec746af54 v8.2.5021
patch 8.2.5021: build fails with normal features and +terminal
Commit: https://github.com/vim/vim/commit/30b9a41ad9963b8c57afea1f33a4e180fc23a892
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu May 26 14:06:37 2022 +0100
patch 8.2.5021: build fails with normal features and +terminal
Problem: Build fails with normal features and +terminal. (Dominique Pell?)
Solution: Add #ifdefs. (closes https://github.com/vim/vim/issues/10484)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 26 May 2022 15:15:03 +0200 |
parents | 99c1356f4210 |
children | ad99b7b9df13 |
comparison
equal
deleted
inserted
replaced
28997:35261e839a6d | 28998:983ec746af54 |
---|---|
242 cursor_color_get(char_u *color) | 242 cursor_color_get(char_u *color) |
243 { | 243 { |
244 return (color == NULL) ? (char_u *)"" : color; | 244 return (color == NULL) ? (char_u *)"" : color; |
245 } | 245 } |
246 | 246 |
247 /* | |
248 * Return TRUE if the user-defined palette (either g:terminal_ansi_colors or the | |
249 * "ansi_colors" argument in term_start()) shall be applied. | |
250 */ | |
251 static int | |
252 term_use_palette() | |
253 { | |
254 if (0 | |
255 #ifdef FEAT_GUI | |
256 || gui.in_use | |
257 #endif | |
258 #ifdef FEAT_TERMGUICOLORS | |
259 || p_tgc | |
260 #endif | |
261 ) | |
262 return TRUE; | |
263 return FALSE; | |
264 } | |
265 | |
266 | 247 |
267 /* | 248 /* |
268 * Parse 'termwinsize' and set "rows" and "cols" for the terminal size in the | 249 * Parse 'termwinsize' and set "rows" and "cols" for the terminal size in the |
269 * current window. | 250 * current window. |
270 * Sets "rows" and/or "cols" to zero when it should follow the window size. | 251 * Sets "rows" and/or "cols" to zero when it should follow the window size. |
724 term->tl_api = vim_strsave((char_u *)"Tapi_"); | 705 term->tl_api = vim_strsave((char_u *)"Tapi_"); |
725 | 706 |
726 if (opt->jo_set2 & JO2_TERM_HIGHLIGHT) | 707 if (opt->jo_set2 & JO2_TERM_HIGHLIGHT) |
727 term->tl_highlight_name = vim_strsave(opt->jo_term_highlight); | 708 term->tl_highlight_name = vim_strsave(opt->jo_term_highlight); |
728 | 709 |
710 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | |
729 // Save the user-defined palette, it is only used in GUI (or 'tgc' is on). | 711 // Save the user-defined palette, it is only used in GUI (or 'tgc' is on). |
730 if (opt->jo_set2 & JO2_ANSI_COLORS) | 712 if (opt->jo_set2 & JO2_ANSI_COLORS) |
731 { | 713 { |
732 term->tl_palette = ALLOC_MULT(long_u, 16); | 714 term->tl_palette = ALLOC_MULT(long_u, 16); |
733 if (term->tl_palette == NULL) | 715 if (term->tl_palette == NULL) |
735 vim_free(term); | 717 vim_free(term); |
736 return NULL; | 718 return NULL; |
737 } | 719 } |
738 memcpy(term->tl_palette, opt->jo_ansi_colors, sizeof(long_u) * 16); | 720 memcpy(term->tl_palette, opt->jo_ansi_colors, sizeof(long_u) * 16); |
739 } | 721 } |
722 #endif | |
740 | 723 |
741 // System dependent: setup the vterm and maybe start the job in it. | 724 // System dependent: setup the vterm and maybe start the job in it. |
742 if (argv == NULL | 725 if (argv == NULL |
743 && argvar->v_type == VAR_STRING | 726 && argvar->v_type == VAR_STRING |
744 && argvar->vval.v_string != NULL | 727 && argvar->vval.v_string != NULL |
4213 } | 4196 } |
4214 } | 4197 } |
4215 | 4198 |
4216 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | 4199 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
4217 /* | 4200 /* |
4201 * Return TRUE if the user-defined palette (either g:terminal_ansi_colors or the | |
4202 * "ansi_colors" argument in term_start()) shall be applied. | |
4203 */ | |
4204 static int | |
4205 term_use_palette() | |
4206 { | |
4207 if (0 | |
4208 #ifdef FEAT_GUI | |
4209 || gui.in_use | |
4210 #endif | |
4211 #ifdef FEAT_TERMGUICOLORS | |
4212 || p_tgc | |
4213 #endif | |
4214 ) | |
4215 return TRUE; | |
4216 return FALSE; | |
4217 } | |
4218 | |
4219 /* | |
4218 * Set the 16 ANSI colors from array of RGB values | 4220 * Set the 16 ANSI colors from array of RGB values |
4219 */ | 4221 */ |
4220 static void | 4222 static void |
4221 set_vterm_palette(VTerm *vterm, long_u *rgb) | 4223 set_vterm_palette(VTerm *vterm, long_u *rgb) |
4222 { | 4224 { |
4742 } | 4744 } |
4743 | 4745 |
4744 static void | 4746 static void |
4745 term_update_palette(term_T *term) | 4747 term_update_palette(term_T *term) |
4746 { | 4748 { |
4749 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | |
4747 if (term_use_palette() | 4750 if (term_use_palette() |
4748 && (term->tl_palette != NULL | 4751 && (term->tl_palette != NULL |
4749 || find_var((char_u *)"g:terminal_ansi_colors", NULL, TRUE) | 4752 || find_var((char_u *)"g:terminal_ansi_colors", NULL, TRUE) |
4750 != NULL)) | 4753 != NULL)) |
4751 { | 4754 { |
4752 if (term->tl_palette != NULL) | 4755 if (term->tl_palette != NULL) |
4753 set_vterm_palette(term->tl_vterm, term->tl_palette); | 4756 set_vterm_palette(term->tl_vterm, term->tl_palette); |
4754 else | 4757 else |
4755 init_vterm_ansi_colors(term->tl_vterm); | 4758 init_vterm_ansi_colors(term->tl_vterm); |
4756 } | 4759 } |
4757 else | 4760 else |
4761 #endif | |
4758 term_reset_palette(term->tl_vterm); | 4762 term_reset_palette(term->tl_vterm); |
4759 } | 4763 } |
4760 | 4764 |
4761 /* | 4765 /* |
4762 * Called when option 'termguicolors' is changed. | 4766 * Called when option 'termguicolors' is changed. |
6937 vim_free(env_wchar); | 6941 vim_free(env_wchar); |
6938 | 6942 |
6939 if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL) | 6943 if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL) |
6940 goto failed; | 6944 goto failed; |
6941 | 6945 |
6946 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | |
6942 if (term_use_palette()) | 6947 if (term_use_palette()) |
6943 { | 6948 { |
6944 if (term->tl_palette != NULL) | 6949 if (term->tl_palette != NULL) |
6945 set_vterm_palette(term->tl_vterm, term->tl_palette); | 6950 set_vterm_palette(term->tl_vterm, term->tl_palette); |
6946 else | 6951 else |
6947 init_vterm_ansi_colors(term->tl_vterm); | 6952 init_vterm_ansi_colors(term->tl_vterm); |
6948 } | 6953 } |
6954 #endif | |
6949 | 6955 |
6950 channel_set_job(channel, job, opt); | 6956 channel_set_job(channel, job, opt); |
6951 job_set_options(job, opt); | 6957 job_set_options(job, opt); |
6952 | 6958 |
6953 job->jv_channel = channel; | 6959 job->jv_channel = channel; |
7269 vim_free(env_wchar); | 7275 vim_free(env_wchar); |
7270 | 7276 |
7271 if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL) | 7277 if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL) |
7272 goto failed; | 7278 goto failed; |
7273 | 7279 |
7280 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | |
7274 if (term_use_palette()) | 7281 if (term_use_palette()) |
7275 { | 7282 { |
7276 if (term->tl_palette != NULL) | 7283 if (term->tl_palette != NULL) |
7277 set_vterm_palette(term->tl_vterm, term->tl_palette); | 7284 set_vterm_palette(term->tl_vterm, term->tl_palette); |
7278 else | 7285 else |
7279 init_vterm_ansi_colors(term->tl_vterm); | 7286 init_vterm_ansi_colors(term->tl_vterm); |
7280 } | 7287 } |
7288 #endif | |
7281 | 7289 |
7282 channel_set_job(channel, job, opt); | 7290 channel_set_job(channel, job, opt); |
7283 job_set_options(job, opt); | 7291 job_set_options(job, opt); |
7284 | 7292 |
7285 job->jv_channel = channel; | 7293 job->jv_channel = channel; |
7529 term->tl_arg0_cmd = NULL; | 7537 term->tl_arg0_cmd = NULL; |
7530 | 7538 |
7531 if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL) | 7539 if (create_vterm(term, term->tl_rows, term->tl_cols) == FAIL) |
7532 return FAIL; | 7540 return FAIL; |
7533 | 7541 |
7542 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | |
7534 if (term_use_palette()) | 7543 if (term_use_palette()) |
7535 { | 7544 { |
7536 if (term->tl_palette != NULL) | 7545 if (term->tl_palette != NULL) |
7537 set_vterm_palette(term->tl_vterm, term->tl_palette); | 7546 set_vterm_palette(term->tl_vterm, term->tl_palette); |
7538 else | 7547 else |
7539 init_vterm_ansi_colors(term->tl_vterm); | 7548 init_vterm_ansi_colors(term->tl_vterm); |
7540 } | 7549 } |
7550 #endif | |
7541 | 7551 |
7542 // This may change a string in "argvar". | 7552 // This may change a string in "argvar". |
7543 term->tl_job = job_start(argvar, argv, opt, &term->tl_job); | 7553 term->tl_job = job_start(argvar, argv, opt, &term->tl_job); |
7544 if (term->tl_job != NULL) | 7554 if (term->tl_job != NULL) |
7545 ++term->tl_job->jv_refcount; | 7555 ++term->tl_job->jv_refcount; |