ANSI
Script function

world.ANSI

DOC_scripting Read about scripting

Type

Method

Summary

Generates an ANSI colour sequence

Prototype

BSTR ANSI(short Code);

DOC_data_types View list of data type meanings


Description

This generates an ANSI colour sequence, like this:

ESC [ code m

The code number is supplied as an argument.

This is intended to be used with the ANSINote function - which lets you write to the output window with ANSI formatting, or to send to other clients via the chat system.

Useful numbers to use would be:

Miscellaneous

0: reset
1: bold
3: blink (is rendered as italic)
4: underline
7: inverse

22: cancel bold
23: cancel blink
24: cancel underline
27: cancel inverse

Foreground (text) colour

30: Black
31: Red
32: Green
33: Yellow
34: Blue
35: Magenta
36: Cyan
37: White

Background colour

40: Black
41: Red
42: Green
43: Yellow
44: Blue
45: Magenta
46: Cyan
47: White

Suggestion - you could conceivably replace colours in incoming chat messages by doing a world.Replace using ANSI, providing the incoming ANSI codes conform exactly to the rendering used here.

For example:

mymessage = world.Replace (incoming_message, ANSI (36), ANSI (37))

This would hopefully replace the code for Cyan with the code for White.



VBscript example

ANSINote "This is normal" & ANSI (33) & " and this is yellow"



Jscript example

ANSINote ("This is normal" + ANSI (33) + " and this is yellow");



PerlScript example

ANSINote ("This is normal" . ANSI (33) . " and this is yellow");



Python example

world.ANSINote ("This is normal", 
world.ANSI (33, 47), " and this is yellow")



Lua example

AnsiNote ("This is normal ",
          ANSI (33, 47),
          "and this is yellow on white")



Lua notes

You can supply multiple arguments, as in the above example. 
Each one will generate its own ANSI code, so you can easily do multiple changes 

(eg. foreground, background, bold) in a single call to ANSI.

If you supply multiple arguments they will be placed into the same ANSI sequence, like this:

ANSI (33, 47) --> ESC[33;47m



Return value

A string consisting of: ESC "[" Code "m"




See Also ...

Topics

DOC_colours Colour management
DOC_defaults Default triggers/aliases/timers/macros/colours

Functions

FNC_AdjustColour AdjustColour (Adjust an RGB colour)
FNC_AnsiNote AnsiNote (Make a note in the output window from text with ANSI colour codes imbedded)
FNC_BoldColour BoldColour (Gets/sets the RGB colour for one of the 8 ANSI bold colours)
FNC_ChatMessage ChatMessage (Sends a message to a chat user (raw format))
FNC_ChatNote ChatNote (Does a note using ANSI codes for the chat system)
FNC_ColourNameToRGB ColourNameToRGB (Converts a named colour to a RGB colour code.)
FNC_ColourNote ColourNote (Sends a message to the output window in specified colours)
FNC_ColourTell ColourTell (Sends a message to the output window in specified colours - not terminated by a newline)
FNC_CustomColourBackground CustomColourBackground (Sets the RGB value for the background of a custom colour)
FNC_CustomColourText CustomColourText (Sets the RGB value for the text of a custom colour)
FNC_GetCustomColourName GetCustomColourName (Gets the name of a custom colour)
FNC_GetMapColour GetMapColour (Returns the mapping for how a particular colour will be displayed)
FNC_MapColour MapColour (Changes the colour mapping - the way colours are displayed)
FNC_MapColourList MapColourList (Returns an array of all the mapped colours)
FNC_NormalColour NormalColour (Gets/sets the RGB colour for one of the 8 ANSI normal colours)
FNC_NoteColour NoteColour (Chooses which custom colour will be used for world notes.)
FNC_NoteColourBack NoteColourBack (Chooses which RGB colour will be used for world notes - background colour)
FNC_NoteColourFore NoteColourFore (Chooses which RGB colour will be used for world notes - text colour)
FNC_NoteColourName NoteColourName (Chooses which RGB colour name will be used for world notes - text and background)
FNC_NoteColourRGB NoteColourRGB (Chooses which RGB colour will be used for world notes - text and background)
FNC_PickColour PickColour (Invokes the MUSHclient colour picker dialog)
FNC_RGBColourToName RGBColourToName (Converts an RGB colour code to its equivalent name)
FNC_SetCustomColourName SetCustomColourName (Sets the name of a custom colour)
FNC_StripANSI StripANSI (Strips ANSI colour sequences from a string)

(Help topic: function=ANSI)

DOC_contents Documentation contents page