<br><small>(Bits 0-5 added in 2.0.9. Bits 6-8 added in 2.6.6. Bit 9 added in 2.8.0. Bit 10 in 2.8.6)</small></td><td>int</td></tr>
<tr><td>id</td><td>Unique server ID<br><small>(Added in version 2.0.8. Older versions will return -1)</small></td><td>int</td></tr>
<tr><td>lag</td><td>Lag in milliseconds<br><small>(Added in version 2.6.8. Older versions will return -1)</small></td><td>int</td>
<tr><td>maxmodes</td><td>Maximum modes per line<br><small>(Added in version 2.0.9. Older versions will return -1)</small></td><td>int</td>
<tr><td>network</td><td>Network name to which this channel belongs<br><small>(Added in version 2.0.2. Older versions will return NULL)</small></td><td>string</td></tr>
<tr><td>nickprefixes</td><td>Nickname prefixes e.g. "@+"<br><small>(Added in version 2.0.9. Older versions will return NULL)</small></td><td>string</td>
<tr><td>nickmodes</td><td>Nickname mode chars e.g. "ov"<br><small>(Added in version 2.0.9. Older versions will return NULL)</small></td><td>string</td>
<tr><td>queue</td><td>Number of bytes in the send-queue<br><small>(Added in version 2.6.8. Older versions will return -1)</small></td><td>int</td>
<tr><td>server</td><td>Server name to which this channel belongs</td><td>string</td></tr>
<tr><td>type</td><td>Type of context this is: 1-Server 2-Channel 3-Dialog<br><small>(Added in version 2.0.2. Older versions will return -1)</small></td><td>int</td></tr>
<tr><td>users</td><td>Number of users in this channel<br><small>(Added in version 2.0.8. Older versions will return -1)</small></td><td>int</td></tr>
<tr><td>away</td><td>Away status (boolean)<br><small>(Added in version 2.0.6. Older versions will return -1)</small></td><td>int</td></tr>
<tr><td>lasttalk</td><td>Last time the user was seen talking<br><small>(Added in version 2.4.2. Older versions will return -1)</small></td><td>time_t</td></tr>
<tr><td>host</td><td>Host name in the form: user@host (or NULL if not known).</td><td>string</td></tr>
<tr><td>prefix</td><td>Prefix character, .e.g: @ or +. Points to a single char.</td><td>string</td></tr>
<tr><td>realname</td><td>Real name or NULL<br><small>(Added in version 2.8.6)</small></td><td>string</td></tr>
<tr><td>selected</td><td>Selected status in the user list, only works for retrieving the user list of the focused tab<br><small>(Added in version 2.6.1. Older versions will return -1)</small></td><td>int</td></tr>
</table>
</blockquote>
</blockquote>
Example:
<pre>
list = xchat_list_get (ph, "dcc");
if (list)
{
xchat_print (ph, "--- DCC LIST ------------------\nFile To/From KB/s Position\n");
while (xchat_list_next (ph, list))
{
xchat_printf (ph, "%6s %10s %.2f %d\n",
xchat_list_str (ph, list, "file"),
xchat_list_str (ph, list, "nick"),
xchat_list_int (ph, list, "cps") / 1024,
xchat_list_int (ph, list, "pos"));
}
xchat_list_free (ph, list);
}
</pre>
## Plugins on Windows (Win32)
Yes, it can be done. All you need is Visual Studio setup as explained in [Building](http://www.hexchat.org/developers/building). Your best bet is to use an existing plugin in the HexChat solution as a starting point. You should have the following files:
Leave out _xchat\_plugin\_deinit_ if you don't intend to define that
function. Then compile your plugin in Visual Studio as usual.
**Caveat:** plugins compiled on Win32 **must** have a
global variable called _ph_, which is the _plugin\_handle_, much like
in the sample plugin above.
## Controlling the GUI
A simple way to perform basic GUI functions is to use the _/GUI_ command.
You can execute this command through the input box, or by calling _xchat\_command (ph, "GUI .....");_.
<blockquote>
<tableborder=0cellpadding=4>
<tr><td>GUI ATTACH</td><td>Same function as "Attach Window" in the HexChat menu (new for 2.6.2).</td></tr>
<tr><td>GUI DETACH</td><td>Same function as "Detach Tab" in the HexChat menu (new for 2.6.2).</td></tr>
<tr><td>GUI APPLY</td><td>Similar to clicking OK in the settings window. Execute this after /SET to activate GUI changes (new for 2.8.0)</td></tr>
<tr><td>GUI COLOR <i>n</i></td><td>Change the tab color of the current context, where n is a number from 0 to 3.</td></tr>
<tr><td>GUI FOCUS</td><td>Focus the current window or tab.</td></tr>
<tr><td>GUI FLASH</td><td>Flash the taskbar button. It will flash only if the window isn't focused and will stop when it is focused by the user.</td></tr>
<tr><td>GUI HIDE</td><td>Hide the main HexChat window completely (this is used by the Systray plugin).</td></tr>
<tr><td>GUI ICONIFY</td><td>Iconify (minimize to taskbar) the current HexChat window.</td></tr>
<tr><td>GUI MSGBOX <i>text</i></td><td>Displays a asynchronous message box with your text (new for 2.4.5).</td></tr>
<tr><td>GUI SHOW</td><td>Show the main HexChat window (if currently hidden).</td></tr>
</table>
</blockquote>
You can add your own items to the menu bar. The menu command has this syntax:
MENU -k4,101 -t1 ADD "FServe/Enabled" "fs on" "fs off"
MENU -e0 ADD "FServe/Do Something" "fs action"
</pre>
In the example above, it would be recommended to execute _MENU DEL FServe_ inside your _xchat\_plugin\_deinit_ function. The special item with name "-" will add a separator line.
Parameters and flags:
<blockquote>
<tableborder=1cellpadding=4rules=all>
<tr><td>-eX</td><td>Set enable flag to X. -e0 for disable, -e1 for enable. This lets you create a disabled (shaded) item.</td></tr>
<tr><td>-iFILE</td><td>Use an icon filename FILE (new for 2.8.0). Not supported for toggles or radio items.</td></tr>
<tr><td>-k<mod>,<key></td><td>Specify a keyboard shortcut. "mod" is the modifier which is a bitwise OR of: 1-SHIFT 4-CTRL 8-ALT in decimal. "key" is the key value in decimal, e.g. -k5,101 would specify SHIFT-CTRL-E.</td></tr>
<tr><td>-m</td><td>Specify that this label should be treated as <ahref="http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html">Pango Markup</a> language. Since forward slash ("/") is already used in menu paths, you should replace closing tags with an ASCII 003 instead e.g.: xchat_command(ph, "MENU -m ADD \"<b>Bold Menu<\003b>\""); (new for 2.6.6).</td></tr>
<tr><td>-pX</td><td>Specify a menu item's position number. e.g. -p5 will cause the item to be inserted in the 5th place. New for 2.8.0: If the position is a negative number, it will be used as an offset from the bottom/right-most item.</td></tr>
<tr><td>-rX,group</td><td>Specify a radio menu item, with initial state X and a group name (new for 2.8.0). The group name should be the exact label of another menu item (without the path) that this item will be grouped with. For radio items, only a select command will be executed (no unselect command).</td></tr>
<tr><td>-tX</td><td>Specify a toggle menu item with an initial state. -t0 for an "unticked" item and -t1 for a "ticked" item.</td></tr>
</table>
</blockquote>
If you want to change an item's toggle state or enabled flag,
just _ADD_ an item with exactly the same name and command and specify the _-tX -eX_ parameters you need.
It's also possible to add items to HexChat's existing menus, for example:
<pre>
MENU ADD "Settings/Sub Menu"
MENU -t0 ADD "Settings/Sub Menu/My Setting" myseton mysetoff
</pre>
However, internal names and layouts of HexChat's menu may change in the future, so use at own risk.
Here is an example of Radio items:
<pre>
MENU ADD "Language"
MENU -r1,"English" ADD "Language/English" cmd1
MENU -r0,"English" ADD "Language/Spanish" cmd2
MENU -r0,"English" ADD "Language/German" cmd3
</pre>
You can also change menus other than the main one (i.e popup menus). Currently they are:
xchat_hook_command (ph, "ONOTICE", XCHAT_PRI_NORM, onotice_cb, "Usage: ONOTICE <message> Sends a notice to all ops", NULL);
</pre>
***
### xchat\_hook\_fd ()
**Prototype:** xchat\_hook \*xchat\_hook\_fd (xchat\_plugin \*ph, int fd, int flags, xchat\_fd\_cb \*callb, void \*userdata);
**Description:** Hooks a socket or file descriptor. WIN32: Passing a pipe from MSVCR71, MSVCR80 or other variations is not supported at this time.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **fd:** The file descriptor or socket.
* **flags:** One or more of _XCHAT\_FD\_READ_, _XCHAT\_FD\_WRITE_, _XCHAT\_FD\_EXCEPTION_, _XCHAT\_FD\_NOTSOCKET_. Use bitwise OR to combine them. _XCHAT\_FD\_NOTSOCKET_ tells HexChat that the provided _fd__ is not a socket, but an "MSVCRT.DLL" pipe.
* **callb:** Callback function. This will be called when the socket is available for reading/writing or exception (depending on your chosen _flags_)
* **userdata:** Pointer passed to the callback function.
**Returns:** Pointer to the hook. Can be passed to _xchat\_unhook ()_.
**Description:** Unhooks any hook registered with xchat\_hook\_print/server/timer/command. When plugins are unloaded, all of its hooks are automatically removed, so you don't need to call this within your xchat\_plugin\_deinit () function.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **hook:** Pointer to the hook, as returned by xchat\_hook\_*.
**Returns:** The userdata you originally gave to xchat\_hook\_*.
**Description:** Prints some text to the current tab/window and provides formatting like _printf ()_.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **format:** The format string.
***
### xchat\_emit\_print ()
**Prototype:** int xchat\_emit\_print (xchat\_plugin \*ph, const char \*event\_name, ...);
**Description:** Generates a print event. This can be any event found in the Preferences > Advanced > Text Events window. The vararg parameter list **must** always be NULL terminated. Special care should be taken when calling this function inside a print callback (from xchat\_hook\_print), as not to cause endless recursion.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
**Description:** Finds a context based on a channel and servername. If _servname_ is NULL, it finds any channel (or query) by the given name. If _channel_ is NULL, it finds the front-most tab/window of the given _servname_. If NULL is given for both arguments, the currently focused tab/window will be returned.
Changed in 2.6.1. If _servname_ is NULL, it finds the channel (or query) by the given name in the same server group as the current context. If that doesn't exists then find any by the given name.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **servname:** Server name or NULL.
* **channel:** Channel name or NULL.
**Returns:** Context pointer (for use with _xchat\_set\_context_) or NULL.
<tr><td>host</td><td>real hostname of the server you connected to.</td></tr>
<tr><td>inputbox</td><td>the input-box contents, what the user has typed (since 2.4.1).</td></tr>
<tr><td>libdirfs</td><td>library directory. e.g. /usr/lib/xchat. The same directory used for auto-loading plugins (since 2.4.0).<small>This string isn't necessarily UTF-8, but local file system encoding.</small></td></tr>
<tr><td>modes</td><td>channel modes, if known, or NULL (since 2.8.1).</td></tr>
<tr><td>network</td><td>current network name or NULL.</td></tr>
<tr><td>nick</td><td>your current nick name.</td></tr>
<tr><td>nickserv</td><td>nickserv password for this network or NULL (since 2.4.3).</td></tr>
<tr><td>server</td><td>current server name (what the server claims to be). NULL if you are not connected.</td></tr>
<tr><td>win_status</td><td>window status: "active", "hidden" or "normal" (since 2.0.9).</td>
<tr><td>xchatdir</td><td>xchat config directory, e.g.: /home/user/.xchat2 <small>This string is encoded in UTF-8, which means you _should_ convert it to "locale" encoding before using functions like open() or OpenFile(). For best <ahref="#unicode">Unicode support</a> on Linux, convert this string using g_filename_from_utf8 and on Windows convert this string to UTF-16LE (wide) and use OpenFileW() etc.</small></td></tr>
<tr><td>xchatdirfs</td><td>xchat config directory, e.g.: /home/user/.xchat2 (since 2.0.9).<small>This string is encoded in local file system encoding, making it ideal for direct use with functions like open() or OpenFile(). For real Unicode support on Windows, it's best not to use HexChatdirfs, but HexChatdir instead.</small></td></tr>
</table>
</blockquote>
**Returns:** A string of the requested information, or NULL. This string must
not be freed and must be copied if needed after the call to _xchat\_get\_info ()_.
***
### xchat\_get\_prefs ()
**Prototype:** int xchat\_get\_prefs (xchat\_plugin \*ph, const char \*name, const char \*\*string, int \*integer);
**Description:** Provides HexChat's setting information (that which is available through the _/SET_ command).
A few extra bits of information are available that don't appear in the _/SET_ list, currently they are:
* **state_cursor:** Current input box cursor position (characters, not bytes).
* **id:** Unique server id
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **name:** Setting name required.
* **string:** Pointer-pointer which to set.
* **integer:** Pointer to an integer to set, if setting is a boolean or integer type.
**Returns:**
* 0: Failed.
* 1: Returned a string.
* 2: Returned an integer.
* 3: Returned a boolean.
**Example:**
<pre>
{
int i;
const char *str;
if (xchat_get_prefs (ph, "irc_nick1", &str, &i) == 1)
**Description:** Performs a nick name comparision, based on the current server connection. This might be an RFC1459 compliant string compare, or plain ascii (in the case of DALNet). Use this to compare channels and nicknames. The function works the same way as _strcasecmp ()_.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **s1:** String to compare.
* **s2:** String to compare _s1_ to.
**Quote from RFC1459:**
>Because of IRC's scandanavian origin, the characters {}| are
considered to be the lower case equivalents of the characters []\,
respectively. This is a critical issue when determining the
equivalence of two nicknames.
**Returns:** An integer less than, equal to, or greater than zero if _s1_ is found, respectively, to be less than, to match, or be greater than _s2_.
***
### xchat\_strip ()
**Prototype:** char \*xchat\_strip (xchat\_plugin \*ph, const char \*str, int len, int flags);
**Description:** Strips mIRC color codes and/or text attributes (bold, underlined etc) from the given string and returns a newly allocated string.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **str:** String to strip.
* **len:** Length of the string (or -1 for NULL terminated).
* **flags:** Bit-field of flags:
* 0: Strip mIRC colors.
* 1: Strip text attributes.
**Returns:** A newly allocated string or NULL for failure. You must free this string with _xchat\_free ()_.
**Example:**
<pre>
{
char *new_text;
/* strip both colors and attributes by using the 0 and 1 bits (1 BITWISE-OR 2) */
You only need such complex checks if you're saving user input, which can be non-numeric.
***
### xchat\_pluginpref\_get\_int ()
**Prototype:** int xchat\_pluginpref\_get\_int (xchat\_plugin \*ph, const char \*var);
**Description:** Loads a plugin-specific setting with decimal value from a plugin-specific config file.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **var:** Name of the setting to load.
**Returns:** The decimal value of the requested setting upon success, -1 for failure.
***
### xchat\_pluginpref\_delete ()
**Prototype:** int xchat\_pluginpref\_delete (xchat\_plugin \*ph, const char \*var);
**Description:** Deletes a plugin-specific setting from a plugin-specific config file.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **var:** Name of the setting to delete.
**Returns:**
* 1: Success.
* 0: Failure.
If the given setting didn't exist, it also returns 1, so 1 only indicates that the setting won't exist after the call.
***
### xchat\_pluginpref\_list ()
**Prototype:** int xchat\_pluginpref\_list (xchat\_plugin \*ph, char \*dest);
**Description:** Builds a comma-separated list of the currently saved settings from a plugin-specific config file.
**Arguments:**
* **ph:** Plugin handle (as given to _xchat\_plugin\_init ()_).
* **dest:** Array to save the list to.
**Returns:**
* 1: Success.
* 0: Failure (nonexistent, empty or inaccessible config file).
**Example:**
<pre>
static void
list_settings ()
{
char list[512];
char buffer[512];
char *token;
xchat_pluginpref_list (ph, list);
xchat_printf (ph, "Current Settings:\n");
token = strtok (list, ",");
while (token != NULL)
{
xchat_pluginpref_get_str (ph, token, buffer);
xchat_printf (ph, "%s: %s\n", token, buffer);
token = strtok (NULL, ",");
}
}
</pre>
In the example above we query the list of currently stored settings, then print them one by one with their respective values. We always use _xchat\_pluginpref\_get\_str ()_, and that's because we can read an integer as string (but not vice versa).