-
Notifications
You must be signed in to change notification settings - Fork 34
Inconsistent highlighting of single letters #83
Comments
It's a weird behavior with using single-letter matching and how ChromaTerm processes the text. (A bit lengthy; sorry.) As you type on your keyboard ( Now, what if the data doesn't end in a separator? Well, ChromaTerm will wait a very small amount (0.05 ms or 500 µsec) to make sure it won't be receiving any more data, and – if it doesn't – it will processes it as its own chunk. While typing, each character is basically its own chunk (unless you're typing faster than 500 µsec, in which case you are a literal keyboard god). As you type and the remote server sends back output, here's what happens:
This complicated work is needed because ChromaTerm must work with interactive applications. Otherwise, we could just line-buffer everything and call it a day. I may be able to apply some logic to prevent this (i.e. processing unseparated text), but I'm still thinking whether or not they're realistically achievable without any work on the user's side. |
BTW, here's where this logic is present: ChromaTerm/chromaterm/__init__.py Lines 211 to 222 in 8a9774d
The simplest solution would be not to highlight any text not ending a separator and just print it as is. This will work fine as just about everything will contain a separator. The only exception to this is if the piping program's last line (when it closes) doesn't have a separator, like so:
Basically, this diff --git a/chromaterm/__init__.py b/chromaterm/__init__.py
index 226b0d3..a0858dc 100644
--- a/chromaterm/__init__.py
+++ b/chromaterm/__init__.py
@@ -219,3 +219,3 @@ def process_buffer(config, buffer, more):
# No more data; print last split and flush as it doesn't have a new line
- print(highlight(config, splits[-1][0]) + splits[-1][1], end='', flush=True)
+ print(splits[-1][0] + splits[-1][1], end='', flush=True) |
Thank you for the very detailed response! Now I understand why this happens. I realize that trying to fix this might not be straight-forward, either way it is a minor issue for me. Thanks again. |
I'm gonna reopen it and mark it as an enhancement (nearly ready). |
Fixed and will be published in v0.5.8. Thanks a lot for your recent feedback/submissions; I greatly appreciate them. This one, for example, also helped me pick a scientifically better value for the delay, instead of the arbitrary 500 µsec. |
Brilliant! You rock. And it's my pleasure, as soon as I discovered ChromaTerm and realized I could use a proper terminal emulator (I use Windows Terminal and WSL now) instead of SecureCRT, I was so happy. |
Easier to explain with a screenshot:
It seems that the highlight rules for RIP, EIGRP, BGP and OSPF matches the single letters in the Cisco CLI prompt, even though it shouldn't match if these letters are part of a word, i.e. not standalone?
Is this a bug, or is this supposed to happen given the regex below?
The text was updated successfully, but these errors were encountered: