diff --git a/README.asciidoc b/README.asciidoc index 09cdee48..c3d51abe 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -697,7 +697,6 @@ command `q!` has to be used). * `rename-buffer `: set current buffer name * `rename-session `: set current session name * `echo [options] `: show in status line, with the following options: - ** `-color` : print the given text with , most commonly `Error` or `Information` ** `-markup`: expand the markup strings in ** `-debug`: print the given text to the `\*debug*` buffer * `nop`: does nothing, but as with every other commands, arguments may be diff --git a/doc/manpages/commands.asciidoc b/doc/manpages/commands.asciidoc index f80f920a..9618e7b2 100644 --- a/doc/manpages/commands.asciidoc +++ b/doc/manpages/commands.asciidoc @@ -73,9 +73,6 @@ command *q!* has to be used). *echo* [options] :: show *text* in status line, with the following *options*: - *-color* ::: - print the given text with *face*, most commonly *Error* or *Information* - *-markup*::: expand the markup strings in *text* (c.f. the 'expansions' documentation page) diff --git a/rc/base/ctags.kak b/rc/base/ctags.kak index 8c5fdb61..4c5c193e 100644 --- a/rc/base/ctags.kak +++ b/rc/base/ctags.kak @@ -40,7 +40,7 @@ If no symbol is passed then the current selection is used as symbol name} \ out = out " %{" $2 " {MenuInfo}" re "} %{eval -collapse-jumps %{ try %{ edit %{" tagroot $2 "}; exec %{/\\Q" keys "vc} } catch %{ echo %{unable to find tag} } } }" } /[^\t]+\t[^\t]+\t[0-9]+/ { out = out " %{" $2 ":" $3 "} %{eval -collapse-jumps %{ edit %{" tagroot $2 "} %{" $3 "}}}" } - END { print ( length(out) == 0 ? "echo -color Error no such tag " ENVIRON["tagname"] : "menu -markup -auto-single " out ) }' + END { print ( length(out) == 0 ? "echo -markup %{{Error}no such tag " ENVIRON["tagname"] "}" : "menu -markup -auto-single " out ) }' }} def ctags-complete -docstring "Insert completion candidates for the current selection into the buffer's local variables" %{ eval -draft %{ @@ -78,7 +78,7 @@ decl -docstring "options to pass to the `ctags` shell command" \ decl -docstring "path to the directory in which the tags file will be generated" str ctagspaths "." def ctags-generate -docstring 'Generate tag file asynchronously' %{ - echo -color Information "launching tag generation in the background" + echo -markup "{Information}launching tag generation in the background" %sh{ { while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done trap 'rmdir .tags.kaklock' EXIT @@ -90,7 +90,7 @@ def ctags-generate -docstring 'Generate tag file asynchronously' %{ msg="tags generation failed" fi - printf %s\\n "eval -client $kak_client echo -color Information '${msg}'" | kak -p ${kak_session} + printf %s\\n "eval -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} } > /dev/null 2>&1 < /dev/null & } } @@ -110,6 +110,6 @@ def ctags-update-tags -docstring 'Update tags for the given file' %{ msg="tags update failed for $kak_bufname" fi - printf %s\\n "eval -client $kak_client echo -color Information '${msg}'" | kak -p ${kak_session} + printf %s\\n "eval -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} } > /dev/null 2>&1 < /dev/null & } } diff --git a/rc/base/lint.kak b/rc/base/lint.kak index b5df16be..5c570ba0 100644 --- a/rc/base/lint.kak +++ b/rc/base/lint.kak @@ -97,7 +97,7 @@ def lint-next-error -docstring "Jump to the next line that contains an error" %{ if [ -n "$range" ]; then printf '%s\n' "select $range" else - printf 'echo -color Error no lint diagnostics\n' + printf 'echo -markup "{Error}no lint diagnostics"\n' fi } }} @@ -118,7 +118,7 @@ def lint-previous-error -docstring "Jump to the previous line that contains an e if [ -n "$range" ]; then printf '%s\n' "select $range" else - printf 'echo -color Error no lint diagnostics\n' + printf 'echo -markup "{Error}no lint diagnostics"\n' fi } }} diff --git a/rc/base/lua.kak b/rc/base/lua.kak index 4a43a080..0853e711 100644 --- a/rc/base/lua.kak +++ b/rc/base/lua.kak @@ -30,7 +30,7 @@ def lua-alternative-file -docstring 'Jump to the alternate file (implementation case $kak_buffile in *spec/*_spec.lua) altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) - [ ! -f $altfile ] && echo "echo -color Error 'implementation file not found'" && exit + [ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit ;; *.lua) path=$kak_buffile @@ -42,10 +42,10 @@ def lua-alternative-file -docstring 'Jump to the alternate file (implementation break fi done - [ ! -d $altdir ] && echo "echo -color Error 'spec/ not found'" && exit + [ ! -d $altdir ] && echo "echo -markup '{Error}spec/ not found'" && exit ;; *) - echo "echo -color Error 'alternative file not found'" && exit + echo "echo -markup '{Error}alternative file not found'" && exit ;; esac printf %s\\n "edit $altfile" diff --git a/rc/base/ruby.kak b/rc/base/ruby.kak index 1449251a..48d006e6 100644 --- a/rc/base/ruby.kak +++ b/rc/base/ruby.kak @@ -79,7 +79,7 @@ def ruby-alternative-file -docstring 'Jump to the alternate file (implementation case $kak_buffile in *spec/*_spec.rb) altfile=$(eval echo $(echo $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) - [ ! -f $altfile ] && echo "echo -color Error 'implementation file not found'" && exit + [ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit ;; *.rb) path=$kak_buffile @@ -91,10 +91,10 @@ def ruby-alternative-file -docstring 'Jump to the alternate file (implementation break fi done - [ ! -d $altdir ] && echo "echo -color Error 'spec/ not found'" && exit + [ ! -d $altdir ] && echo "echo -markup '{Error}spec/ not found'" && exit ;; *) - echo "echo -color Error 'alternative file not found'" && exit + echo "echo -markup '{Error}alternative file not found'" && exit ;; esac echo "edit $altfile" diff --git a/rc/base/spell.kak b/rc/base/spell.kak index fd69bab1..e1b7915e 100644 --- a/rc/base/spell.kak +++ b/rc/base/spell.kak @@ -18,7 +18,7 @@ Formats of language supported: %sh{ if [ $# -ge 1 ]; then if [ ${#1} -ne 2 ] && [ ${#1} -ne 5 ]; then - echo 'echo -color Error Invalid language code (examples of expected format: en, en_US, en-US)' + echo "echo -markup '{Error}Invalid language code (examples of expected format: en, en_US, en-US)'" rm -rf "$(dirname "$kak_opt_spell_tmp_file")" exit 1 else @@ -46,7 +46,7 @@ Formats of language supported: ;; '') line_num=$((line_num + 1));; \*) ;; - *) printf 'echo -color Error %%{%s}\n' "${line}" | kak -p "${kak_session}";; + *) printf 'echo -markup %%{{Error}%s}\n' "${line}" | kak -p "${kak_session}";; esac done printf 'set "buffer=%s" spell_regions %%{%s}' "${kak_bufname}" "${regions}" \ diff --git a/rc/base/tmux.kak b/rc/base/tmux.kak index 01a84da1..34ece586 100644 --- a/rc/base/tmux.kak +++ b/rc/base/tmux.kak @@ -18,7 +18,7 @@ def -hidden -params 1.. tmux-new-impl %{ %sh{ tmux=${kak_client_env_TMUX:-$TMUX} if [ -z "$tmux" ]; then - echo "echo -color Error 'This command is only available in a tmux session'" + echo "echo -markup '{Error}This command is only available in a tmux session'" exit fi tmux_args="$1" diff --git a/rc/base/x11.kak b/rc/base/x11.kak index 83ee6029..8b0dab36 100644 --- a/rc/base/x11.kak +++ b/rc/base/x11.kak @@ -27,7 +27,7 @@ The optional arguments will be passed as arguments to the new client} \ -command-completion \ x11-new %{ %sh{ if [ -z "${kak_opt_termcmd}" ]; then - echo "echo -color Error 'termcmd option is not set'" + echo "echo -markup '{Error}termcmd option is not set'" exit fi if [ $# -ne 0 ]; then kakoune_params="-e '$@'"; fi diff --git a/rc/core/c-family.kak b/rc/core/c-family.kak index caff5fbb..d640c64e 100644 --- a/rc/core/c-family.kak +++ b/rc/core/c-family.kak @@ -333,9 +333,9 @@ def c-family-alternative-file -docstring "Jump to the alternate file (header/imp done ;; *) - echo "echo -color Error 'extension not recognized'" + echo "echo -markup '{Error}extension not recognized'" exit ;; esac - echo "echo -color Error 'alternative file not found'" + echo "echo -markup '{Error}alternative file not found'" }} diff --git a/rc/core/doc.kak b/rc/core/doc.kak index 478dc926..342bc176 100644 --- a/rc/core/doc.kak +++ b/rc/core/doc.kak @@ -23,7 +23,7 @@ def -hidden -params 1..2 doc-open %{ printf %s\\n "try %{ exec '%(?i)^\h+[^\n]*?\Q${needle}\E\'' } catch %{ exec gg }" fi else - printf %s\\n "echo -color Error %{doc '$@' failed: see *debug* buffer for details}" + printf %s\\n "echo -markup %{{Error}doc '$@' failed: see *debug* buffer for details}" rm ${manout} fi } @@ -44,7 +44,7 @@ An optional keyword argument can be passed to the function, which will be automa if [ -f "${PATH_DOC}" ]; then printf %s\\n "eval -try-client %opt{docsclient} doc-open ${PATH_DOC} $@" else - printf %s\\n "echo -color Error No such doc file: ${PATH_DOC}" + printf %s\\n "echo -markup '{Error}No such doc file: ${PATH_DOC}'" fi } } diff --git a/rc/core/formatter.kak b/rc/core/formatter.kak index 358e54d8..b531a8a6 100644 --- a/rc/core/formatter.kak +++ b/rc/core/formatter.kak @@ -16,7 +16,7 @@ def format -docstring "Format the contents of the current buffer" %{ eval -draft printf '%s\\n' \"%sh{ rm -f '\${path_file_out}' }\" else printf '%s\\n' \" - eval -client '${kak_client}' echo -color Error formatter returned an error (\$?) + eval -client '${kak_client}' echo -markup '{Error}formatter returned an error (\$?)' \" rm -f \"\${path_file_out}\" fi @@ -25,7 +25,7 @@ def format -docstring "Format the contents of the current buffer" %{ eval -draft } " else - printf '%s\n' "eval -client '${kak_client}' echo -color Error formatcmd option not specified" + printf '%s\n' "eval -client '${kak_client}' echo -markup '{Error}formatcmd option not specified'" fi } } } diff --git a/rc/core/make.kak b/rc/core/make.kak index 09821e4e..99eb958e 100644 --- a/rc/core/make.kak +++ b/rc/core/make.kak @@ -53,11 +53,11 @@ def -hidden make-jump %{ # Try to parse the error into capture groups, failing on absolute paths exec s "Entering directory '([^']+)'.*\n([^:/][^:]*):(\d+):(?:(\d+):)?([^\n]+)\'" l set buffer make_current_error_line %val{cursor_line} - eval -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -color Information %{%reg{5}}; try %{ focus }" + eval -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -markup %{{Information}%reg{5}}; try %{ focus }" } catch %{ exec s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\'" l set buffer make_current_error_line %val{cursor_line} - eval -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -color Information %{%reg{4}}; try %{ focus }" + eval -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -markup %{{Information}%reg{4}}; try %{ focus }" } } } diff --git a/rc/core/man.kak b/rc/core/man.kak index 0ee92687..6533fa68 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -43,7 +43,7 @@ def -hidden -params 1..2 man-impl %{ %sh{ set window manpage '$@' " else - printf %s\\n "echo -color Error %{man '$@' failed: see *debug* buffer for details }" + printf %s\\n "echo -markup %{{Error}man '$@' failed: see *debug* buffer for details}" rm ${colout} fi } } diff --git a/rc/extra/autorestore.kak b/rc/extra/autorestore.kak index ad074116..b6cb7699 100644 --- a/rc/extra/autorestore.kak +++ b/rc/extra/autorestore.kak @@ -49,7 +49,7 @@ def autorestore-purge-backups -docstring "Remove all the backups of the current rm -f "${f}" done } - echo -color Information 'Backup files removed' + echo -markup '{Information}Backup files removed' } ## If for some reason, backup files need to be ignored diff --git a/rc/extra/clang.kak b/rc/extra/clang.kak index b4f956b2..2382bedb 100644 --- a/rc/extra/clang.kak +++ b/rc/extra/clang.kak @@ -172,7 +172,7 @@ def clang-diagnostics-next -docstring "Jump to the next line that contains an er if [ -n "$line" ]; then printf %s\\n "exec ${line} g" else - echo 'echo -color Error no next clang diagnostic' + echo "echo -markup '{Error}no next clang diagnostic'" fi ) } } diff --git a/rc/extra/editorconfig.kak b/rc/extra/editorconfig.kak index a6f43461..dc028c4c 100644 --- a/rc/extra/editorconfig.kak +++ b/rc/extra/editorconfig.kak @@ -6,7 +6,7 @@ decl -hidden bool editorconfig_trim_trailing_whitespace false def editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set formatting behavior according to editorconfig" %{ remove-hooks buffer editorconfig-hooks %sh{ - command -v editorconfig >/dev/null 2>&1 || { echo 'echo -color Error editorconfig could not be found'; exit 1; } + command -v editorconfig >/dev/null 2>&1 || { echo 'echo -markup "{Error}editorconfig could not be found"'; exit 1; } editorconfig "${1:-$kak_buffile}" | awk -F= -- ' /indent_style=/ { indent_style = $2 } /indent_size=/ { indent_size = $2 == "tab" ? 4 : $2 } diff --git a/rc/extra/git-tools.kak b/rc/extra/git-tools.kak index ba8dade7..7b2381ac 100644 --- a/rc/extra/git-tools.kak +++ b/rc/extra/git-tools.kak @@ -115,9 +115,9 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n # Handle case where message needs not to be edited if grep -E -q -e "-m|-F|-C|--message=.*|--file=.*|--reuse-message=.*|--no-edit"; then if git commit "$@" > /dev/null 2>&1; then - echo 'echo -color Information Commit succeeded' + echo 'echo -markup "{Information}Commit succeeded"' else - echo 'echo -color Error Commit failed' + echo 'echo -markup "{Error}Commit failed"' fi exit fi <<-EOF @@ -130,9 +130,9 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n printf %s "edit '$msgfile' hook buffer BufWritePost '.*\Q$msgfile\E' %{ %sh{ if git commit -F '$msgfile' --cleanup=strip $@ > /dev/null; then - printf %s 'eval -client $kak_client echo -color Information Commit succeeded; delete-buffer' + printf %s 'eval -client $kak_client echo -markup %{{Information}Commit succeeded}; delete-buffer' else - printf %s 'eval -client $kak_client echo -color Error Commit failed' + printf %s 'eval -client $kak_client echo -markup %{{Error}Commit failed}' fi } }" } @@ -159,19 +159,19 @@ Available commands:\n-add\n-rm\n-blame\n-commit\n-checkout\n-diff\n-hide-blame\n add) name="${2:-${kak_buffile}}" if git add -- "${name}" > /dev/null 2>&1; then - printf %s "echo -color Information 'git: added ${name}'" + printf %s "echo -markup '{Information}git: added ${name}'" else - printf %s "echo -color Error 'git: unable to add ${name}'" + printf %s "echo -markup '{Error}git: unable to add ${name}'" fi ;; rm) name="${2:-${kak_buffile}}" if git rm -- "${name}" > /dev/null 2>&1; then - printf %s "echo -color Information 'git: removed ${name}'" + printf %s "echo -markup '{Information}git: removed ${name}'" else - printf %s "echo -color Error 'git: unable to remove ${name}'" + printf %s "echo -markup '{Error}git: unable to remove ${name}'" fi ;; - *) printf %s "echo -color Error %{unknown git command '$1'}"; exit ;; + *) printf %s "echo -markup %{{Error}unknown git command '$1'}"; exit ;; esac }} diff --git a/rc/extra/iterm.kak b/rc/extra/iterm.kak index 80ed64a8..f4cda7d2 100644 --- a/rc/extra/iterm.kak +++ b/rc/extra/iterm.kak @@ -80,5 +80,5 @@ def -params ..1 -client-completion \ If no client is passed then the current one is used} \ iterm-focus %{ # Should be possible using ${kak_client_env_ITERM_SESSION_ID}. - %sh{echo "echo -color Error 'Not implemented yet for iTerm'"} + %sh{echo "echo -markup '{Error}Not implemented yet for iTerm'"} } diff --git a/rc/extra/moon.kak b/rc/extra/moon.kak index cbba288c..2f63f60a 100644 --- a/rc/extra/moon.kak +++ b/rc/extra/moon.kak @@ -34,7 +34,7 @@ def moon-alternative-file -docstring 'Jump to the alternate file (implementation case $kak_buffile in *spec/*_spec.moon) altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) - [ ! -f $altfile ] && echo "echo -color Error 'implementation file not found'" && exit + [ ! -f $altfile ] && echo "echo -markup '{Error}implementation file not found'" && exit ;; *.moon) path=$kak_buffile @@ -46,10 +46,10 @@ def moon-alternative-file -docstring 'Jump to the alternate file (implementation break fi done - [ ! -d $altdir ] && echo "echo -color Error 'spec/ not found'" && exit + [ ! -d $altdir ] && echo "echo -markup '{Error}spec/ not found'" && exit ;; *) - echo "echo -color Error 'alternative file not found'" && exit + echo "echo -markup '{Error}alternative file not found'" && exit ;; esac printf %s\\n "edit $altfile" diff --git a/rc/extra/tmux-repl.kak b/rc/extra/tmux-repl.kak index fe191946..f86b84da 100644 --- a/rc/extra/tmux-repl.kak +++ b/rc/extra/tmux-repl.kak @@ -25,7 +25,7 @@ hook global KakBegin .* %{ def -hidden -params 1..2 tmux-repl-impl %{ %sh{ if [ -z "$TMUX" ]; then - echo "echo -color Error This command is only available in a tmux session" + echo "echo -markup '{Error}This command is only available in a tmux session'" exit fi tmux_args="$1" @@ -64,5 +64,5 @@ def -hidden tmux-send-text -docstring "Send the selected text to the repl pane" def -hidden tmux-repl-disabled %{ %sh{ VERSION_TMUX=$(tmux -V) - printf %s "echo -color Error %{The version of tmux is too old: got ${VERSION_TMUX}, expected >= 2.x}" + printf %s "echo -markup %{{Error}The version of tmux is too old: got ${VERSION_TMUX}, expected >= 2.x}" } } diff --git a/rc/extra/x11-repl.kak b/rc/extra/x11-repl.kak index 679c13d8..13bcd88b 100644 --- a/rc/extra/x11-repl.kak +++ b/rc/extra/x11-repl.kak @@ -5,7 +5,7 @@ All optional parameters are forwarded to the new window} \ -command-completion \ x11-repl %{ %sh{ if [ -z "${kak_opt_termcmd}" ]; then - echo "echo -color Error 'termcmd option is not set'" + echo "echo -markup '{Error}termcmd option is not set'" exit fi if [ $# -eq 0 ]; then cmd="${SHELL:-sh}"; else cmd="$@"; fi diff --git a/src/commands.cc b/src/commands.cc index e9bcfb9c..05c9e81e 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1087,8 +1087,7 @@ const CommandDesc echo_cmd = { nullptr, "echo ...: display given parameters in the status line", ParameterDesc{ - { { "color", { true, "set message color" } }, - { "markup", { false, "parse markup" } }, + { { "markup", { false, "parse markup" } }, { "debug", { false, "write to debug buffer instead of status line" } } }, ParameterDesc::Flags::SwitchesOnlyAtStart }, @@ -1103,10 +1102,7 @@ const CommandDesc echo_cmd = { else if (parser.get_switch("markup")) context.print_status(parse_display_line(message)); else - { - auto face = get_face(parser.get_switch("color").value_or("StatusLine").str()); - context.print_status({ std::move(message), face } ); - } + context.print_status({ std::move(message), get_face("StatusLine") }); } };