summary refs log tree commit diff stats
path: root/README
blob: 809a903c0707cf99ce9640d149f90b8451fb4391 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
X-Chat README
~~~~~~~~~~~~~
 X-Chat ("xchat") Copyright (c) 1998-2010 By Peter Zelezny.

 This program is released under the GPL v2 with the additional exemption
 that compiling, linking, and/or using OpenSSL is allowed. You may
 provide binary packages linked to the OpenSSL libraries, provided that
 all other requirements of the GPL are met. 
 See file COPYING for details.


What is it?
~~~~~~~~~~~
 X-Chat is an IRC client for UNIX operating systems. I.R.C. is Internet
 Relay Chat, see http://irchelp.org for more information about IRC in
 general. Xchat runs on most BSD and POSIX compliant operating systems.


Requirements:
~~~~~~~~~~~~~
 * GTK+ 2.10 (this is available at http://www.gtk.org).

 X-Chat is known to work on, at least:

	* Linux
	* FreeBSD
	* OpenBSD
	* NetBSD
	* Solaris
	* AIX
	* IRIX
	* DEC/Compaq Tru64 UNIX
	* HP-UX 10.20 and 11
	* MacOS X
	* Windows XP/2000/Vista/7


Notes for packagers:
~~~~~~~~~~~~~~~~~~~~

 If you need your packages to work on i386, you don't need to compile with
 --disable-mmx, because it's also checked at run-time.


Python Scripts:
~~~~~~~~~~~~~~~
 Scripts for 1.8.x are not compatible, and a brand new interface has be
 written. Documentation can be found here: http://xchat.org/docs/.
 Consider using the Python interface for your scripts, it's a very nice
 API, allows for loading/unloading individual scripts, and gives you
 almost all the features of the C-Plugin API.


Perl Scripts:
~~~~~~~~~~~~~
 Scripts for 1.8.x are compatible with the following exceptions:

* IRC::command will not interpret %C, %B, %U etc.

* user_list and user_list_short:
  If a user has both op and voice, only the op flag will be 1.

* add_user_list/sub_user_list/clear_user_list
  These functions do nothing.

* notify_list
  Not implemented. Always returns an empty list.

* server_list
  Lists servers that are not connected aswell.

* Some print events may have new names and some were added.

* Text printed by scripts must now be UTF8.

* Text passed to scripts (via add_message_handler) will be encoded in UTF8.


Autoloading Perl Scripts and Plugins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * X-Chat automatically loads, at startup:
	~/.xchat2/*.pl Perl scripts
	~/.xchat2/*.py Python scripts
	~/.xchat2/*.so Plugins
	$(libdir)/xchat/plugins/*.so plugins
	(this usually translates to /usr/lib/xchat/plugins/*.so)


Control Codes:
~~~~~~~~~~~~~~
 %%     -  A single percentage sign
 %C     -  Control-C (mIRC color code)
 %B     -  Bold Text
 %U     -  Underline Text
 %R     -  Reverse Text
 %O     -  Reset all Text attributes
 %XXX   -  ASCII XXX (where XXX is a decimal 3 digit number)
           (Eg: %007 sends a BEEP)

 %Cforeground,background will produce a color code, eg: %C03,10

 These are now disabled by default (see Settings > Prefs > Input Box).
 Instead you can insert the real codes via ctrl-k, ctrl-b and ctrl-o.
ass='oid'>9634e457 ^
4a6ceffb ^
4a6ceffb ^
4a6ceffb ^















4a6ceffb ^


83032b1a ^
4a6ceffb ^


dc69f24a ^
4a6ceffb ^
a51a6913 ^
4a6ceffb ^


83032b1a ^




4a6ceffb ^
95febd97 ^
83032b1a ^








95febd97 ^
83032b1a ^



4a6ceffb ^
83032b1a ^
4a6ceffb ^









a51a6913 ^
4a6ceffb ^




95febd97 ^
4a6ceffb ^





95febd97 ^
4a6ceffb ^





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171














                                                                       
                                                                            



                   



                      


               


                   


                    
                              

                               
                              



                              















                                                          
 









                                                       
                                                  
                                                        

                                                          

                                                        
 




                                                                   

                            




                                                                       
  
 















                                                                                 


                   
                     


                           
                                 
 
                                                               


                                




                                                 
                 
                                                                              








                                                                           
                                                                              



                                                                           
                 
                             









                           
                                                                                               




                                               
                                                                              





                                                                                                     
                                                                              





                                                                                                     
/* X-Chat
 * Copyright (C) 1998 Peter Zelezny.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

#include "fe-gtk.h"
#include "palette.h"

#include "../common/hexchat.h"
#include "../common/util.h"
#include "../common/cfgfiles.h"
#include "../common/typedef.h"


GdkColor colors[] = {
	/* colors for xtext */
	{0, 0xd3d3, 0xd7d7, 0xcfcf}, /* 0 white */
	{0, 0x2e2e, 0x3434, 0x3636}, /* 1 black */
	{0, 0x3434, 0x6565, 0xa4a4}, /* 2 blue */
	{0, 0x4e4e, 0x9a9a, 0x0606}, /* 3 green */
	{0, 0xcccc, 0x0000, 0x0000}, /* 4 red */
	{0, 0x8f8f, 0x3939, 0x0202}, /* 5 light red */
	{0, 0x5c5c, 0x3535, 0x6666}, /* 6 purple */
	{0, 0xcece, 0x5c5c, 0x0000}, /* 7 orange */
	{0, 0xc4c4, 0xa0a0, 0x0000}, /* 8 yellow */
	{0, 0x7373, 0xd2d2, 0x1616}, /* 9 green */
	{0, 0x1111, 0xa8a8, 0x7979}, /* 10 aqua */
	{0, 0x5858, 0xa1a1, 0x9d9d}, /* 11 light aqua */
	{0, 0x5757, 0x7979, 0x9e9e}, /* 12 blue */
	{0, 0xa0d0, 0x42d4, 0x6562}, /* 13 light purple */
	{0, 0x5555, 0x5757, 0x5353}, /* 14 grey */
	{0, 0x8888, 0x8a8a, 0x8585}, /* 15 light grey */

	{0, 0xd3d3, 0xd7d7, 0xcfcf}, /* 16 white */
	{0, 0x2e2e, 0x3434, 0x3636}, /* 17 black */
	{0, 0x3434, 0x6565, 0xa4a4}, /* 18 blue */
	{0, 0x4e4e, 0x9a9a, 0x0606}, /* 19 green */
	{0, 0xcccc, 0x0000, 0x0000}, /* 20 red */
	{0, 0x8f8f, 0x3939, 0x0202}, /* 21 light red */
	{0, 0x5c5c, 0x3535, 0x6666}, /* 22 purple */
	{0, 0xcece, 0x5c5c, 0x0000}, /* 23 orange */
	{0, 0xc4c4, 0xa0a0, 0x0000}, /* 24 yellow */
	{0, 0x7373, 0xd2d2, 0x1616}, /* 25 green */
	{0, 0x1111, 0xa8a8, 0x7979}, /* 26 aqua */
	{0, 0x5858, 0xa1a1, 0x9d9d}, /* 27 light aqua */
	{0, 0x5757, 0x7979, 0x9e9e}, /* 28 blue */
	{0, 0xa0d0, 0x42d4, 0x6562}, /* 29 light purple */
	{0, 0x5555, 0x5757, 0x5353}, /* 30 grey */
	{0, 0x8888, 0x8a8a, 0x8585}, /* 31 light grey */

	{0, 0xd3d3, 0xd7d7, 0xcfcf}, /* 32 marktext Fore (white) */
	{0, 0x2020, 0x4a4a, 0x8787}, /* 33 marktext Back (blue) */
	{0, 0x2512, 0x29e8, 0x2b85}, /* 34 foreground (black) */
	{0, 0xfae0, 0xfae0, 0xf8c4}, /* 35 background (white) */
	{0, 0x8f8f, 0x3939, 0x0202}, /* 36 marker line (red) */

	/* colors for GUI */
	{0, 0x3434, 0x6565, 0xa4a4}, /* 37 tab New Data (dark red) */
	{0, 0x4e4e, 0x9a9a, 0x0606}, /* 38 tab Nick Mentioned (blue) */
	{0, 0xcece, 0x5c5c, 0x0000}, /* 39 tab New Message (red) */
	{0, 0x8888, 0x8a8a, 0x8585}, /* 40 away user (grey) */
	{0, 0xa4a4, 0x0000, 0x0000}, /* 41 spell checker color (red) */
};

void
palette_alloc (GtkWidget * widget)
{
	int i;
	static int done_alloc = FALSE;
	GdkColormap *cmap;

	if (!done_alloc)		  /* don't do it again */
	{
		done_alloc = TRUE;
		cmap = gtk_widget_get_colormap (widget);
		for (i = MAX_COL; i >= 0; i--)
			gdk_colormap_alloc_color (cmap, &colors[i], FALSE, TRUE);
	}
}

void
palette_load (void)
{
	int i, j, fh;
	char prefname[256];
	struct stat st;
	char *cfg;
	guint16 red, green, blue;

	fh = hexchat_open_file ("colors.conf", O_RDONLY, 0, 0);
	if (fh != -1)
	{
		fstat (fh, &st);
		cfg = g_malloc0 (st.st_size + 1);
		read (fh, cfg, st.st_size);

		/* mIRC colors 0-31 are here */
		for (i = 0; i < 32; i++)
		{
			g_snprintf (prefname, sizeof prefname, "color_%d", i);
			cfg_get_color (cfg, prefname, &red, &green, &blue);
			colors[i].red = red;
			colors[i].green = green;
			colors[i].blue = blue;
		}

		/* our special colors are mapped at 256+ */
		for (i = 256, j = 32; j < MAX_COL+1; i++, j++)
		{
			g_snprintf (prefname, sizeof prefname, "color_%d", i);
			cfg_get_color (cfg, prefname, &red, &green, &blue);
			colors[j].red = red;
			colors[j].green = green;
			colors[j].blue = blue;
		}
		g_free (cfg);
		close (fh);
	}
}

void
palette_save (void)
{
	int i, j, fh;
	char prefname[256];

	fh = hexchat_open_file ("colors.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
	if (fh != -1)
	{
		/* mIRC colors 0-31 are here */
		for (i = 0; i < 32; i++)
		{
			g_snprintf (prefname, sizeof prefname, "color_%d", i);
			cfg_put_color (fh, colors[i].red, colors[i].green, colors[i].blue, prefname);
		}

		/* our special colors are mapped at 256+ */
		for (i = 256, j = 32; j < MAX_COL+1; i++, j++)
		{
			g_snprintf (prefname, sizeof prefname, "color_%d", i);
			cfg_put_color (fh, colors[j].red, colors[j].green, colors[j].blue, prefname);
		}

		close (fh);
	}
}