Mercurial > vim
comparison src/channel.c @ 15725:a3e2e7948ee4 v8.1.0870
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
commit https://github.com/vim/vim/commit/aa5df7e3127dff6b7336df0903f5c569a40eb174
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 3 14:53:10 2019 +0100
patch 8.1.0870: Vim doesn't use the new ConPTY support in Windows 10
Problem: Vim doesn't use the new ConPTY support in Windows 10.
Solution: Use ConPTY support, if available. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/3794)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 03 Feb 2019 15:00:08 +0100 |
parents | 287104a1d51e |
children | c017195b121b |
comparison
equal
deleted
inserted
replaced
15724:c75264abac54 | 15725:a3e2e7948ee4 |
---|---|
1718 readq_T *node = head->rq_next; | 1718 readq_T *node = head->rq_next; |
1719 long_u len = 0; | 1719 long_u len = 0; |
1720 char_u *res; | 1720 char_u *res; |
1721 char_u *p; | 1721 char_u *p; |
1722 | 1722 |
1723 /* If there is only one buffer just get that one. */ | 1723 // Concatenate everything into one buffer. |
1724 if (head->rq_next == NULL || head->rq_next->rq_next == NULL) | |
1725 return channel_get(channel, part, outlen); | |
1726 | |
1727 /* Concatenate everything into one buffer. */ | |
1728 for (node = head->rq_next; node != NULL; node = node->rq_next) | 1724 for (node = head->rq_next; node != NULL; node = node->rq_next) |
1729 len += node->rq_buflen; | 1725 len += node->rq_buflen; |
1730 res = lalloc(len + 1, TRUE); | 1726 res = lalloc(len + 1, TRUE); |
1731 if (res == NULL) | 1727 if (res == NULL) |
1732 return NULL; | 1728 return NULL; |
1736 mch_memmove(p, node->rq_buffer, node->rq_buflen); | 1732 mch_memmove(p, node->rq_buffer, node->rq_buflen); |
1737 p += node->rq_buflen; | 1733 p += node->rq_buflen; |
1738 } | 1734 } |
1739 *p = NUL; | 1735 *p = NUL; |
1740 | 1736 |
1741 /* Free all buffers */ | 1737 // Free all buffers |
1742 do | 1738 do |
1743 { | 1739 { |
1744 p = channel_get(channel, part, NULL); | 1740 p = channel_get(channel, part, NULL); |
1745 vim_free(p); | 1741 vim_free(p); |
1746 } while (p != NULL); | 1742 } while (p != NULL); |
1747 | 1743 |
1748 if (outlen != NULL) | 1744 if (outlen != NULL) |
1749 { | 1745 { |
1746 // Returning the length, keep NUL characters. | |
1750 *outlen += len; | 1747 *outlen += len; |
1751 return res; | 1748 return res; |
1752 } | 1749 } |
1753 | 1750 |
1754 /* turn all NUL into NL */ | 1751 // Turn all NUL into NL, so that the result can be used as a string. |
1755 while (len > 0) | 1752 p = res; |
1756 { | 1753 while (p < res + len) |
1757 --len; | 1754 { |
1758 if (res[len] == NUL) | 1755 if (*p == NUL) |
1759 res[len] = NL; | 1756 *p = NL; |
1757 #ifdef WIN32 | |
1758 else if (*p == 0x1b) | |
1759 { | |
1760 // crush the escape sequence OSC 0/1/2: ESC ]0; | |
1761 if (p + 3 < res + len | |
1762 && p[1] == ']' | |
1763 && (p[2] == '0' || p[2] == '1' || p[2] == '2') | |
1764 && p[3] == ';') | |
1765 { | |
1766 // '\a' becomes a NL | |
1767 while (p < res + (len - 1) && *p != '\a') | |
1768 ++p; | |
1769 // BEL is zero width characters, suppress display mistake | |
1770 // ConPTY (after 10.0.18317) requires advance checking | |
1771 if (p[-1] == NUL) | |
1772 p[-1] = 0x07; | |
1773 } | |
1774 } | |
1775 #endif | |
1776 ++p; | |
1760 } | 1777 } |
1761 | 1778 |
1762 return res; | 1779 return res; |
1763 } | 1780 } |
1764 | 1781 |
4328 channel_close_now(channel); | 4345 channel_close_now(channel); |
4329 /* channel may have been freed, start over */ | 4346 /* channel may have been freed, start over */ |
4330 channel = first_channel; | 4347 channel = first_channel; |
4331 continue; | 4348 continue; |
4332 } | 4349 } |
4333 if (channel->ch_to_be_freed) | 4350 if (channel->ch_to_be_freed || channel->ch_killing) |
4334 { | 4351 { |
4335 channel_free(channel); | 4352 channel_free(channel); |
4336 /* channel has been freed, start over */ | 4353 /* channel has been freed, start over */ |
4337 channel = first_channel; | 4354 channel = first_channel; |
4338 continue; | 4355 continue; |
4928 if (!(supported2 & JO2_TERM_KILL)) | 4945 if (!(supported2 & JO2_TERM_KILL)) |
4929 break; | 4946 break; |
4930 opt->jo_set2 |= JO2_TERM_KILL; | 4947 opt->jo_set2 |= JO2_TERM_KILL; |
4931 opt->jo_term_kill = tv_get_string_chk(item); | 4948 opt->jo_term_kill = tv_get_string_chk(item); |
4932 } | 4949 } |
4950 else if (STRCMP(hi->hi_key, "term_mode") == 0) | |
4951 { | |
4952 char_u *p; | |
4953 | |
4954 if (!(supported2 & JO2_TERM_MODE)) | |
4955 break; | |
4956 opt->jo_set2 |= JO2_TERM_MODE; | |
4957 p = tv_get_string_chk(item); | |
4958 if (p == NULL) | |
4959 { | |
4960 semsg(_(e_invargval), "term_mode"); | |
4961 return FAIL; | |
4962 } | |
4963 // Allow empty string, "winpty", "conpty". | |
4964 if (!(*p == NUL || STRCMP(p, "winpty") == 0 | |
4965 || STRCMP(p, "conpty") == 0)) | |
4966 { | |
4967 semsg(_(e_invargval), "term_mode"); | |
4968 return FAIL; | |
4969 } | |
4970 opt->jo_term_mode = p[0]; | |
4971 } | |
4933 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) | 4972 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
4934 else if (STRCMP(hi->hi_key, "ansi_colors") == 0) | 4973 else if (STRCMP(hi->hi_key, "ansi_colors") == 0) |
4935 { | 4974 { |
4936 int n = 0; | 4975 int n = 0; |
4937 listitem_T *li; | 4976 listitem_T *li; |
5438 clear_tv(&rettv); | 5477 clear_tv(&rettv); |
5439 --job->jv_refcount; | 5478 --job->jv_refcount; |
5440 channel_need_redraw = TRUE; | 5479 channel_need_redraw = TRUE; |
5441 } | 5480 } |
5442 | 5481 |
5482 if (job->jv_channel != NULL | |
5483 && job->jv_channel->ch_anonymous_pipe && !job->jv_channel->ch_killing) | |
5484 { | |
5485 ++safe_to_invoke_callback; | |
5486 channel_free_contents(job->jv_channel); | |
5487 job->jv_channel->ch_job = NULL; | |
5488 job->jv_channel = NULL; | |
5489 --safe_to_invoke_callback; | |
5490 } | |
5491 | |
5443 // Do not free the job in case the close callback of the associated channel | 5492 // Do not free the job in case the close callback of the associated channel |
5444 // isn't invoked yet and may get information by job_info(). | 5493 // isn't invoked yet and may get information by job_info(). |
5445 if (job->jv_refcount == 0 && !job_channel_still_useful(job)) | 5494 if (job->jv_refcount == 0 && !job_channel_still_useful(job)) |
5446 // The job was already unreferenced and the associated channel was | 5495 // The job was already unreferenced and the associated channel was |
5447 // detached, now that it ended it can be freed. However, a caller might | 5496 // detached, now that it ended it can be freed. However, a caller might |