diff --git a/doc/pages/faces.asciidoc b/doc/pages/faces.asciidoc index 973e37eb..4af8f663 100644 --- a/doc/pages/faces.asciidoc +++ b/doc/pages/faces.asciidoc @@ -156,3 +156,14 @@ echo -markup 'default {Error}error{Default} default' Inside a markup string, a literal `{` character is written `\{`, and a literal backslash (`\`) that precedes a '{' character is escaped as well (`\\`). + +The `{\}` string disables markup processing for the rest of the line, +and can be used to avoid having to escape text that might be mistaken +for markup instructions. + +For example this will prevent any '{' in the current buffer name from +being incorrectly interpreted as markup instructions. + +---- +echo -markup "{Information}name:{\} %val{bufname}" +---- diff --git a/rc/tools/ctags.kak b/rc/tools/ctags.kak index da1481e6..b39eeb66 100644 --- a/rc/tools/ctags.kak +++ b/rc/tools/ctags.kak @@ -44,20 +44,20 @@ define-command -params ..1 \ /^!TAGROOT\t/ { tagroot=$2 } /[^\t]+\t[^\t]+\t\/\^.*\$?\// { line = $0; sub(".*\t/\\^", "", line); sub("\\$?/$", "", line); - menu_info = line; gsub("!", "!!", menu_info); gsub(/^[\t ]+/, "", menu_info); gsub("{", "\\{", menu_info); gsub(/\t/, " ", menu_info); + menu_info = line; gsub("!", "!!", menu_info); gsub(/^[\t ]+/, "", menu_info); gsub(/\t/, " ", menu_info); keys = line; gsub(/", keys); gsub(/\t/, "", keys); gsub("!", "!!", keys); gsub("&", "&&", keys); gsub("#", "##", keys); gsub("\\|", "||", keys); gsub("\\\\/", "/", keys); menu_item = $2; gsub("!", "!!", menu_item); edit_path = path($2); gsub("&", "&&", edit_path); gsub("#", "##", edit_path); gsub("\\|", "||", edit_path); select = $1; gsub(/", select); gsub(/\t/, "", select); gsub("!", "!!", select); gsub("&", "&&", select); gsub("#", "##", select); gsub("\\|", "||", select); - out = out "%!" menu_item ": {MenuInfo}" menu_info "! %!evaluate-commands %# try %& edit -existing %|" edit_path "|; execute-keys %|/\\Q" keys "vc| & catch %& fail unable to find tag &; try %& execute-keys %|s\\Q" select "| & # !" + out = out "%!" menu_item ": {MenuInfo}{\\}" menu_info "! %!evaluate-commands %# try %& edit -existing %|" edit_path "|; execute-keys %|/\\Q" keys "vc| & catch %& fail unable to find tag &; try %& execute-keys %|s\\Q" select "| & # !" } /[^\t]+\t[^\t]+\t[0-9]+/ { menu_item = $2; gsub("!", "!!", menu_item); select = $1; gsub(/", select); gsub(/\t/, "", select); gsub("!", "!!", select); gsub("&", "&&", select); gsub("#", "##", select); gsub("\\|", "||", select); - menu_info = $3; gsub("!", "!!", menu_info); gsub("{", "\\{", menu_info); + menu_info = $3; gsub("!", "!!", menu_info); edit_path = path($2); gsub("!", "!!", edit_path); gsub("#", "##", edit_path); gsub("&", "&&", edit_path); gsub("\\|", "||", edit_path); line_number = $3; - out = out "%!" menu_item ": {MenuInfo}" menu_info "! %!evaluate-commands %# try %& edit -existing %|" edit_path "|; execute-keys %|" line_number "gx| & catch %& fail unable to find tag &; try %& execute-keys %|s\\Q" select "| & # !" + out = out "%!" menu_item ": {MenuInfo}{\}" menu_info "! %!evaluate-commands %# try %& edit -existing %|" edit_path "|; execute-keys %|" line_number "gx| & catch %& fail unable to find tag &; try %& execute-keys %|s\\Q" select "| & # !" } END { print ( length(out) == 0 ? "fail no such tag " ENVIRON["tagname"] : "menu -markup -auto-single " out ) } # Ensure x is an absolute file path, by prepending with tagroot diff --git a/rc/tools/make.kak b/rc/tools/make.kak index fabd7e75..5ae1cf52 100644 --- a/rc/tools/make.kak +++ b/rc/tools/make.kak @@ -44,7 +44,7 @@ declare-option -docstring "name of the client in which all source code jumps wil define-command -hidden make-open-error -params 4 %{ evaluate-commands -try-client %opt{jumpclient} %{ edit -existing "%arg{1}" %arg{2} %arg{3} - echo -markup "{Information}%arg{4}" + echo -markup "{Information}{\}%arg{4}" try %{ focus } } } diff --git a/src/display_buffer.cc b/src/display_buffer.cc index e7e2da54..7df0aa1e 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -280,6 +280,11 @@ DisplayLine parse_display_line(StringView line, const FaceRegistry& faces, const // closing is now at the first char of "}}", advance it to the second ++closing; } + else if (closing == it+2 and *(it+1) == '\\') + { + pos = closing + 1; + break; + } else face = faces[{it+1, closing}]; it = closing;