mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
Added history limit (text buffer & commands)
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2004-06-05
|
||||
ChangeLog - 2004-06-13
|
||||
|
||||
|
||||
Version 0.0.7 (under dev!):
|
||||
* added history limit (text buffer & commands)
|
||||
|
||||
Version 0.0.6 (2004-06-05):
|
||||
* improved channel highlight (priority to message vs join/part)
|
||||
* fixed bug when opened private win and remote user changes his nick
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2004-06-05
|
||||
TODO - 2004-06-13
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -10,7 +10,7 @@ Legend:
|
||||
? is this really necessary?
|
||||
|
||||
|
||||
v0.0.6:
|
||||
v0.0.7:
|
||||
------
|
||||
|
||||
* General:
|
||||
@@ -18,15 +18,13 @@ v0.0.6:
|
||||
+ Solaris version
|
||||
|
||||
* IRC protocol:
|
||||
# "/mode" command: change the user/channels modes
|
||||
+ "/dcc" command (for chat and sending/receiving files)
|
||||
# "/query" command: start private conversation
|
||||
|
||||
* Interface:
|
||||
+ internationalization (traduce WeeChat in many languages)
|
||||
# display current channel modes (example : #weechat(+nt))
|
||||
|
||||
* Configuration:
|
||||
# history limit (text buffer & commands)
|
||||
+ add missing options for config file
|
||||
- add key bindings to config file
|
||||
|
||||
|
||||
+44
-3
@@ -29,11 +29,14 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "history.h"
|
||||
#include "weeconfig.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
|
||||
t_history *history_general = NULL;
|
||||
t_history *history_general_last = NULL;
|
||||
t_history *history_general_ptr = NULL;
|
||||
int num_history_general = 0;
|
||||
|
||||
|
||||
/*
|
||||
@@ -43,25 +46,63 @@ t_history *history_general_ptr = NULL;
|
||||
void
|
||||
history_add (void *window, char *string)
|
||||
{
|
||||
t_history *new_history;
|
||||
t_history *new_history, *ptr_history;
|
||||
|
||||
/* add history to general 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;
|
||||
else
|
||||
history_general_last = new_history;
|
||||
new_history->next_history = history_general;
|
||||
new_history->prev_history = NULL;
|
||||
history_general = new_history;
|
||||
num_history_general++;
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((cfg_history_max_commands > 0)
|
||||
&& (num_history_general > cfg_history_max_commands))
|
||||
{
|
||||
ptr_history = history_general_last->prev_history;
|
||||
history_general_last->prev_history->next_history = NULL;
|
||||
if (history_general_last->text)
|
||||
free (history_general_last->text);
|
||||
free (history_general_last);
|
||||
history_general_last = ptr_history;
|
||||
num_history_general--;
|
||||
}
|
||||
}
|
||||
|
||||
/* add history to local history */
|
||||
new_history = (t_history *)malloc (sizeof (t_history));
|
||||
if (new_history)
|
||||
{
|
||||
new_history->text = strdup (string);
|
||||
|
||||
/* add history to local history */
|
||||
if (((t_gui_window *)(window))->history)
|
||||
((t_gui_window *)(window))->history->prev_history = new_history;
|
||||
else
|
||||
((t_gui_window *)(window))->last_history = new_history;
|
||||
new_history->next_history = ((t_gui_window *)(window))->history;
|
||||
new_history->prev_history = NULL;
|
||||
((t_gui_window *)window)->history = new_history;
|
||||
((t_gui_window *)(window))->num_history++;
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((cfg_history_max_commands > 0)
|
||||
&& (((t_gui_window *)(window))->num_history > cfg_history_max_commands))
|
||||
{
|
||||
ptr_history = ((t_gui_window *)window)->last_history->prev_history;
|
||||
((t_gui_window *)window)->last_history->prev_history->next_history = NULL;
|
||||
if (((t_gui_window *)window)->last_history->text)
|
||||
free (((t_gui_window *)window)->last_history->text);
|
||||
free (((t_gui_window *)window)->last_history);
|
||||
((t_gui_window *)window)->last_history = ptr_history;
|
||||
((t_gui_window *)(window))->num_history++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1258,8 +1258,8 @@ config_write (char *config_name)
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) ||
|
||||
(i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY))
|
||||
if ((i == CONFIG_SECTION_LOG) || (i == CONFIG_SECTION_DCC) ||
|
||||
(i == CONFIG_SECTION_PROXY))
|
||||
fprintf (file,
|
||||
"# WARNING!!! Options for section \"%s\" are not developed!\n",
|
||||
config_sections[i].section_name);
|
||||
|
||||
+44
-11
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "../common/weechat.h"
|
||||
#include "gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../irc/irc.h"
|
||||
|
||||
|
||||
@@ -92,6 +93,7 @@ gui_window_new (void *server, void *channel, int switch_to_window
|
||||
/* init lines */
|
||||
new_window->lines = NULL;
|
||||
new_window->last_line = NULL;
|
||||
new_window->num_lines = 0;
|
||||
new_window->first_line_displayed = 1;
|
||||
new_window->sub_lines = 0;
|
||||
new_window->line_complete = 1;
|
||||
@@ -110,7 +112,9 @@ gui_window_new (void *server, void *channel, int switch_to_window
|
||||
|
||||
/* init history */
|
||||
new_window->history = NULL;
|
||||
new_window->last_history = NULL;
|
||||
new_window->ptr_history = NULL;
|
||||
new_window->num_history = 0;
|
||||
|
||||
/* switch to new window */
|
||||
if (switch_to_window)
|
||||
@@ -161,6 +165,7 @@ gui_window_clear (t_gui_window *window)
|
||||
|
||||
window->lines = NULL;
|
||||
window->last_line = NULL;
|
||||
window->num_lines = 0;
|
||||
window->first_line_displayed = 1;
|
||||
window->sub_lines = 0;
|
||||
window->line_complete = 1;
|
||||
@@ -239,6 +244,26 @@ gui_infobar_remove ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_line_free: delete a line from a window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_line_free (t_gui_line *line)
|
||||
{
|
||||
t_gui_message *ptr_message;
|
||||
|
||||
while (line->messages)
|
||||
{
|
||||
ptr_message = line->messages->next_message;
|
||||
if (line->messages->message)
|
||||
free (line->messages->message);
|
||||
free (line->messages);
|
||||
line->messages = ptr_message;
|
||||
}
|
||||
free (line);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_free: delete a window
|
||||
*/
|
||||
@@ -247,7 +272,6 @@ void
|
||||
gui_window_free (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
t_gui_message *ptr_message;
|
||||
int create_new;
|
||||
|
||||
create_new = (window->server || window->channel);
|
||||
@@ -261,15 +285,7 @@ gui_window_free (t_gui_window *window)
|
||||
while (window->lines)
|
||||
{
|
||||
ptr_line = window->lines->next_line;
|
||||
while (window->lines->messages)
|
||||
{
|
||||
ptr_message = window->lines->messages->next_message;
|
||||
if (window->lines->messages->message)
|
||||
free (window->lines->messages->message);
|
||||
free (window->lines->messages);
|
||||
window->lines->messages = ptr_message;
|
||||
}
|
||||
free (window->lines);
|
||||
gui_line_free (window->lines);
|
||||
window->lines = ptr_line;
|
||||
}
|
||||
if (window->input_buffer)
|
||||
@@ -301,7 +317,7 @@ gui_window_free (t_gui_window *window)
|
||||
t_gui_line *
|
||||
gui_new_line (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *new_line;
|
||||
t_gui_line *new_line, *ptr_line;
|
||||
|
||||
if ((new_line = (t_gui_line *) malloc (sizeof (struct t_gui_line))))
|
||||
{
|
||||
@@ -317,12 +333,29 @@ gui_new_line (t_gui_window *window)
|
||||
new_line->prev_line = window->last_line;
|
||||
new_line->next_line = NULL;
|
||||
window->last_line = new_line;
|
||||
window->num_lines++;
|
||||
}
|
||||
else
|
||||
{
|
||||
wee_log_printf (_("%s not enough memory for new line!\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* remove one line if necessary */
|
||||
if ((cfg_history_max_lines > 0)
|
||||
&& (window->num_lines > cfg_history_max_lines))
|
||||
{
|
||||
if (window->last_line == window->lines)
|
||||
window->last_line = NULL;
|
||||
ptr_line = window->lines->next_line;
|
||||
gui_line_free (window->lines);
|
||||
window->lines = ptr_line;
|
||||
ptr_line->prev_line = NULL;
|
||||
window->num_lines--;
|
||||
if (window->first_line_displayed)
|
||||
gui_redraw_window_chat (window);
|
||||
}
|
||||
|
||||
return new_line;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ struct t_gui_window
|
||||
/* chat content (lines, line is composed by many messages) */
|
||||
t_gui_line *lines; /* lines of chat window */
|
||||
t_gui_line *last_line; /* last line of chat window */
|
||||
int num_lines; /* number of lines in the window */
|
||||
int first_line_displayed; /* = 1 if first line is displayed */
|
||||
int sub_lines; /* if > 0 then do not display until end */
|
||||
int line_complete; /* current line complete ? (\n ending) */
|
||||
@@ -185,7 +186,9 @@ struct t_gui_window
|
||||
|
||||
/* history */
|
||||
t_history *history; /* commands history */
|
||||
t_history *last_history; /* last command in history */
|
||||
t_history *ptr_history; /* current command in history */
|
||||
int num_history; /* number of commands in history */
|
||||
|
||||
/* link to next window */
|
||||
t_gui_window *prev_window; /* link to previous window */
|
||||
|
||||
+4
-1
@@ -1,9 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2004-06-05
|
||||
ChangeLog - 2004-06-13
|
||||
|
||||
|
||||
Version 0.0.7 (under dev!):
|
||||
* added history limit (text buffer & commands)
|
||||
|
||||
Version 0.0.6 (2004-06-05):
|
||||
* improved channel highlight (priority to message vs join/part)
|
||||
* fixed bug when opened private win and remote user changes his nick
|
||||
|
||||
+3
-5
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2004-06-05
|
||||
TODO - 2004-06-13
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -10,7 +10,7 @@ Legend:
|
||||
? is this really necessary?
|
||||
|
||||
|
||||
v0.0.6:
|
||||
v0.0.7:
|
||||
------
|
||||
|
||||
* General:
|
||||
@@ -18,15 +18,13 @@ v0.0.6:
|
||||
+ Solaris version
|
||||
|
||||
* IRC protocol:
|
||||
# "/mode" command: change the user/channels modes
|
||||
+ "/dcc" command (for chat and sending/receiving files)
|
||||
# "/query" command: start private conversation
|
||||
|
||||
* Interface:
|
||||
+ internationalization (traduce WeeChat in many languages)
|
||||
# display current channel modes (example : #weechat(+nt))
|
||||
|
||||
* Configuration:
|
||||
# history limit (text buffer & commands)
|
||||
+ add missing options for config file
|
||||
- add key bindings to config file
|
||||
|
||||
|
||||
@@ -29,11 +29,14 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "history.h"
|
||||
#include "weeconfig.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
|
||||
t_history *history_general = NULL;
|
||||
t_history *history_general_last = NULL;
|
||||
t_history *history_general_ptr = NULL;
|
||||
int num_history_general = 0;
|
||||
|
||||
|
||||
/*
|
||||
@@ -43,25 +46,63 @@ t_history *history_general_ptr = NULL;
|
||||
void
|
||||
history_add (void *window, char *string)
|
||||
{
|
||||
t_history *new_history;
|
||||
t_history *new_history, *ptr_history;
|
||||
|
||||
/* add history to general 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;
|
||||
else
|
||||
history_general_last = new_history;
|
||||
new_history->next_history = history_general;
|
||||
new_history->prev_history = NULL;
|
||||
history_general = new_history;
|
||||
num_history_general++;
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((cfg_history_max_commands > 0)
|
||||
&& (num_history_general > cfg_history_max_commands))
|
||||
{
|
||||
ptr_history = history_general_last->prev_history;
|
||||
history_general_last->prev_history->next_history = NULL;
|
||||
if (history_general_last->text)
|
||||
free (history_general_last->text);
|
||||
free (history_general_last);
|
||||
history_general_last = ptr_history;
|
||||
num_history_general--;
|
||||
}
|
||||
}
|
||||
|
||||
/* add history to local history */
|
||||
new_history = (t_history *)malloc (sizeof (t_history));
|
||||
if (new_history)
|
||||
{
|
||||
new_history->text = strdup (string);
|
||||
|
||||
/* add history to local history */
|
||||
if (((t_gui_window *)(window))->history)
|
||||
((t_gui_window *)(window))->history->prev_history = new_history;
|
||||
else
|
||||
((t_gui_window *)(window))->last_history = new_history;
|
||||
new_history->next_history = ((t_gui_window *)(window))->history;
|
||||
new_history->prev_history = NULL;
|
||||
((t_gui_window *)window)->history = new_history;
|
||||
((t_gui_window *)(window))->num_history++;
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((cfg_history_max_commands > 0)
|
||||
&& (((t_gui_window *)(window))->num_history > cfg_history_max_commands))
|
||||
{
|
||||
ptr_history = ((t_gui_window *)window)->last_history->prev_history;
|
||||
((t_gui_window *)window)->last_history->prev_history->next_history = NULL;
|
||||
if (((t_gui_window *)window)->last_history->text)
|
||||
free (((t_gui_window *)window)->last_history->text);
|
||||
free (((t_gui_window *)window)->last_history);
|
||||
((t_gui_window *)window)->last_history = ptr_history;
|
||||
((t_gui_window *)(window))->num_history++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1258,8 +1258,8 @@ config_write (char *config_name)
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
fprintf (file, "\n[%s]\n", config_sections[i].section_name);
|
||||
if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) ||
|
||||
(i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY))
|
||||
if ((i == CONFIG_SECTION_LOG) || (i == CONFIG_SECTION_DCC) ||
|
||||
(i == CONFIG_SECTION_PROXY))
|
||||
fprintf (file,
|
||||
"# WARNING!!! Options for section \"%s\" are not developed!\n",
|
||||
config_sections[i].section_name);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "../common/weechat.h"
|
||||
#include "gui.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../irc/irc.h"
|
||||
|
||||
|
||||
@@ -92,6 +93,7 @@ gui_window_new (void *server, void *channel, int switch_to_window
|
||||
/* init lines */
|
||||
new_window->lines = NULL;
|
||||
new_window->last_line = NULL;
|
||||
new_window->num_lines = 0;
|
||||
new_window->first_line_displayed = 1;
|
||||
new_window->sub_lines = 0;
|
||||
new_window->line_complete = 1;
|
||||
@@ -110,7 +112,9 @@ gui_window_new (void *server, void *channel, int switch_to_window
|
||||
|
||||
/* init history */
|
||||
new_window->history = NULL;
|
||||
new_window->last_history = NULL;
|
||||
new_window->ptr_history = NULL;
|
||||
new_window->num_history = 0;
|
||||
|
||||
/* switch to new window */
|
||||
if (switch_to_window)
|
||||
@@ -161,6 +165,7 @@ gui_window_clear (t_gui_window *window)
|
||||
|
||||
window->lines = NULL;
|
||||
window->last_line = NULL;
|
||||
window->num_lines = 0;
|
||||
window->first_line_displayed = 1;
|
||||
window->sub_lines = 0;
|
||||
window->line_complete = 1;
|
||||
@@ -239,6 +244,26 @@ gui_infobar_remove ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_line_free: delete a line from a window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_line_free (t_gui_line *line)
|
||||
{
|
||||
t_gui_message *ptr_message;
|
||||
|
||||
while (line->messages)
|
||||
{
|
||||
ptr_message = line->messages->next_message;
|
||||
if (line->messages->message)
|
||||
free (line->messages->message);
|
||||
free (line->messages);
|
||||
line->messages = ptr_message;
|
||||
}
|
||||
free (line);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_window_free: delete a window
|
||||
*/
|
||||
@@ -247,7 +272,6 @@ void
|
||||
gui_window_free (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
t_gui_message *ptr_message;
|
||||
int create_new;
|
||||
|
||||
create_new = (window->server || window->channel);
|
||||
@@ -261,15 +285,7 @@ gui_window_free (t_gui_window *window)
|
||||
while (window->lines)
|
||||
{
|
||||
ptr_line = window->lines->next_line;
|
||||
while (window->lines->messages)
|
||||
{
|
||||
ptr_message = window->lines->messages->next_message;
|
||||
if (window->lines->messages->message)
|
||||
free (window->lines->messages->message);
|
||||
free (window->lines->messages);
|
||||
window->lines->messages = ptr_message;
|
||||
}
|
||||
free (window->lines);
|
||||
gui_line_free (window->lines);
|
||||
window->lines = ptr_line;
|
||||
}
|
||||
if (window->input_buffer)
|
||||
@@ -301,7 +317,7 @@ gui_window_free (t_gui_window *window)
|
||||
t_gui_line *
|
||||
gui_new_line (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *new_line;
|
||||
t_gui_line *new_line, *ptr_line;
|
||||
|
||||
if ((new_line = (t_gui_line *) malloc (sizeof (struct t_gui_line))))
|
||||
{
|
||||
@@ -317,12 +333,29 @@ gui_new_line (t_gui_window *window)
|
||||
new_line->prev_line = window->last_line;
|
||||
new_line->next_line = NULL;
|
||||
window->last_line = new_line;
|
||||
window->num_lines++;
|
||||
}
|
||||
else
|
||||
{
|
||||
wee_log_printf (_("%s not enough memory for new line!\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* remove one line if necessary */
|
||||
if ((cfg_history_max_lines > 0)
|
||||
&& (window->num_lines > cfg_history_max_lines))
|
||||
{
|
||||
if (window->last_line == window->lines)
|
||||
window->last_line = NULL;
|
||||
ptr_line = window->lines->next_line;
|
||||
gui_line_free (window->lines);
|
||||
window->lines = ptr_line;
|
||||
ptr_line->prev_line = NULL;
|
||||
window->num_lines--;
|
||||
if (window->first_line_displayed)
|
||||
gui_redraw_window_chat (window);
|
||||
}
|
||||
|
||||
return new_line;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ struct t_gui_window
|
||||
/* chat content (lines, line is composed by many messages) */
|
||||
t_gui_line *lines; /* lines of chat window */
|
||||
t_gui_line *last_line; /* last line of chat window */
|
||||
int num_lines; /* number of lines in the window */
|
||||
int first_line_displayed; /* = 1 if first line is displayed */
|
||||
int sub_lines; /* if > 0 then do not display until end */
|
||||
int line_complete; /* current line complete ? (\n ending) */
|
||||
@@ -185,7 +186,9 @@ struct t_gui_window
|
||||
|
||||
/* history */
|
||||
t_history *history; /* commands history */
|
||||
t_history *last_history; /* last command in history */
|
||||
t_history *ptr_history; /* current command in history */
|
||||
int num_history; /* number of commands in history */
|
||||
|
||||
/* link to next window */
|
||||
t_gui_window *prev_window; /* link to previous window */
|
||||
|
||||
Reference in New Issue
Block a user