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

MUSHclient scripting

Description of MUSHclient world function: world.GetStyleInfo


Name GetStyleInfo
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);

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).


Note: Available in version 3.18 onwards.


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
Returns 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.
Introduced in version 3.18

See also ...

Function Description
BoldColour Gets/sets the RGB colour for one of the 8 ANSI bold colours
GetInfo Gets information about the current world
GetLineInfo Gets details about a specified line in the output window
GetLinesInBufferCount Returns the number of lines in the output window
GetSelectionEndColumn Returns the endling column of the selection in the output window
GetSelectionEndLine Returns the last line of the selection in the output window
GetSelectionStartColumn Returns the starting column of the selection in the output window
GetSelectionStartLine Returns the starting line of the selection in the output window
NormalColour Gets/sets the RGB colour for one of the 8 ANSI normal colours

Search for script function

Enter a word or phrase in the box below to narrow the list down to those that match.

The function name, prototype, summary, and description are searched.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

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 FutureQuest]