[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Hyperlinks with | character in action or tooltip seems to be broken?

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

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Athlau   (2 posts)  [Biography] bio
Date Thu 09 Feb 2023 05:13 AM (UTC)

Amended on Thu 09 Feb 2023 09:50 AM (UTC) by Athlau

Message
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?
[Go to top] top

Posted by AdInfinitum   (74 posts)  [Biography] bio
Date Reply #1 on Thu 09 Feb 2023 03:53 PM (UTC)

Amended on Thu 09 Feb 2023 03:59 PM (UTC) by AdInfinitum

Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Thu 09 Feb 2023 06:55 PM (UTC)
Message
Are you using "|" as a command separator? I'm confused as to why you expect the "|" character to have a special action here.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by AdInfinitum   (74 posts)  [Biography] bio
Date Reply #3 on Thu 09 Feb 2023 08:30 PM (UTC)
Message
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.
[Go to top] top

Posted by Athlau   (2 posts)  [Biography] bio
Date Reply #4 on Thu 09 Feb 2023 09:04 PM (UTC)

Amended on Thu 09 Feb 2023 09:12 PM (UTC) by Athlau

Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,966 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 09 Feb 2023 10:03 PM (UTC)

Amended on Thu 09 Feb 2023 10:12 PM (UTC) by Nick Gammon

Message
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 "¦".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


4,382 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]