diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/nvim/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/nvim/api/keysets.lua | 2 | ||||
-rw-r--r-- | src/nvim/highlight.c | 64 | ||||
-rw-r--r-- | src/nvim/highlight_defs.h | 20 | ||||
-rw-r--r-- | src/nvim/highlight_group.c | 13 | ||||
-rw-r--r-- | src/nvim/po/tr.po | 3 | ||||
-rw-r--r-- | src/nvim/po/uk.po | 3 | ||||
-rw-r--r-- | src/nvim/po/zh_CN.UTF-8.po | 17 | ||||
-rw-r--r-- | src/nvim/tui/tui.c | 27 | ||||
-rw-r--r-- | src/nvim/version.c | 53 |
10 files changed, 126 insertions, 78 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 0929aeeb2a..2361210e59 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -684,8 +684,6 @@ foreach(hfile ${NVIM_GENERATED_FOR_HEADERS}) endif() endforeach() -# Our dependencies come first. - if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") target_link_libraries(main_lib INTERFACE pthread c++abi) endif() diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua index bd709b7b25..30dcef6127 100644 --- a/src/nvim/api/keysets.lua +++ b/src/nvim/api/keysets.lua @@ -114,6 +114,7 @@ return { "underdashed"; "italic"; "reverse"; + "altfont"; "nocombine"; "default"; "cterm"; @@ -140,6 +141,7 @@ return { "underdashed"; "italic"; "reverse"; + "altfont"; "nocombine"; }}; -- Autocmds diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index c3a259c87d..9dab91cc2b 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -649,7 +649,7 @@ int hl_blend_attrs(int back_attr, int front_attr, bool *through) cattrs = battrs; cattrs.rgb_fg_color = rgb_blend(ratio, battrs.rgb_fg_color, fattrs.rgb_bg_color); - if (cattrs.rgb_ae_attr & (HL_ANY_UNDERLINE)) { + if (cattrs.rgb_ae_attr & (HL_UNDERLINE_MASK)) { cattrs.rgb_sp_color = rgb_blend(ratio, battrs.rgb_sp_color, fattrs.rgb_bg_color); } else { @@ -667,7 +667,7 @@ int hl_blend_attrs(int back_attr, int front_attr, bool *through) } cattrs.rgb_fg_color = rgb_blend(ratio/2, battrs.rgb_fg_color, fattrs.rgb_fg_color); - if (cattrs.rgb_ae_attr & (HL_ANY_UNDERLINE)) { + if (cattrs.rgb_ae_attr & (HL_UNDERLINE_MASK)) { cattrs.rgb_sp_color = rgb_blend(ratio/2, battrs.rgb_bg_color, fattrs.rgb_sp_color); } else { @@ -825,46 +825,52 @@ void hlattrs2dict(Dictionary *dict, HlAttrs ae, bool use_rgb) Dictionary hl = *dict; int mask = use_rgb ? ae.rgb_ae_attr : ae.cterm_ae_attr; + if (mask & HL_INVERSE) { + PUT_C(hl, "reverse", BOOLEAN_OBJ(true)); + } + if (mask & HL_BOLD) { PUT_C(hl, "bold", BOOLEAN_OBJ(true)); } - if (mask & HL_STANDOUT) { - PUT_C(hl, "standout", BOOLEAN_OBJ(true)); + if (mask & HL_ITALIC) { + PUT_C(hl, "italic", BOOLEAN_OBJ(true)); } - if (mask & HL_UNDERLINE) { + switch (mask & HL_UNDERLINE_MASK) { + case HL_UNDERLINE: PUT_C(hl, "underline", BOOLEAN_OBJ(true)); - } - - if (mask & HL_UNDERCURL) { - PUT_C(hl, "undercurl", BOOLEAN_OBJ(true)); - } + break; - if (mask & HL_UNDERDOUBLE) { + case HL_UNDERDOUBLE: PUT_C(hl, "underdouble", BOOLEAN_OBJ(true)); - } + break; + + case HL_UNDERCURL: + PUT_C(hl, "undercurl", BOOLEAN_OBJ(true)); + break; - if (mask & HL_UNDERDOTTED) { + case HL_UNDERDOTTED: PUT_C(hl, "underdotted", BOOLEAN_OBJ(true)); - } + break; - if (mask & HL_UNDERDASHED) { + case HL_UNDERDASHED: PUT_C(hl, "underdashed", BOOLEAN_OBJ(true)); + break; } - if (mask & HL_ITALIC) { - PUT_C(hl, "italic", BOOLEAN_OBJ(true)); - } - - if (mask & HL_INVERSE) { - PUT_C(hl, "reverse", BOOLEAN_OBJ(true)); + if (mask & HL_STANDOUT) { + PUT_C(hl, "standout", BOOLEAN_OBJ(true)); } if (mask & HL_STRIKETHROUGH) { PUT_C(hl, "strikethrough", BOOLEAN_OBJ(true)); } + if (mask & HL_ALTFONT) { + PUT_C(hl, "altfont", BOOLEAN_OBJ(true)); + } + if (mask & HL_NOCOMBINE) { PUT_C(hl, "nocombine", BOOLEAN_OBJ(true)); } @@ -920,16 +926,17 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e m = m | flag; \ } + CHECK_FLAG(dict, mask, reverse, , HL_INVERSE); CHECK_FLAG(dict, mask, bold, , HL_BOLD); - CHECK_FLAG(dict, mask, standout, , HL_STANDOUT); + CHECK_FLAG(dict, mask, italic, , HL_ITALIC); CHECK_FLAG(dict, mask, underline, , HL_UNDERLINE); - CHECK_FLAG(dict, mask, undercurl, , HL_UNDERCURL); CHECK_FLAG(dict, mask, underdouble, , HL_UNDERDOUBLE); + CHECK_FLAG(dict, mask, undercurl, , HL_UNDERCURL); CHECK_FLAG(dict, mask, underdotted, , HL_UNDERDOTTED); CHECK_FLAG(dict, mask, underdashed, , HL_UNDERDASHED); - CHECK_FLAG(dict, mask, italic, , HL_ITALIC); - CHECK_FLAG(dict, mask, reverse, , HL_INVERSE); + CHECK_FLAG(dict, mask, standout, , HL_STANDOUT); CHECK_FLAG(dict, mask, strikethrough, , HL_STRIKETHROUGH); + CHECK_FLAG(dict, mask, altfont, , HL_ALTFONT); if (use_rgb) { CHECK_FLAG(dict, mask, fg_indexed, , HL_FG_INDEXED); CHECK_FLAG(dict, mask, bg_indexed, , HL_BG_INDEXED); @@ -1005,13 +1012,14 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e } cterm_mask_provided = true; + CHECK_FLAG(cterm, cterm_mask, reverse, , HL_INVERSE); CHECK_FLAG(cterm, cterm_mask, bold, , HL_BOLD); - CHECK_FLAG(cterm, cterm_mask, standout, , HL_STANDOUT); + CHECK_FLAG(cterm, cterm_mask, italic, , HL_ITALIC); CHECK_FLAG(cterm, cterm_mask, underline, , HL_UNDERLINE); CHECK_FLAG(cterm, cterm_mask, undercurl, , HL_UNDERCURL); - CHECK_FLAG(cterm, cterm_mask, italic, , HL_ITALIC); - CHECK_FLAG(cterm, cterm_mask, reverse, , HL_INVERSE); + CHECK_FLAG(cterm, cterm_mask, standout, , HL_STANDOUT); CHECK_FLAG(cterm, cterm_mask, strikethrough, , HL_STRIKETHROUGH); + CHECK_FLAG(cterm, cterm_mask, altfont, , HL_ALTFONT); CHECK_FLAG(cterm, cterm_mask, nocombine, , HL_NOCOMBINE); } else if (dict->cterm.type == kObjectTypeArray && dict->cterm.data.array.size == 0) { // empty list from Lua API should clear all cterm attributes diff --git a/src/nvim/highlight_defs.h b/src/nvim/highlight_defs.h index 2557a248c3..a4dcf6eb60 100644 --- a/src/nvim/highlight_defs.h +++ b/src/nvim/highlight_defs.h @@ -15,19 +15,23 @@ typedef enum { HL_INVERSE = 0x01, HL_BOLD = 0x02, HL_ITALIC = 0x04, + // The next three bits are all underline styles + HL_UNDERLINE_MASK = 0x38, HL_UNDERLINE = 0x08, - HL_UNDERCURL = 0x10, - HL_UNDERDOUBLE = 0x20, - HL_UNDERDOTTED = 0x40, - HL_UNDERDASHED = 0x80, - HL_STANDOUT = 0x0100, - HL_NOCOMBINE = 0x0200, - HL_STRIKETHROUGH = 0x0400, + HL_UNDERDOUBLE = 0x10, + HL_UNDERCURL = 0x18, + HL_UNDERDOTTED = 0x20, + HL_UNDERDASHED = 0x28, + // 0x30 and 0x38 spare for underline styles + HL_STANDOUT = 0x0040, + HL_STRIKETHROUGH = 0x0080, + HL_ALTFONT = 0x0100, + // 0x0200 spare + HL_NOCOMBINE = 0x0400, HL_BG_INDEXED = 0x0800, HL_FG_INDEXED = 0x1000, HL_DEFAULT = 0x2000, HL_GLOBAL = 0x4000, - HL_ANY_UNDERLINE = HL_UNDERLINE | HL_UNDERDOUBLE | HL_UNDERCURL | HL_UNDERDOTTED | HL_UNDERDASHED, } HlAttrFlags; /// Stores a complete highlighting entry, including colors and attributes diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 373ce32e05..5b1ea9967d 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -67,11 +67,13 @@ Map(cstr_t, int) highlight_unames = MAP_INIT; static char *(hl_name_table[]) = { "bold", "standout", "underline", "undercurl", "underdouble", "underdotted", "underdashed", - "italic", "reverse", "inverse", "strikethrough", "nocombine", "NONE" }; + "italic", "reverse", "inverse", "strikethrough", "altfont", + "nocombine", "NONE" }; static int hl_attr_table[] = { HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_UNDERDOUBLE, HL_UNDERDOTTED, HL_UNDERDASHED, - HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_STRIKETHROUGH, HL_NOCOMBINE, 0 }; + HL_ITALIC, HL_INVERSE, HL_INVERSE, HL_STRIKETHROUGH, HL_ALTFONT, + HL_NOCOMBINE, 0 }; /// Structure that stores information about a highlight group. /// The ID of a highlight group is also called group ID. It is the index in @@ -1595,7 +1597,12 @@ const char *highlight_has_attr(const int id, const int flag, const int modec) attr = hl_table[id - 1].sg_cterm; } - return (attr & flag) ? "1" : NULL; + if (flag & HL_UNDERLINE_MASK) { + int ul = attr & HL_UNDERLINE_MASK; + return ul == flag ? "1" : NULL; + } else { + return (attr & flag) ? "1" : NULL; + } } /// Return color name of the given highlight group diff --git a/src/nvim/po/tr.po b/src/nvim/po/tr.po index 7d6af4d2cf..eb7879efc4 100644 --- a/src/nvim/po/tr.po +++ b/src/nvim/po/tr.po @@ -5625,9 +5625,6 @@ msgstr "$VIMRUNTIME öntanımlı konumu: \"" msgid "Nvim is open source and freely distributable" msgstr "Nvim açık kaynaklıdır ve özgürce dağıtılabilir" -msgid "https://neovim.io/#chat" -msgstr "https://neovim.io/#chat" - msgid "type :help nvim<Enter> if you are new! " msgstr "eğer yeniyseniz :help nvim<Enter> " diff --git a/src/nvim/po/uk.po b/src/nvim/po/uk.po index b521e37177..06f845f113 100644 --- a/src/nvim/po/uk.po +++ b/src/nvim/po/uk.po @@ -5550,9 +5550,6 @@ msgstr " заміна для $VIMRUNTIME: \"" msgid "Nvim is open source and freely distributable" msgstr "Nvim — це відкрита й вільно розповсюджувана програма" -msgid "https://neovim.io/#chat" -msgstr "https://neovim.io/#chat" - msgid "type :help nvim<Enter> if you are new! " msgstr ":help nvim<Enter> якщо ви вперше! " diff --git a/src/nvim/po/zh_CN.UTF-8.po b/src/nvim/po/zh_CN.UTF-8.po index 0606adcc37..af050823d3 100644 --- a/src/nvim/po/zh_CN.UTF-8.po +++ b/src/nvim/po/zh_CN.UTF-8.po @@ -19,7 +19,7 @@ msgstr "" "Project-Id-Version: Vim(Simplified Chinese)\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2022-11-17 08:00+0800\n" -"PO-Revision-Date: 2022-11-17 22:29+0800\n" +"PO-Revision-Date: 2023-01-24 13:00+0800\n" "Last-Translator: Sizhe Zhao <prc.zhao@outlook.com>\n" "Language-Team: Simplified Chinese <i18n-translation@lists.linux.net.cn>\n" "Language: zh_CN\n" @@ -7248,17 +7248,13 @@ msgstr " $VIMRUNTIME 预设值: \"" msgid "Nvim is open source and freely distributable" msgstr "Nvim 是可自由分发的开放源代码软件" -#: ../version.c:2806 -msgid "https://neovim.io/#chat" -msgstr "" - #: ../version.c:2808 msgid "type :help nvim<Enter> if you are new! " -msgstr "" +msgstr "输入 :help nvim<Enter> 了解 Neovim! " #: ../version.c:2809 msgid "type :checkhealth<Enter> to optimize Nvim" -msgstr "" +msgstr "输入 :checkhealth<Enter> 优化 Neovim " #: ../version.c:2810 msgid "type :q<Enter> to exit " @@ -7266,11 +7262,12 @@ msgstr "输入 :q<Enter> 退出 " #: ../version.c:2811 msgid "type :help<Enter> for help " -msgstr "" +msgstr "输入 :help<Enter> 查看帮助 " #: ../version.c:2813 -msgid "type :help news<Enter> to see changes in" -msgstr "" +#, c-format +msgid "type :help news<Enter> to see changes in v%s.%s" +msgstr "输入 :help news<Enter> 查看 v%s.%s 的变化" #: ../version.c:2816 msgid "Help poor children in Uganda!" diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 44b99f6c84..a50e44f7a3 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -137,6 +137,7 @@ struct TUIData { int enable_bracketed_paste, disable_bracketed_paste; int enable_lr_margin, disable_lr_margin; int enter_strikethrough_mode; + int enter_altfont_mode; int set_rgb_foreground, set_rgb_background; int set_cursor_color; int reset_cursor_color; @@ -251,6 +252,7 @@ static void terminfo_start(TUIData *tui) tui->unibi_ext.enable_bracketed_paste = -1; tui->unibi_ext.disable_bracketed_paste = -1; tui->unibi_ext.enter_strikethrough_mode = -1; + tui->unibi_ext.enter_altfont_mode = -1; tui->unibi_ext.enable_lr_margin = -1; tui->unibi_ext.disable_lr_margin = -1; tui->unibi_ext.enable_focus_reporting = -1; @@ -457,6 +459,7 @@ static void tui_terminal_stop(TUIData *tui) void tui_stop(TUIData *tui) { tui_terminal_stop(tui); + stream_set_blocking(tui->input.in_fd, true); // normalize stream (#2598) tinput_destroy(&tui->input); tui->stopped = true; signal_watcher_close(&tui->winch_handle, NULL); @@ -511,7 +514,7 @@ static bool attrs_differ(TUIData *tui, int id1, int id2, bool rgb) return a1.cterm_fg_color != a2.cterm_fg_color || a1.cterm_bg_color != a2.cterm_bg_color || a1.cterm_ae_attr != a2.cterm_ae_attr - || (a1.cterm_ae_attr & HL_ANY_UNDERLINE + || (a1.cterm_ae_attr & HL_UNDERLINE_MASK && a1.rgb_sp_color != a2.rgb_sp_color); } } @@ -531,6 +534,7 @@ static void update_attrs(TUIData *tui, int attr_id) bool reverse = attr & HL_INVERSE; bool standout = attr & HL_STANDOUT; bool strikethrough = attr & HL_STRIKETHROUGH; + bool altfont = attr & HL_ALTFONT; bool underline; bool undercurl; @@ -538,13 +542,14 @@ static void update_attrs(TUIData *tui, int attr_id) bool underdotted; bool underdashed; if (tui->unibi_ext.set_underline_style != -1) { - underline = attr & HL_UNDERLINE; - undercurl = attr & HL_UNDERCURL; - underdouble = attr & HL_UNDERDOUBLE; - underdashed = attr & HL_UNDERDASHED; - underdotted = attr & HL_UNDERDOTTED; + int ul = attr & HL_UNDERLINE_MASK; + underline = ul == HL_UNDERLINE; + undercurl = ul == HL_UNDERCURL; + underdouble = ul == HL_UNDERDOUBLE; + underdashed = ul == HL_UNDERDASHED; + underdotted = ul == HL_UNDERDOTTED; } else { - underline = attr & HL_ANY_UNDERLINE; + underline = attr & HL_UNDERLINE_MASK; undercurl = false; underdouble = false; underdotted = false; @@ -589,6 +594,9 @@ static void update_attrs(TUIData *tui, int attr_id) if (italic) { unibi_out(tui, unibi_enter_italics_mode); } + if (altfont && tui->unibi_ext.enter_altfont_mode != -1) { + unibi_out_ext(tui, tui->unibi_ext.enter_altfont_mode); + } if (strikethrough && tui->unibi_ext.enter_strikethrough_mode != -1) { unibi_out_ext(tui, tui->unibi_ext.enter_strikethrough_mode); } @@ -2037,6 +2045,11 @@ static void augment_terminfo(TUIData *tui, const char *term, long vte_version, l // to the ECMA-48 strikeout/crossed-out attributes. tui->unibi_ext.enter_strikethrough_mode = unibi_find_ext_str(ut, "smxx"); + // It should be pretty safe to always enable this, as terminals will ignore + // unrecognised SGR numbers. + tui->unibi_ext.enter_altfont_mode = (int)unibi_add_ext_str(ut, "ext.enter_altfont_mode", + "\x1b[11m"); + // Dickey ncurses terminfo does not include the setrgbf and setrgbb // capabilities, proposed by Rüdiger Sonderfeld on 2013-10-15. Adding // them here when terminfo lacks them is an augmentation, not a fixup. diff --git a/src/nvim/version.c b/src/nvim/version.c index 44f795cdf1..417e5116a5 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -29,6 +29,7 @@ #include "nvim/highlight_defs.h" #include "nvim/lua/executor.h" #include "nvim/mbyte.h" +#include "nvim/memory.h" #include "nvim/message.h" #include "nvim/option_defs.h" #include "nvim/os/os_defs.h" @@ -2789,19 +2790,20 @@ void intro_message(int colon) long blanklines; int sponsor; char *p; + char *mesg; + int mesg_size; static char *(lines[]) = { N_(NVIM_VERSION_LONG), "", N_("Nvim is open source and freely distributable"), - N_("https://neovim.io/#chat"), + "https://neovim.io/#chat", "", N_("type :help nvim<Enter> if you are new! "), N_("type :checkhealth<Enter> to optimize Nvim"), N_("type :q<Enter> to exit "), N_("type :help<Enter> for help "), "", - N_("type :help news<Enter> to see changes in") - " v" STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR), + N_("type :help news<Enter> to see changes in v%s.%s"), "", N_("Help poor children in Uganda!"), N_("type :help iccf<Enter> for information "), @@ -2833,25 +2835,48 @@ void intro_message(int colon) if (((row >= 2) && (Columns >= 50)) || colon) { for (i = 0; i < (int)ARRAY_SIZE(lines); i++) { p = lines[i]; + mesg = NULL; + mesg_size = 0; + + if (strstr(p, "news") != NULL) { + p = _(p); + mesg_size = snprintf(NULL, 0, p, + STR(NVIM_VERSION_MAJOR), STR(NVIM_VERSION_MINOR)); + assert(mesg_size > 0); + mesg = xmallocz((size_t)mesg_size); + snprintf(mesg, (size_t)mesg_size + 1, p, + STR(NVIM_VERSION_MAJOR), STR(NVIM_VERSION_MINOR)); + } if (sponsor != 0) { if (strstr(p, "children") != NULL) { - p = sponsor < 0 - ? N_("Sponsor Vim development!") - : N_("Become a registered Vim user!"); - } else if (strstr(p, "iccf") != NULL) { - p = sponsor < 0 - ? N_("type :help sponsor<Enter> for information ") - : N_("type :help register<Enter> for information "); - } else if (strstr(p, "Orphans") != NULL) { - p = N_("menu Help->Sponsor/Register for information "); + mesg = sponsor < 0 + ? _("Sponsor Vim development!") + : _("Become a registered Vim user!"); + } + if (strstr(p, "iccf") != NULL) { + mesg = sponsor < 0 + ? _("type :help sponsor<Enter> for information ") + : _("type :help register<Enter> for information "); + } + } + + if (mesg == NULL) { + if (*p != NUL) { + mesg = _(p); + } else { + mesg = ""; } } - if (*p != NUL) { - do_intro_line(row, _(p), 0); + if (*mesg != NUL) { + do_intro_line(row, mesg, 0); } row++; + + if (mesg_size > 0) { + XFREE_CLEAR(mesg); + } } } |