comparison src/terminal.c @ 20488:1d595fada804 v8.2.0798

patch 8.2.0798: libvterm code lags behind the upstream version Commit: https://github.com/vim/vim/commit/be593bf135f6967335b14ba188bd5f8f32175c75 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 19 21:20:04 2020 +0200 patch 8.2.0798: libvterm code lags behind the upstream version Problem: Libvterm code lags behind the upstream version. Solution: Include revisions 755 - 758.
author Bram Moolenaar <Bram@vim.org>
date Tue, 19 May 2020 21:30:07 +0200
parents 28d82a342331
children 4f6904d8b258
comparison
equal deleted inserted replaced
20487:f4ada29cdf4b 20488:1d595fada804
2996 VTermProp prop, 2996 VTermProp prop,
2997 VTermValue *value, 2997 VTermValue *value,
2998 void *user) 2998 void *user)
2999 { 2999 {
3000 term_T *term = (term_T *)user; 3000 term_T *term = (term_T *)user;
3001 char_u *strval = NULL;
3001 3002
3002 switch (prop) 3003 switch (prop)
3003 { 3004 {
3004 case VTERM_PROP_TITLE: 3005 case VTERM_PROP_TITLE:
3006 strval = vim_strnsave((char_u *)value->string.str,
3007 (int)value->string.len);
3008 if (strval == NULL)
3009 break;
3005 vim_free(term->tl_title); 3010 vim_free(term->tl_title);
3006 // a blank title isn't useful, make it empty, so that "running" is 3011 // a blank title isn't useful, make it empty, so that "running" is
3007 // displayed 3012 // displayed
3008 if (*skipwhite((char_u *)value->string) == NUL) 3013 if (*skipwhite(strval) == NUL)
3009 term->tl_title = NULL; 3014 term->tl_title = NULL;
3010 // Same as blank 3015 // Same as blank
3011 else if (term->tl_arg0_cmd != NULL 3016 else if (term->tl_arg0_cmd != NULL
3012 && STRNCMP(term->tl_arg0_cmd, (char_u *)value->string, 3017 && STRNCMP(term->tl_arg0_cmd, strval,
3013 (int)STRLEN(term->tl_arg0_cmd)) == 0) 3018 (int)STRLEN(term->tl_arg0_cmd)) == 0)
3014 term->tl_title = NULL; 3019 term->tl_title = NULL;
3015 // Empty corrupted data of winpty 3020 // Empty corrupted data of winpty
3016 else if (STRNCMP(" - ", (char_u *)value->string, 4) == 0) 3021 else if (STRNCMP(" - ", strval, 4) == 0)
3017 term->tl_title = NULL; 3022 term->tl_title = NULL;
3018 #ifdef MSWIN 3023 #ifdef MSWIN
3019 else if (!enc_utf8 && enc_codepage > 0) 3024 else if (!enc_utf8 && enc_codepage > 0)
3020 { 3025 {
3021 WCHAR *ret = NULL; 3026 WCHAR *ret = NULL;
3022 int length = 0; 3027 int length = 0;
3023 3028
3024 MultiByteToWideChar_alloc(CP_UTF8, 0, 3029 MultiByteToWideChar_alloc(CP_UTF8, 0,
3025 (char*)value->string, (int)STRLEN(value->string), 3030 (char*)value->string.str,
3026 &ret, &length); 3031 (int)value->string.len, &ret, &length);
3027 if (ret != NULL) 3032 if (ret != NULL)
3028 { 3033 {
3029 WideCharToMultiByte_alloc(enc_codepage, 0, 3034 WideCharToMultiByte_alloc(enc_codepage, 0,
3030 ret, length, (char**)&term->tl_title, 3035 ret, length, (char**)&term->tl_title,
3031 &length, 0, 0); 3036 &length, 0, 0);
3032 vim_free(ret); 3037 vim_free(ret);
3033 } 3038 }
3034 } 3039 }
3035 #endif 3040 #endif
3036 else 3041 else
3037 term->tl_title = vim_strsave((char_u *)value->string); 3042 {
3043 term->tl_title = vim_strsave(strval);
3044 strval = NULL;
3045 }
3038 VIM_CLEAR(term->tl_status_text); 3046 VIM_CLEAR(term->tl_status_text);
3039 if (term == curbuf->b_term) 3047 if (term == curbuf->b_term)
3040 maketitle(); 3048 maketitle();
3041 break; 3049 break;
3042 3050
3055 term->tl_cursor_shape = value->number; 3063 term->tl_cursor_shape = value->number;
3056 may_set_cursor_props(term); 3064 may_set_cursor_props(term);
3057 break; 3065 break;
3058 3066
3059 case VTERM_PROP_CURSORCOLOR: 3067 case VTERM_PROP_CURSORCOLOR:
3060 cursor_color_copy(&term->tl_cursor_color, (char_u*)value->string); 3068 strval = vim_strnsave((char_u *)value->string.str,
3069 (int)value->string.len);
3070 if (strval == NULL)
3071 break;
3072 cursor_color_copy(&term->tl_cursor_color, strval);
3061 may_set_cursor_props(term); 3073 may_set_cursor_props(term);
3062 break; 3074 break;
3063 3075
3064 case VTERM_PROP_ALTSCREEN: 3076 case VTERM_PROP_ALTSCREEN:
3065 // TODO: do anything else? 3077 // TODO: do anything else?
3067 break; 3079 break;
3068 3080
3069 default: 3081 default:
3070 break; 3082 break;
3071 } 3083 }
3084 vim_free(strval);
3085
3072 // Always return 1, otherwise vterm doesn't store the value internally. 3086 // Always return 1, otherwise vterm doesn't store the value internally.
3073 return 1; 3087 return 1;
3074 } 3088 }
3075 3089
3076 /* 3090 /*
4179 /* 4193 /*
4180 * Called by libvterm when it cannot recognize an OSC sequence. 4194 * Called by libvterm when it cannot recognize an OSC sequence.
4181 * We recognize a terminal API command. 4195 * We recognize a terminal API command.
4182 */ 4196 */
4183 static int 4197 static int
4184 parse_osc(const char *command, size_t cmdlen, void *user) 4198 parse_osc(int command, VTermStringFragment frag, void *user)
4185 { 4199 {
4186 term_T *term = (term_T *)user; 4200 term_T *term = (term_T *)user;
4187 js_read_T reader; 4201 js_read_T reader;
4188 typval_T tv; 4202 typval_T tv;
4189 channel_T *channel = term->tl_job == NULL ? NULL 4203 channel_T *channel = term->tl_job == NULL ? NULL
4190 : term->tl_job->jv_channel; 4204 : term->tl_job->jv_channel;
4191 4205
4192 // We recognize only OSC 5 1 ; {command} 4206 // We recognize only OSC 5 1 ; {command}
4193 if (cmdlen < 3 || STRNCMP(command, "51;", 3) != 0) 4207 if (command != 51)
4194 return 0; // not handled 4208 return 0;
4195 4209
4196 reader.js_buf = vim_strnsave((char_u *)command + 3, (int)(cmdlen - 3)); 4210 reader.js_buf = vim_strnsave((char_u *)frag.str, (int)(frag.len));
4197 if (reader.js_buf == NULL) 4211 if (reader.js_buf == NULL)
4198 return 1; 4212 return 1;
4199 reader.js_fill = NULL; 4213 reader.js_fill = NULL;
4200 reader.js_used = 0; 4214 reader.js_used = 0;
4201 if (json_decode(&reader, &tv, 0) == OK 4215 if (json_decode(&reader, &tv, 0) == OK