HTML Link Colors (adv3Lite)

I’ve been looking through the docs and can’t find the answer to this one. I’m thinking of adding clickable links to my WIP (for examining objects, for example). But the default link is blue with an underline, and that’s ugly. The links in the banner for unvisited directions are an attractive green color, and that’s what I’d like – but I can’t find where in the documentation that link color is specified.

I’d like to do this once, hopefully, in a setup function somewhere. I wouldn’t like to have to include the code for the color in every single aHref block (if that’s even possible).

See the Adv3Lite Library Manual (file:///adv3Lite/manual/room.htm) for a discussion of how to modify html tags globally.

See also the StyleTags Class in the library reference manual. Looks like you’d want to start experimenting with the hyperlinkStyleTag object of the HtmlStyleTag subclass.

Jerry

The hyperlinkStyleTag is defined in the library as ‘a’ – no help there. The StyleTag class defines a number of global objects, none of which seems to relate to command hyperlinks. It also has a subclass, HtmlStyleTag, but the openText and closeText for that class are defined as ’ ’ (nothing), so it’s pretty clear that the default blue text with underlining is not being defined in that class.

So … thanks for offering suggestions, but I’m no forwarder than before.

The good news (on an entirely different subject) is that I figured out how to use a Doer to create an auto-locking exit door. Heh-heh-heh.

It turns out aHref is a macro. It’s defined this way: aHref(href, txt?, title?, flags = 0). The flags parameter might, in theory, be used to change the appearance of the link, but the only value defined in the library is AHREF_Plain. No help there. But I think maybe I can redefine the macro. We’ll see.

Nope – no luck there. Trying to define props as ‘color=green’ produces a string of compiler warnings, and also hoses the link colors in the banner. Grrr.

The hyperlinkStyleTag object modifies the style used when creating the HTML tag.

To change the color of the link to green, put this somewhere in your code…

modify hyperlinkStyleTag openText = '<font color=green>' closeText = '</font>' ;

Getting rid of the underscore may be a bit more complicated; not sure how you’d go about that. In HTML destined for a web browser, it would be done like this…

<a href="target" style="text-decoration: none">

But the hyperlinkStyleTag modificatons appear to be inserted between the <a href’"…"> tag and its corresponding closing tag. Some experimentation may be in order.

Jerry

Okay, found out how to suppress the underscore in HREFs, and it’s surprisingly easy.

Simply pass the flag AHREF_Plain when you create the tag, as a fourth parameter (note the empty ’ ’ between ‘south’ and the flag)…

room: Room 'room'
    "In the room. You could go <<aHref('go south', 'south', '', AHREF_Plain)>> from here. <.p>"

…produces this…

…where south is a link with no underscore.

Jerry

Thanks, Jerry! That almost solves the problem. With your two tips, I can indeed get nice green links in my game text. But there’s a side effect. The mechanism that modifies the Exits listing in the banner so that unvisited directions are green and visited directions are black has now been overridden. They all stay green, as does the room name in the banner, which wasn’t green before.

And if I choose something other than green, I get the same color for the stuff in the StatusLine (banner). This should not be the case, because in the library, statuslineExitLister.unvisitedExitColour is still ‘green’.

I’ll investigate further.

What seems to be happening is that a system action called ExitsColour is stepping on the default unvisitedExitColour, probably during preinit. But I don’t see where that action is being initiated.

In addition, my modification of the library code also overrides the user ‘exits color’ command. I now can’t turn the StatusLine exits to a different color from within the game.

There’s something really gnarly going on here. I think I’ll wait until Eric returns from Kuala Lumpur or wherever he has gone; it’s too deep for me.

The room name in the satus line appears to default to the same color specified for links, but you can force it to the color of your choice by modifying the statusroomStyleTag…

modify statusroomStyleTag openText = '<font color=black>' closeText = '</font>' ;

As for the link staying green, change the code that modifies the html style tag to the following…

modify hyperlinkStyleTag openText = '<<if !gLocation.visited>> <font color=green> <<else>> <font color=black> <<end>>' closeText = '</font>' ;

Jerry

I don’t think that’s quite right. It’s not the visited status of gLocation that’s at issue. (I’m pretty sure that will always be true.) Here’s the relevant code, from statusLineExitLister:

showListItem(obj, options, pov, infoTab) { if(highlightUnvisitedExits && (obj.dest_ == nil || !obj.dest_.seen)) htmlSay('<FONT COLOR="<<unvisitedExitColour>>">'); "<<aHref(obj.dir_.name, obj.dir_.name, 'Go ' + obj.dir_.name, AHREF_Plain)>>"; if(highlightUnvisitedExits && (obj.dest_ == nil || !obj.dest_.seen)) htmlSay('</FONT>'); }
The relevant bit, I think, is !obj.dest_.seen. But obj is a parameter passed in from elsewhere. It refers to the destination of the link. It’s a property of the DestInfo class. I’ll try tracing it backward to see what’s calling showListItem, but I may have trouble figuring it out… Searching for statuslineExitLister.showListItem, I find that this string is nowhere in the library. But there are too many uses of showListItem itself to even bother trying to paw through them.

The immediate source of that call is probably ExitLister.showListAll(). But who is calling that? It seems to be coming from showExitsWithLister(), which builds the list of exits from the current location. I have no idea where or how one would intervene in this process.

Hmmm. You’re right about gLocation; I noticed the same thing a short while after posting it as the end-all-be-all solution. Oh, well.

I think I see what’s going on now from what you found in showListItem(). If I’m right, it’s not something you or I can fix.

What it looks like to me is showListItem() is doing the following…

A. Defines the color for the text, according to the default unvisited exit color
B. Creates the HTML tag.
C. Closes the unvisited-link font tag.

The problem we are seeing is what happens inside step B, where the href tag is created as…

<a href="destination"><.a>display text</.a></a>

The <.a>display text</.a> part comes from the modified hyperlinkStyleTag code, and it contains the customized font color information, like this: <.a>display text</.a>.

So the entire sequence looks like this:

<font color=<<default unvisited>>>
    <a href="destination">
        <.a>
            <font color=green>displaytext</font>
        </.a>
    </a>
</font>

So, the library sets the text color to one value which is overridden in the <.a>…</.a> part in the center.

That’s my current theory, anyway.

Jerry