Пример #1
0
/* SYNTAX: ECHO [-current] [-window <name>] [-level <level>] <text> */
static void cmd_echo(const char *data, void *server, WI_ITEM_REC *item)
{
    WINDOW_REC *window;
    GHashTable *optlist;
    char *msg, *levelstr, *winname;
    void *free_arg;
    int level;

    g_return_if_fail(data != NULL);

    if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
                        PARAM_FLAG_GETREST, "echo", &optlist, &msg))
        return;

    levelstr = g_hash_table_lookup(optlist, "level");
    level = levelstr == NULL ? 0 :
            level2bits(g_hash_table_lookup(optlist, "level"), NULL);
    if (level == 0) level = MSGLEVEL_CRAP;

    winname = g_hash_table_lookup(optlist, "window");
    window = winname == NULL ? NULL :
             is_numeric(winname, '\0') ?
             window_find_refnum(atoi(winname)) :
             window_find_item(NULL, winname);
    if (window == NULL) window = active_win;

    printtext_window(window, level, "%s", msg);
    cmd_params_free(free_arg);
}
Пример #2
0
static void sig_exec_input(PROCESS_REC *rec, const char *text)
{
	WI_ITEM_REC *item;
	SERVER_REC *server;
        char *str;

	if (rec->quiet)
		return;

        item = NULL;
	server = NULL;

	if (rec->target != NULL) {
		item = window_item_find(NULL, rec->target);
		server = item != NULL ? item->server :
			active_win->active_server;

		str = g_strconcat(rec->target_nick ? "-nick " :
				  rec->target_channel ? "-channel " : "",
				  rec->target, " ", text, NULL);
		signal_emit(rec->notice ? "command notice" : "command msg",
			    3, str, server, item);
                g_free(str);
	} else if (rec->target_item != NULL) {
		printtext(NULL, rec->target_item->visible_name,
			  rec->level, "%s", text);
	} else {
		printtext_window(rec->target_win, rec->level, "%s", text);
	}
}
Пример #3
0
static void sig_exec_input(PROCESS_REC *rec, const char *text)
{
	WI_ITEM_REC *item;
	SERVER_REC *server;
        char *str;

        item = NULL;
	server = NULL;

	if (rec->target != NULL) {
		item = window_item_find(NULL, rec->target);
		server = item != NULL ? item->server :
			active_win->active_server;

                str = g_strconcat(rec->target, " ", text, NULL);
		signal_emit(rec->notice ? "command notice" : "command msg",
			    3, str, server, item);
                g_free(str);
	} else if (rec->target_item != NULL) {
		printtext(NULL, rec->target_item->name, MSGLEVEL_CLIENTCRAP,
			  "%s", text);
	} else {
		printtext_window(rec->target_win, MSGLEVEL_CLIENTCRAP,
				 "%s", text);
	}
}
Пример #4
0
static void textui_finish_init(void)
{
	quitting = FALSE;

	screen_refresh_freeze();
	gui_entry_init();
	gui_printtext_init();
	gui_readline_init();
	gui_special_vars_init();
	gui_textwidget_init();
	mainwindows_init();
	mainwindow_activity_init();
	gui_windows_init();
	statusbar_init();

	fe_common_core_finish_init();
	fe_common_irc_finish_init();

#ifdef HAVE_STATIC_PERL
        perl_init();
#endif
	signal_emit("irssi init finished", 0);

	if (display_firsttimer) {
		printtext_window(active_win, MSGLEVEL_CLIENTNOTICE,
				 "%s", firsttimer_text);
	}

	screen_refresh_thaw();
}
Пример #5
0
static void textui_finish_init(void)
{
	quitting = FALSE;

	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();

		/* don't check settings with dummy mode */
		settings_check();
	}

	module_register("core", "fe-text");

#ifdef HAVE_STATIC_PERL
	perl_core_init();
	fe_perl_init();
#endif

	dirty_check();

	fe_common_core_finish_init();
	signal_emit("irssi init finished", 0);

	if (display_firsttimer) {
		printtext_window(active_win, MSGLEVEL_CLIENTNOTICE,
				 "%s", firsttimer_text);
	}
}
Пример #6
0
static void show_lastlog(const char *searchtext, GHashTable *optlist,
			 int start, int count, FILE *fhandle)
{
	WINDOW_REC *window;
        LINE_REC *startline;
	GList *list, *tmp;
	GString *line;
        char *str;
	int level, before, after, len, date = FALSE;

        level = cmd_options_get_level("lastlog", optlist);
	if (level == -1) return; /* error in options */
        if (level == 0) level = MSGLEVEL_ALL;

	if (g_hash_table_lookup(optlist, "clear") != NULL) {
		textbuffer_view_remove_lines_by_level(WINDOW_GUI(active_win)->view, MSGLEVEL_LASTLOG);
		if (*searchtext == '\0')
                        return;
	}

        /* which window's lastlog to look at? */
        window = active_win;
        str = g_hash_table_lookup(optlist, "window");
	if (str != NULL) {
		window = is_numeric(str, '\0') ?
			window_find_refnum(atoi(str)) :
			window_find_item(NULL, str);
		if (window == NULL) {
			printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
                                    TXT_REFNUM_NOT_FOUND, str);
			return;
		}
	}

	if (g_hash_table_lookup(optlist, "new") != NULL)
		startline = textbuffer_view_get_bookmark(WINDOW_GUI(window)->view, "lastlog_last_check");
	else if (g_hash_table_lookup(optlist, "away") != NULL)
		startline = textbuffer_view_get_bookmark(WINDOW_GUI(window)->view, "lastlog_last_away");
	else
		startline = NULL;

	if (startline == NULL)
                startline = textbuffer_view_get_lines(WINDOW_GUI(window)->view);

	str = g_hash_table_lookup(optlist, "#");
	if (str != NULL) {
		before = after = atoi(str);
	} else {
		str = g_hash_table_lookup(optlist, "before");
		before = str == NULL ? 0 : *str != '\0' ?
			atoi(str) : DEFAULT_LASTLOG_BEFORE;

		str = g_hash_table_lookup(optlist, "after");
		if (str == NULL) str = g_hash_table_lookup(optlist, "a");
		after = str == NULL ? 0 : *str != '\0' ?
			atoi(str) : DEFAULT_LASTLOG_AFTER;
	}

	if (g_hash_table_lookup(optlist, "date") != NULL)
		date = TRUE;

	list = textbuffer_find_text(WINDOW_GUI(window)->view->buffer, startline,
				    level, MSGLEVEL_LASTLOG,
				    searchtext, before, after,
				    g_hash_table_lookup(optlist, "regexp") != NULL,
				    g_hash_table_lookup(optlist, "word") != NULL,
				    g_hash_table_lookup(optlist, "case") != NULL);

        len = g_list_length(list);
	if (count <= 0)
		tmp = list;
	else {
		int pos = len-count-start;
		if (pos < 0) pos = 0;

		tmp = pos > len ? NULL : g_list_nth(list, pos);
		len = g_list_length(tmp);
	}

	if (g_hash_table_lookup(optlist, "count") != NULL) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_LASTLOG_COUNT, len);
		g_list_free(list);
		return;
	}

	if (len > MAX_LINES_WITHOUT_FORCE && fhandle == NULL &&
	    g_hash_table_lookup(optlist, "force") == NULL) {
		printformat_window(active_win,
				   MSGLEVEL_CLIENTNOTICE|MSGLEVEL_LASTLOG,
				   TXT_LASTLOG_TOO_LONG, len);
		g_list_free(list);
		return;
	}

	if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL)
		printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_START);

	line = g_string_new(NULL);
        while (tmp != NULL && (count < 0 || count > 0)) {
		LINE_REC *rec = tmp->data;

		if (rec == NULL) {
			if (tmp->next == NULL)
                                break;
			if (fhandle != NULL) {
				fwrite("--\n", 3, 1, fhandle);
			} else {
				printformat_window(active_win,
						   MSGLEVEL_LASTLOG,
						   TXT_LASTLOG_SEPARATOR);
			}
                        tmp = tmp->next;
			continue;
		}

                /* get the line text */
		textbuffer_line2text(rec, fhandle == NULL, line);
		if (!settings_get_bool("timestamps")) {
			struct tm *tm = localtime(&rec->info.time);
                        char timestamp[10];

			g_snprintf(timestamp, sizeof(timestamp),
				   "%02d:%02d ",
				   tm->tm_hour, tm->tm_min);
                        g_string_prepend(line, timestamp);
		}

		if (date == TRUE)
			prepend_date(window, rec, line);

                /* write to file/window */
		if (fhandle != NULL) {
			fwrite(line->str, line->len, 1, fhandle);
			fputc('\n', fhandle);
		} else {
			printtext_window(active_win, MSGLEVEL_LASTLOG,
					 "%s", line->str);
		}

		count--;
		tmp = tmp->next;
	}
        g_string_free(line, TRUE);

	if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL)
		printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_END);

	textbuffer_view_set_bookmark_bottom(WINDOW_GUI(window)->view,
					    "lastlog_last_check");

	g_list_free(list);
}
Пример #7
0
/* SYNTAX: ECHO [<text>] */
static void cmd_echo(const char *data, void *server, WI_ITEM_REC *item)
{
	g_return_if_fail(data != NULL);

	printtext_window(active_win, MSGLEVEL_CRAP, "%s", data);
}