Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ Embedding a hyperlink into a matched line
|
Embedding a hyperlink into a matched line
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Twisol
USA (2,257 posts) Bio
|
| Date
| Tue 02 Sep 2008 08:46 AM (UTC) |
| Message
| Hi, I'm trying to embed a hyperlink into part of the Achaea prompt - for example, "3106h, 3710m, 14000e, 16040w ex Vote-" - specifically, the Vote, and make it link to the web page to vote for Achaea. I was at first trying to use lookbehind (and lookahead for the '-'), so I would only actually match the Vote, but acknowledge the existance of the rest of the prompt. That didn't work very well, mostly because I've never done any lookarounds before.
Also, apparently Hyperlink() only echoes the hyperlink to the output, it doesn't actually replace text with the hyperlink. I guess this means I would have to omit the prompt altogether, and re-echo it with the hyperlink, right? Seems kind of painful...
This is the trigger I'm using for the prompt. This works, at least. It's rather complex because I want to match any configuration of the prompt (it can be off, it can list only health and mana, etc)
^(?:\d+h, )?(?:\d+m,? )?(?:\d+e,? )?(?:\d+w,? )?c?e?x?k?d?b?@?\s?(?:Vote)?-\s?$
That Vote thing at the end is what I want to hyperlink. Help? :| |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | | Top |
|
| Posted by
| WillFa
USA (525 posts) Bio
|
| Date
| Reply #1 on Tue 02 Sep 2008 06:49 PM (UTC) Amended on Tue 02 Sep 2008 07:18 PM (UTC) by WillFa
|
| Message
| Hmm If the prompt ends in a newline then this may work...
the general RegExp tho can be more succinctly:
^$(?P<Start>(?:\d++[hmew], )*[cexkdb@]* ?)(?P<Vote>)Vote)?-\s?$
Omit from Output
Send to: Script
Tell("%<Start>")
if "%<Vote>" ~= "false" then
HyperLink(....too lazy to doublecheck syntax)
end
So it's not really that painful to omit and re-echo. | | Top |
|
| Posted by
| Twisol
USA (2,257 posts) Bio
|
| Date
| Reply #2 on Tue 02 Sep 2008 07:22 PM (UTC) Amended on Tue 02 Sep 2008 11:31 PM (UTC) by Twisol
|
| Message
| OK, this is what I have so far. It works, but is there any way to re-print the prompt in exactly the same color(s) as it was before? I know I can use AnsiTell, but it would be nice to be able to "catch" the colors used in the prompt and re-use them in the script.
Trigger:
^(?P<Start>(?:\d+h, )?(?:\d+m,? )?(?:\d+e,? )?(?:\d+w,? )?c?e?x?k?d?b?@? ?)(?P<Vote>Vote)- ?$
Script (after omit):
if "%<Vote>" ~= "" then
Tell("%<Start>")
Hyperlink("http://www.achaea.com/vote/", "Vote", "Vote!", "green", "black", true)
Tell("-")
if ("%<Start>" == "") then
Tell(" ")
end
Note()
end |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Tue 02 Sep 2008 09:20 PM (UTC) |
| Message
| The general technique to keep the colours is described in http://mushclient.com/faq point 23. Although that mentions going to another world window, the same idea applies if omitting a line and redrawing it.
Also check out http://www.gammon.com.au/plugins/ and look for the Hyperlink_URL2 plugin, which probably does most of what you want. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
15,089 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top