GetStyleInfo
Script function

world.GetStyleInfo

DOC_scripting Read about scripting

Type

Method

Summary

Gets details about a specified style run for a specified line in the output window

Prototype

VARIANT GetStyleInfo(long LineNumber, long StyleNumber, short InfoType);

DOC_data_types View list of data type meanings


Description

Returns details about any style run for any line in the output buffer (window).

The line number can be from 1 (the first line) to the number of lines in the output window. You can use "world.GetLinesInBufferCount" to find how many lines are currently in the output window.

The style number can be from 1 (the first style on the line) to the number of styles in that line. You can use "world.GetLineInfo(LineNumber, 11)" to find the number of styles in each line.

You can obtain one of 15 "types" of information about the style by specifying an "InfoType". The possible InfoTypes are:

1: text of style (string)
2: length of style run (short)
3: starting column of style (short)
4: action type - 0=none, 1=send to mud, 2=hyperlink, 3=prompt (short)
5: action (eg. what to send) (string)
6: hint (what to show) (string)
7: variable (variable to set) (string)
8: true if bold (boolean)
9: true if underlined (boolean)
10: true if blinking (boolean)
11: true if inverse (boolean)
12: true if changed by trigger from original (boolean)
13: true if start of a tag (action is tag name) (boolean)
14: foreground (text) colour in RGB (long)
15: background colour in RGB (long)

You could use this function to "reassemble" lines with ANSI codes or other markup, by putting appropriate codes around each style run. For instance, if the "bold" flag was set, you might use <b> ... </b> .

The "action type", "action", "hint" and "variable" fields are used by MXP. See the MXP write-ups on the MUSHclient forum for more detail about what they are used for.

The colour codes are in RGB - you could use NormalColour or BoldColour to work out which ANSI colour they corresponded to (note, they might not correspond to any ANSI colour if MXP, or world.note has been used to output non-standard colours).



VBscript example

' find foreground colour in RGB of style 2 on line 100

world.note world.GetStyleInfo (100, 2, 14)



Jscript example

// find foreground colour in RGB of style 2 on line 100

world.note (world.GetStyleInfo (100, 2, 14));



PerlScript example

# find foreground colour in RGB of style 2 on line 100

$world->note ($world->GetStyleInfo (100, 2, 14));



Python example

# find foreground colour in RGB of style 2 on line 100

world.note (world.GetStyleInfo (100, 2, 14))



Lua example

-- find foreground colour in RGB of style 2 on line 100

Note (GetStyleInfo (100, 2, 14))

-- display the text for style 2 on line 71

Note (GetStyleInfo (71) [2].text)

-- Same thing, done differently:

Note (GetStyleInfo (71, 2).text)



Lua notes

Lua returns nil where applicable instead of an "empty variant" or "null variant".

As an extension, you can supply zero for the StyleNumber and/or the InfoType.

If the StyleNumber is zero, then a table of all styles will be returned 
(keyed numerically starting at one).

If the InfoType is omitted or zero, then all types of information
for the nominated style are returned in a table, keyed by type:

 text:       text of style (string)                                   
 length:     length of style run (number) 
 column:     starting column of style run (number) 
 actiontype: action type - 0=none, 1=send to mud, 2=hyperlink, 3=prompt
 action:     action (eg. what to send) (string) 
 hint:       hint (what to show) (string) 
 variable:   variable (variable to set) (string) 
 bold:       true if bold (boolean) 
 ul:         true if underlined (boolean) 
 blink:      true if blinking (boolean) 
 inverse:    true if inverse (boolean) 
 changed:    true if changed by trigger from original (boolean) 
 starttag:   true if start of a tag (action is tag name) (boolean) 
 textcolour: foreground (text) colour in RGB (number) 
 backcolour: background colour in RGB (number)

This lets you readily re-assemble data from a particular line with only one
function call. Then just process the returned table.

If you omit (or set to zero) both the StyleNumber and InfoType then the 
returned result will be a table of tables. The outer table will have one entry 
per style, the inner table will have one entry per InfoType.

Example:

t = GetStyleInfo (71)     -- get all styles, all types for line 71
for k, v in pairs (t) do 
  Note ("style run = ", k)  -- this is one style
  for a, b in pairs (v) do  -- display all info types for style
    Note (" item = ", a, " value = ", b)
  end  
end



Return value

The specified information about the style run, as described above. 
An EMPTY variant, if the line or style does not exist. 
A NULL variant if the InfoType is not a valid type.




See Also ...

Topic

DOC_info Information

Functions

FNC_BoldColour BoldColour (Gets/sets the RGB colour for one of the 8 ANSI bold colours)
FNC_Debug Debug (Displays debugging information about the world)
FNC_EchoInput EchoInput (A flag to indicate whether we are echoing command input to the output window)
FNC_GetConnectDuration GetConnectDuration (Returns the number of seconds this world has been connected.)
FNC_GetEntity GetEntity (Retrieves the value of an MXP server-defined entity)
FNC_GetHostAddress GetHostAddress (Returns a list of IP addresses that correspond to a host name on the Internet)
FNC_GetHostName GetHostName (Returns the host name that corresponds to an IP address on the Internet)
FNC_GetInfo GetInfo (Gets information about the current world)
FNC_GetInternalCommandsList GetInternalCommandsList (Returns a list of the internal MUSHclient command names)
FNC_GetLineCount GetLineCount (Gets count of lines received)
FNC_GetLineInfo GetLineInfo (Gets details about a specified line in the output window)
FNC_GetLinesInBufferCount GetLinesInBufferCount (Returns the number of lines in the output window)
FNC_GetMainWindowPosition GetMainWindowPosition (Returns the position and size of the main MUSHclient window)
FNC_GetNotepadWindowPosition GetNotepadWindowPosition (Returns the position and size of the specified notepad window)
FNC_GetNotes GetNotes (Gets the world's notes)
FNC_GetQueue GetQueue (Returns a variant array which is a list of queued commands)
FNC_GetReceivedBytes GetReceivedBytes (Returns the number of bytes received from the world)
FNC_GetRecentLines GetRecentLines (Assembles a block of text from recent MUD output)
FNC_GetSelectionEndColumn GetSelectionEndColumn (Returns the endling column of the selection in the output window)
FNC_GetSelectionEndLine GetSelectionEndLine (Returns the last line of the selection in the output window)
FNC_GetSelectionStartColumn GetSelectionStartColumn (Returns the starting column of the selection in the output window)
FNC_GetSelectionStartLine GetSelectionStartLine (Returns the starting line of the selection in the output window)
FNC_GetSentBytes GetSentBytes (Returns the number of bytes sent to the world)
FNC_GetSysColor GetSysColor (Gets the colour of various windows items)
FNC_GetSystemMetrics GetSystemMetrics (Returns selected system information from Windows)
FNC_GetWorldID GetWorldID (Returns the 24-character ID of the current world)
FNC_GetWorldWindowPosition GetWorldWindowPosition (Returns the position and size of the current world window)
FNC_GetWorldWindowPositionX GetWorldWindowPositionX (Returns the position and size of a specific world window)
FNC_GetXMLEntity GetXMLEntity (Retrieves the value of a standard entity)
FNC_IsConnected IsConnected (Tests to see if the world is connected to the MUD server)
FNC_NormalColour NormalColour (Gets/sets the RGB colour for one of the 8 ANSI normal colours)
FNC_SetChanged SetChanged (Sets or clears the "document has changed" flag)
FNC_SetEntity SetEntity (Sets the value of an MXP entity)
FNC_UdpPortList UdpPortList (Returns an array of all the UDP ports in use by this world)
FNC_Version Version (Gets the MUSHclient version string.)
FNC_WorldAddress WorldAddress (Returns the TCP/IP address of the current world.)
FNC_WorldName WorldName (Gets the world's name)
FNC_WorldPort WorldPort (Returns the port number of the current world.)

(Help topic: function=GetStyleInfo)

DOC_contents Documentation contents page