Hyperlinks with | character in action or tooltip seems to be broken?

Posted by Athlau on Thu 09 Feb 2023 05:13 AM — 6 posts, 17,071 views.

#0
It seems that for some reason Hyperlink's action and tooltip are cut at the first | character.

I'm running the following code from command input box, doing that in a separate script file have exactly the same behaviour:

\\\k="echo A|B|C";Hyperlink(k, k, k, "cyan", "blue", false, false);Note()

\\\ is lua script prefix for command line in client settings.

As expected it shows "A|B|C" with cyan on blue, however
mouse tooltip shows only "echo A" and if I click the hyperlink it will only send "echo A" command.

I've tried to escape '|' as
k="echo A\\|B"
k="echo A||B"
k="echo A%|B"
It displays hyperlink as expected but the tooltip and action are still cut at first |

Any ideas how to workaround that?
Amended on Thu 09 Feb 2023 09:50 AM by Athlau
#1
I don't see where Hyperlinks ever accepted multiple options in one hyperlink.

However, one workaround you can do to produce the result you're wanting is something like:


k = "echo "
kc = {"A", "B", "C"}

for i,v in ipairs(kc) do
   if i < #kc then v = v .. "|" end
   Hyperlink(k .. v, (v and i == 1 and k or "") .. v, v, "cyan", "blue", false, false)
end
Note("")


That will produce the output of:

echo A|B|C

and function correctly when selecting the letter.

There probably is a cleaner way to do that, but that's my solution that works.
Amended on Thu 09 Feb 2023 03:59 PM by AdInfinitum
Australia Forum Administrator #2
Are you using "|" as a command separator? I'm confused as to why you expect the "|" character to have a special action here.
#3
Nick Gammon said:

Are you using "|" as a command separator? I'm confused as to why you expect the "|" character to have a special action here.


I think that's precisely what Athlau intended to do, and I have no idea where the thought it was even possible originated.
#4
It looks like I wasn't clear in my message, sorry.

I have no intention to use | as multi choice separator or anything like that. All I'm trying to do is literally issue a command "echo A|B", regardless of where you click on a Hyperlink. But for some reason the Hyperlink code just strips out all the characters starting from "|". And yes, there's nothing in the docs suggesting that "|" should have any special meaning for Hyperlinks... but somehow it does have it?

I've tried to simplify the test case, so it started to look like it's A or B thingy, but it's not.

In fact I'm just dumping hyperlinks for mapper's custom exits which contain some minimap matching strings and "|" often appears there as a vertical wall.
So for Hyperlinks like:
"minimap_to [ <$>|]", it will correctly output a line
minimap_to [ <$>|]"
But both tooltip and actual command executed when clicking it
will be stripping all starting from first encountered "|".
So it becomes just "minimap_to [ <$>"

Here's a screenshot just in case...
https://user-images.githubusercontent.com/118027636/217938628-4e822b6a-b964-4119-b4d4-2bf991c2b21e.png

Hope it clarifies my question.
Amended on Thu 09 Feb 2023 09:12 PM by Athlau
Australia Forum Administrator #5
I haven't worked on this code for a while, but it seems that in:

https://github.com/nickgammon/mushclient/blob/master/mushview.cpp#L2250 (around line 2250)

The code appears to be separating what you entered at the "|" symbols, as it would for a menu item:

http://www.gammon.com.au/scripts/doc.php?function=Menu

On the face of it, this looks like a bug.

As a work-around I suggest replacing "|" with something similar (like a forward slash) or maybe some Unicode symbol if you are displaying Unicode (UTF-8).

A possible candidate would be "¦".