| View previous topic :: View next topic |
| Author |
Message |
titeuf
Joined: 29 Jul 2006 Posts: 84
|
Posted: Thu Dec 21, 2006 2:04 pm Post subject: Some highlight stuff |
|
|
I've played again with the highlight function and has found something that think causes 99% of my problems with it, here's an example of a mud with #config convert on:
| Code: |
\e[37m\e[32m3079h,\e[37m\e[32m 4259m,\e[37m\e[32m 13660e,\e[37m\e[32m 21850w\e[37m exk-\e[1;33m
Savira tells you, "Heh."
\e[0;37m\e[32m3079h,\e[37m\e[32m 4259m,\e[37m\e[32m 13660e,\e[37m\e[32m 21850w\e[37m exk-\e[34m
|
The first and last line are my prompt, that is displayed in green and gray,
the second one is a tell displayed in yellow.
As you can see the colour of the tell is set on the line before, followed by a linebreak.
This works well, except with #high, when I use for instance #high {Savira} {bold red}, it changes her name to the correct colour, but the rest of the line get sets to the default colour, grey.
With other lines where the colour is set on the same line instead of on the line before, it works without problems.
I've tought to fix it manually with #sub, but I can't really do that as I want sometimes to highlight multiple words on one line.
Also, can you add support for 256 colours with #high, that would be nice? |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
Posted: Tue Dec 26, 2006 1:32 pm Post subject: |
|
|
There's not much I can do about that. Possibly you can ask your mud admin to fix it on the server side.
One option is using a substitution to fix up tells, says, etc. The highlights should still work after #sub sets the default color at the begin of the line.
#sub {%0 tells you, "%1"^} {<138>%0 tells you, "%1"}
#high {Savira} {bold red}
I updated the beta, and <###> color codes should work in highlights now. |
|
| Back to top |
|
 |
titeuf
Joined: 29 Jul 2006 Posts: 84
|
Posted: Tue Dec 26, 2006 3:02 pm Post subject: |
|
|
| Scandum wrote: | There's not much I can do about that. Possibly you can ask your mud admin to fix it on the server side.
One option is using a substitution to fix up tells, says, etc. The highlights should still work after #sub sets the default color at the begin of the line.
#sub {%0 tells you, "%1"^} {<138>%0 tells you, "%1"}
#high {Savira} {bold red}
I updated the beta, and <###> color codes should work in highlights now. |
That works well! Thank you |
|
| Back to top |
|
 |
titeuf
Joined: 29 Jul 2006 Posts: 84
|
Posted: Tue Dec 11, 2007 2:13 pm Post subject: |
|
|
I'm going to necro this topic instead of creating a new one.
The solution you posted worked well so far, but now I'm stumbling on a new problem: I want to highlight names but I can't create #subs for it like I do with tells and such as the lines vary a lot and don't follow a certain pattern.
So it looks like this:
Blablabla Someone got killed.
so the last part lost its color cause of the #highlight
As a possible way to fix this: isn't it possible to copy the last color code found on the start of each following line? I think there is already something like this for #split mode when scrolling up.
If you look at the example that I posted (almost a year ago now :O ) it'll become this:
| Code: |
\e[37m\e[32m3079h,\e[37m\e[32m 4259m,\e[37m\e[32m 13660e,\e[37m\e[32m 21850w\e[37m exk-\e[1;33m
\e[1;33mSavira tells you, "Heh."
\e[0;37m\e[32m3079h,\e[37m\e[32m 4259m,\e[37m\e[32m 13660e,\e[37m\e[32m 21850w\e[37m exk-\e[34m |
|
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
Posted: Wed Dec 12, 2007 8:21 am Post subject: |
|
|
Too much trouble to add (and obfuscate the code with) for just a handful of muds.
You can try to grab the code by matching your prompt and grabbing the last color code:
| Code: |
#act {~(your prompt)-\e[%8;%9m} {#var lastcolor {\e[%8;%9m}
#var names [John|Jack|Sarrah]
#sub {~%0$names%2} {${lastcolor}%0%1%2}
|
edit:
You'll still need to make a highlight for each individual name.
| Code: |
#forall {John Jack Sarrah}
{
#highlight {&0} {light green}
}
|
|
|
| Back to top |
|
 |
titeuf
Joined: 29 Jul 2006 Posts: 84
|
Posted: Thu Dec 13, 2007 11:51 am Post subject: |
|
|
| Scandum wrote: | Too much trouble to add (and obfuscate the code with) for just a handful of muds.
...
|
fair enough
I didn't try the code you posted, but added that feature in myself, was a nice opportunity to see how C works (I really don't know a lot about it) and how tt++'s source code is structured (wasn't too hard to understand, but it could use more comments )
My patch is probably ugly and inefficient and you'll probably cry at how bad it is, but it works for me!  |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
Posted: Thu Dec 13, 2007 2:07 pm Post subject: |
|
|
It's my experience that a piece of code is either too easy or too complex to bother with comments.
I'll probably rewrite the strip_non_vt102_codes function sometime to also compress the resulting codes, which would make implementation of this feature an option.
I'm curious of course if the script does the trick  |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
|
| Back to top |
|
 |
titeuf
Joined: 29 Jul 2006 Posts: 84
|
Posted: Tue Dec 18, 2007 2:11 pm Post subject: |
|
|
Awesome!
This also fixes a minor prompt isue discussed here
Already had the opportunity to find some bugs in it
-combinining #high and #config convert crashes tt++, it's a bit random though so can't give you an example on how to reproduce it.
When it crashes it gives various errors:
| Code: |
*** glibc detected *** ../tt/src/tt++: free(): invalid next size (normal): 0x08137e58 ***
#THERE'S NO ACTIVE SESSION NOW.
/lib/tls/i686/cmov/libc.so.6[0xb7e6cd65]
Goodbye from TinTin++bc.so.6(cfree+0x90)[0xb7e70800]
../tt/src/tt++[0x80753bd]
|
or
| Code: |
\e[0m############################################# DEBUG STACK ########################################
#####\e[0m
\e[0m\e[1;31mDEBUG_STACK[000] = main(0x2,0xbf8e48b4)\e[0m
\e[0m\e[1;31mDEBUG_STACK[001] = readmud(0x811e078)\e[0m
\e[0m\e[1;31mDEBUG_STACK[002] = [achaea] do_one_line(0xbf8cbe64,0x811e078)\e[0m
\e[0m##################################################################################################
#####\e[0m
|
-when it receives a colored line from the mud, it shows an empty line bellow my prompt:
| Code: |
e[0;37m\e[32m3322h,\e[37m\e[32m 3660m,\e[37m\e[32m 17000e,\e[37m\e[32m 19490w\e[37m cexkdb-
\e[0;1;32m\e[1;32m
\e[0;1;32m(Hashan): Aduan says, "Thanks for supporting me Alasha."
\e[0;37m\e[0;37m\e[32m3322h,\e[37m\e[32m 3660m,\e[37m\e[32m 17000e,\e[37m\e[32m 19490w\e[37m cexkdb-
|
this doesn't happen when the received line is in the default gray color.
Otherwise, nice work! |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
Posted: Tue Dec 18, 2007 6:07 pm Post subject: |
|
|
Uploaded a new beta with a fix for the crash bug.
The blank line spawn is from the prompt fixes, little I can do about it since few muds handle prompts correctly.
You can probably remove it with:
#gag {~^\e[0;1;32m\e[1;32m^} |
|
| Back to top |
|
 |
titeuf
Joined: 29 Jul 2006 Posts: 84
|
Posted: Tue Dec 18, 2007 7:16 pm Post subject: |
|
|
Now it works perfect
To remove the blank lines, I use the following two gags:
| Code: |
#GAG {~^\e[0;1;[30|31|32|33|34|35|36|37]m\e[1;[30|31|32|33|34|35|36|37]m^}
#GAG {~^\e[0;[30|31|32|33|34|35|36|37]m\e[[30|31|32|33|34|35|36|37]m^}
|
that way I don't have to create separate ones for everything. |
|
| Back to top |
|
 |
Scandum Site Admin
Joined: 03 Dec 2004 Posts: 3281
|
Posted: Wed Dec 19, 2007 3:07 am Post subject: |
|
|
Could be slightly shorter/faster I think:
| Code: |
#GAG {~^\e[0;1;3[0|1|2|3|4|5|6|7]m\e[1;3[0|1|2|3|4|5|6|7]m^}
#GAG {~^\e[0;3[0|1|2|3|4|5|6|7]m\e[3[0|1|2|3|4|5|6|7]m^}
|
|
|
| Back to top |
|
 |
|