Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax highlighting for eval #2042

Closed
pascalpoitras opened this issue Nov 13, 2023 · 3 comments
Closed

syntax highlighting for eval #2042

pascalpoitras opened this issue Nov 13, 2023 · 3 comments
Assignees
Labels
feature New feature request
Milestone

Comments

@pascalpoitras
Copy link

pascalpoitras commented Nov 13, 2023

Feature description

It would be useful to have syntax highlighting for eval. It would be available in two ways

  1. using /eval -h
  2. using ${highlighting:...}

the highlighting variable would have the second top priority (so just after raw). Nothing would be evaluated inside highlighting (exactly like raw does).

So if the cut variable is green and the rev variable is red, both

/eval -h ${cut:1,,${rev:hello}}

and

/eval -n ${highlighting:${cut:1,,${rev:hello}}}

will print

WeeChat Screenshot

We could also have an option similar to weechat.color.chat_nick_colors which contains a list of colors and an option similar to weechat.look.nick_color_hash taking an algorithm so the color will be choosed automatically

All ${info:...} would be colored the same way no matter the info name, same for ${modifier:...} OR different color not sure what is the best here

the ${define:...} is interesting since it priority allow it to redefine variable so for example what the color the following ${info:version} should be

/eval -h ${define:info:version,hello}${info:version}

the color for info or the color for custom variables ?

This feature is useful in many scenario, for example

  1. sending an eval string on IRC with syntax highlighting

/eval ${modifier:irc_color_decode_ansi,1,${modifier:color_encode_ansi,,${highlighting:${cut:1,,${rev:hello}}}}}

  1. using it in a input_text_display modifier so you have syntax highlighting when writting a code snippet in the input bar
@pascalpoitras pascalpoitras added the feature New feature request label Nov 13, 2023
@pascalpoitras
Copy link
Author

Ok so, FlashCode accepted this feature so here it was it look like in the input bar

byzanz-record-2023-11-20-154503

@flashcode flashcode self-assigned this Nov 20, 2023
@flashcode flashcode added this to the 4.2.0 milestone Nov 20, 2023
flashcode added a commit that referenced this issue Nov 23, 2023
…n weechat.color.eval_syntax_colors (issue #2042)

Syntax highlighting (raw string without evaluation): `${raw_hl:xxx}`
Syntax highlighting: `${hl:xxx}`
@flashcode
Copy link
Member

Done with ${raw_hl:...} (raw string with syntax highlighting) and ${hl:...} (evaluated string with syntax highlighting).

@flashcode
Copy link
Member

Trigger to colorize /eval command in input:

/trigger add eval_hl modifier "input_text_display" "${tg_string} =~ ^/eval" "/.*/${hl:${re:0}}/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

2 participants