Exemplo n.º 1
0
/* SYNTAX: WINDOW IMMORTAL on|off|toggle */
static void cmd_window_immortal(const char *data)
{
	int set;

	if (*data == '\0')
		set = active_win->immortal;
	else if (g_ascii_strcasecmp(data, "ON") == 0)
                set = TRUE;
	else if (g_ascii_strcasecmp(data, "OFF") == 0)
                set = FALSE;
	else if (g_ascii_strcasecmp(data, "TOGGLE") == 0)
                set = !active_win->immortal;
	else {
		printformat_window(active_win, MSGLEVEL_CLIENTERROR,
				   TXT_NOT_TOGGLE);
		return;
	}

	if (set) {
                window_set_immortal(active_win, TRUE);
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_SET_IMMORTAL);
	} else {
                window_set_immortal(active_win, FALSE);
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_UNSET_IMMORTAL);
	}
}
Exemplo n.º 2
0
/* SYNTAX: WINDOW SERVER [-sticky | -unsticky] <tag> */
static void cmd_window_server(const char *data)
{
	GHashTable *optlist;
	SERVER_REC *server;
        char *tag;
	void *free_arg;

	if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
			    "window server", &optlist, &tag))
		return;

	if (*tag == '\0' && active_win->active_server != NULL &&
	    (g_hash_table_lookup(optlist, "sticky") != NULL ||
	     g_hash_table_lookup(optlist, "unsticky") != NULL)) {
		tag = active_win->active_server->tag;
	}

	if (*tag == '\0')
		cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
	server = server_find_tag(tag);
	if (server == NULL)
		server = server_find_lookup_tag(tag);

	if (g_hash_table_lookup(optlist, "unsticky") != NULL &&
	    active_win->servertag != NULL) {
		g_free_and_null(active_win->servertag);
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_UNSET_SERVER_STICKY);
	}

	if (active_win->servertag != NULL &&
	    g_hash_table_lookup(optlist, "sticky") == NULL) {
		printformat_window(active_win, MSGLEVEL_CLIENTERROR,
				   TXT_ERROR_SERVER_STICKY);
	} else if (server == NULL) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_UNKNOWN_SERVER_TAG, tag);
	} else if (active_win->active == NULL) {
		window_change_server(active_win, server);
		if (g_hash_table_lookup(optlist, "sticky") != NULL) {
                        g_free_not_null(active_win->servertag);
			active_win->servertag = g_strdup(server->tag);
			printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
					   TXT_SET_SERVER_STICKY, server->tag);
		}
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_SERVER_CHANGED,
				   server->tag, server->connrec->address,
				   server->connrec->chatnet == NULL ? "" :
				   server->connrec->chatnet);
	}

	cmd_params_free(free_arg);
}
Exemplo n.º 3
0
/* SYNTAX: WINDOW NUMBER [-sticky] <number> */
static void cmd_window_number(const char *data)
{
	GHashTable *optlist;
        char *refnum;
	void *free_arg;
        int num;

	if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
			    "window number", &optlist, &refnum))
		return;

	if (*refnum == '\0')
		cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);

	num = atoi(refnum);
	if (num < 1) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_REFNUM_TOO_LOW);
	} else {
		window_set_refnum(active_win, num);
		active_win->sticky_refnum =
			g_hash_table_lookup(optlist, "sticky") != NULL;
	}

        cmd_params_free(free_arg);
}
Exemplo n.º 4
0
static void cmd_window_scroll(const char *data)
{
	GUI_WINDOW_REC *gui;

	gui = WINDOW_GUI(active_win);
	if (g_strcasecmp(data, "default") == 0) {
                gui->use_scroll = FALSE;
	} else if (g_strcasecmp(data, "on") == 0) {
		gui->use_scroll = TRUE;
		gui->scroll = TRUE;
	} else if (g_strcasecmp(data, "off") == 0) {
		gui->use_scroll = TRUE;
		gui->scroll = FALSE;
	} else if (*data != '\0') {
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
			    TXT_WINDOW_SCROLL_UNKNOWN, data);
                return;
	}

	printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
			   TXT_WINDOW_SCROLL, !gui->use_scroll ? "DEFAULT" :
			   gui->scroll ? "ON" : "OFF");
	textbuffer_view_set_scroll(gui->view, gui->use_scroll ?
				   gui->scroll : settings_get_bool("scroll"));
}
Exemplo n.º 5
0
static void window_print_binds(WINDOW_REC *win)
{
	GSList *tmp;

	printformat_window(win, MSGLEVEL_CLIENTCRAP,
			   TXT_WINDOW_INFO_BOUND_ITEMS_HEADER);
	for (tmp = win->bound_items; tmp != NULL; tmp = tmp->next) {
		WINDOW_BIND_REC *bind = tmp->data;

		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_BOUND_ITEM,
				   bind->name, bind->servertag,
				   bind->sticky ? "sticky" : "");
	}
	printformat_window(win, MSGLEVEL_CLIENTCRAP,
			   TXT_WINDOW_INFO_BOUND_ITEMS_FOOTER);
}
Exemplo n.º 6
0
/* SYNTAX: WINDOW THEME <name> */
static void cmd_window_theme(const char *data)
{
	THEME_REC *theme;

	g_free_not_null(active_win->theme_name);
	active_win->theme_name = g_strdup(data);

	active_win->theme = theme = theme_load(data);
	if (theme != NULL) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_THEME_CHANGED,
				   theme->name, theme->path);
	} else {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_THEME_NOT_FOUND, data);
	}
}
Exemplo n.º 7
0
/* SYNTAX: WINDOW SHRINK [<lines>] */
static void cmd_window_shrink(const char *data)
{
	int count;

	count = *data == '\0' ? 1 : atoi(data);
	if (!mainwindow_shrink(WINDOW_MAIN(active_win), count, FALSE)) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_TOO_SMALL);
	}
}
Exemplo n.º 8
0
/* SYNTAX: WINDOW THEME [-delete] [<name>] */
static void cmd_window_theme(const char *data)
{
	THEME_REC *theme;
	GHashTable *optlist;
        char *name;
	void *free_arg;

	if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS,
			    "window theme", &optlist, &name))
		return;

	if (g_hash_table_lookup(optlist, "delete") != NULL) {
		g_free_and_null(active_win->theme_name);

		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_THEME_REMOVED);
	} else if (*name == '\0') {
		if (active_win->theme == NULL) {
			printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
					   TXT_WINDOW_THEME_DEFAULT);
		} else {
                        theme = active_win->theme;
			printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
					   TXT_WINDOW_THEME,
					   theme->name, theme->path);
		}
	} else {
		g_free_not_null(active_win->theme_name);
		active_win->theme_name = g_strdup(data);

		active_win->theme = theme = theme_load(data);
		if (theme != NULL) {
			printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
					   TXT_WINDOW_THEME_CHANGED,
					   theme->name, theme->path);
		} else {
			printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
					   TXT_THEME_NOT_FOUND, data);
		}
	}

	cmd_params_free(free_arg);
}
Exemplo n.º 9
0
static void window_print_items(WINDOW_REC *win)
{
	GSList *tmp;
        const char *type;

	printformat_window(win, MSGLEVEL_CLIENTCRAP,
			   TXT_WINDOW_INFO_ITEMS_HEADER);
	for (tmp = win->items; tmp != NULL; tmp = tmp->next) {
		WI_ITEM_REC *item = tmp->data;

		type = module_find_id_str("WINDOW ITEM TYPE", item->type);
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_ITEM,
				   type == NULL ? "??" : type,
				   item->visible_name,
				   item->server == NULL ? "" :
				   item->server->tag);
	}
	printformat_window(win, MSGLEVEL_CLIENTCRAP,
			   TXT_WINDOW_INFO_ITEMS_FOOTER);
}
Exemplo n.º 10
0
/* SYNTAX: WINDOW STICK [<ref#>] [ON|OFF] */
static void cmd_window_stick(const char *data)
{
        MAIN_WINDOW_REC *mainwin;
        WINDOW_REC *win;

        mainwin = active_mainwin;
        win = active_mainwin->active;

	if (is_numeric(data, ' ')) {
		/* ref# specified */
		win = window_find_refnum(atoi(data));
		if (win == NULL) {
			printformat_window(active_win, MSGLEVEL_CLIENTERROR,
					   TXT_REFNUM_NOT_FOUND, data);
			return;
		}

		while (*data != ' ' && *data != '\0') data++;
		while (*data == ' ') data++;
	}

	if (g_strncasecmp(data, "OF", 2) == 0 || i_toupper(*data) == 'N') {
		/* unset sticky */
		if (!WINDOW_GUI(win)->sticky) {
			printformat_window(win, MSGLEVEL_CLIENTERROR,
					   TXT_WINDOW_NOT_STICKY);
		} else {
                        gui_window_set_unsticky(win);
			printformat_window(win, MSGLEVEL_CLIENTNOTICE,
					   TXT_WINDOW_UNSET_STICKY);
		}
	} else {
		/* set sticky */
		window_reparent(win, mainwin);
                gui_window_set_sticky(win);

		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_SET_STICKY);
	}
}
Exemplo n.º 11
0
/* SYNTAX: WINDOW NAME <name> */
static void cmd_window_name(const char *data)
{
	WINDOW_REC *win;

	win = window_find_name(data);
	if (win == NULL || win == active_win)
		window_set_name(active_win, data);
	else if (active_win->name == NULL ||
		 strcmp(active_win->name, data) != 0) {
		printformat_window(active_win, MSGLEVEL_CLIENTERROR,
				   TXT_WINDOW_NAME_NOT_UNIQUE, data);
	}
}
Exemplo n.º 12
0
/* SYNTAX: WINDOW GROW [<lines>] */
static void cmd_window_grow(const char *data)
{
	MAIN_WINDOW_REC *window;
	int count;

	count = *data == '\0' ? 1 : atoi(data);
	window = WINDOW_MAIN(active_win);

	if (!mainwindow_grow(window, count, FALSE)) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_WINDOW_TOO_SMALL);
	}
}
Exemplo n.º 13
0
/* SYNTAX: WINDOW HIDE [<number>|<name>] */
static void cmd_window_hide(const char *data)
{
	WINDOW_REC *window;

	if (mainwindows->next == NULL) {
		printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
				   TXT_CANT_HIDE_LAST);
		return;
	}

	if (*data == '\0')
		window = active_win;
	else if (is_numeric(data, 0)) {
		window = window_find_refnum(atoi(data));
		if (window == NULL) {
			printformat_window(active_win, MSGLEVEL_CLIENTERROR,
					   TXT_REFNUM_NOT_FOUND, data);
		}
	} else {
		window = window_find_item(active_win->active_server, data);
	}

	if (window == NULL || !is_window_visible(window))
		return;

	if (WINDOW_MAIN(window)->sticky_windows) {
		printformat_window(active_win, MSGLEVEL_CLIENTERROR,
				   TXT_CANT_HIDE_STICKY_WINDOWS);
                return;
	}

	mainwindow_destroy(WINDOW_MAIN(window));

	if (active_mainwin == NULL) {
		active_mainwin = WINDOW_MAIN(active_win);
                window_set_active(active_mainwin->active);
	}
}
Exemplo n.º 14
0
static void sig_window_print_info(WINDOW_REC *win)
{
	GUI_WINDOW_REC *gui;

	gui = WINDOW_GUI(win);
	if (gui->use_scroll) {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_SCROLL,
				   gui->scroll ? "yes" : "no");
	}

	if (WINDOW_MAIN(win)->sticky_windows)
                windows_print_sticky(win);
}
Exemplo n.º 15
0
/* SYNTAX: WINDOW LEVEL [<level>] */
static void cmd_window_level(const char *data)
{
	char *level;

	g_return_if_fail(data != NULL);

	window_set_level(active_win, combine_level(active_win->level, data));

	level = active_win->level == 0 ? g_strdup("NONE") :
		bits2level(active_win->level);
	printformat_window(active_win, MSGLEVEL_CLIENTNOTICE,
			   TXT_WINDOW_LEVEL, level);
	g_free(level);
}
Exemplo n.º 16
0
/* SYNTAX: WINDOW SHOW <number>|<name> */
static void cmd_window_show(const char *data)
{
        MAIN_WINDOW_REC *parent;
	WINDOW_REC *window;

	if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);

	if (is_numeric(data, '\0')) {
                window = window_find_refnum(atoi(data));
		if (window == NULL) {
			printformat_window(active_win, MSGLEVEL_CLIENTERROR,
					   TXT_REFNUM_NOT_FOUND, data);
		}
	} else {
		window = window_find_item(active_win->active_server, data);
	}

	if (window == NULL || is_window_visible(window))
		return;

	if (WINDOW_MAIN(window)->sticky_windows) {
		printformat_window(active_win, MSGLEVEL_CLIENTERROR,
				   TXT_CANT_SHOW_STICKY_WINDOWS);
                return;
	}

	parent = mainwindow_create();
	parent->active = window;
        gui_window_reparent(window, parent);

	if (settings_get_bool("autostick_split_windows"))
                gui_window_set_sticky(window);

	active_mainwin = NULL;
	window_set_active(window);
}
Exemplo n.º 17
0
/* SYNTAX: WINDOW CLOSE [<first> [<last>]] */
static void cmd_window_close(const char *data)
{
        GSList *tmp, *destroys;
	char *first, *last;
        int first_num, last_num;
	void *free_arg;

	if (!cmd_get_params(data, &free_arg, 2, &first, &last))
		return;

	if ((*first != '\0' && !is_numeric(first, '\0')) ||
	    ((*last != '\0') && !is_numeric(last, '\0'))) {
		cmd_params_free(free_arg);
                return;
	}

	first_num = *first == '\0' ? active_win->refnum : atoi(first);
	last_num = *last == '\0' ? first_num : atoi(last);

        /* get list of windows to destroy */
        destroys = NULL;
	for (tmp = windows; tmp != NULL; tmp = tmp->next) {
		WINDOW_REC *rec = tmp->data;

		if (rec->refnum >= first_num && rec->refnum <= last_num)
			destroys = g_slist_append(destroys, rec);
	}

        /* really destroy the windows */
	while (destroys != NULL) {
		WINDOW_REC *rec = destroys->data;

		if (windows->next != NULL) {
			if (!rec->immortal)
				window_destroy(rec);
			else {
				printformat_window(rec, MSGLEVEL_CLIENTERROR,
						   TXT_WINDOW_IMMORTAL_ERROR);
			}
		}

                destroys = g_slist_remove(destroys, rec);
	}

	cmd_params_free(free_arg);
}
Exemplo n.º 18
0
static void sig_print_text(void)
{
	GSList *tmp;
	char month[10];
	time_t t;
	struct tm *tm;

	t = time(NULL);
	tm = localtime(&t);
	strftime(month, sizeof(month)-1, "%b", tm);

	if (tm->tm_hour != 0 || tm->tm_min != 0)
		return;

	daycheck = 2;
	signal_remove("print text", (SIGNAL_FUNC) sig_print_text);

	/* day changed, print notice about it to every window */
	for (tmp = windows; tmp != NULL; tmp = tmp->next) {
		printformat_window(tmp->data, MSGLEVEL_NEVER, IRCTXT_DAYCHANGE,
				   tm->tm_mday, tm->tm_mon+1, 1900+tm->tm_year, month);
	}
}
Exemplo n.º 19
0
static void windows_print_sticky(WINDOW_REC *win)
{
        MAIN_WINDOW_REC *mainwin;
        GSList *tmp, *list;
	GString *str;

        mainwin = WINDOW_MAIN(win);

        /* convert to string */
	str = g_string_new(NULL);
	list = get_sticky_windows_sorted(mainwin);
	for (tmp = list; tmp != NULL; tmp = tmp->next) {
		WINDOW_REC *rec = tmp->data;

		g_string_sprintfa(str, "#%d, ", rec->refnum);
	}
        g_string_truncate(str, str->len-2);
        g_slist_free(list);

	printformat_window(win, MSGLEVEL_CLIENTCRAP,
			   TXT_WINDOW_INFO_STICKY, str->str);
        g_string_free(str, TRUE);
}
Exemplo n.º 20
0
static void cmd_window_info(WINDOW_REC *win)
{
        char *levelstr;

	printformat_window(win, MSGLEVEL_CLIENTCRAP,
			   TXT_WINDOW_INFO_HEADER);

        /* Window reference number + sticky status */
	if (!win->sticky_refnum) {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_REFNUM, win->refnum);
	} else {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_REFNUM_STICKY, win->refnum);
	}

        /* Window name */
	if (win->name != NULL) {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_NAME, win->name);
	}

        /* Window width / height */
	printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_SIZE,
			   win->width, win->height);

	/* Window immortality */
	if (win->immortal) {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_IMMORTAL);
	}

	/* Window history name */
	if (win->history_name != NULL) {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_HISTORY, win->history_name);
	}

        /* Window level */
	levelstr = win->level == 0 ?
		g_strdup("NONE") : bits2level(win->level);
	printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_LEVEL,
			   levelstr);
	g_free(levelstr);

        /* Active window server + sticky status */
	if (win->servertag == NULL) {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_SERVER,
				   win->active_server != NULL ?
				   win->active_server->tag : "NONE");
	} else {
		if (win->active_server != NULL &&
		    strcmp(win->active_server->tag, win->servertag) != 0)
                        g_warning("Active server isn't the sticky server!");

		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_SERVER_STICKY,
				   win->servertag);
	}

        /* Window theme + error status */
	if (win->theme_name != NULL) {
		printformat_window(win, MSGLEVEL_CLIENTCRAP,
				   TXT_WINDOW_INFO_THEME, win->theme_name,
				   win->theme != NULL ? "" : "(not loaded)");
	}

        /* Bound items in window */
	if (win->bound_items != NULL)
                window_print_binds(win);

        /* Item */
	if (win->items != NULL)
                window_print_items(win);

        signal_emit("window print info", 1, win);

	printformat_window(win, MSGLEVEL_CLIENTCRAP,
			   TXT_WINDOW_INFO_FOOTER);
}
Exemplo n.º 21
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);
}