Register forum user name Search FAQ

Gammon Forum

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 ➜ General ➜ Displaying HTML entities

Displaying HTML entities

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


Posted by AdInfinitum   (74 posts)  Bio
Date Wed 09 May 2018 03:13 AM (UTC)
Message
I'm attempting to convert a script from an old client to MUSHclient, and part of that script uses MXP to display things like headers and paragraph breaks using <h1> and <p>.

I know MUSHclient can use MXP, but how can I get it to display things as an HTML page would? For example, if I had:

<h2>Title</h2>


I'd want that "Title" to be at a size 2 header. Is this possible, or do I need to seek an alternate way of doing so?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 09 May 2018 04:52 AM (UTC)
Message

No, MUSHclient does not support rich text in the output window. The best you could do is make text bold/italic etc. And there are already MXP elements to do that. See here for what MUSHclient supports.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #2 on Wed 09 May 2018 05:01 AM (UTC)
Message
Okay, that explains a bit then. h# seems to be supported, according to the page, but all it does is return the <bold> element instead, which I can understand.

How would I go about displaying these MXP elements, however? For instance, I have a code that displays a calendar, and I want it to display the current day in bold. I've not figured that out yet.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 09 May 2018 06:59 AM (UTC)
Message
AdInfinitum said:

How would I go about displaying these MXP elements, however?


I don't quite understand that question.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #4 on Wed 09 May 2018 07:47 AM (UTC)
Message
Nick Gammon said:

AdInfinitum said:

How would I go about displaying these MXP elements, however?


I don't quite understand that question.


Well, forgive my ignorance with MXP, because it's a new project to tackle.

What I'm trying to figure out is of the MXP elements that are available to MUSH, how would I go about using them if, for instance, I wanted to make a certain text bold? I know that I can't do something like:

Note("<bold>Test</bold>")


because that doesn't work. I realize I can use NoteStyle for that particular instance, but I was under the impression that I could use the actual bold tags somehow to produce output. Am I wrong?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 09 May 2018 07:58 AM (UTC)
Message
Oh I see. MXP is really intended to be interpreted from the server, not when you just display notes in the output window.

For doing it client-side, see, for example:

Template:function=NoteStyle NoteStyle

The documentation for the NoteStyle script function is available online. It is also in the MUSHclient help file.



You can also use ColourNote to do different colours.

Template:function=ColourNote ColourNote

The documentation for the ColourNote script function is available online. It is also in the MUSHclient help file.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by AdInfinitum   (74 posts)  Bio
Date Reply #6 on Wed 09 May 2018 08:11 AM (UTC)
Message
Fair enough. I wasn't sure if it worked the same way CMUD did with MXP. I was hoping there was something like an MXPDisplay("<color = red><b>Testing</b></color>") to display a bold Testing in red.

I think it's mainly because to me, it's easier to remember rather than remembering NoteStyle(5) is bold italic, etc. Thanks for the explanations!
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 09 May 2018 08:31 PM (UTC)

Amended on Wed 09 May 2018 08:32 PM (UTC) by Nick Gammon

Message
You can make a simple coloured-line displayer. For example see this thread:

http://www.gammon.com.au/forum/?id=9529


To round that out to actually display them I take the code from reply #8 and add a display function:


-- copied from http://www.gammon.com.au/forum/?id=8947
local BLACK = 1
local RED = 2
local GREEN = 3  
local YELLOW = 4 
local BLUE = 5 
local MAGENTA = 6 
local CYAN = 7 
local WHITE = 8

-- colour styles (eg. @r is normal red, @R is bold red)

-- @- is shown as ~
-- @@ is shown as @

-- This table uses the colours as defined in the MUSHclient ANSI tab, however the
-- defaults are shown on the right if you prefer to use those.
local colour_conversion = {
   k = GetNormalColour (BLACK)   ,   -- 0x000000 
   r = GetNormalColour (RED)     ,   -- 0x000080 
   g = GetNormalColour (GREEN)   ,   -- 0x008000 
   y = GetNormalColour (YELLOW)  ,   -- 0x008080 
   b = GetNormalColour (BLUE)    ,   -- 0x800000 
   m = GetNormalColour (MAGENTA) ,   -- 0x800080 
   c = GetNormalColour (CYAN)    ,   -- 0x808000 
   w = GetNormalColour (WHITE)   ,   -- 0xC0C0C0 
   K = GetBoldColour   (BLACK)   ,   -- 0x808080 
   R = GetBoldColour   (RED)     ,   -- 0x0000FF 
   G = GetBoldColour   (GREEN)   ,   -- 0x00FF00 
   Y = GetBoldColour   (YELLOW)  ,   -- 0x00FFFF 
   B = GetBoldColour   (BLUE)    ,   -- 0xFF0000 
   M = GetBoldColour   (MAGENTA) ,   -- 0xFF00FF 
   C = GetBoldColour   (CYAN)    ,   -- 0xFFFF00 
   W = GetBoldColour   (WHITE)   ,   -- 0xFFFFFF 
   
   -- add custom colours here

  }  -- end conversion table


-----------
-- our code:  :)

local P, C, Ct, Cs, Cg, S, Cc = lpeg.P, lpeg.C, lpeg.Ct, lpeg.Cs, lpeg.Cg, lpeg.S, lpeg.Cc

local tmpcolorkeys = {}
for k,v in pairs(colour_conversion) do tmpcolorkeys[#tmpcolorkeys+1] = k end

local Colors = P"@" * C(S( table.concat(tmpcolorkeys, "") ))
tmpcolorkeys = nil  -- Clean up on aisle tempvar!
local NotAt = P(1) - P"@"
local NotAColor = P(1) - Colors
local text = Cg(Cs( (NotAt + P"@-"/"~" + P"@@"/"@" + NotAColor )^1 ),"text") 
local color = Cg( (Colors + Cc('w')) / colour_conversion ,"textcolour") 
local res = Ct( Ct( color * text)^1) 


function ShowStyledLine (s)
 local styles = res:match(s)
  for k, v in ipairs (t) do
    ColourTell (RGBColourToName (v.textcolour), "", v.text)
  end -- for each style run
  print ()  -- finish off the line
end -- ShowStyledLine 


If you put that into your script file (language: Lua) then you can display colours like this using the same syntax that Aardwolf does:


ShowStyledLine ("an @RAardwolf @WAdventurer's Guide@w (type @Rread guide@w)")


Then you just use things like @R for bold red, and @r for normal red, and so on as you can see in the script near the top.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #8 on Thu 10 May 2018 12:51 AM (UTC)
Message
If this is actually for Aardwolf, functions like that are already built https://github.com/fiendish/aardwolfclientpackage/wiki/Color-Functions

https://github.com/fiendish/aardwolfclientpackage
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.


22,406 views.

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

Go to topic:           Search the forum


[Go to top] top

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