diff options
-rw-r--r-- | src/fe-text/Makefile.am | 14 | ||||
-rw-r--r-- | src/fe-text/irssi.c | 91 | ||||
-rw-r--r-- | src/fe-text/term-dummy.c (renamed from src/fe-text/irssi-dummy.c) | 120 |
3 files changed, 64 insertions, 161 deletions
diff --git a/src/fe-text/Makefile.am b/src/fe-text/Makefile.am index 763ece11..e8feffaa 100644 --- a/src/fe-text/Makefile.am +++ b/src/fe-text/Makefile.am @@ -8,24 +8,18 @@ INCLUDES = \ $(CURSES_INCLUDEDIR) \ -DLOCALEDIR=\""$(datadir)/locale"\" -IRSSIDEPS = \ +irssi_DEPENDENCIES = \ @COMMON_LIBS@ \ @PERL_LINK_LIBS@ \ @PERL_FE_LINK_LIBS@ -irssi_DEPENDENCIES = $(IRSSIDEPS) -irssi_dummy_DEPENDENCIES = $(IRSSIDEPS) - -IRSSILINK = \ +irssi_LDADD = \ @COMMON_LIBS@ \ @PERL_LINK_LIBS@ \ @PERL_FE_LINK_LIBS@ \ @PERL_LINK_FLAGS@ \ @PROG_LIBS@ -irssi_LDADD = $(IRSSILINK) -irssi_dummy_LDADD = $(IRSSILINK) - tparm_sources = \ tparm.c @@ -46,9 +40,6 @@ else use_term_sources = $(terminfo_sources) endif -irssi_dummy_SOURCES = \ - irssi-dummy.c - irssi_SOURCES = \ gui-entry.c \ gui-expandos.c \ @@ -63,6 +54,7 @@ irssi_SOURCES = \ statusbar-config.c \ statusbar-items.c \ term.c \ + term-dummy.c \ $(use_tparm_sources) \ $(use_term_sources) \ textbuffer.c \ diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index 4b2ed8d8..b0b69e64 100644 --- a/src/fe-text/irssi.c +++ b/src/fe-text/irssi.c @@ -72,7 +72,10 @@ void mainwindow_activity_deinit(void); void mainwindows_layout_init(void); void mainwindows_layout_deinit(void); -static int dirty, full_redraw; +void term_dummy_init(void); +void term_dummy_deinit(void); + +static int dirty, full_redraw, dummy; static GMainLoop *main_loop; int quitting; @@ -107,7 +110,7 @@ void irssi_set_dirty(void) static void dirty_check(void) { - if (!dirty) + if (!dirty || dummy) return; term_resize_dirty(); @@ -147,21 +150,25 @@ static void textui_finish_init(void) { quitting = FALSE; - term_refresh_freeze(); - textbuffer_init(); - textbuffer_view_init(); - textbuffer_commands_init(); - textbuffer_reformat_init(); - gui_expandos_init(); - gui_printtext_init(); - gui_readline_init(); - lastlog_init(); - mainwindows_init(); - mainwindow_activity_init(); - mainwindows_layout_init(); - gui_windows_init(); - statusbar_init(); - term_refresh_thaw(); + if (dummy) + term_dummy_init(); + else { + term_refresh_freeze(); + textbuffer_init(); + textbuffer_view_init(); + textbuffer_commands_init(); + textbuffer_reformat_init(); + gui_expandos_init(); + gui_printtext_init(); + gui_readline_init(); + lastlog_init(); + mainwindows_init(); + mainwindow_activity_init(); + mainwindows_layout_init(); + gui_windows_init(); + statusbar_init(); + term_refresh_thaw(); + } settings_check(); module_register("core", "fe-text"); @@ -198,22 +205,26 @@ static void textui_deinit(void) dirty_check(); /* one last time to print any quit messages */ signal_remove("gui exit", (SIGNAL_FUNC) sig_exit); - lastlog_deinit(); - statusbar_deinit(); - gui_printtext_deinit(); - gui_readline_deinit(); - gui_windows_deinit(); - mainwindows_layout_deinit(); - mainwindow_activity_deinit(); - mainwindows_deinit(); - gui_expandos_deinit(); - textbuffer_reformat_deinit(); - textbuffer_commands_deinit(); - textbuffer_view_deinit(); - textbuffer_deinit(); - - term_refresh_thaw(); - term_deinit(); + if (dummy) + term_dummy_deinit(); + else { + lastlog_deinit(); + statusbar_deinit(); + gui_printtext_deinit(); + gui_readline_deinit(); + gui_windows_deinit(); + mainwindows_layout_deinit(); + mainwindow_activity_deinit(); + mainwindows_deinit(); + gui_expandos_deinit(); + textbuffer_reformat_deinit(); + textbuffer_commands_deinit(); + textbuffer_view_deinit(); + textbuffer_deinit(); + + term_refresh_thaw(); + term_deinit(); + } theme_unregister(); @@ -288,6 +299,12 @@ static void winsock_init(void) int main(int argc, char **argv) { + static struct poptOption options[] = { + { "dummy", 'd', POPT_ARG_NONE, &dummy, 0, "Use the dummy terminal mode", NULL }, + { NULL, '\0', 0, NULL } + }; + + dummy = FALSE; quitting = FALSE; core_init_paths(argc, argv); @@ -305,10 +322,14 @@ int main(int argc, char **argv) #endif textui_init(); + args_register(options); args_execute(argc, argv); - if (!term_init()) - g_error("Can't initialize screen handling, quitting.\n"); + if (!dummy && !term_init()) { + fprintf(stderr, "Can't initialize screen handling, quitting.\n"); + fprintf(stderr, "You can still use the dummy mode with -d parameter\n"); + return 1; + } textui_finish_init(); main_loop = g_main_new(TRUE); diff --git a/src/fe-text/irssi-dummy.c b/src/fe-text/term-dummy.c index cfab96e3..a4f5c091 100644 --- a/src/fe-text/irssi-dummy.c +++ b/src/fe-text/term-dummy.c @@ -1,7 +1,7 @@ /* - irssi-dummy.c : irssi + term-dummy.c : irssi - Copyright (C) 1999-2001 Timo Sirainen + Copyright (C) 2001 Timo Sirainen 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 @@ -19,47 +19,16 @@ */ #include "module.h" -#include "module-formats.h" -#include "modules-load.h" -#include "args.h" #include "signals.h" -#include "levels.h" -#include "core.h" -#include "settings.h" -#include "session.h" -#include "printtext.h" -#include "fe-common-core.h" #include "fe-windows.h" -#include <signal.h> - -#ifdef HAVE_STATIC_PERL -void perl_core_init(void); -void perl_core_deinit(void); - -void fe_perl_init(void); -void fe_perl_deinit(void); -#endif - -void irc_init(void); -void irc_deinit(void); - -void fe_common_irc_init(void); -void fe_common_irc_deinit(void); - -static GMainLoop *main_loop; static int newline; static GIOChannel *stdin_channel; static int readtag; static GString *input; -static void sig_exit(void) -{ - g_main_quit(main_loop); -} - static void sig_gui_printtext(WINDOW_REC *window, void *fgcolor, void *bgcolor, void *pflags, char *str, void *level) @@ -84,16 +53,6 @@ static void sig_window_created(WINDOW_REC *window) window->height = 25; } -static void dummyui_init(void) -{ - irssi_gui = IRSSI_GUI_TEXT; - - core_init(); - irc_init(); - fe_common_core_init(); - fe_common_irc_init(); -} - static void readline(void) { unsigned char buffer[128]; @@ -120,97 +79,28 @@ static void readline(void) } } -static void dummyui_finish_init(void) +void term_dummy_init(void) { - settings_check(); - module_register("core", "fe-text"); - -#ifdef HAVE_STATIC_PERL - perl_core_init(); - fe_perl_init(); -#endif - newline = TRUE; + input = g_string_new(NULL); signal_add("gui print text", (SIGNAL_FUNC) sig_gui_printtext); signal_add("gui print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished); signal_add("window created", (SIGNAL_FUNC) sig_window_created); - signal_add_last("gui exit", (SIGNAL_FUNC) sig_exit); - input = g_string_new(NULL); stdin_channel = g_io_channel_unix_new(0); readtag = g_input_add_full(stdin_channel, G_PRIORITY_HIGH, G_INPUT_READ, (GInputFunction) readline, NULL); g_io_channel_unref(stdin_channel); - - fe_common_core_finish_init(); - signal_emit("irssi init finished", 0); } -static void dummyui_deinit(void) +void term_dummy_deinit(void) { - signal(SIGINT, SIG_DFL); - - while (modules != NULL) - module_unload(modules->data); - -#ifdef HAVE_STATIC_PERL - perl_core_deinit(); - fe_perl_deinit(); -#endif - signal_remove("gui print text", (SIGNAL_FUNC) sig_gui_printtext); signal_remove("gui print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished); signal_remove("window created", (SIGNAL_FUNC) sig_window_created); - signal_remove("gui exit", (SIGNAL_FUNC) sig_exit); g_source_remove(readtag); g_string_free(input, TRUE); - - fe_common_irc_deinit(); - fe_common_core_deinit(); - irc_deinit(); - core_deinit(); -} - -#ifdef WIN32 -static void winsock_init(void) -{ - WORD wVersionRequested; - WSADATA wsaData; - - wVersionRequested = MAKEWORD(2, 2); - - if (WSAStartup(wVersionRequested, &wsaData) != 0) { - printf("Error initializing winsock\n"); - exit(1); - } -} -#endif - -int main(int argc, char **argv) -{ - core_init_paths(argc, argv); - -#ifdef WIN32 - winsock_init(); -#endif -#ifdef HAVE_SOCKS - SOCKSinit(argv[0]); -#endif - - dummyui_init(); - args_execute(argc, argv); - - dummyui_finish_init(); - - main_loop = g_main_new(TRUE); - g_main_run(main_loop); - g_main_destroy(main_loop); - - dummyui_deinit(); - - session_upgrade(); /* if we /UPGRADEd, start the new process */ - return 0; } |