comparison src/terminal.c @ 15868:7fad90423bd2 v8.1.0941

patch 8.1.0941: macros for MS-Windows are inconsistent commit https://github.com/vim/vim/commit/4f97475d326c2773a78561fb874e4f23c25cbcd9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 17 17:44:42 2019 +0100 patch 8.1.0941: macros for MS-Windows are inconsistent Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and others. Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the GUI build. (Hirohito Higashi, closes #3932)
author Bram Moolenaar <Bram@vim.org>
date Sun, 17 Feb 2019 17:45:08 +0100
parents 63e71d195cee
children f5620f490af2
comparison
equal deleted inserted replaced
15867:4a3823e692d3 15868:7fad90423bd2
64 cellattr_T *sb_cells; // allocated 64 cellattr_T *sb_cells; // allocated
65 cellattr_T sb_fill_attr; // for short line 65 cellattr_T sb_fill_attr; // for short line
66 char_u *sb_text; // for tl_scrollback_postponed 66 char_u *sb_text; // for tl_scrollback_postponed
67 } sb_line_T; 67 } sb_line_T;
68 68
69 #ifdef WIN3264 69 #ifdef MSWIN
70 # ifndef HPCON 70 # ifndef HPCON
71 # define HPCON VOID* 71 # define HPCON VOID*
72 # endif 72 # endif
73 # ifndef EXTENDED_STARTUPINFO_PRESENT 73 # ifndef EXTENDED_STARTUPINFO_PRESENT
74 # define EXTENDED_STARTUPINFO_PRESENT 0x00080000 74 # define EXTENDED_STARTUPINFO_PRESENT 0x00080000
110 char_u *tl_opencmd; 110 char_u *tl_opencmd;
111 char_u *tl_eof_chars; 111 char_u *tl_eof_chars;
112 112
113 char_u *tl_arg0_cmd; // To format the status bar 113 char_u *tl_arg0_cmd; // To format the status bar
114 114
115 #ifdef WIN3264 115 #ifdef MSWIN
116 void *tl_winpty_config; 116 void *tl_winpty_config;
117 void *tl_winpty; 117 void *tl_winpty;
118 118
119 HPCON tl_conpty; 119 HPCON tl_conpty;
120 DYN_STARTUPINFOEXW tl_siex; // Structure that always needs to be hold 120 DYN_STARTUPINFOEXW tl_siex; // Structure that always needs to be hold
170 static term_T *first_term = NULL; 170 static term_T *first_term = NULL;
171 171
172 /* Terminal active in terminal_loop(). */ 172 /* Terminal active in terminal_loop(). */
173 static term_T *in_terminal_loop = NULL; 173 static term_T *in_terminal_loop = NULL;
174 174
175 #ifdef WIN3264 175 #ifdef MSWIN
176 static BOOL has_winpty = FALSE; 176 static BOOL has_winpty = FALSE;
177 static BOOL has_conpty = FALSE; 177 static BOOL has_conpty = FALSE;
178 #endif 178 #endif
179 179
180 #define MAX_ROW 999999 /* used for tl_dirty_row_end to update all rows */ 180 #define MAX_ROW 999999 /* used for tl_dirty_row_end to update all rows */
322 * Set job options mandatory for a terminal job. 322 * Set job options mandatory for a terminal job.
323 */ 323 */
324 static void 324 static void
325 setup_job_options(jobopt_T *opt, int rows, int cols) 325 setup_job_options(jobopt_T *opt, int rows, int cols)
326 { 326 {
327 #ifndef WIN3264 327 #ifndef MSWIN
328 /* Win32: Redirecting the job output won't work, thus always connect stdout 328 /* Win32: Redirecting the job output won't work, thus always connect stdout
329 * here. */ 329 * here. */
330 if (!(opt->jo_set & JO_OUT_IO)) 330 if (!(opt->jo_set & JO_OUT_IO))
331 #endif 331 #endif
332 { 332 {
335 opt->jo_io_buf[PART_OUT] = curbuf->b_fnum; 335 opt->jo_io_buf[PART_OUT] = curbuf->b_fnum;
336 opt->jo_modifiable[PART_OUT] = 0; 336 opt->jo_modifiable[PART_OUT] = 0;
337 opt->jo_set |= JO_OUT_IO + JO_OUT_BUF + JO_OUT_MODIFIABLE; 337 opt->jo_set |= JO_OUT_IO + JO_OUT_BUF + JO_OUT_MODIFIABLE;
338 } 338 }
339 339
340 #ifndef WIN3264 340 #ifndef MSWIN
341 /* Win32: Redirecting the job output won't work, thus always connect stderr 341 /* Win32: Redirecting the job output won't work, thus always connect stderr
342 * here. */ 342 * here. */
343 if (!(opt->jo_set & JO_ERR_IO)) 343 if (!(opt->jo_set & JO_ERR_IO))
344 #endif 344 #endif
345 { 345 {
568 /* Mark the buffer as not modifiable. It can only be made modifiable after 568 /* Mark the buffer as not modifiable. It can only be made modifiable after
569 * the job finished. */ 569 * the job finished. */
570 curbuf->b_p_ma = FALSE; 570 curbuf->b_p_ma = FALSE;
571 571
572 set_term_and_win_size(term); 572 set_term_and_win_size(term);
573 #ifdef WIN3264 573 #ifdef MSWIN
574 mch_memmove(orig_opt.jo_io, opt->jo_io, sizeof(orig_opt.jo_io)); 574 mch_memmove(orig_opt.jo_io, opt->jo_io, sizeof(orig_opt.jo_io));
575 #endif 575 #endif
576 setup_job_options(opt, term->tl_rows, term->tl_cols); 576 setup_job_options(opt, term->tl_rows, term->tl_cols);
577 577
578 if (flags & TERM_START_NOJOB) 578 if (flags & TERM_START_NOJOB)
746 opt.jo_set2 |= JO2_EOF_CHARS; 746 opt.jo_set2 |= JO2_EOF_CHARS;
747 opt.jo_eof_chars = vim_strsave(keys); 747 opt.jo_eof_chars = vim_strsave(keys);
748 vim_free(buf); 748 vim_free(buf);
749 *p = ' '; 749 *p = ' ';
750 } 750 }
751 #ifdef WIN3264 751 #ifdef MSWIN
752 else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "type", 4) == 0 752 else if ((int)(p - cmd) == 4 && STRNICMP(cmd, "type", 4) == 0
753 && ep != NULL) 753 && ep != NULL)
754 { 754 {
755 int tty_type = NUL; 755 int tty_type = NUL;
756 756
822 * risk, but let's assume the user only creates a session when this 822 * risk, but let's assume the user only creates a session when this
823 * will be OK. */ 823 * will be OK. */
824 if (fprintf(fd, "terminal ++curwin ++cols=%d ++rows=%d ", 824 if (fprintf(fd, "terminal ++curwin ++cols=%d ++rows=%d ",
825 term->tl_cols, term->tl_rows) < 0) 825 term->tl_cols, term->tl_rows) < 0)
826 return FAIL; 826 return FAIL;
827 #ifdef WIN3264 827 #ifdef MSWIN
828 if (fprintf(fd, "++type=%s ", term->tl_job->jv_tty_type) < 0) 828 if (fprintf(fd, "++type=%s ", term->tl_job->jv_tty_type) < 0)
829 return FAIL; 829 return FAIL;
830 #endif 830 #endif
831 if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0) 831 if (term->tl_command != NULL && fputs((char *)term->tl_command, fd) < 0)
832 return FAIL; 832 return FAIL;
930 vim_free(term->tl_kill); 930 vim_free(term->tl_kill);
931 vim_free(term->tl_status_text); 931 vim_free(term->tl_status_text);
932 vim_free(term->tl_opencmd); 932 vim_free(term->tl_opencmd);
933 vim_free(term->tl_eof_chars); 933 vim_free(term->tl_eof_chars);
934 vim_free(term->tl_arg0_cmd); 934 vim_free(term->tl_arg0_cmd);
935 #ifdef WIN3264 935 #ifdef MSWIN
936 if (term->tl_out_fd != NULL) 936 if (term->tl_out_fd != NULL)
937 fclose(term->tl_out_fd); 937 fclose(term->tl_out_fd);
938 #endif 938 #endif
939 vim_free(term->tl_cursor_color); 939 vim_free(term->tl_cursor_color);
940 vim_free(term); 940 vim_free(term);
1025 write_to_term(buf_T *buffer, char_u *msg, channel_T *channel) 1025 write_to_term(buf_T *buffer, char_u *msg, channel_T *channel)
1026 { 1026 {
1027 size_t len = STRLEN(msg); 1027 size_t len = STRLEN(msg);
1028 term_T *term = buffer->b_term; 1028 term_T *term = buffer->b_term;
1029 1029
1030 #ifdef WIN3264 1030 #ifdef MSWIN
1031 /* Win32: Cannot redirect output of the job, intercept it here and write to 1031 /* Win32: Cannot redirect output of the job, intercept it here and write to
1032 * the file. */ 1032 * the file. */
1033 if (term->tl_out_fd != NULL) 1033 if (term->tl_out_fd != NULL)
1034 { 1034 {
1035 ch_log(channel, "Writing %d bytes to output file", (int)len); 1035 ch_log(channel, "Writing %d bytes to output file", (int)len);
1469 { 1469 {
1470 buf_T *buf = term->tl_buffer; 1470 buf_T *buf = term->tl_buffer;
1471 int empty = (buf->b_ml.ml_flags & ML_EMPTY); 1471 int empty = (buf->b_ml.ml_flags & ML_EMPTY);
1472 linenr_T lnum = buf->b_ml.ml_line_count; 1472 linenr_T lnum = buf->b_ml.ml_line_count;
1473 1473
1474 #ifdef WIN3264 1474 #ifdef MSWIN
1475 if (!enc_utf8 && enc_codepage > 0) 1475 if (!enc_utf8 && enc_codepage > 0)
1476 { 1476 {
1477 WCHAR *ret = NULL; 1477 WCHAR *ret = NULL;
1478 int length = 0; 1478 int length = 0;
1479 1479
1873 int c; 1873 int c;
1874 int save_State = State; 1874 int save_State = State;
1875 1875
1876 State = TERMINAL; 1876 State = TERMINAL;
1877 got_int = FALSE; 1877 got_int = FALSE;
1878 #ifdef WIN3264 1878 #ifdef MSWIN
1879 ctrl_break_was_pressed = FALSE; 1879 ctrl_break_was_pressed = FALSE;
1880 #endif 1880 #endif
1881 c = vgetc(); 1881 c = vgetc();
1882 got_int = FALSE; 1882 got_int = FALSE;
1883 State = save_State; 1883 State = save_State;
2014 { 2014 {
2015 type = get_reg_type(c, &reglen); 2015 type = get_reg_type(c, &reglen);
2016 for (item = l->lv_first; item != NULL; item = item->li_next) 2016 for (item = l->lv_first; item != NULL; item = item->li_next)
2017 { 2017 {
2018 char_u *s = tv_get_string(&item->li_tv); 2018 char_u *s = tv_get_string(&item->li_tv);
2019 #ifdef WIN3264 2019 #ifdef MSWIN
2020 char_u *tmp = s; 2020 char_u *tmp = s;
2021 2021
2022 if (!enc_utf8 && enc_codepage > 0) 2022 if (!enc_utf8 && enc_codepage > 0)
2023 { 2023 {
2024 WCHAR *ret = NULL; 2024 WCHAR *ret = NULL;
2034 } 2034 }
2035 } 2035 }
2036 #endif 2036 #endif
2037 channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN, 2037 channel_send(curbuf->b_term->tl_job->jv_channel, PART_IN,
2038 s, (int)STRLEN(s), NULL); 2038 s, (int)STRLEN(s), NULL);
2039 #ifdef WIN3264 2039 #ifdef MSWIN
2040 if (tmp != s) 2040 if (tmp != s)
2041 vim_free(s); 2041 vim_free(s);
2042 #endif 2042 #endif
2043 2043
2044 if (item->li_next != NULL || type == MLINE) 2044 if (item->li_next != NULL || type == MLINE)
2291 if (get_tty_info(tty_fd, &info) == OK) 2291 if (get_tty_info(tty_fd, &info) == OK)
2292 term_backspace_char = info.backspace; 2292 term_backspace_char = info.backspace;
2293 } 2293 }
2294 #endif 2294 #endif
2295 2295
2296 #ifdef WIN3264 2296 #ifdef MSWIN
2297 /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT. 2297 /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
2298 * Use CTRL-BREAK to kill the job. */ 2298 * Use CTRL-BREAK to kill the job. */
2299 if (ctrl_break_was_pressed) 2299 if (ctrl_break_was_pressed)
2300 mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill"); 2300 mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill");
2301 #endif 2301 #endif
2368 stuffcharReadbuff(c); 2368 stuffcharReadbuff(c);
2369 ret = OK; 2369 ret = OK;
2370 goto theend; 2370 goto theend;
2371 } 2371 }
2372 } 2372 }
2373 # ifdef WIN3264 2373 # ifdef MSWIN
2374 if (!enc_utf8 && has_mbyte && c >= 0x80) 2374 if (!enc_utf8 && has_mbyte && c >= 0x80)
2375 { 2375 {
2376 WCHAR wc; 2376 WCHAR wc;
2377 char_u mb[3]; 2377 char_u mb[3];
2378 2378
2717 (int)STRLEN(term->tl_arg0_cmd)) == 0) 2717 (int)STRLEN(term->tl_arg0_cmd)) == 0)
2718 term->tl_title = NULL; 2718 term->tl_title = NULL;
2719 // Empty corrupted data of winpty 2719 // Empty corrupted data of winpty
2720 else if (STRNCMP(" - ", (char_u *)value->string, 4) == 0) 2720 else if (STRNCMP(" - ", (char_u *)value->string, 4) == 0)
2721 term->tl_title = NULL; 2721 term->tl_title = NULL;
2722 #ifdef WIN3264 2722 #ifdef MSWIN
2723 else if (!enc_utf8 && enc_codepage > 0) 2723 else if (!enc_utf8 && enc_codepage > 0)
2724 { 2724 {
2725 WCHAR *ret = NULL; 2725 WCHAR *ret = NULL;
2726 int length = 0; 2726 int length = 0;
2727 2727
3070 term->tl_channel_closed = TRUE; 3070 term->tl_channel_closed = TRUE;
3071 did_one = TRUE; 3071 did_one = TRUE;
3072 3072
3073 VIM_CLEAR(term->tl_title); 3073 VIM_CLEAR(term->tl_title);
3074 VIM_CLEAR(term->tl_status_text); 3074 VIM_CLEAR(term->tl_status_text);
3075 #ifdef WIN3264 3075 #ifdef MSWIN
3076 if (term->tl_out_fd != NULL) 3076 if (term->tl_out_fd != NULL)
3077 { 3077 {
3078 fclose(term->tl_out_fd); 3078 fclose(term->tl_out_fd);
3079 term->tl_out_fd = NULL; 3079 term->tl_out_fd = NULL;
3080 } 3080 }
3182 { 3182 {
3183 ScreenLines[off] = c; 3183 ScreenLines[off] = c;
3184 ScreenLinesUC[off] = NUL; 3184 ScreenLinesUC[off] = NUL;
3185 } 3185 }
3186 } 3186 }
3187 #ifdef WIN3264 3187 #ifdef MSWIN
3188 else if (has_mbyte && c >= 0x80) 3188 else if (has_mbyte && c >= 0x80)
3189 { 3189 {
3190 char_u mb[MB_MAXBYTES+1]; 3190 char_u mb[MB_MAXBYTES+1];
3191 WCHAR wc = c; 3191 WCHAR wc = c;
3192 3192
3555 if (term_default_cterm_bg >= 0) 3555 if (term_default_cterm_bg >= 0)
3556 cterm_color2vterm(term_default_cterm_bg, bg); 3556 cterm_color2vterm(term_default_cterm_bg, bg);
3557 } 3557 }
3558 else 3558 else
3559 { 3559 {
3560 #if defined(WIN3264) && !defined(FEAT_GUI_W32) 3560 #if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
3561 int tmp; 3561 int tmp;
3562 #endif 3562 #endif
3563 3563
3564 /* In an MS-Windows console we know the normal colors. */ 3564 /* In an MS-Windows console we know the normal colors. */
3565 if (cterm_normal_fg_color > 0) 3565 if (cterm_normal_fg_color > 0)
3566 { 3566 {
3567 cterm_color2vterm(cterm_normal_fg_color - 1, fg); 3567 cterm_color2vterm(cterm_normal_fg_color - 1, fg);
3568 # if defined(WIN3264) && !defined(FEAT_GUI_W32) 3568 # if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
3569 tmp = fg->red; 3569 tmp = fg->red;
3570 fg->red = fg->blue; 3570 fg->red = fg->blue;
3571 fg->blue = tmp; 3571 fg->blue = tmp;
3572 # endif 3572 # endif
3573 } 3573 }
3577 # endif 3577 # endif
3578 3578
3579 if (cterm_normal_bg_color > 0) 3579 if (cterm_normal_bg_color > 0)
3580 { 3580 {
3581 cterm_color2vterm(cterm_normal_bg_color - 1, bg); 3581 cterm_color2vterm(cterm_normal_bg_color - 1, bg);
3582 # if defined(WIN3264) && !defined(FEAT_GUI_W32) 3582 # if defined(MSWIN) && !defined(FEAT_GUI_MSWIN)
3583 tmp = bg->red; 3583 tmp = bg->red;
3584 bg->red = bg->blue; 3584 bg->red = bg->blue;
3585 bg->blue = tmp; 3585 bg->blue = tmp;
3586 # endif 3586 # endif
3587 } 3587 }
3920 vterm_screen_enable_altscreen(screen, 1); 3920 vterm_screen_enable_altscreen(screen, 1);
3921 3921
3922 /* For unix do not use a blinking cursor. In an xterm this causes the 3922 /* For unix do not use a blinking cursor. In an xterm this causes the
3923 * cursor to blink if it's blinking in the xterm. 3923 * cursor to blink if it's blinking in the xterm.
3924 * For Windows we respect the system wide setting. */ 3924 * For Windows we respect the system wide setting. */
3925 #ifdef WIN3264 3925 #ifdef MSWIN
3926 if (GetCaretBlinkTime() == INFINITE) 3926 if (GetCaretBlinkTime() == INFINITE)
3927 value.boolean = 0; 3927 value.boolean = 0;
3928 else 3928 else
3929 value.boolean = 1; 3929 value.boolean = 1;
3930 #else 3930 #else
5586 { 5586 {
5587 channel_send(ch, PART_IN, term->tl_eof_chars, 5587 channel_send(ch, PART_IN, term->tl_eof_chars,
5588 (int)STRLEN(term->tl_eof_chars), NULL); 5588 (int)STRLEN(term->tl_eof_chars), NULL);
5589 channel_send(ch, PART_IN, (char_u *)"\r", 1, NULL); 5589 channel_send(ch, PART_IN, (char_u *)"\r", 1, NULL);
5590 } 5590 }
5591 # ifdef WIN3264 5591 # ifdef MSWIN
5592 else 5592 else
5593 /* Default: CTRL-D */ 5593 /* Default: CTRL-D */
5594 channel_send(ch, PART_IN, (char_u *)"\004\r", 2, NULL); 5594 channel_send(ch, PART_IN, (char_u *)"\004\r", 2, NULL);
5595 # endif 5595 # endif
5596 } 5596 }
5602 { 5602 {
5603 return term != NULL ? term->tl_job : NULL; 5603 return term != NULL ? term->tl_job : NULL;
5604 } 5604 }
5605 #endif 5605 #endif
5606 5606
5607 # if defined(WIN3264) || defined(PROTO) 5607 # if defined(MSWIN) || defined(PROTO)
5608 5608
5609 /************************************** 5609 /**************************************
5610 * 2. MS-Windows implementation. 5610 * 2. MS-Windows implementation.
5611 */ 5611 */
5612 5612