cyd01 / KiTTY

:computer: KiTTY, a free telnet/ssh client for Windows
https://www.9bis.com/kitty
Other
1.6k stars 136 forks source link

Poor man's syntax highlighting #9

Closed kellerza closed 1 year ago

kellerza commented 5 years ago

Since the forum seems to be closed, I'l post this here. This is an enhancement request, and a suggestion for a workaround to get syntax highlighting. Very handy when configuring routers and could also help when looking for certain text in logs.

In current versions of Kitty, you can (mis-)use the URL highlighting feature to underline words

image

My example pattern highlights Enabled, Up, Down and IP addresses:

(Enabled|Up|Down|([0-9]{1,3}\.){3}[0-9]{1,3})

It would be even better if you could have a list of regular expressions with colours, for example: Up->green, down->red and IP Addresses->blue. Hopefully this will inspire someone to implement this... the URL highlighting patch is probably a good place to start :wink:

lars18th commented 4 years ago

Hi @cyd01 ,

I suggest to copy/move/link this in the Wiki and close this issue.

What you think?

CWempe commented 4 years ago

Like @kellerza wrote, this is an enhancement request which is not fulfilled or denied, yet.

But the workaround to highlight keywords as links could be moved to a wiki.

CWempe commented 4 years ago

Here is a suggestion:

Another way to implement this "Poor man's syntax highlighting" could be to have multiple RegEx fields with individual options/font settings.

Example:

field name user defined Value
RegEx 1 (((((https?|ftp|svn):\/\/)|www.)(([0-9]+.[0-9]+.[0-9]+.[0-9]+)|localhost|([a-zA-Z0-9-]+.)[a-zA-Z0-9-]+.(com|net|org|info|biz|int|gov|name|edu|[a-zA-Z][a-zA-Z]))(:[0-9]+)?((\/|\?)[^ "][^ ,;.:">)])?)|(mailto:\/\/[a-zA-Z0-9-.]+@[a-zA-Z0-9-.]+.[a-z]{2,}))
font settings 1 underlined, clickable
RegEx 2 (up|enabled)
font settings 2 green, underlined
RegEx 3 (down|disabled)
font settings 3 red, bold
RegEx 4 (notconnected|([0-9]{1,3}.){3}[0-9]{1,3})
font settings 4 bright cyan
RegEx 5 (down|disabled)
font settings 5 white, red background

So I would think these options/font settings would make sense:

What I personally do not need (to reduce the effort for the developer):

If Kitty had this feature it would make managing my switches and routers much more comfortable. 🤩

What do others think? Would you need more or less options? How many RegEx fields would be best?

lars18th commented 4 years ago

Hi @CWempe ,

What do others think?

I think it's an interesting idea.

kellerza commented 4 years ago

Indeed @CWempe my idea was multiple RegExes with individual results. Look at this screencast to see it in action.

Limited colors is not an issue, just basic ANSI colors should be ok. Even if this is only configurable in config files it will be acceptable.

Maybe 8 regexes? Will probably have to see when this has a performance hit.

CWempe commented 3 years ago

@cyd01 Any thoughts from your side?

Do you think this would be possible to implement?

Limited colors is not an issue, just basic ANSI colors should be ok. Even if this is only configurable in config files it will be acceptable.

Maybe it would make sense to link the RegExes to the colors defined under Window > Colours instead of custom colors for each RegEx.

image

This would make it compatible with putty color schemes.

But I would be happy either way.

cyd01 commented 1 year ago

Issue closed due to inactivity

kellerza commented 1 year ago

No worries, I've been using labctl color to do the highlighting.

It works nicely with most terminals: Kitty / Windows Terminal / inside VSCode