Added ./configure script to build WeeChat

This commit is contained in:
Sebastien Helleu 2003-10-25 14:49:18 +00:00
parent b837017ba6
commit f966b6a829
74 changed files with 8082 additions and 166 deletions

3
BUGS
View File

@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
WeeChat known bugs, 2003-10-09
WeeChat known bugs, 2003-10-25
- too much nicks in the channel (> height of window) => display bug
- some IRC commands are marked as 'unknown' when received
@ -12,3 +12,4 @@ WeeChat known bugs, 2003-10-09
- when function key (non used by WeeChat) is pressed, prompt is deleted
- when quitting WeeChat term title is not restored (if look_set_title is ON)
- command name for /server can not contain spaces
- wrong alias is not created and not saved when quitting WeeChat

View File

@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2003-10-12
ChangeLog - 2003-10-25
Version 0.0.3 (under dev!):
* ./configure script to build WeeChat (now multi-platform)
* nicks are now correctly sorted (op, halfop, voice, other)
* fixed crash when entering text without any server connection
* fixed display bug (text was blinking when scrolling)

View File

@ -1,10 +1,12 @@
WeeChat - Installation instructions
===================================
1) Run 'make'
1) Run './configure'
2) As root, run 'make install'
2) Run 'make'
3) Enjoy ! :-)
3) As root, run 'make install'
4) Enjoy ! :-)
See AUTHORS for any support, feel free to contact us for any problem ;)

18
Makefile.am Normal file
View File

@ -0,0 +1,18 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
SUBDIRS = src

4
README
View File

@ -10,7 +10,7 @@ It is customizable and extensible with scripts.
Features
--------
* IRC chat client with multi-server connection
* many GUI (curses, Gtk, QT) (1)
* many GUI (curses, Gtk, Qt) (1)
* small, fast and very light
* customizable and extensible with scripts (Perl, Python, Ruby) (2)
* compliant with RFC 1459,2810,2811,2812,2813
@ -46,6 +46,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
(1) only curses & text interfaces are available today
(1) only curses interface is available today
(2) plugin interfaces are not yet developed
(3) only GNU/Linux version is available today

30
TODO
View File

@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
TODO - 2003-10-12
TODO - 2003-10-25
Legend:
# done
@ -13,6 +13,9 @@ Legend:
v0.0.3:
------
* General:
+ use of ./configure for building WeeChat
* IRC protocol:
# implement RFC 2812
+ "/mode" command: change the user/channels modes
@ -20,29 +23,15 @@ v0.0.3:
persons with the flag +w enable
* WeeChat commands:
- "/reload" command: reload the WeeChat's config file
- "/highlight" command: highlight a given word when it appears on
channels/privates
+ "/set" command: allow the user to set the WeeChat variables
under WeeChat without editing the config file (colours, time
format, etc)
* Interface:
+ Gtk GUI
- display current channel modes (example : #weechat(+nt))
- interpret special chars in messages (color & bold for example)
+ internationalization (traduce WeeChat in many languages)
- log chats to file
* TCP/IP communication:
- proxy support
* Configuration:
- add missing options for config file
- wrong alias is not created and not saved when quitting WeeChat
# do not stop program if problem with options in config file
- load config file after GUI (so init values by default (colors, ...) before
loading config)
Future versions:
@ -60,6 +49,9 @@ Future versions:
nick/host connect to the given irc network
* WeeChat commands:
- "/reload" command: reload the WeeChat's config file
- "/highlight" command: highlight a given word when it appears on
channels/privates
- "/completion" command: do shortcuts (for example when we type "u"
in the text bar it send it to the server as "you")
- "/exec" command: execute a command as if we was in shell
@ -68,6 +60,9 @@ Future versions:
channel/private
* Interface:
+ Gtk GUI
- display current channel modes (example : #weechat(+nt))
- interpret special chars in messages (color & bold for example)
- many channel windows in one window/term (window split)
- add lag indicator
- forget some old lines that were displayed long time ago (now all is saved,
@ -75,15 +70,20 @@ Future versions:
- improve completion (for example complete command parameters when possible)
- understand incomplete commands if unambigous (for example: /he for /help is ok)
- add clock (in status bar?)
- log chats to file
? Qt GUI
* TCP/IP communication:
- connect to server with child process (background)
- proxy support
- SSL support
- IPv6 protocol implementation
* Configuration:
- add key bindings to config file
- add missing options for config file
- load config file after GUI (so init values by default (colors, ...) before
loading config)
* Plugins:
- add Perl plugin

126
configure.in Normal file
View File

@ -0,0 +1,126 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
AC_INIT(WeeChat, 0.0.3, flashcode@flashtux.org)
AC_CONFIG_SRCDIR([src/common/weechat.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([weechat], [0.0.3])
# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_RANLIB
# Checks for libraries.
# AC_CHECK_LIB([curses], [initscr])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h libintl.h limits.h locale.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([gethostbyname gethostname gettimeofday inet_ntoa memset mkdir select setlocale socket strcasecmp strchr strdup strncasecmp strpbrk strrchr strstr uname])
AC_ARG_ENABLE(curses, [ --disable-curses Turn off Curses interface (default=auto)],,enable_curses=yes)
AC_ARG_ENABLE(gtk, [ --disable-gtk Turn off Gtk+ interface (default=auto)],,enable_gtk=yes)
AC_ARG_ENABLE(qt, [ --disable-qt Turn off Qt interface (default=auto)],,enable_qt=yes)
enable_plugins=no
enable_perl=no
PERL_CFLAGS=
enable_python=no
PYTHON_CFLAGS=
enable_ruby=no
RUBY_CFLAGS=
enable_debug=no
DEBUG_CFLAGS=
AM_CONDITIONAL(GUI_CURSES, test "$enable_curses" = "yes")
AM_CONDITIONAL(GUI_GTK, test "$enable_gtk" = "yes")
AM_CONDITIONAL(GUI_QT, test "$enable_qt" = "yes")
#if test "x$enable_gtk" = "xyes" ; then
# AM_PATH_GTK_2_0(2.0.0, havegtk=yes, havegtk=no)
# if test "$havegtk" = no; then
# enable_gtk="no"
# echo
# echo Cannot find Gtk+\! Not building Gtk+ interface...
# echo
# fi
#fi
CURSES_LIBS=-lcurses
GTK_CFLAGS=`pkg-config --cflags gtk+-2.0`
GTK_LIBS=`pkg-config --libs gtk+-2.0`
AC_SUBST(CURSES_LIBS)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
CFLAGS="-Wall -W -pipe -O2"
AC_OUTPUT([Makefile
src/Makefile
src/common/Makefile
src/irc/Makefile
src/gui/Makefile
src/gui/curses/Makefile
src/gui/gtk/Makefile
src/gui/qt/Makefile])
echo
echo $PACKAGE $VERSION
listgui=
if test "x$enable_curses" = "xyes" ; then
listgui="$listgui Curses"
fi
if test "x$enable_gtk" = "xyes" ; then
listgui="$listgui Gtk+"
fi
if test "x$enable_qt" = "xyes" ; then
listgui="$listgui Qt"
fi
echo
echo Interfaces.................... :$listgui
echo
echo Build with Plugin support..... : $enable_plugins
echo Build with Perl support....... : $enable_perl
echo Build with Python support..... : $enable_python
echo Build with Ruby support....... : $enable_ruby
echo
echo Print debugging messages...... : $enable_debug
echo
eval eval echo WeeChat will be installed in $bindir.
echo
echo configure complete, now type \'make\' to build WeeChat
echo

18
src/Makefile.am Normal file
View File

@ -0,0 +1,18 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
SUBDIRS = common irc gui

24
src/common/Makefile.am Normal file
View File

@ -0,0 +1,24 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
noinst_LIBRARIES = lib_weechat_main.a
lib_weechat_main_a_SOURCES = weechat.c \
command.c \
completion.c \
config.c \
history.c

1387
src/common/command.c Normal file

File diff suppressed because it is too large Load Diff

80
src/common/command.h Normal file
View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_COMMAND_H
#define __WEECHAT_COMMAND_H 1
#include "../irc/irc.h"
#define MAX_ARGS 8192
typedef struct t_weechat_command t_weechat_command;
struct t_weechat_command
{
char *command_name;
char *command_description;
char *arguments;
char *arguments_description;
int min_arg, max_arg;
int (*cmd_function_args)(int, char **);
int (*cmd_function_1arg)(char *);
};
typedef struct t_weechat_alias t_weechat_alias;
struct t_weechat_alias
{
char *alias_name;
char *alias_command;
t_weechat_alias *prev_alias;
t_weechat_alias *next_alias;
};
typedef struct t_index_command t_index_command;
struct t_index_command
{
char *command_name;
t_index_command *prev_index;
t_index_command *next_index;
};
extern t_weechat_alias *weechat_alias;
extern t_index_command *index_commands;
extern t_index_command *index_command_new (char *);
extern void index_command_build ();
extern t_weechat_alias *alias_new (char *, char *);
extern int exec_weechat_command (t_irc_server *, char *);
extern void user_command (t_irc_server *, char *);
extern int weechat_cmd_alias (char *);
extern int weechat_cmd_clear (int, char **);
extern int weechat_cmd_connect (int, char **);
extern int weechat_cmd_disconnect (int, char **);
extern int weechat_cmd_help (int, char **);
extern int weechat_cmd_server (int, char **);
extern int weechat_cmd_save (int, char **);
extern int weechat_cmd_set (int, char **);
extern int weechat_cmd_unalias (char *);
#endif /* command.h */

210
src/common/completion.c Normal file
View File

@ -0,0 +1,210 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* completion.c: completes words according to context (cmd/nick) */
#include <stdlib.h>
#include <string.h>
#include "weechat.h"
#include "completion.h"
#include "../irc/irc.h"
#include "command.h"
/*
* completion_init: init completion
*/
void
completion_init (t_completion *completion)
{
completion->position = -1;
completion->base_word = NULL;
}
/*
* completion_free: free completion
*/
void
completion_free (t_completion *completion)
{
if (completion->base_word)
free (completion->base_word);
}
/*
* completion_command: complete a command
*/
void
completion_command (t_completion *completion)
{
int length, word_found_seen;
t_index_command *ptr_index;
length = strlen (completion->base_word) - 1;
word_found_seen = 0;
for (ptr_index = index_commands; ptr_index; ptr_index = ptr_index->next_index)
{
if (strncasecmp (ptr_index->command_name, completion->base_word + 1, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_index->command_name;
return;
}
}
if (completion->word_found &&
(strcasecmp (ptr_index->command_name, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
completion_command (completion);
}
}
/*
* completion_nick: complete a nick
*/
void
completion_nick (t_completion *completion, t_irc_channel *channel)
{
int length, word_found_seen;
t_irc_nick *ptr_nick;
length = strlen (completion->base_word);
word_found_seen = 0;
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
if (strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_nick->nick;
return;
}
}
if (completion->word_found &&
(strcasecmp (ptr_nick->nick, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
completion_nick (completion, channel);
}
}
/*
* completion_search: complete word according to context
*/
void
completion_search (t_completion *completion, void *channel,
char *buffer, int size, int pos)
{
int i, pos_start, pos_end;
char *old_word_found;
/* TODO: complete when no word is there with command according to context */
if (size == 0)
{
completion->word_found = NULL;
return;
}
/* if new complation => look for base word */
if (pos != completion->position)
{
completion->word_found = NULL;
if ((pos == size) || (buffer[pos-1] != ' '))
pos--;
if ((pos > 0) && (buffer[pos] == ' '))
return;
i = pos;
while ((i >= 0) && (buffer[i] != ' '))
i--;
pos_start = i + 1;
i = pos;
while ((i < size) && (buffer[i] != ' '))
i++;
pos_end = i - 1;
if (pos_start > pos_end)
return;
completion->base_word_pos = pos_start;
if (completion->base_word)
free (completion->base_word);
completion->base_word = (char *) malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
completion->base_word[i - pos_start] = buffer[i];
completion->base_word[pos_end - pos_start + 1] = '\0';
if (completion->base_word[0] == '/')
completion->position_replace = pos_start + 1;
else
completion->position_replace = pos_start;
}
/* completion */
old_word_found = completion->word_found;
if (completion->base_word[0] == '/')
{
completion_command (completion);
if (completion->word_found)
{
if (old_word_found)
completion->diff_size = strlen (completion->word_found) -
strlen (old_word_found);
else
completion->diff_size = strlen (completion->word_found) -
strlen (completion->base_word) + 1;
}
}
else
{
if (channel)
{
completion_nick (completion, (t_irc_channel *)channel);
if (completion->word_found)
{
if (old_word_found)
completion->diff_size = strlen (completion->word_found) -
strlen (old_word_found);
else
completion->diff_size = strlen (completion->word_found) -
strlen (completion->base_word);
}
}
}
}

42
src/common/completion.h Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_COMPLETION_H
#define __WEECHAT_COMPLETION_H 1
typedef struct t_completion t_completion;
struct t_completion
{
char *base_word; /* word to complete (when Tab was pressed) */
int base_word_pos; /* beggining of base word */
int position; /* position where we shoud complete */
char *word_found; /* word found (to replace base word) */
int position_replace; /* position where word should be replaced */
int diff_size; /* size difference (< 0 = char(s) deleted) */
};
extern void completion_init (t_completion *);
extern void completion_free (t_completion *);
extern void completion_search (t_completion *, void *, char *, int, int);
#endif /* completion.h */

1198
src/common/config.c Normal file

File diff suppressed because it is too large Load Diff

157
src/common/config.h Normal file
View File

@ -0,0 +1,157 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_CONFIG_H
#define __WEECHAT_CONFIG_H 1
#define WEECHAT_CONFIG_NAME "weechat.rc"
#define CONFIG_SECTION_NONE -1
#define CONFIG_SECTION_LOOK 0
#define CONFIG_SECTION_COLORS 1
#define CONFIG_SECTION_HISTORY 2
#define CONFIG_SECTION_LOG 3
#define CONFIG_SECTION_DCC 4
#define CONFIG_SECTION_PROXY 5
#define CONFIG_SECTION_ALIAS 6
#define CONFIG_SECTION_SERVER 7
#define CONFIG_NUMBER_SECTIONS 8
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
#define OPTION_TYPE_INT 2 /* values: from min to max */
#define OPTION_TYPE_INT_WITH_STRING 3 /* values: one from **array_values */
#define OPTION_TYPE_COLOR 4 /* values: a color name */
#define OPTION_TYPE_STRING 5 /* values: any string, may be empty */
#define BOOL_FALSE 0
#define BOOL_TRUE 1
#define CFG_LOOK_NICKLIST_LEFT 0
#define CFG_LOOK_NICKLIST_RIGHT 1
#define CFG_LOOK_NICKLIST_TOP 2
#define CFG_LOOK_NICKLIST_BOTTOM 3
typedef struct t_config_section t_config_section;
struct t_config_section
{
int section_number;
char *section_name;
};
typedef struct t_config_option t_config_option;
struct t_config_option
{
char *option_name;
char *short_description;
char *long_description;
int option_type;
int min, max;
int default_int;
char *default_string;
char **array_values;
int *ptr_int;
char **ptr_string;
int (*handler_change)(int *, char **);
};
extern int cfg_look_set_title;
extern int cfg_look_startup_logo;
extern int cfg_look_startup_version;
extern char *cfg_look_weechat_slogan;
extern int cfg_look_color_nicks;
extern int cfg_look_color_actions;
extern int cfg_look_remove_colors_from_msgs;
extern int cfg_look_nicklist;
extern int cfg_look_nicklist_position;
extern int cfg_look_nicklist_min_size;
extern int cfg_look_nicklist_max_size;
extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern int cfg_col_title;
extern int cfg_col_title_bg;
extern int cfg_col_chat;
extern int cfg_col_chat_time;
extern int cfg_col_chat_time_sep;
extern int cfg_col_chat_prefix1;
extern int cfg_col_chat_prefix2;
extern int cfg_col_chat_nick;
extern int cfg_col_chat_host;
extern int cfg_col_chat_channel;
extern int cfg_col_chat_dark;
extern int cfg_col_chat_bg;
extern int cfg_col_status;
extern int cfg_col_status_active;
extern int cfg_col_status_data_msg;
extern int cfg_col_status_data_other;
extern int cfg_col_status_more;
extern int cfg_col_status_bg;
extern int cfg_col_input;
extern int cfg_col_input_channel;
extern int cfg_col_input_nick;
extern int cfg_col_input_bg;
extern int cfg_col_nick;
extern int cfg_col_nick_op;
extern int cfg_col_nick_halfop;
extern int cfg_col_nick_voice;
extern int cfg_col_nick_sep;
extern int cfg_col_nick_self;
extern int cfg_col_nick_private;
extern int cfg_col_nick_bg;
extern int cfg_history_max_lines;
extern int cfg_history_max_commands;
extern int cfg_log_auto_channels;
extern int cfg_log_auto_private;
extern char *cfg_log_path;
extern char *cfg_log_name;
extern char *cfg_log_timestamp;
extern char *cfg_log_start_string;
extern char *cfg_log_end_string;
extern int cfg_dcc_auto_accept_files;
extern int cfg_dcc_auto_accept_max_size;
extern int cfg_dcc_auto_accept_chats;
extern int cfg_dcc_timeout;
extern char *cfg_dcc_download_path;
extern char *cfg_dcc_upload_path;
extern int cfg_dcc_auto_rename;
extern int cfg_dcc_auto_resume;
extern int cfg_proxy_use;
extern char *cfg_proxy_address;
extern int cfg_proxy_port;
extern char *cfg_proxy_password;
extern t_config_section config_sections [CONFIG_NUMBER_SECTIONS];
extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
extern int config_read ();
extern int config_create_default ();
extern int config_write ();
#endif /* config.h */

66
src/common/history.c Normal file
View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* history.c: memorize and call again commands or text */
#include <stdlib.h>
#include <string.h>
#include "weechat.h"
#include "history.h"
#include "../gui/gui.h"
t_history *history_general = NULL;
t_history *history_general_ptr = NULL;
/*
* history_add: add a text/command to history
*/
void
history_add (void *window, char *string)
{
t_history *new_history;
new_history = (t_history *)malloc (sizeof (t_history));
if (new_history)
{
new_history->text = strdup (string);
/* add history to general history */
if (history_general)
history_general->prev_history = new_history;
new_history->next_history = history_general;
new_history->prev_history = NULL;
history_general = new_history;
/* add history to local history */
if (((t_gui_window *)(window))->history)
((t_gui_window *)(window))->history->prev_history = new_history;
new_history->next_history = ((t_gui_window *)(window))->history;
new_history->prev_history = NULL;
((t_gui_window *)window)->history = new_history;
}
}

37
src/common/history.h Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_HISTORY_H
#define __WEECHAT_HISTORY_H 1
typedef struct t_history t_history;
struct t_history
{
char *text; /* text or command (as entered by user) */
t_history *next_history; /* link to next text/command */
t_history *prev_history; /* link to previous text/command */
};
extern void history_add (void *, char *);
#endif /* history.h */

324
src/common/weechat.c Normal file
View File

@ -0,0 +1,324 @@
/* ############################################################################
* ### ___ __ ______________ _____ ###
* ### __ | / /___________ ____/__ /_______ __ /_ ###
* ### __ | /| / /_ _ \ _ \ / __ __ \ __ `/ __/ ###
* ### __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ ###
* ### ____/|__/ \___/\___/\____/ /_/ /_/\__,_/ \__/ ###
* ### ###
* ### WeeChat - Wee Enhanced Environment for Chat ###
* ### Fast & light environment for Chat ###
* ### ###
* ### By: FlashCode <flashcode@flashtux.org> ###
* ### Bounga <bounga@altern.org> ###
* ### Xahlexx <xahlexx@tuxisland.org> ###
* ### ###
* ### http://weechat.flashtux.org ###
* ### ###
* ############################################################################
*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* weechat.c: core functions for WeeChat */
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include "weechat.h"
#include "config.h"
#include "command.h"
#include "../irc/irc.h"
#include "../gui/gui.h"
/* char *display_name; */
int quit_weechat; /* = 1 if quit request from user... why ? :'( */
FILE *log_file; /* WeeChat log file (~/.weechat/weechat.log */
/*
* log_printf: displays a message in WeeChat log (~/.weechat/weechat.log)
*/
void
log_printf (char *message, ...)
{
static char buffer[4096];
va_list argptr;
static time_t seconds;
struct tm *date_tmp;
if (!log_file)
return;
va_start (argptr, message);
vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
va_end (argptr);
seconds = time (NULL);
date_tmp = localtime (&seconds);
fprintf (log_file, "[%04d-%02d-%02d %02d:%02d:%02d] %s",
date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, date_tmp->tm_mday,
date_tmp->tm_hour, date_tmp->tm_min, date_tmp->tm_sec,
buffer);
fflush (log_file);
}
/*
* wee_parse_args: parse command line args
*/
void
wee_parse_args (int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++)
{
if ((strcmp (argv[i], "-h") == 0)
|| (strcmp (argv[i], "--help") == 0))
{
printf ("\n%s%s", WEE_USAGE);
exit (0);
}
else if ((strcmp (argv[i], "-l") == 0)
|| (strcmp (argv[i], "--license") == 0))
{
printf ("\n%s%s", WEE_LICENSE);
exit (0);
}
/*else if ((strcmp (argv[i], "-d") == 0)
|| (strcmp (argv[i], "--display") == 0))
{
if (i == (argc - 1))
fprintf (stderr,
_("%s no display specified (parameter '%s'), ignored\n"),
WEECHAT_WARNING, argv[i]);
else
{
display_name = argv[i + 1];
i++;
}
}*/
else if ((strcmp (argv[i], "-v") == 0)
|| (strcmp (argv[i], "--version") == 0))
{
printf (WEECHAT_VERSION "\n");
exit (0);
}
else
{
fprintf (stderr,
_("%s unknown parameter '%s', ignored\n"),
WEECHAT_WARNING, argv[i]);
}
}
}
/*
* wee_create_home_dir: create weechat home directory (if not found)
*/
void
wee_create_home_dir ()
{
char *weechat_home_dir;
int return_code;
weechat_home_dir =
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
sprintf (weechat_home_dir, "%s/.weechat", getenv ("HOME"));
return_code = mkdir (weechat_home_dir, 0755);
if (return_code < 0)
{
if (errno != EEXIST)
{
fprintf (stderr, _("%s cannot create directory \"%s\"\n"),
WEECHAT_ERROR, weechat_home_dir);
free (weechat_home_dir);
exit (1);
}
}
free (weechat_home_dir);
}
/*
* wee_init_vars: initialize some variables
*/
void
wee_init_vars ()
{
/* GUI not yet initialized */
gui_ready = 0;
/* init received messages queue */
recv_msgq = NULL;
msgq_last_msg = NULL;
}
/*
* wee_init_log: initialize log file
*/
void
wee_init_log ()
{
char *filename;
filename =
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
sprintf (filename, "%s/.weechat/" WEECHAT_LOG_NAME, getenv ("HOME"));
if ((log_file = fopen (filename, "wt")) == NULL)
{
free (filename);
fprintf (stderr,
_("%s unable to create/append to log file (~/.weechat/"
WEECHAT_LOG_NAME), WEECHAT_ERROR);
}
free (filename);
}
/*
* wee_shutdown: shutdown WeeChat
*/
void
wee_shutdown ()
{
server_free_all ();
gui_end ();
if (log_file)
fclose (log_file);
exit (0);
}
/*
* main: WeeChat startup
*/
int
main (int argc, char *argv[])
{
t_irc_server *ptr_server;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, "/usr/share/locale");
textdomain (PACKAGE);
/* pre-initiliaze interface */
gui_pre_init (&argc, &argv);
/* initialize variables */
wee_init_vars ();
/* parse command line args */
wee_parse_args (argc, argv);
/* create weechat home directory */
wee_create_home_dir ();
/* init log file */
wee_init_log ();
/* build commands index (sorted), for completion */
index_command_build ();
/* read configuration */
switch (config_read ())
{
case 0: /* success */
break;
case -1: /* config file not found */
config_create_default ();
config_read ();
break;
default: /* other error (fatal) */
server_free_all ();
return 1;
}
/* init gui */
gui_init ();
/* Welcome message - yeah! */
if (cfg_look_startup_logo)
{
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
" ___ __ ______________ _____ \n"
" __ | / /___________ ____/__ /_______ __ /_\n"
" __ | /| / /_ _ \\ _ \\ / __ __ \\ __ `/ __/\n"
" __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ \n"
" ____/|__/ \\___/\\___/\\____/ /_/ /_/\\__,_/ \\__/ \n");
}
if (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0])
{
gui_printf_color (NULL, COLOR_WIN_CHAT, _("%sWelcome to "),
(cfg_look_startup_logo) ? " " : "");
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, WEECHAT_NAME);
gui_printf_color (NULL, COLOR_WIN_CHAT,
", %s\n", cfg_look_weechat_slogan);
}
if (cfg_look_startup_version)
{
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2,
"%s" WEECHAT_NAME_AND_VERSION,
(cfg_look_startup_logo) ? " " : "");
gui_printf_color (NULL, COLOR_WIN_CHAT,
", %s %s %s\n",
_("compiled on"), __DATE__, __TIME__);
}
if (cfg_look_startup_logo ||
(cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) ||
cfg_look_startup_version)
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
/* connect to all servers (with autoconnect flag) */
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (ptr_server->autoconnect)
{
gui_window_new (ptr_server, NULL);
if (server_connect (ptr_server))
irc_login (ptr_server);
}
}
gui_main_loop ();
server_disconnect_all ();
/* save config file */
config_write (NULL);
/* program ending */
wee_shutdown ();
/* make gcc happy (statement never executed) */
return 0;
}

98
src/common/weechat.h Normal file
View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_H
#define __WEECHAT_H 1
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#define PACKAGE "weechat"
#define _(string) gettext(string)
#define N_(string) (string)
#define WEECHAT_NAME "WeeChat"
#define WEECHAT_VERSION "0.0.3-pre2"
#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION
#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team"
#define WEECHAT_WEBSITE "http://weechat.flashtux.org"
#define WEECHAT_ERROR _(WEECHAT_NAME " Error:")
#define WEECHAT_WARNING _(WEECHAT_NAME " Warning:")
/* debug mode, 0=normal use, 1=some debug msg, 2=full debug (developers only) */
#define DEBUG 0
/* log file */
#define WEECHAT_LOG_NAME "weechat.log"
/* license */
#define WEE_LICENSE \
WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \
"Developed by FlashCode <flashcode@flashtux.org>\n" \
" Bounga <bounga@altern.org>\n" \
" Xahlexx <xahlexx@tuxisland.org>\n\n" \
"This program is free software; you can redistribute it and/or modify\n" \
"it under the terms of the GNU General Public License as published by\n" \
"the Free Software Foundation; either version 2 of the License, or\n" \
"(at your option) any later version.\n" \
"\n", \
\
"This program is distributed in the hope that it will be useful,\n" \
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \
"GNU General Public License for more details.\n" \
"\n" \
"You should have received a copy of the GNU General Public License\n" \
"along with this program; if not, write to the Free Software\n" \
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n"
#define WEE_USAGE \
WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \
"Developed by FlashCode <flashcode@flashtux.org>\n" \
" Bounga <bounga@altern.org>\n" \
" Xahlexx <xahlexx@tuxisland.org>\n\n" \
" Bounga <bounga@altern.org>\n" \
" Xahlexx <xahlexx@tuxisland.org>\n\n" \
" -h, --help this help screen\n", \
" -l, --license display WeeChat license\n" \
" -v, --version display WeeChat version\n\n"
/* " -d, --display choose X display\n" \*/
/*#define DEFAULT_DISPLAY ":0" */
/*extern char *display_name; */
int quit_weechat;
extern int quit_weechat;
extern void log_printf (char *, ...);
extern void wee_shutdown ();
#endif /* weechat.h */

30
src/gui/Makefile.am Normal file
View File

@ -0,0 +1,30 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
if GUI_CURSES
curses_dir=curses
endif
if GUI_GTK
gtk_dir=gtk
endif
if GUI_QT
qt_dir=qt
endif
SUBDIRS = $(curses_dir) $(gtk_dir) $(qt_dir)

View File

@ -0,0 +1,26 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
bin_PROGRAMS = weechat-curses
weechat_curses_LDADD = ../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
$(CURSES_LIBS)
weechat_curses_SOURCES = ../gui-common.c \
gui-display.c \
gui-input.c

View File

@ -29,10 +29,11 @@
#include <string.h>
#include <signal.h>
#include <time.h>
#include <curses.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../common/config.h"
#include "../../irc/irc.h"
@ -150,6 +151,17 @@ gui_window_set_color (WINDOW *window, int num_color)
}
}
/*
* gui_window_has_nicklist: returns 1 if window has nicklist
*/
int
gui_window_has_nicklist (t_gui_window *window)
{
return (window->win_nick != NULL);
}
/*
* gui_calculate_pos_size: calculate position and size for a window & sub-win
*/
@ -1245,6 +1257,18 @@ gui_window_init_subwindows (t_gui_window *window)
window->win_input = NULL;
}
/*
* gui_pre_init: pre-initialize GUI (called before gui_init)
*/
void
gui_pre_init (int *argc, char **argv[])
{
/* nothing for Curses interface */
(void) argc;
(void) argv;
}
/*
* gui_init_colors: init GUI colors
*/

View File

@ -30,13 +30,15 @@
#include <signal.h>
#include <time.h>
#include <sys/socket.h>
#include <curses.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../command.h"
#include "../../common/config.h"
#include "../../common/command.h"
#include "../../irc/irc.h"
#define KEY_ESCAPE 27
/*
* gui_read_keyb: read keyboard line

28
src/gui/gtk/Makefile.am Normal file
View File

@ -0,0 +1,28 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
bin_PROGRAMS = weechat-gtk
INCLUDES = $(GTK_CFLAGS)
weechat_gtk_LDADD = ../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
$(GTK_LIBS)
weechat_gtk_SOURCES = ../gui-common.c \
gui-display.c \
gui-input.c

View File

@ -29,10 +29,11 @@
#include <string.h>
#include <signal.h>
#include <time.h>
#include <gtk/gtk.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../common/config.h"
#include "../../irc/irc.h"
@ -143,6 +144,16 @@ gui_get_color_by_value (int color_value)
return NULL;
}
/*
* gui_window_has_nicklist: returns 1 if window has nicklist
*/
int
gui_window_has_nicklist (t_gui_window *window)
{
return (window->textbuffer_nicklist != NULL);
}
/*
* gui_calculate_pos_size: calculate position and size for a window & sub-win
*/
@ -379,7 +390,7 @@ gui_redraw_window (t_gui_window *window)
gui_redraw_window_title (window);
gui_redraw_window_chat (window);
if (WIN_HAS_NICKLIST(window))
if (gui_window_has_nicklist (window))
gui_redraw_window_nick (window);
gui_redraw_window_status (window);
gui_redraw_window_input (window);
@ -537,6 +548,17 @@ gui_window_init_subwindows (t_gui_window *window)
window->textbuffer_nicklist = NULL;
}
/*
* gui_pre_init: pre-initialize GUI (called before gui_init)
*/
void
gui_pre_init (int *argc, char **argv[])
{
/* Initialise Gtk+ */
gtk_init (argc, argv);
}
/*
* gui_init_colors: init GUI colors
*/

View File

@ -30,11 +30,12 @@
#include <signal.h>
#include <time.h>
#include <sys/socket.h>
#include <gtk/gtk.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../command.h"
#include "../../common/config.h"
#include "../../common/command.h"
#include "../../irc/irc.h"

View File

@ -31,7 +31,7 @@
#include <time.h>
#include <curses.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "gui.h"
#include "../irc/irc.h"

View File

@ -23,19 +23,8 @@
#ifndef __WEECHAT_GUI_H
#define __WEECHAT_GUI_H 1
#ifdef WEE_CURSES
#include <curses.h>
#endif
#ifdef WEE_GTK
#include <gtk/gtk.h>
#endif
#include "../completion.h"
#include "../history.h"
#ifdef WEE_CURSES
#define KEY_ESCAPE 27
#endif
#include "../common/completion.h"
#include "../common/history.h"
#define INPUT_BUFFER_BLOCK_SIZE 256
@ -77,10 +66,10 @@
#define WIN_IS_PRIVATE(window) (CHANNEL(window) && (CHANNEL(window)->type == CHAT_PRIVATE))
#ifdef WEE_CURSES
#define WIN_HAS_NICKLIST(window) (window->win_nick)
//#define WIN_HAS_NICKLIST(window) (window->win_nick)
#endif
#ifdef WEE_GTK
#define WIN_HAS_NICKLIST(window) (window->textbuffer_nicklist)
//#define WIN_HAS_NICKLIST(window) (window->textbuffer_nicklist)
#endif
#define MSG_TYPE_TIME 0
@ -152,24 +141,27 @@ struct t_gui_window
int win_nick_width; /* width of chat window */
int win_nick_height; /* height of chat window */
/* windows */
#ifdef WEE_CURSES
WINDOW *win_title; /* title window */
WINDOW *win_chat; /* chat window (exemple: channel) */
WINDOW *win_nick; /* nick window */
WINDOW *win_status; /* status window */
WINDOW *win_input; /* input window */
#endif
#ifdef WEE_GTK
GtkWidget *textview_chat; /* textview widget for chat */
GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */
GtkTextTag *texttag_chat; /* texttag widget for chat */
GtkWidget *textview_nicklist; /* textview widget for nicklist */
GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */
#endif
#ifdef WEE_QT
/* windows for Curses GUI */
void *win_title; /* title window */
void *win_chat; /* chat window (exemple: channel) */
void *win_nick; /* nick window */
void *win_status; /* status window */
void *win_input; /* input window */
/* windows for Curses GUI */
//GtkWidget *textview_chat; /* textview widget for chat */
//GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */
//GtkTextTag *texttag_chat; /* texttag widget for chat */
//GtkWidget *textview_nicklist; /* textview widget for nicklist */
//GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */
void *textview_chat; /* textview widget for chat */
void *textbuffer_chat; /* textbuffer widget for chat */
void *texttag_chat; /* texttag widget for chat */
void *textview_nicklist; /* textview widget for nicklist */
void *textbuffer_nicklist; /* textbuffer widget for nicklist */
/* windows for Curses GUI */
/* TODO: declare Qt window */
#endif
/* chat content (lines, line is composed by many messages) */
t_gui_line *lines; /* lines of chat window */
@ -222,6 +214,7 @@ extern void gui_buffer_insert_string (char *, int);
extern int gui_assign_color (int *, char *);
extern int gui_get_color_by_name (char *);
extern char *gui_get_color_by_value (int);
extern int gui_window_has_nicklist (t_gui_window *);
extern void gui_calculate_pos_size (t_gui_window *);
extern void gui_draw_window_title (t_gui_window *);
extern void gui_redraw_window_title (t_gui_window *);
@ -240,7 +233,8 @@ extern void gui_switch_to_next_window ();
extern void gui_move_page_up ();
extern void gui_move_page_down ();
extern void gui_window_init_subwindows (t_gui_window *);
extern void gui_init_colors ();
extern void gui_pre_init (int *, char **[]);
//extern void gui_init_colors ();
extern void gui_init ();
extern void gui_window_free (t_gui_window *);
extern void gui_end ();

16
src/gui/qt/Makefile.am Normal file
View File

@ -0,0 +1,16 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

26
src/irc/Makefile.am Normal file
View File

@ -0,0 +1,26 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
noinst_LIBRARIES = lib_weechat_irc.a
lib_weechat_irc_a_SOURCES = irc-commands.c \
irc-send.c \
irc-recv.c \
irc-server.c \
irc-channel.c \
irc-nick.c \
irc-display.c

View File

@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"

View File

@ -24,9 +24,9 @@
RFC 1459,2810,2811,2812 */
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../command.h"
#include "../common/command.h"
t_irc_command irc_commands[] =

View File

@ -28,9 +28,9 @@
#include <stdio.h>
#include <string.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../config.h"
#include "../common/config.h"
#include "../gui/gui.h"

View File

@ -27,7 +27,7 @@
#include <string.h>
#include <limits.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"

View File

@ -32,10 +32,10 @@
#include <time.h>
#include <sys/utsname.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../command.h"
#include "../config.h"
#include "../common/command.h"
#include "../common/config.h"
#include "../gui/gui.h"
@ -501,7 +501,7 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *arguments)
COLOR_WIN_CHAT_NICK,
"%s\n",
arguments);
if (WIN_HAS_NICKLIST(ptr_channel->window))
if (gui_window_has_nicklist (ptr_channel->window))
gui_redraw_window_nick (ptr_channel->window);
}
}
@ -692,7 +692,7 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
gui_printf (ptr_channel->window, "\n");
/* redraw nick list if this is current window */
if (WIN_HAS_NICKLIST(ptr_channel->window))
if (gui_window_has_nicklist (ptr_channel->window))
gui_redraw_window_nick (ptr_channel->window);
}
}
@ -978,7 +978,7 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_DARK, ")\n");
if ((ptr_channel->window == gui_current_window) &&
(WIN_HAS_NICKLIST(ptr_channel->window)))
(gui_window_has_nicklist (ptr_channel->window)))
gui_redraw_window_nick (ptr_channel->window);
}
}

View File

@ -32,10 +32,10 @@
#include <time.h>
#include <sys/utsname.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../command.h"
#include "../config.h"
#include "../common/command.h"
#include "../common/config.h"
#include "../gui/gui.h"

View File

@ -34,7 +34,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../gui/gui.h"

View File

@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
WeeChat known bugs, 2003-10-09
WeeChat known bugs, 2003-10-25
- too much nicks in the channel (> height of window) => display bug
- some IRC commands are marked as 'unknown' when received
@ -12,3 +12,4 @@ WeeChat known bugs, 2003-10-09
- when function key (non used by WeeChat) is pressed, prompt is deleted
- when quitting WeeChat term title is not restored (if look_set_title is ON)
- command name for /server can not contain spaces
- wrong alias is not created and not saved when quitting WeeChat

View File

@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
ChangeLog - 2003-10-12
ChangeLog - 2003-10-25
Version 0.0.3 (under dev!):
* ./configure script to build WeeChat (now multi-platform)
* nicks are now correctly sorted (op, halfop, voice, other)
* fixed crash when entering text without any server connection
* fixed display bug (text was blinking when scrolling)

View File

@ -1,10 +1,12 @@
WeeChat - Installation instructions
===================================
1) Run 'make'
1) Run './configure'
2) As root, run 'make install'
2) Run 'make'
3) Enjoy ! :-)
3) As root, run 'make install'
4) Enjoy ! :-)
See AUTHORS for any support, feel free to contact us for any problem ;)

18
weechat/Makefile.am Normal file
View File

@ -0,0 +1,18 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
SUBDIRS = src

View File

@ -10,7 +10,7 @@ It is customizable and extensible with scripts.
Features
--------
* IRC chat client with multi-server connection
* many GUI (curses, Gtk, QT) (1)
* many GUI (curses, Gtk, Qt) (1)
* small, fast and very light
* customizable and extensible with scripts (Perl, Python, Ruby) (2)
* compliant with RFC 1459,2810,2811,2812,2813
@ -46,6 +46,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---
(1) only curses & text interfaces are available today
(1) only curses interface is available today
(2) plugin interfaces are not yet developed
(3) only GNU/Linux version is available today

View File

@ -1,7 +1,7 @@
WeeChat - Wee Enhanced Environment for Chat
===========================================
TODO - 2003-10-12
TODO - 2003-10-25
Legend:
# done
@ -13,6 +13,9 @@ Legend:
v0.0.3:
------
* General:
+ use of ./configure for building WeeChat
* IRC protocol:
# implement RFC 2812
+ "/mode" command: change the user/channels modes
@ -20,29 +23,15 @@ v0.0.3:
persons with the flag +w enable
* WeeChat commands:
- "/reload" command: reload the WeeChat's config file
- "/highlight" command: highlight a given word when it appears on
channels/privates
+ "/set" command: allow the user to set the WeeChat variables
under WeeChat without editing the config file (colours, time
format, etc)
* Interface:
+ Gtk GUI
- display current channel modes (example : #weechat(+nt))
- interpret special chars in messages (color & bold for example)
+ internationalization (traduce WeeChat in many languages)
- log chats to file
* TCP/IP communication:
- proxy support
* Configuration:
- add missing options for config file
- wrong alias is not created and not saved when quitting WeeChat
# do not stop program if problem with options in config file
- load config file after GUI (so init values by default (colors, ...) before
loading config)
Future versions:
@ -60,6 +49,9 @@ Future versions:
nick/host connect to the given irc network
* WeeChat commands:
- "/reload" command: reload the WeeChat's config file
- "/highlight" command: highlight a given word when it appears on
channels/privates
- "/completion" command: do shortcuts (for example when we type "u"
in the text bar it send it to the server as "you")
- "/exec" command: execute a command as if we was in shell
@ -68,6 +60,9 @@ Future versions:
channel/private
* Interface:
+ Gtk GUI
- display current channel modes (example : #weechat(+nt))
- interpret special chars in messages (color & bold for example)
- many channel windows in one window/term (window split)
- add lag indicator
- forget some old lines that were displayed long time ago (now all is saved,
@ -75,15 +70,20 @@ Future versions:
- improve completion (for example complete command parameters when possible)
- understand incomplete commands if unambigous (for example: /he for /help is ok)
- add clock (in status bar?)
- log chats to file
? Qt GUI
* TCP/IP communication:
- connect to server with child process (background)
- proxy support
- SSL support
- IPv6 protocol implementation
* Configuration:
- add key bindings to config file
- add missing options for config file
- load config file after GUI (so init values by default (colors, ...) before
loading config)
* Plugins:
- add Perl plugin

126
weechat/configure.in Normal file
View File

@ -0,0 +1,126 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
AC_INIT(WeeChat, 0.0.3, flashcode@flashtux.org)
AC_CONFIG_SRCDIR([src/common/weechat.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([weechat], [0.0.3])
# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_RANLIB
# Checks for libraries.
# AC_CHECK_LIB([curses], [initscr])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h libintl.h limits.h locale.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_TIME
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([gethostbyname gethostname gettimeofday inet_ntoa memset mkdir select setlocale socket strcasecmp strchr strdup strncasecmp strpbrk strrchr strstr uname])
AC_ARG_ENABLE(curses, [ --disable-curses Turn off Curses interface (default=auto)],,enable_curses=yes)
AC_ARG_ENABLE(gtk, [ --disable-gtk Turn off Gtk+ interface (default=auto)],,enable_gtk=yes)
AC_ARG_ENABLE(qt, [ --disable-qt Turn off Qt interface (default=auto)],,enable_qt=yes)
enable_plugins=no
enable_perl=no
PERL_CFLAGS=
enable_python=no
PYTHON_CFLAGS=
enable_ruby=no
RUBY_CFLAGS=
enable_debug=no
DEBUG_CFLAGS=
AM_CONDITIONAL(GUI_CURSES, test "$enable_curses" = "yes")
AM_CONDITIONAL(GUI_GTK, test "$enable_gtk" = "yes")
AM_CONDITIONAL(GUI_QT, test "$enable_qt" = "yes")
#if test "x$enable_gtk" = "xyes" ; then
# AM_PATH_GTK_2_0(2.0.0, havegtk=yes, havegtk=no)
# if test "$havegtk" = no; then
# enable_gtk="no"
# echo
# echo Cannot find Gtk+\! Not building Gtk+ interface...
# echo
# fi
#fi
CURSES_LIBS=-lcurses
GTK_CFLAGS=`pkg-config --cflags gtk+-2.0`
GTK_LIBS=`pkg-config --libs gtk+-2.0`
AC_SUBST(CURSES_LIBS)
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
CFLAGS="-Wall -W -pipe -O2"
AC_OUTPUT([Makefile
src/Makefile
src/common/Makefile
src/irc/Makefile
src/gui/Makefile
src/gui/curses/Makefile
src/gui/gtk/Makefile
src/gui/qt/Makefile])
echo
echo $PACKAGE $VERSION
listgui=
if test "x$enable_curses" = "xyes" ; then
listgui="$listgui Curses"
fi
if test "x$enable_gtk" = "xyes" ; then
listgui="$listgui Gtk+"
fi
if test "x$enable_qt" = "xyes" ; then
listgui="$listgui Qt"
fi
echo
echo Interfaces.................... :$listgui
echo
echo Build with Plugin support..... : $enable_plugins
echo Build with Perl support....... : $enable_perl
echo Build with Python support..... : $enable_python
echo Build with Ruby support....... : $enable_ruby
echo
echo Print debugging messages...... : $enable_debug
echo
eval eval echo WeeChat will be installed in $bindir.
echo
echo configure complete, now type \'make\' to build WeeChat
echo

18
weechat/src/Makefile.am Normal file
View File

@ -0,0 +1,18 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
SUBDIRS = common irc gui

View File

@ -0,0 +1,24 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
noinst_LIBRARIES = lib_weechat_main.a
lib_weechat_main_a_SOURCES = weechat.c \
command.c \
completion.c \
config.c \
history.c

1387
weechat/src/common/command.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_COMMAND_H
#define __WEECHAT_COMMAND_H 1
#include "../irc/irc.h"
#define MAX_ARGS 8192
typedef struct t_weechat_command t_weechat_command;
struct t_weechat_command
{
char *command_name;
char *command_description;
char *arguments;
char *arguments_description;
int min_arg, max_arg;
int (*cmd_function_args)(int, char **);
int (*cmd_function_1arg)(char *);
};
typedef struct t_weechat_alias t_weechat_alias;
struct t_weechat_alias
{
char *alias_name;
char *alias_command;
t_weechat_alias *prev_alias;
t_weechat_alias *next_alias;
};
typedef struct t_index_command t_index_command;
struct t_index_command
{
char *command_name;
t_index_command *prev_index;
t_index_command *next_index;
};
extern t_weechat_alias *weechat_alias;
extern t_index_command *index_commands;
extern t_index_command *index_command_new (char *);
extern void index_command_build ();
extern t_weechat_alias *alias_new (char *, char *);
extern int exec_weechat_command (t_irc_server *, char *);
extern void user_command (t_irc_server *, char *);
extern int weechat_cmd_alias (char *);
extern int weechat_cmd_clear (int, char **);
extern int weechat_cmd_connect (int, char **);
extern int weechat_cmd_disconnect (int, char **);
extern int weechat_cmd_help (int, char **);
extern int weechat_cmd_server (int, char **);
extern int weechat_cmd_save (int, char **);
extern int weechat_cmd_set (int, char **);
extern int weechat_cmd_unalias (char *);
#endif /* command.h */

View File

@ -0,0 +1,210 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* completion.c: completes words according to context (cmd/nick) */
#include <stdlib.h>
#include <string.h>
#include "weechat.h"
#include "completion.h"
#include "../irc/irc.h"
#include "command.h"
/*
* completion_init: init completion
*/
void
completion_init (t_completion *completion)
{
completion->position = -1;
completion->base_word = NULL;
}
/*
* completion_free: free completion
*/
void
completion_free (t_completion *completion)
{
if (completion->base_word)
free (completion->base_word);
}
/*
* completion_command: complete a command
*/
void
completion_command (t_completion *completion)
{
int length, word_found_seen;
t_index_command *ptr_index;
length = strlen (completion->base_word) - 1;
word_found_seen = 0;
for (ptr_index = index_commands; ptr_index; ptr_index = ptr_index->next_index)
{
if (strncasecmp (ptr_index->command_name, completion->base_word + 1, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_index->command_name;
return;
}
}
if (completion->word_found &&
(strcasecmp (ptr_index->command_name, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
completion_command (completion);
}
}
/*
* completion_nick: complete a nick
*/
void
completion_nick (t_completion *completion, t_irc_channel *channel)
{
int length, word_found_seen;
t_irc_nick *ptr_nick;
length = strlen (completion->base_word);
word_found_seen = 0;
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
{
if (strncasecmp (ptr_nick->nick, completion->base_word, length) == 0)
{
if ((!completion->word_found) || word_found_seen)
{
completion->word_found = ptr_nick->nick;
return;
}
}
if (completion->word_found &&
(strcasecmp (ptr_nick->nick, completion->word_found) == 0))
word_found_seen = 1;
}
if (completion->word_found)
{
completion->word_found = NULL;
completion_nick (completion, channel);
}
}
/*
* completion_search: complete word according to context
*/
void
completion_search (t_completion *completion, void *channel,
char *buffer, int size, int pos)
{
int i, pos_start, pos_end;
char *old_word_found;
/* TODO: complete when no word is there with command according to context */
if (size == 0)
{
completion->word_found = NULL;
return;
}
/* if new complation => look for base word */
if (pos != completion->position)
{
completion->word_found = NULL;
if ((pos == size) || (buffer[pos-1] != ' '))
pos--;
if ((pos > 0) && (buffer[pos] == ' '))
return;
i = pos;
while ((i >= 0) && (buffer[i] != ' '))
i--;
pos_start = i + 1;
i = pos;
while ((i < size) && (buffer[i] != ' '))
i++;
pos_end = i - 1;
if (pos_start > pos_end)
return;
completion->base_word_pos = pos_start;
if (completion->base_word)
free (completion->base_word);
completion->base_word = (char *) malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
completion->base_word[i - pos_start] = buffer[i];
completion->base_word[pos_end - pos_start + 1] = '\0';
if (completion->base_word[0] == '/')
completion->position_replace = pos_start + 1;
else
completion->position_replace = pos_start;
}
/* completion */
old_word_found = completion->word_found;
if (completion->base_word[0] == '/')
{
completion_command (completion);
if (completion->word_found)
{
if (old_word_found)
completion->diff_size = strlen (completion->word_found) -
strlen (old_word_found);
else
completion->diff_size = strlen (completion->word_found) -
strlen (completion->base_word) + 1;
}
}
else
{
if (channel)
{
completion_nick (completion, (t_irc_channel *)channel);
if (completion->word_found)
{
if (old_word_found)
completion->diff_size = strlen (completion->word_found) -
strlen (old_word_found);
else
completion->diff_size = strlen (completion->word_found) -
strlen (completion->base_word);
}
}
}
}

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_COMPLETION_H
#define __WEECHAT_COMPLETION_H 1
typedef struct t_completion t_completion;
struct t_completion
{
char *base_word; /* word to complete (when Tab was pressed) */
int base_word_pos; /* beggining of base word */
int position; /* position where we shoud complete */
char *word_found; /* word found (to replace base word) */
int position_replace; /* position where word should be replaced */
int diff_size; /* size difference (< 0 = char(s) deleted) */
};
extern void completion_init (t_completion *);
extern void completion_free (t_completion *);
extern void completion_search (t_completion *, void *, char *, int, int);
#endif /* completion.h */

1198
weechat/src/common/config.c Normal file

File diff suppressed because it is too large Load Diff

157
weechat/src/common/config.h Normal file
View File

@ -0,0 +1,157 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_CONFIG_H
#define __WEECHAT_CONFIG_H 1
#define WEECHAT_CONFIG_NAME "weechat.rc"
#define CONFIG_SECTION_NONE -1
#define CONFIG_SECTION_LOOK 0
#define CONFIG_SECTION_COLORS 1
#define CONFIG_SECTION_HISTORY 2
#define CONFIG_SECTION_LOG 3
#define CONFIG_SECTION_DCC 4
#define CONFIG_SECTION_PROXY 5
#define CONFIG_SECTION_ALIAS 6
#define CONFIG_SECTION_SERVER 7
#define CONFIG_NUMBER_SECTIONS 8
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
#define OPTION_TYPE_INT 2 /* values: from min to max */
#define OPTION_TYPE_INT_WITH_STRING 3 /* values: one from **array_values */
#define OPTION_TYPE_COLOR 4 /* values: a color name */
#define OPTION_TYPE_STRING 5 /* values: any string, may be empty */
#define BOOL_FALSE 0
#define BOOL_TRUE 1
#define CFG_LOOK_NICKLIST_LEFT 0
#define CFG_LOOK_NICKLIST_RIGHT 1
#define CFG_LOOK_NICKLIST_TOP 2
#define CFG_LOOK_NICKLIST_BOTTOM 3
typedef struct t_config_section t_config_section;
struct t_config_section
{
int section_number;
char *section_name;
};
typedef struct t_config_option t_config_option;
struct t_config_option
{
char *option_name;
char *short_description;
char *long_description;
int option_type;
int min, max;
int default_int;
char *default_string;
char **array_values;
int *ptr_int;
char **ptr_string;
int (*handler_change)(int *, char **);
};
extern int cfg_look_set_title;
extern int cfg_look_startup_logo;
extern int cfg_look_startup_version;
extern char *cfg_look_weechat_slogan;
extern int cfg_look_color_nicks;
extern int cfg_look_color_actions;
extern int cfg_look_remove_colors_from_msgs;
extern int cfg_look_nicklist;
extern int cfg_look_nicklist_position;
extern int cfg_look_nicklist_min_size;
extern int cfg_look_nicklist_max_size;
extern int cfg_look_nickmode;
extern int cfg_look_nickmode_empty;
extern char *cfg_look_no_nickname;
extern char *cfg_look_completor;
extern int cfg_col_title;
extern int cfg_col_title_bg;
extern int cfg_col_chat;
extern int cfg_col_chat_time;
extern int cfg_col_chat_time_sep;
extern int cfg_col_chat_prefix1;
extern int cfg_col_chat_prefix2;
extern int cfg_col_chat_nick;
extern int cfg_col_chat_host;
extern int cfg_col_chat_channel;
extern int cfg_col_chat_dark;
extern int cfg_col_chat_bg;
extern int cfg_col_status;
extern int cfg_col_status_active;
extern int cfg_col_status_data_msg;
extern int cfg_col_status_data_other;
extern int cfg_col_status_more;
extern int cfg_col_status_bg;
extern int cfg_col_input;
extern int cfg_col_input_channel;
extern int cfg_col_input_nick;
extern int cfg_col_input_bg;
extern int cfg_col_nick;
extern int cfg_col_nick_op;
extern int cfg_col_nick_halfop;
extern int cfg_col_nick_voice;
extern int cfg_col_nick_sep;
extern int cfg_col_nick_self;
extern int cfg_col_nick_private;
extern int cfg_col_nick_bg;
extern int cfg_history_max_lines;
extern int cfg_history_max_commands;
extern int cfg_log_auto_channels;
extern int cfg_log_auto_private;
extern char *cfg_log_path;
extern char *cfg_log_name;
extern char *cfg_log_timestamp;
extern char *cfg_log_start_string;
extern char *cfg_log_end_string;
extern int cfg_dcc_auto_accept_files;
extern int cfg_dcc_auto_accept_max_size;
extern int cfg_dcc_auto_accept_chats;
extern int cfg_dcc_timeout;
extern char *cfg_dcc_download_path;
extern char *cfg_dcc_upload_path;
extern int cfg_dcc_auto_rename;
extern int cfg_dcc_auto_resume;
extern int cfg_proxy_use;
extern char *cfg_proxy_address;
extern int cfg_proxy_port;
extern char *cfg_proxy_password;
extern t_config_section config_sections [CONFIG_NUMBER_SECTIONS];
extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
extern int config_read ();
extern int config_create_default ();
extern int config_write ();
#endif /* config.h */

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* history.c: memorize and call again commands or text */
#include <stdlib.h>
#include <string.h>
#include "weechat.h"
#include "history.h"
#include "../gui/gui.h"
t_history *history_general = NULL;
t_history *history_general_ptr = NULL;
/*
* history_add: add a text/command to history
*/
void
history_add (void *window, char *string)
{
t_history *new_history;
new_history = (t_history *)malloc (sizeof (t_history));
if (new_history)
{
new_history->text = strdup (string);
/* add history to general history */
if (history_general)
history_general->prev_history = new_history;
new_history->next_history = history_general;
new_history->prev_history = NULL;
history_general = new_history;
/* add history to local history */
if (((t_gui_window *)(window))->history)
((t_gui_window *)(window))->history->prev_history = new_history;
new_history->next_history = ((t_gui_window *)(window))->history;
new_history->prev_history = NULL;
((t_gui_window *)window)->history = new_history;
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_HISTORY_H
#define __WEECHAT_HISTORY_H 1
typedef struct t_history t_history;
struct t_history
{
char *text; /* text or command (as entered by user) */
t_history *next_history; /* link to next text/command */
t_history *prev_history; /* link to previous text/command */
};
extern void history_add (void *, char *);
#endif /* history.h */

View File

@ -0,0 +1,324 @@
/* ############################################################################
* ### ___ __ ______________ _____ ###
* ### __ | / /___________ ____/__ /_______ __ /_ ###
* ### __ | /| / /_ _ \ _ \ / __ __ \ __ `/ __/ ###
* ### __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ ###
* ### ____/|__/ \___/\___/\____/ /_/ /_/\__,_/ \__/ ###
* ### ###
* ### WeeChat - Wee Enhanced Environment for Chat ###
* ### Fast & light environment for Chat ###
* ### ###
* ### By: FlashCode <flashcode@flashtux.org> ###
* ### Bounga <bounga@altern.org> ###
* ### Xahlexx <xahlexx@tuxisland.org> ###
* ### ###
* ### http://weechat.flashtux.org ###
* ### ###
* ############################################################################
*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* weechat.c: core functions for WeeChat */
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include "weechat.h"
#include "config.h"
#include "command.h"
#include "../irc/irc.h"
#include "../gui/gui.h"
/* char *display_name; */
int quit_weechat; /* = 1 if quit request from user... why ? :'( */
FILE *log_file; /* WeeChat log file (~/.weechat/weechat.log */
/*
* log_printf: displays a message in WeeChat log (~/.weechat/weechat.log)
*/
void
log_printf (char *message, ...)
{
static char buffer[4096];
va_list argptr;
static time_t seconds;
struct tm *date_tmp;
if (!log_file)
return;
va_start (argptr, message);
vsnprintf (buffer, sizeof (buffer) - 1, message, argptr);
va_end (argptr);
seconds = time (NULL);
date_tmp = localtime (&seconds);
fprintf (log_file, "[%04d-%02d-%02d %02d:%02d:%02d] %s",
date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, date_tmp->tm_mday,
date_tmp->tm_hour, date_tmp->tm_min, date_tmp->tm_sec,
buffer);
fflush (log_file);
}
/*
* wee_parse_args: parse command line args
*/
void
wee_parse_args (int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++)
{
if ((strcmp (argv[i], "-h") == 0)
|| (strcmp (argv[i], "--help") == 0))
{
printf ("\n%s%s", WEE_USAGE);
exit (0);
}
else if ((strcmp (argv[i], "-l") == 0)
|| (strcmp (argv[i], "--license") == 0))
{
printf ("\n%s%s", WEE_LICENSE);
exit (0);
}
/*else if ((strcmp (argv[i], "-d") == 0)
|| (strcmp (argv[i], "--display") == 0))
{
if (i == (argc - 1))
fprintf (stderr,
_("%s no display specified (parameter '%s'), ignored\n"),
WEECHAT_WARNING, argv[i]);
else
{
display_name = argv[i + 1];
i++;
}
}*/
else if ((strcmp (argv[i], "-v") == 0)
|| (strcmp (argv[i], "--version") == 0))
{
printf (WEECHAT_VERSION "\n");
exit (0);
}
else
{
fprintf (stderr,
_("%s unknown parameter '%s', ignored\n"),
WEECHAT_WARNING, argv[i]);
}
}
}
/*
* wee_create_home_dir: create weechat home directory (if not found)
*/
void
wee_create_home_dir ()
{
char *weechat_home_dir;
int return_code;
weechat_home_dir =
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
sprintf (weechat_home_dir, "%s/.weechat", getenv ("HOME"));
return_code = mkdir (weechat_home_dir, 0755);
if (return_code < 0)
{
if (errno != EEXIST)
{
fprintf (stderr, _("%s cannot create directory \"%s\"\n"),
WEECHAT_ERROR, weechat_home_dir);
free (weechat_home_dir);
exit (1);
}
}
free (weechat_home_dir);
}
/*
* wee_init_vars: initialize some variables
*/
void
wee_init_vars ()
{
/* GUI not yet initialized */
gui_ready = 0;
/* init received messages queue */
recv_msgq = NULL;
msgq_last_msg = NULL;
}
/*
* wee_init_log: initialize log file
*/
void
wee_init_log ()
{
char *filename;
filename =
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
sprintf (filename, "%s/.weechat/" WEECHAT_LOG_NAME, getenv ("HOME"));
if ((log_file = fopen (filename, "wt")) == NULL)
{
free (filename);
fprintf (stderr,
_("%s unable to create/append to log file (~/.weechat/"
WEECHAT_LOG_NAME), WEECHAT_ERROR);
}
free (filename);
}
/*
* wee_shutdown: shutdown WeeChat
*/
void
wee_shutdown ()
{
server_free_all ();
gui_end ();
if (log_file)
fclose (log_file);
exit (0);
}
/*
* main: WeeChat startup
*/
int
main (int argc, char *argv[])
{
t_irc_server *ptr_server;
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, "/usr/share/locale");
textdomain (PACKAGE);
/* pre-initiliaze interface */
gui_pre_init (&argc, &argv);
/* initialize variables */
wee_init_vars ();
/* parse command line args */
wee_parse_args (argc, argv);
/* create weechat home directory */
wee_create_home_dir ();
/* init log file */
wee_init_log ();
/* build commands index (sorted), for completion */
index_command_build ();
/* read configuration */
switch (config_read ())
{
case 0: /* success */
break;
case -1: /* config file not found */
config_create_default ();
config_read ();
break;
default: /* other error (fatal) */
server_free_all ();
return 1;
}
/* init gui */
gui_init ();
/* Welcome message - yeah! */
if (cfg_look_startup_logo)
{
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
" ___ __ ______________ _____ \n"
" __ | / /___________ ____/__ /_______ __ /_\n"
" __ | /| / /_ _ \\ _ \\ / __ __ \\ __ `/ __/\n"
" __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ \n"
" ____/|__/ \\___/\\___/\\____/ /_/ /_/\\__,_/ \\__/ \n");
}
if (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0])
{
gui_printf_color (NULL, COLOR_WIN_CHAT, _("%sWelcome to "),
(cfg_look_startup_logo) ? " " : "");
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, WEECHAT_NAME);
gui_printf_color (NULL, COLOR_WIN_CHAT,
", %s\n", cfg_look_weechat_slogan);
}
if (cfg_look_startup_version)
{
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2,
"%s" WEECHAT_NAME_AND_VERSION,
(cfg_look_startup_logo) ? " " : "");
gui_printf_color (NULL, COLOR_WIN_CHAT,
", %s %s %s\n",
_("compiled on"), __DATE__, __TIME__);
}
if (cfg_look_startup_logo ||
(cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) ||
cfg_look_startup_version)
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
/* connect to all servers (with autoconnect flag) */
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
if (ptr_server->autoconnect)
{
gui_window_new (ptr_server, NULL);
if (server_connect (ptr_server))
irc_login (ptr_server);
}
}
gui_main_loop ();
server_disconnect_all ();
/* save config file */
config_write (NULL);
/* program ending */
wee_shutdown ();
/* make gcc happy (statement never executed) */
return 0;
}

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 2003 by FlashCode <flashcode@flashtux.org>
* Bounga <bounga@altern.org>
* Xahlexx <xahlexx@tuxisland.org>
* See README for License detail.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WEECHAT_H
#define __WEECHAT_H 1
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#define PACKAGE "weechat"
#define _(string) gettext(string)
#define N_(string) (string)
#define WEECHAT_NAME "WeeChat"
#define WEECHAT_VERSION "0.0.3-pre2"
#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION
#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team"
#define WEECHAT_WEBSITE "http://weechat.flashtux.org"
#define WEECHAT_ERROR _(WEECHAT_NAME " Error:")
#define WEECHAT_WARNING _(WEECHAT_NAME " Warning:")
/* debug mode, 0=normal use, 1=some debug msg, 2=full debug (developers only) */
#define DEBUG 0
/* log file */
#define WEECHAT_LOG_NAME "weechat.log"
/* license */
#define WEE_LICENSE \
WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \
"Developed by FlashCode <flashcode@flashtux.org>\n" \
" Bounga <bounga@altern.org>\n" \
" Xahlexx <xahlexx@tuxisland.org>\n\n" \
"This program is free software; you can redistribute it and/or modify\n" \
"it under the terms of the GNU General Public License as published by\n" \
"the Free Software Foundation; either version 2 of the License, or\n" \
"(at your option) any later version.\n" \
"\n", \
\
"This program is distributed in the hope that it will be useful,\n" \
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \
"GNU General Public License for more details.\n" \
"\n" \
"You should have received a copy of the GNU General Public License\n" \
"along with this program; if not, write to the Free Software\n" \
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n"
#define WEE_USAGE \
WEECHAT_NAME_AND_VERSION " (c) Copyright 2003, compiled on " __DATE__ __TIME__ \
"Developed by FlashCode <flashcode@flashtux.org>\n" \
" Bounga <bounga@altern.org>\n" \
" Xahlexx <xahlexx@tuxisland.org>\n\n" \
" Bounga <bounga@altern.org>\n" \
" Xahlexx <xahlexx@tuxisland.org>\n\n" \
" -h, --help this help screen\n", \
" -l, --license display WeeChat license\n" \
" -v, --version display WeeChat version\n\n"
/* " -d, --display choose X display\n" \*/
/*#define DEFAULT_DISPLAY ":0" */
/*extern char *display_name; */
int quit_weechat;
extern int quit_weechat;
extern void log_printf (char *, ...);
extern void wee_shutdown ();
#endif /* weechat.h */

View File

@ -0,0 +1,30 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
if GUI_CURSES
curses_dir=curses
endif
if GUI_GTK
gtk_dir=gtk
endif
if GUI_QT
qt_dir=qt
endif
SUBDIRS = $(curses_dir) $(gtk_dir) $(qt_dir)

View File

@ -0,0 +1,26 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
bin_PROGRAMS = weechat-curses
weechat_curses_LDADD = ../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
$(CURSES_LIBS)
weechat_curses_SOURCES = ../gui-common.c \
gui-display.c \
gui-input.c

View File

@ -29,10 +29,11 @@
#include <string.h>
#include <signal.h>
#include <time.h>
#include <curses.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../common/config.h"
#include "../../irc/irc.h"
@ -150,6 +151,17 @@ gui_window_set_color (WINDOW *window, int num_color)
}
}
/*
* gui_window_has_nicklist: returns 1 if window has nicklist
*/
int
gui_window_has_nicklist (t_gui_window *window)
{
return (window->win_nick != NULL);
}
/*
* gui_calculate_pos_size: calculate position and size for a window & sub-win
*/
@ -1245,6 +1257,18 @@ gui_window_init_subwindows (t_gui_window *window)
window->win_input = NULL;
}
/*
* gui_pre_init: pre-initialize GUI (called before gui_init)
*/
void
gui_pre_init (int *argc, char **argv[])
{
/* nothing for Curses interface */
(void) argc;
(void) argv;
}
/*
* gui_init_colors: init GUI colors
*/

View File

@ -30,13 +30,15 @@
#include <signal.h>
#include <time.h>
#include <sys/socket.h>
#include <curses.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../command.h"
#include "../../common/config.h"
#include "../../common/command.h"
#include "../../irc/irc.h"
#define KEY_ESCAPE 27
/*
* gui_read_keyb: read keyboard line

View File

@ -0,0 +1,28 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
bin_PROGRAMS = weechat-gtk
INCLUDES = $(GTK_CFLAGS)
weechat_gtk_LDADD = ../../common/lib_weechat_main.a \
../../irc/lib_weechat_irc.a \
$(GTK_LIBS)
weechat_gtk_SOURCES = ../gui-common.c \
gui-display.c \
gui-input.c

View File

@ -29,10 +29,11 @@
#include <string.h>
#include <signal.h>
#include <time.h>
#include <gtk/gtk.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../common/config.h"
#include "../../irc/irc.h"
@ -143,6 +144,16 @@ gui_get_color_by_value (int color_value)
return NULL;
}
/*
* gui_window_has_nicklist: returns 1 if window has nicklist
*/
int
gui_window_has_nicklist (t_gui_window *window)
{
return (window->textbuffer_nicklist != NULL);
}
/*
* gui_calculate_pos_size: calculate position and size for a window & sub-win
*/
@ -379,7 +390,7 @@ gui_redraw_window (t_gui_window *window)
gui_redraw_window_title (window);
gui_redraw_window_chat (window);
if (WIN_HAS_NICKLIST(window))
if (gui_window_has_nicklist (window))
gui_redraw_window_nick (window);
gui_redraw_window_status (window);
gui_redraw_window_input (window);
@ -537,6 +548,17 @@ gui_window_init_subwindows (t_gui_window *window)
window->textbuffer_nicklist = NULL;
}
/*
* gui_pre_init: pre-initialize GUI (called before gui_init)
*/
void
gui_pre_init (int *argc, char **argv[])
{
/* Initialise Gtk+ */
gtk_init (argc, argv);
}
/*
* gui_init_colors: init GUI colors
*/

View File

@ -30,11 +30,12 @@
#include <signal.h>
#include <time.h>
#include <sys/socket.h>
#include <gtk/gtk.h>
#include "../../weechat.h"
#include "../../common/weechat.h"
#include "../gui.h"
#include "../../config.h"
#include "../../command.h"
#include "../../common/config.h"
#include "../../common/command.h"
#include "../../irc/irc.h"

View File

@ -31,7 +31,7 @@
#include <time.h>
#include <curses.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "gui.h"
#include "../irc/irc.h"

View File

@ -23,19 +23,8 @@
#ifndef __WEECHAT_GUI_H
#define __WEECHAT_GUI_H 1
#ifdef WEE_CURSES
#include <curses.h>
#endif
#ifdef WEE_GTK
#include <gtk/gtk.h>
#endif
#include "../completion.h"
#include "../history.h"
#ifdef WEE_CURSES
#define KEY_ESCAPE 27
#endif
#include "../common/completion.h"
#include "../common/history.h"
#define INPUT_BUFFER_BLOCK_SIZE 256
@ -77,10 +66,10 @@
#define WIN_IS_PRIVATE(window) (CHANNEL(window) && (CHANNEL(window)->type == CHAT_PRIVATE))
#ifdef WEE_CURSES
#define WIN_HAS_NICKLIST(window) (window->win_nick)
//#define WIN_HAS_NICKLIST(window) (window->win_nick)
#endif
#ifdef WEE_GTK
#define WIN_HAS_NICKLIST(window) (window->textbuffer_nicklist)
//#define WIN_HAS_NICKLIST(window) (window->textbuffer_nicklist)
#endif
#define MSG_TYPE_TIME 0
@ -152,24 +141,27 @@ struct t_gui_window
int win_nick_width; /* width of chat window */
int win_nick_height; /* height of chat window */
/* windows */
#ifdef WEE_CURSES
WINDOW *win_title; /* title window */
WINDOW *win_chat; /* chat window (exemple: channel) */
WINDOW *win_nick; /* nick window */
WINDOW *win_status; /* status window */
WINDOW *win_input; /* input window */
#endif
#ifdef WEE_GTK
GtkWidget *textview_chat; /* textview widget for chat */
GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */
GtkTextTag *texttag_chat; /* texttag widget for chat */
GtkWidget *textview_nicklist; /* textview widget for nicklist */
GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */
#endif
#ifdef WEE_QT
/* windows for Curses GUI */
void *win_title; /* title window */
void *win_chat; /* chat window (exemple: channel) */
void *win_nick; /* nick window */
void *win_status; /* status window */
void *win_input; /* input window */
/* windows for Curses GUI */
//GtkWidget *textview_chat; /* textview widget for chat */
//GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */
//GtkTextTag *texttag_chat; /* texttag widget for chat */
//GtkWidget *textview_nicklist; /* textview widget for nicklist */
//GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */
void *textview_chat; /* textview widget for chat */
void *textbuffer_chat; /* textbuffer widget for chat */
void *texttag_chat; /* texttag widget for chat */
void *textview_nicklist; /* textview widget for nicklist */
void *textbuffer_nicklist; /* textbuffer widget for nicklist */
/* windows for Curses GUI */
/* TODO: declare Qt window */
#endif
/* chat content (lines, line is composed by many messages) */
t_gui_line *lines; /* lines of chat window */
@ -222,6 +214,7 @@ extern void gui_buffer_insert_string (char *, int);
extern int gui_assign_color (int *, char *);
extern int gui_get_color_by_name (char *);
extern char *gui_get_color_by_value (int);
extern int gui_window_has_nicklist (t_gui_window *);
extern void gui_calculate_pos_size (t_gui_window *);
extern void gui_draw_window_title (t_gui_window *);
extern void gui_redraw_window_title (t_gui_window *);
@ -240,7 +233,8 @@ extern void gui_switch_to_next_window ();
extern void gui_move_page_up ();
extern void gui_move_page_down ();
extern void gui_window_init_subwindows (t_gui_window *);
extern void gui_init_colors ();
extern void gui_pre_init (int *, char **[]);
//extern void gui_init_colors ();
extern void gui_init ();
extern void gui_window_free (t_gui_window *);
extern void gui_end ();

View File

@ -0,0 +1,16 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

View File

@ -0,0 +1,26 @@
# Copyright (c) 2003 FlashCode <flashcode@flashtux.org>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
noinst_LIBRARIES = lib_weechat_irc.a
lib_weechat_irc_a_SOURCES = irc-commands.c \
irc-send.c \
irc-recv.c \
irc-server.c \
irc-channel.c \
irc-nick.c \
irc-display.c

View File

@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"

View File

@ -24,9 +24,9 @@
RFC 1459,2810,2811,2812 */
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../command.h"
#include "../common/command.h"
t_irc_command irc_commands[] =

View File

@ -28,9 +28,9 @@
#include <stdio.h>
#include <string.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../config.h"
#include "../common/config.h"
#include "../gui/gui.h"

View File

@ -27,7 +27,7 @@
#include <string.h>
#include <limits.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"

View File

@ -32,10 +32,10 @@
#include <time.h>
#include <sys/utsname.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../command.h"
#include "../config.h"
#include "../common/command.h"
#include "../common/config.h"
#include "../gui/gui.h"
@ -501,7 +501,7 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *arguments)
COLOR_WIN_CHAT_NICK,
"%s\n",
arguments);
if (WIN_HAS_NICKLIST(ptr_channel->window))
if (gui_window_has_nicklist (ptr_channel->window))
gui_redraw_window_nick (ptr_channel->window);
}
}
@ -692,7 +692,7 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
gui_printf (ptr_channel->window, "\n");
/* redraw nick list if this is current window */
if (WIN_HAS_NICKLIST(ptr_channel->window))
if (gui_window_has_nicklist (ptr_channel->window))
gui_redraw_window_nick (ptr_channel->window);
}
}
@ -978,7 +978,7 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
gui_printf_color (ptr_channel->window,
COLOR_WIN_CHAT_DARK, ")\n");
if ((ptr_channel->window == gui_current_window) &&
(WIN_HAS_NICKLIST(ptr_channel->window)))
(gui_window_has_nicklist (ptr_channel->window)))
gui_redraw_window_nick (ptr_channel->window);
}
}

View File

@ -32,10 +32,10 @@
#include <time.h>
#include <sys/utsname.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../command.h"
#include "../config.h"
#include "../common/command.h"
#include "../common/config.h"
#include "../gui/gui.h"

View File

@ -34,7 +34,7 @@
#include <arpa/inet.h>
#include <netdb.h>
#include "../weechat.h"
#include "../common/weechat.h"
#include "irc.h"
#include "../gui/gui.h"