mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 15:53:12 +02:00
Added hotlist sort with new option "look_hotlist_sort" (task #5870)
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2007-06-07
|
||||
ChangeLog - 2007-06-08
|
||||
|
||||
|
||||
Version 0.2.5 (under dev!):
|
||||
* added hotlist sort with new option "look_hotlist_sort" (task #5870)
|
||||
|
||||
Version 0.2.5 (2007-06-07):
|
||||
* fixed QUOTE command: now allowed when socket is ok (even if IRC
|
||||
connection to server is not ok) (bug #20113)
|
||||
|
||||
+8
-1
@@ -257,10 +257,17 @@
|
||||
<entry>0</entry>
|
||||
<entry>Maximale Länge der Namen in der Hotlist (0: kein Limit)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_hotlist_sort</option></entry>
|
||||
<entry>Zeichenfolge</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'group_time_asc'</entry>
|
||||
<entry>Hotlist sort type (group_time_asc (default), group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_day_change</option></entry>
|
||||
<entry>Boolean</entry>
|
||||
<entry>zwischen 0 und 32</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'on'</entry>
|
||||
<entry>Spezielle Nachricht anzeigen, wenn ein neuer Tag beginnt</entry>
|
||||
</row>
|
||||
|
||||
@@ -257,6 +257,13 @@
|
||||
<entry>0</entry>
|
||||
<entry>Max length of names in hotlist (0 = no limit)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_hotlist_sort</option></entry>
|
||||
<entry>string</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'group_time_asc'</entry>
|
||||
<entry>Hotlist sort type (group_time_asc (default), group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_day_change</option></entry>
|
||||
<entry>boolean</entry>
|
||||
|
||||
@@ -257,6 +257,13 @@
|
||||
<entry>0</entry>
|
||||
<entry>Nombre maximum des noms dans la liste d'activité (0 = pas de limite)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_hotlist_sort</option></entry>
|
||||
<entry>chaîne</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'group_time_asc'</entry>
|
||||
<entry>Type de tri pour la liste d'activité (group_time_asc (par défaut), group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_day_change</option></entry>
|
||||
<entry>booléen</entry>
|
||||
|
||||
+407
-397
File diff suppressed because it is too large
Load Diff
+206
-50
@@ -25,15 +25,19 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "weechat.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "weeconfig.h"
|
||||
#include "../irc/irc.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
|
||||
t_weechat_hotlist *hotlist = NULL;
|
||||
t_weechat_hotlist *last_hotlist = NULL;
|
||||
t_weechat_hotlist *weechat_hotlist = NULL;
|
||||
t_weechat_hotlist *last_weechat_hotlist = NULL;
|
||||
t_gui_buffer *hotlist_initial_buffer = NULL;
|
||||
|
||||
|
||||
@@ -42,7 +46,7 @@ t_gui_buffer *hotlist_initial_buffer = NULL;
|
||||
*/
|
||||
|
||||
t_weechat_hotlist *
|
||||
hotlist_search (t_gui_buffer *buffer)
|
||||
hotlist_search (t_weechat_hotlist *hotlist, t_gui_buffer *buffer)
|
||||
{
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
@@ -59,27 +63,128 @@ hotlist_search (t_gui_buffer *buffer)
|
||||
*/
|
||||
|
||||
t_weechat_hotlist *
|
||||
hotlist_find_pos (t_weechat_hotlist *new_hotlist)
|
||||
hotlist_find_pos (t_weechat_hotlist *hotlist, t_weechat_hotlist *new_hotlist)
|
||||
{
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
switch (cfg_look_hotlist_sort)
|
||||
{
|
||||
if (new_hotlist->priority > ptr_hotlist->priority)
|
||||
return ptr_hotlist;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (get_timeval_diff (&(new_hotlist->creation_time),
|
||||
&(ptr_hotlist->creation_time)) > 0)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (get_timeval_diff (&(new_hotlist->creation_time),
|
||||
&(ptr_hotlist->creation_time)) < 0)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (new_hotlist->buffer->number < ptr_hotlist->buffer->number)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (new_hotlist->buffer->number > ptr_hotlist->buffer->number)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_NUMBER_ASC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if (new_hotlist->buffer->number < ptr_hotlist->buffer->number)
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_NUMBER_DESC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if (new_hotlist->buffer->number > ptr_hotlist->buffer->number)
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_add: add a buffer to hotlist, with priority
|
||||
* hotlist_add_hotlist: add new hotlist in list
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
hotlist_add_hotlist (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist,
|
||||
t_weechat_hotlist *new_hotlist)
|
||||
{
|
||||
t_weechat_hotlist *pos_hotlist;
|
||||
|
||||
if (*hotlist)
|
||||
{
|
||||
pos_hotlist = hotlist_find_pos (*hotlist, new_hotlist);
|
||||
|
||||
if (pos_hotlist)
|
||||
{
|
||||
/* insert hotlist into the hotlist (before hotlist found) */
|
||||
new_hotlist->prev_hotlist = pos_hotlist->prev_hotlist;
|
||||
new_hotlist->next_hotlist = pos_hotlist;
|
||||
if (pos_hotlist->prev_hotlist)
|
||||
pos_hotlist->prev_hotlist->next_hotlist = new_hotlist;
|
||||
else
|
||||
*hotlist = new_hotlist;
|
||||
pos_hotlist->prev_hotlist = new_hotlist;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add hotlist to the end */
|
||||
new_hotlist->prev_hotlist = *last_hotlist;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
(*last_hotlist)->next_hotlist = new_hotlist;
|
||||
*last_hotlist = new_hotlist;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_hotlist->prev_hotlist = NULL;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
*hotlist = new_hotlist;
|
||||
*last_hotlist = new_hotlist;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_add: add a buffer to hotlist, with priority
|
||||
* if creation_time is NULL, current time is used
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_add (int priority, struct timeval *creation_time,
|
||||
t_irc_server *server, t_gui_buffer *buffer,
|
||||
int allow_current_buffer)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist, *pos_hotlist;
|
||||
t_weechat_hotlist *new_hotlist, *ptr_hotlist;
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
@@ -89,13 +194,13 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
&& (!allow_current_buffer) && (!gui_buffer_is_scrolled (buffer)))
|
||||
return;
|
||||
|
||||
if ((pos_hotlist = hotlist_search (buffer)))
|
||||
if ((ptr_hotlist = hotlist_search (weechat_hotlist, buffer)))
|
||||
{
|
||||
/* return if priority is greater or equal than the one to add */
|
||||
if (pos_hotlist->priority >= priority)
|
||||
if (ptr_hotlist->priority >= priority)
|
||||
return;
|
||||
/* remove buffer if present with lower priority and go on */
|
||||
hotlist_free (pos_hotlist);
|
||||
hotlist_free (&weechat_hotlist, &last_weechat_hotlist, ptr_hotlist);
|
||||
}
|
||||
|
||||
if ((new_hotlist = (t_weechat_hotlist *) malloc (sizeof (t_weechat_hotlist))) == NULL)
|
||||
@@ -106,40 +211,66 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
}
|
||||
|
||||
new_hotlist->priority = priority;
|
||||
if (creation_time)
|
||||
memcpy (&(new_hotlist->creation_time),
|
||||
creation_time, sizeof (creation_time));
|
||||
else
|
||||
gettimeofday (&(new_hotlist->creation_time), NULL);
|
||||
new_hotlist->server = server;
|
||||
new_hotlist->buffer = buffer;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
new_hotlist->prev_hotlist = NULL;
|
||||
|
||||
if (hotlist)
|
||||
{
|
||||
pos_hotlist = hotlist_find_pos (new_hotlist);
|
||||
|
||||
if (pos_hotlist)
|
||||
{
|
||||
/* insert hotlist into the hotlist (before hotlist found) */
|
||||
new_hotlist->prev_hotlist = pos_hotlist->prev_hotlist;
|
||||
new_hotlist->next_hotlist = pos_hotlist;
|
||||
if (pos_hotlist->prev_hotlist)
|
||||
pos_hotlist->prev_hotlist->next_hotlist = new_hotlist;
|
||||
else
|
||||
hotlist = new_hotlist;
|
||||
pos_hotlist->prev_hotlist = new_hotlist;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add hotlist to the end */
|
||||
new_hotlist->prev_hotlist = last_hotlist;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
last_hotlist->next_hotlist = new_hotlist;
|
||||
last_hotlist = new_hotlist;
|
||||
}
|
||||
}
|
||||
else
|
||||
hotlist_add_hotlist (&weechat_hotlist, &last_weechat_hotlist, new_hotlist);
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_dup: duplicate hotlist element
|
||||
*/
|
||||
|
||||
t_weechat_hotlist *
|
||||
hotlist_dup (t_weechat_hotlist *hotlist)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist;
|
||||
|
||||
if ((new_hotlist = (t_weechat_hotlist *) malloc (sizeof (t_weechat_hotlist))))
|
||||
{
|
||||
new_hotlist->priority = hotlist->priority;
|
||||
memcpy (&(new_hotlist->creation_time), &(hotlist->creation_time),
|
||||
sizeof (new_hotlist->creation_time));
|
||||
new_hotlist->server = hotlist->server;
|
||||
new_hotlist->buffer = hotlist->buffer;
|
||||
new_hotlist->prev_hotlist = NULL;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
hotlist = new_hotlist;
|
||||
last_hotlist = new_hotlist;
|
||||
return new_hotlist;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_resort: resort hotlist with new sort type
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_resort ()
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist, *last_new_hotlist;
|
||||
t_weechat_hotlist *ptr_hotlist, *element;
|
||||
|
||||
/* copy and resort hotlist in new linked list */
|
||||
new_hotlist = NULL;
|
||||
last_new_hotlist = NULL;
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
element = hotlist_dup (ptr_hotlist);
|
||||
hotlist_add_hotlist (&new_hotlist, &last_new_hotlist, element);
|
||||
}
|
||||
|
||||
hotlist_free_all (&weechat_hotlist, &last_weechat_hotlist);
|
||||
|
||||
weechat_hotlist = new_hotlist;
|
||||
last_weechat_hotlist = last_new_hotlist;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -147,17 +278,18 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_free (t_weechat_hotlist *ptr_hotlist)
|
||||
hotlist_free (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist,
|
||||
t_weechat_hotlist *ptr_hotlist)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist;
|
||||
|
||||
/* remove hotlist from queue */
|
||||
if (last_hotlist == ptr_hotlist)
|
||||
last_hotlist = ptr_hotlist->prev_hotlist;
|
||||
if (*last_hotlist == ptr_hotlist)
|
||||
*last_hotlist = ptr_hotlist->prev_hotlist;
|
||||
if (ptr_hotlist->prev_hotlist)
|
||||
{
|
||||
(ptr_hotlist->prev_hotlist)->next_hotlist = ptr_hotlist->next_hotlist;
|
||||
new_hotlist = hotlist;
|
||||
new_hotlist = *hotlist;
|
||||
}
|
||||
else
|
||||
new_hotlist = ptr_hotlist->next_hotlist;
|
||||
@@ -166,7 +298,7 @@ hotlist_free (t_weechat_hotlist *ptr_hotlist)
|
||||
(ptr_hotlist->next_hotlist)->prev_hotlist = ptr_hotlist->prev_hotlist;
|
||||
|
||||
free (ptr_hotlist);
|
||||
hotlist = new_hotlist;
|
||||
*hotlist = new_hotlist;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -174,11 +306,11 @@ hotlist_free (t_weechat_hotlist *ptr_hotlist)
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_free_all ()
|
||||
hotlist_free_all (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist)
|
||||
{
|
||||
/* remove all hotlists */
|
||||
while (hotlist)
|
||||
hotlist_free (hotlist);
|
||||
while (*hotlist)
|
||||
hotlist_free (hotlist, last_hotlist, *hotlist);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -190,7 +322,31 @@ hotlist_remove_buffer (t_gui_buffer *buffer)
|
||||
{
|
||||
t_weechat_hotlist *pos_hotlist;
|
||||
|
||||
pos_hotlist = hotlist_search (buffer);
|
||||
pos_hotlist = hotlist_search (weechat_hotlist, buffer);
|
||||
if (pos_hotlist)
|
||||
hotlist_free (pos_hotlist);
|
||||
hotlist_free (&weechat_hotlist, &last_weechat_hotlist, pos_hotlist);
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_print_log: print hotlist in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_print_log ()
|
||||
{
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
weechat_log_printf ("[hotlist (addr:0x%X)]\n", ptr_hotlist);
|
||||
weechat_log_printf (" priority . . . . . . . : %d\n", ptr_hotlist->priority);
|
||||
weechat_log_printf (" creation_time. . . . . : tv_sec:%d, tv_usec:%d\n",
|
||||
ptr_hotlist->creation_time.tv_sec,
|
||||
ptr_hotlist->creation_time.tv_usec);
|
||||
weechat_log_printf (" server . . . . . . . . : 0x%X\n", ptr_hotlist->server);
|
||||
weechat_log_printf (" buffer . . . . . . . . : 0x%X\n", ptr_hotlist->buffer);
|
||||
weechat_log_printf (" prev_hotlist . . . . . : 0x%X\n", ptr_hotlist->prev_hotlist);
|
||||
weechat_log_printf (" next_hotlist . . . . . : 0x%X\n", ptr_hotlist->next_hotlist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,18 +34,22 @@ struct t_weechat_hotlist
|
||||
{
|
||||
int priority; /* 0=crappy msg (join/part), 1=msg, */
|
||||
/* 2=pv, 3=nick highlight */
|
||||
struct timeval creation_time; /* time when entry was added */
|
||||
t_irc_server *server; /* associated server */
|
||||
t_gui_buffer *buffer; /* associated buffer */
|
||||
t_weechat_hotlist *prev_hotlist; /* link to previous hotlist */
|
||||
t_weechat_hotlist *next_hotlist; /* link to next hotlist */
|
||||
};
|
||||
|
||||
extern t_weechat_hotlist *hotlist;
|
||||
extern t_weechat_hotlist *weechat_hotlist;
|
||||
extern t_weechat_hotlist *last_weechat_hotlist;
|
||||
extern t_gui_buffer *hotlist_initial_buffer;
|
||||
|
||||
extern void hotlist_add (int, t_irc_server *, t_gui_buffer *, int);
|
||||
extern void hotlist_free (t_weechat_hotlist *);
|
||||
extern void hotlist_free_all ();
|
||||
extern void hotlist_add (int, struct timeval *, t_irc_server *, t_gui_buffer *, int);
|
||||
extern void hotlist_resort ();
|
||||
extern void hotlist_free (t_weechat_hotlist **, t_weechat_hotlist **, t_weechat_hotlist *);
|
||||
extern void hotlist_free_all (t_weechat_hotlist **, t_weechat_hotlist **);
|
||||
extern void hotlist_remove_buffer (t_gui_buffer *);
|
||||
extern void hotlist_print_log ();
|
||||
|
||||
#endif /* hotlist.h */
|
||||
|
||||
@@ -450,13 +450,14 @@ session_save_hotlist (FILE *file)
|
||||
|
||||
rc = 1;
|
||||
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
rc = rc && (session_write_id (file, SESSION_OBJ_HOTLIST));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_PRIORITY, ptr_hotlist->priority));
|
||||
rc = rc && (session_write_str (file, SESSION_HOTL_SERVER, (ptr_hotlist->server) ? ptr_hotlist->server->name : NULL));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_BUFFER_NUMBER, ptr_hotlist->buffer->number));
|
||||
rc = rc && (session_write_buf (file, SESSION_HOTL_CREATION_TIME, &(ptr_hotlist->creation_time), sizeof (struct timeval)));
|
||||
rc = rc && (session_write_id (file, SESSION_HOTL_END));
|
||||
|
||||
if (!rc)
|
||||
@@ -1654,12 +1655,15 @@ session_load_hotlist (FILE *file)
|
||||
{
|
||||
int object_id, rc;
|
||||
int priority;
|
||||
struct timeval creation_time;
|
||||
char *server_name;
|
||||
t_irc_server *ptr_server;
|
||||
int buffer_number;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
priority = 0;
|
||||
creation_time.tv_sec = 0;
|
||||
creation_time.tv_usec = 0;
|
||||
ptr_server = NULL;
|
||||
ptr_buffer = NULL;
|
||||
|
||||
@@ -1677,7 +1681,7 @@ session_load_hotlist (FILE *file)
|
||||
switch (object_id)
|
||||
{
|
||||
case SESSION_HOTL_END:
|
||||
hotlist_add (priority, ptr_server, ptr_buffer, 1);
|
||||
hotlist_add (priority, &creation_time, ptr_server, ptr_buffer, 1);
|
||||
return 1;
|
||||
case SESSION_HOTL_PRIORITY:
|
||||
rc = rc && (session_read_int (file, &priority));
|
||||
@@ -1693,6 +1697,9 @@ session_load_hotlist (FILE *file)
|
||||
rc = rc && (session_read_int (file, &buffer_number));
|
||||
ptr_buffer = gui_buffer_search_by_number (buffer_number);
|
||||
break;
|
||||
case SESSION_HOTL_CREATION_TIME:
|
||||
rc = rc && (session_read_buf (file, &creation_time, sizeof (struct timeval)));
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"history (object id: %d)\n"),
|
||||
|
||||
@@ -195,7 +195,8 @@ enum t_session_hotlist
|
||||
SESSION_HOTL_END = 0,
|
||||
SESSION_HOTL_PRIORITY,
|
||||
SESSION_HOTL_SERVER,
|
||||
SESSION_HOTL_BUFFER_NUMBER
|
||||
SESSION_HOTL_BUFFER_NUMBER,
|
||||
SESSION_HOTL_CREATION_TIME
|
||||
};
|
||||
|
||||
int session_save (char *filename);
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "backtrace.h"
|
||||
#include "command.h"
|
||||
#include "fifo.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "session.h"
|
||||
#include "utf8.h"
|
||||
@@ -755,6 +756,9 @@ weechat_dump (int crash)
|
||||
|
||||
weechat_log_printf ("\n");
|
||||
irc_ignore_print_log ();
|
||||
|
||||
weechat_log_printf ("\n");
|
||||
hotlist_print_log ();
|
||||
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf ("****** End of dump ******\n");
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "alias.h"
|
||||
#include "command.h"
|
||||
#include "fifo.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
@@ -106,6 +107,11 @@ int cfg_look_infobar_delay_highlight;
|
||||
int cfg_look_hotlist_names_count;
|
||||
int cfg_look_hotlist_names_level;
|
||||
int cfg_look_hotlist_names_length;
|
||||
int cfg_look_hotlist_sort;
|
||||
char *cfg_look_hotlist_sort_values[] =
|
||||
{ "group_time_asc", "group_time_desc",
|
||||
"group_number_asc", "group_number_desc",
|
||||
"number_asc", "number_desc" };
|
||||
int cfg_look_day_change;
|
||||
char *cfg_look_day_change_timestamp;
|
||||
char *cfg_look_read_marker;
|
||||
@@ -261,6 +267,11 @@ t_config_option weechat_options_look[] =
|
||||
N_("max length of names in hotlist (0 = no limit)"),
|
||||
OPTION_TYPE_INT, 0, 32, 0,
|
||||
NULL, NULL, &cfg_look_hotlist_names_length, NULL, config_change_buffer_content },
|
||||
{ "look_hotlist_sort", N_("hotlist sort type"),
|
||||
N_("hotlist sort type (group_time_asc (default), group_time_desc, "
|
||||
"group_number_asc, group_number_desc, number_asc, number_desc)"),
|
||||
OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
|
||||
"group_time_asc", cfg_look_hotlist_sort_values, &cfg_look_hotlist_sort, NULL, config_change_hotlist },
|
||||
{ "look_day_change", N_("display special message when day changes"),
|
||||
N_("display special message when day changes"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
@@ -1160,6 +1171,17 @@ config_change_buffer_content ()
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_hotlist: called when hotlist changes
|
||||
*/
|
||||
|
||||
void
|
||||
config_change_hotlist ()
|
||||
{
|
||||
hotlist_resort ();
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_read_marker: called when read marker is changed
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,13 @@
|
||||
#define CFG_LOOK_ALIGN_NICK_LEFT 1
|
||||
#define CFG_LOOK_ALIGN_NICK_RIGHT 2
|
||||
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3
|
||||
#define CFG_LOOK_HOTLIST_SORT_NUMBER_ASC 4
|
||||
#define CFG_LOOK_HOTLIST_SORT_NUMBER_DESC 5
|
||||
|
||||
#define CFG_IRC_DISPLAY_AWAY_OFF 0
|
||||
#define CFG_IRC_DISPLAY_AWAY_LOCAL 1
|
||||
#define CFG_IRC_DISPLAY_AWAY_CHANNEL 2
|
||||
@@ -123,6 +130,7 @@ extern int cfg_look_infobar_delay_highlight;
|
||||
extern int cfg_look_hotlist_names_count;
|
||||
extern int cfg_look_hotlist_names_level;
|
||||
extern int cfg_look_hotlist_names_length;
|
||||
extern int cfg_look_hotlist_sort;
|
||||
extern int cfg_look_day_change;
|
||||
extern char *cfg_look_day_change_timestamp;
|
||||
extern char *cfg_look_read_marker;
|
||||
@@ -254,6 +262,7 @@ extern void config_change_save_on_exit ();
|
||||
extern void config_change_title ();
|
||||
extern void config_change_buffers ();
|
||||
extern void config_change_buffer_content ();
|
||||
extern void config_change_hotlist ();
|
||||
extern void config_change_read_marker ();
|
||||
extern void config_change_charset ();
|
||||
extern void config_change_one_server_buffer ();
|
||||
|
||||
@@ -236,7 +236,7 @@ gui_status_draw (t_gui_buffer *buffer, int erase)
|
||||
}
|
||||
|
||||
/* display list of other active windows (if any) with numbers */
|
||||
if (hotlist)
|
||||
if (weechat_hotlist)
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
@@ -245,7 +245,7 @@ gui_status_draw (t_gui_buffer *buffer, int erase)
|
||||
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, _("Act: "));
|
||||
|
||||
names_count = 0;
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
switch (ptr_hotlist->priority)
|
||||
|
||||
@@ -1080,11 +1080,11 @@ gui_action_jump_smart (t_gui_window *window, char *args)
|
||||
|
||||
if (window->buffer->text_search == TEXT_SEARCH_DISABLED)
|
||||
{
|
||||
if (hotlist)
|
||||
if (weechat_hotlist)
|
||||
{
|
||||
if (!hotlist_initial_buffer)
|
||||
hotlist_initial_buffer = window->buffer;
|
||||
gui_window_switch_to_buffer (window, hotlist->buffer);
|
||||
gui_window_switch_to_buffer (window, weechat_hotlist->buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
else
|
||||
@@ -1373,9 +1373,9 @@ gui_action_hotlist_clear (t_gui_window *window, char *args)
|
||||
/* make C compiler happy */
|
||||
(void) args;
|
||||
|
||||
if (hotlist)
|
||||
if (weechat_hotlist)
|
||||
{
|
||||
hotlist_free_all ();
|
||||
hotlist_free_all (&weechat_hotlist, &last_weechat_hotlist);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
hotlist_initial_buffer = window->buffer;
|
||||
|
||||
@@ -186,13 +186,13 @@ gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *
|
||||
buffer->notify_level)
|
||||
{
|
||||
if (buffer->last_line->line_with_highlight)
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, NULL, SERVER(buffer), buffer, 0);
|
||||
else if (BUFFER_IS_PRIVATE(buffer) && (buffer->last_line->line_with_message))
|
||||
hotlist_add (HOTLIST_PRIVATE, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_PRIVATE, NULL, SERVER(buffer), buffer, 0);
|
||||
else if (buffer->last_line->line_with_message)
|
||||
hotlist_add (HOTLIST_MSG, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_MSG, NULL, SERVER(buffer), buffer, 0);
|
||||
else
|
||||
hotlist_add (HOTLIST_LOW, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_LOW, NULL, SERVER(buffer), buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ irc_dcc_redraw (int highlight)
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
if (highlight && gui_add_hotlist && (ptr_buffer->num_displayed == 0))
|
||||
{
|
||||
hotlist_add (highlight, NULL, ptr_buffer, 0);
|
||||
hotlist_add (highlight, NULL, NULL, ptr_buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -419,7 +419,7 @@ irc_recv_cmd_invite (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
if (gui_add_hotlist
|
||||
&& ((server->buffer->num_displayed == 0) || (gui_buffer_is_scrolled (server->buffer))))
|
||||
{
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, server, server->buffer, 0);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, NULL, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
@@ -1061,7 +1061,7 @@ irc_recv_cmd_notice (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
if (gui_add_hotlist
|
||||
&& ((server->buffer->num_displayed == 0) || (gui_buffer_is_scrolled (server->buffer))))
|
||||
{
|
||||
hotlist_add (HOTLIST_PRIVATE, server, server->buffer, 0);
|
||||
hotlist_add (HOTLIST_PRIVATE, NULL, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,9 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2007-06-07
|
||||
ChangeLog - 2007-06-08
|
||||
|
||||
|
||||
Version 0.2.5 (under dev!):
|
||||
* added hotlist sort with new option "look_hotlist_sort" (task #5870)
|
||||
|
||||
Version 0.2.5 (2007-06-07):
|
||||
* fixed QUOTE command: now allowed when socket is ok (even if IRC
|
||||
connection to server is not ok) (bug #20113)
|
||||
|
||||
@@ -257,10 +257,17 @@
|
||||
<entry>0</entry>
|
||||
<entry>Maximale Länge der Namen in der Hotlist (0: kein Limit)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_hotlist_sort</option></entry>
|
||||
<entry>Zeichenfolge</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'group_time_asc'</entry>
|
||||
<entry>Hotlist sort type (group_time_asc (default), group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_day_change</option></entry>
|
||||
<entry>Boolean</entry>
|
||||
<entry>zwischen 0 und 32</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'on'</entry>
|
||||
<entry>Spezielle Nachricht anzeigen, wenn ein neuer Tag beginnt</entry>
|
||||
</row>
|
||||
|
||||
@@ -257,6 +257,13 @@
|
||||
<entry>0</entry>
|
||||
<entry>Max length of names in hotlist (0 = no limit)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_hotlist_sort</option></entry>
|
||||
<entry>string</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'group_time_asc'</entry>
|
||||
<entry>Hotlist sort type (group_time_asc (default), group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_day_change</option></entry>
|
||||
<entry>boolean</entry>
|
||||
|
||||
@@ -257,6 +257,13 @@
|
||||
<entry>0</entry>
|
||||
<entry>Nombre maximum des noms dans la liste d'activité (0 = pas de limite)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_hotlist_sort</option></entry>
|
||||
<entry>chaîne</entry>
|
||||
<entry>'group_time_asc', 'group_time_desc', 'group_number_asc', 'group_number_desc', 'number_asc', 'number_desc'</entry>
|
||||
<entry>'group_time_asc'</entry>
|
||||
<entry>Type de tri pour la liste d'activité (group_time_asc (par défaut), group_time_desc, group_number_asc, group_number_desc, number_asc, number_desc)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><option>look_day_change</option></entry>
|
||||
<entry>booléen</entry>
|
||||
|
||||
+407
-397
File diff suppressed because it is too large
Load Diff
+407
-397
File diff suppressed because it is too large
Load Diff
+407
-397
File diff suppressed because it is too large
Load Diff
+411
-398
File diff suppressed because it is too large
Load Diff
+407
-397
File diff suppressed because it is too large
Load Diff
+407
-397
File diff suppressed because it is too large
Load Diff
+407
-397
File diff suppressed because it is too large
Load Diff
+206
-50
@@ -25,15 +25,19 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "weechat.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "weeconfig.h"
|
||||
#include "../irc/irc.h"
|
||||
#include "../gui/gui.h"
|
||||
|
||||
|
||||
t_weechat_hotlist *hotlist = NULL;
|
||||
t_weechat_hotlist *last_hotlist = NULL;
|
||||
t_weechat_hotlist *weechat_hotlist = NULL;
|
||||
t_weechat_hotlist *last_weechat_hotlist = NULL;
|
||||
t_gui_buffer *hotlist_initial_buffer = NULL;
|
||||
|
||||
|
||||
@@ -42,7 +46,7 @@ t_gui_buffer *hotlist_initial_buffer = NULL;
|
||||
*/
|
||||
|
||||
t_weechat_hotlist *
|
||||
hotlist_search (t_gui_buffer *buffer)
|
||||
hotlist_search (t_weechat_hotlist *hotlist, t_gui_buffer *buffer)
|
||||
{
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
@@ -59,27 +63,128 @@ hotlist_search (t_gui_buffer *buffer)
|
||||
*/
|
||||
|
||||
t_weechat_hotlist *
|
||||
hotlist_find_pos (t_weechat_hotlist *new_hotlist)
|
||||
hotlist_find_pos (t_weechat_hotlist *hotlist, t_weechat_hotlist *new_hotlist)
|
||||
{
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist; ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
switch (cfg_look_hotlist_sort)
|
||||
{
|
||||
if (new_hotlist->priority > ptr_hotlist->priority)
|
||||
return ptr_hotlist;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (get_timeval_diff (&(new_hotlist->creation_time),
|
||||
&(ptr_hotlist->creation_time)) > 0)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (get_timeval_diff (&(new_hotlist->creation_time),
|
||||
&(ptr_hotlist->creation_time)) < 0)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (new_hotlist->buffer->number < ptr_hotlist->buffer->number)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if ((new_hotlist->priority > ptr_hotlist->priority)
|
||||
|| ((new_hotlist->priority == ptr_hotlist->priority)
|
||||
&& (new_hotlist->buffer->number > ptr_hotlist->buffer->number)))
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_NUMBER_ASC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if (new_hotlist->buffer->number < ptr_hotlist->buffer->number)
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
case CFG_LOOK_HOTLIST_SORT_NUMBER_DESC:
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
if (new_hotlist->buffer->number > ptr_hotlist->buffer->number)
|
||||
return ptr_hotlist;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_add: add a buffer to hotlist, with priority
|
||||
* hotlist_add_hotlist: add new hotlist in list
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
hotlist_add_hotlist (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist,
|
||||
t_weechat_hotlist *new_hotlist)
|
||||
{
|
||||
t_weechat_hotlist *pos_hotlist;
|
||||
|
||||
if (*hotlist)
|
||||
{
|
||||
pos_hotlist = hotlist_find_pos (*hotlist, new_hotlist);
|
||||
|
||||
if (pos_hotlist)
|
||||
{
|
||||
/* insert hotlist into the hotlist (before hotlist found) */
|
||||
new_hotlist->prev_hotlist = pos_hotlist->prev_hotlist;
|
||||
new_hotlist->next_hotlist = pos_hotlist;
|
||||
if (pos_hotlist->prev_hotlist)
|
||||
pos_hotlist->prev_hotlist->next_hotlist = new_hotlist;
|
||||
else
|
||||
*hotlist = new_hotlist;
|
||||
pos_hotlist->prev_hotlist = new_hotlist;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add hotlist to the end */
|
||||
new_hotlist->prev_hotlist = *last_hotlist;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
(*last_hotlist)->next_hotlist = new_hotlist;
|
||||
*last_hotlist = new_hotlist;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_hotlist->prev_hotlist = NULL;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
*hotlist = new_hotlist;
|
||||
*last_hotlist = new_hotlist;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_add: add a buffer to hotlist, with priority
|
||||
* if creation_time is NULL, current time is used
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_add (int priority, struct timeval *creation_time,
|
||||
t_irc_server *server, t_gui_buffer *buffer,
|
||||
int allow_current_buffer)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist, *pos_hotlist;
|
||||
t_weechat_hotlist *new_hotlist, *ptr_hotlist;
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
@@ -89,13 +194,13 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
&& (!allow_current_buffer) && (!gui_buffer_is_scrolled (buffer)))
|
||||
return;
|
||||
|
||||
if ((pos_hotlist = hotlist_search (buffer)))
|
||||
if ((ptr_hotlist = hotlist_search (weechat_hotlist, buffer)))
|
||||
{
|
||||
/* return if priority is greater or equal than the one to add */
|
||||
if (pos_hotlist->priority >= priority)
|
||||
if (ptr_hotlist->priority >= priority)
|
||||
return;
|
||||
/* remove buffer if present with lower priority and go on */
|
||||
hotlist_free (pos_hotlist);
|
||||
hotlist_free (&weechat_hotlist, &last_weechat_hotlist, ptr_hotlist);
|
||||
}
|
||||
|
||||
if ((new_hotlist = (t_weechat_hotlist *) malloc (sizeof (t_weechat_hotlist))) == NULL)
|
||||
@@ -106,40 +211,66 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
}
|
||||
|
||||
new_hotlist->priority = priority;
|
||||
if (creation_time)
|
||||
memcpy (&(new_hotlist->creation_time),
|
||||
creation_time, sizeof (creation_time));
|
||||
else
|
||||
gettimeofday (&(new_hotlist->creation_time), NULL);
|
||||
new_hotlist->server = server;
|
||||
new_hotlist->buffer = buffer;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
new_hotlist->prev_hotlist = NULL;
|
||||
|
||||
if (hotlist)
|
||||
{
|
||||
pos_hotlist = hotlist_find_pos (new_hotlist);
|
||||
|
||||
if (pos_hotlist)
|
||||
{
|
||||
/* insert hotlist into the hotlist (before hotlist found) */
|
||||
new_hotlist->prev_hotlist = pos_hotlist->prev_hotlist;
|
||||
new_hotlist->next_hotlist = pos_hotlist;
|
||||
if (pos_hotlist->prev_hotlist)
|
||||
pos_hotlist->prev_hotlist->next_hotlist = new_hotlist;
|
||||
else
|
||||
hotlist = new_hotlist;
|
||||
pos_hotlist->prev_hotlist = new_hotlist;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add hotlist to the end */
|
||||
new_hotlist->prev_hotlist = last_hotlist;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
last_hotlist->next_hotlist = new_hotlist;
|
||||
last_hotlist = new_hotlist;
|
||||
}
|
||||
}
|
||||
else
|
||||
hotlist_add_hotlist (&weechat_hotlist, &last_weechat_hotlist, new_hotlist);
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_dup: duplicate hotlist element
|
||||
*/
|
||||
|
||||
t_weechat_hotlist *
|
||||
hotlist_dup (t_weechat_hotlist *hotlist)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist;
|
||||
|
||||
if ((new_hotlist = (t_weechat_hotlist *) malloc (sizeof (t_weechat_hotlist))))
|
||||
{
|
||||
new_hotlist->priority = hotlist->priority;
|
||||
memcpy (&(new_hotlist->creation_time), &(hotlist->creation_time),
|
||||
sizeof (new_hotlist->creation_time));
|
||||
new_hotlist->server = hotlist->server;
|
||||
new_hotlist->buffer = hotlist->buffer;
|
||||
new_hotlist->prev_hotlist = NULL;
|
||||
new_hotlist->next_hotlist = NULL;
|
||||
hotlist = new_hotlist;
|
||||
last_hotlist = new_hotlist;
|
||||
return new_hotlist;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_resort: resort hotlist with new sort type
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_resort ()
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist, *last_new_hotlist;
|
||||
t_weechat_hotlist *ptr_hotlist, *element;
|
||||
|
||||
/* copy and resort hotlist in new linked list */
|
||||
new_hotlist = NULL;
|
||||
last_new_hotlist = NULL;
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
element = hotlist_dup (ptr_hotlist);
|
||||
hotlist_add_hotlist (&new_hotlist, &last_new_hotlist, element);
|
||||
}
|
||||
|
||||
hotlist_free_all (&weechat_hotlist, &last_weechat_hotlist);
|
||||
|
||||
weechat_hotlist = new_hotlist;
|
||||
last_weechat_hotlist = last_new_hotlist;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -147,17 +278,18 @@ hotlist_add (int priority, t_irc_server *server, t_gui_buffer *buffer,
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_free (t_weechat_hotlist *ptr_hotlist)
|
||||
hotlist_free (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist,
|
||||
t_weechat_hotlist *ptr_hotlist)
|
||||
{
|
||||
t_weechat_hotlist *new_hotlist;
|
||||
|
||||
/* remove hotlist from queue */
|
||||
if (last_hotlist == ptr_hotlist)
|
||||
last_hotlist = ptr_hotlist->prev_hotlist;
|
||||
if (*last_hotlist == ptr_hotlist)
|
||||
*last_hotlist = ptr_hotlist->prev_hotlist;
|
||||
if (ptr_hotlist->prev_hotlist)
|
||||
{
|
||||
(ptr_hotlist->prev_hotlist)->next_hotlist = ptr_hotlist->next_hotlist;
|
||||
new_hotlist = hotlist;
|
||||
new_hotlist = *hotlist;
|
||||
}
|
||||
else
|
||||
new_hotlist = ptr_hotlist->next_hotlist;
|
||||
@@ -166,7 +298,7 @@ hotlist_free (t_weechat_hotlist *ptr_hotlist)
|
||||
(ptr_hotlist->next_hotlist)->prev_hotlist = ptr_hotlist->prev_hotlist;
|
||||
|
||||
free (ptr_hotlist);
|
||||
hotlist = new_hotlist;
|
||||
*hotlist = new_hotlist;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -174,11 +306,11 @@ hotlist_free (t_weechat_hotlist *ptr_hotlist)
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_free_all ()
|
||||
hotlist_free_all (t_weechat_hotlist **hotlist, t_weechat_hotlist **last_hotlist)
|
||||
{
|
||||
/* remove all hotlists */
|
||||
while (hotlist)
|
||||
hotlist_free (hotlist);
|
||||
while (*hotlist)
|
||||
hotlist_free (hotlist, last_hotlist, *hotlist);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -190,7 +322,31 @@ hotlist_remove_buffer (t_gui_buffer *buffer)
|
||||
{
|
||||
t_weechat_hotlist *pos_hotlist;
|
||||
|
||||
pos_hotlist = hotlist_search (buffer);
|
||||
pos_hotlist = hotlist_search (weechat_hotlist, buffer);
|
||||
if (pos_hotlist)
|
||||
hotlist_free (pos_hotlist);
|
||||
hotlist_free (&weechat_hotlist, &last_weechat_hotlist, pos_hotlist);
|
||||
}
|
||||
|
||||
/*
|
||||
* hotlist_print_log: print hotlist in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
hotlist_print_log ()
|
||||
{
|
||||
t_weechat_hotlist *ptr_hotlist;
|
||||
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
weechat_log_printf ("[hotlist (addr:0x%X)]\n", ptr_hotlist);
|
||||
weechat_log_printf (" priority . . . . . . . : %d\n", ptr_hotlist->priority);
|
||||
weechat_log_printf (" creation_time. . . . . : tv_sec:%d, tv_usec:%d\n",
|
||||
ptr_hotlist->creation_time.tv_sec,
|
||||
ptr_hotlist->creation_time.tv_usec);
|
||||
weechat_log_printf (" server . . . . . . . . : 0x%X\n", ptr_hotlist->server);
|
||||
weechat_log_printf (" buffer . . . . . . . . : 0x%X\n", ptr_hotlist->buffer);
|
||||
weechat_log_printf (" prev_hotlist . . . . . : 0x%X\n", ptr_hotlist->prev_hotlist);
|
||||
weechat_log_printf (" next_hotlist . . . . . : 0x%X\n", ptr_hotlist->next_hotlist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,18 +34,22 @@ struct t_weechat_hotlist
|
||||
{
|
||||
int priority; /* 0=crappy msg (join/part), 1=msg, */
|
||||
/* 2=pv, 3=nick highlight */
|
||||
struct timeval creation_time; /* time when entry was added */
|
||||
t_irc_server *server; /* associated server */
|
||||
t_gui_buffer *buffer; /* associated buffer */
|
||||
t_weechat_hotlist *prev_hotlist; /* link to previous hotlist */
|
||||
t_weechat_hotlist *next_hotlist; /* link to next hotlist */
|
||||
};
|
||||
|
||||
extern t_weechat_hotlist *hotlist;
|
||||
extern t_weechat_hotlist *weechat_hotlist;
|
||||
extern t_weechat_hotlist *last_weechat_hotlist;
|
||||
extern t_gui_buffer *hotlist_initial_buffer;
|
||||
|
||||
extern void hotlist_add (int, t_irc_server *, t_gui_buffer *, int);
|
||||
extern void hotlist_free (t_weechat_hotlist *);
|
||||
extern void hotlist_free_all ();
|
||||
extern void hotlist_add (int, struct timeval *, t_irc_server *, t_gui_buffer *, int);
|
||||
extern void hotlist_resort ();
|
||||
extern void hotlist_free (t_weechat_hotlist **, t_weechat_hotlist **, t_weechat_hotlist *);
|
||||
extern void hotlist_free_all (t_weechat_hotlist **, t_weechat_hotlist **);
|
||||
extern void hotlist_remove_buffer (t_gui_buffer *);
|
||||
extern void hotlist_print_log ();
|
||||
|
||||
#endif /* hotlist.h */
|
||||
|
||||
@@ -450,13 +450,14 @@ session_save_hotlist (FILE *file)
|
||||
|
||||
rc = 1;
|
||||
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
rc = rc && (session_write_id (file, SESSION_OBJ_HOTLIST));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_PRIORITY, ptr_hotlist->priority));
|
||||
rc = rc && (session_write_str (file, SESSION_HOTL_SERVER, (ptr_hotlist->server) ? ptr_hotlist->server->name : NULL));
|
||||
rc = rc && (session_write_int (file, SESSION_HOTL_BUFFER_NUMBER, ptr_hotlist->buffer->number));
|
||||
rc = rc && (session_write_buf (file, SESSION_HOTL_CREATION_TIME, &(ptr_hotlist->creation_time), sizeof (struct timeval)));
|
||||
rc = rc && (session_write_id (file, SESSION_HOTL_END));
|
||||
|
||||
if (!rc)
|
||||
@@ -1654,12 +1655,15 @@ session_load_hotlist (FILE *file)
|
||||
{
|
||||
int object_id, rc;
|
||||
int priority;
|
||||
struct timeval creation_time;
|
||||
char *server_name;
|
||||
t_irc_server *ptr_server;
|
||||
int buffer_number;
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
priority = 0;
|
||||
creation_time.tv_sec = 0;
|
||||
creation_time.tv_usec = 0;
|
||||
ptr_server = NULL;
|
||||
ptr_buffer = NULL;
|
||||
|
||||
@@ -1677,7 +1681,7 @@ session_load_hotlist (FILE *file)
|
||||
switch (object_id)
|
||||
{
|
||||
case SESSION_HOTL_END:
|
||||
hotlist_add (priority, ptr_server, ptr_buffer, 1);
|
||||
hotlist_add (priority, &creation_time, ptr_server, ptr_buffer, 1);
|
||||
return 1;
|
||||
case SESSION_HOTL_PRIORITY:
|
||||
rc = rc && (session_read_int (file, &priority));
|
||||
@@ -1693,6 +1697,9 @@ session_load_hotlist (FILE *file)
|
||||
rc = rc && (session_read_int (file, &buffer_number));
|
||||
ptr_buffer = gui_buffer_search_by_number (buffer_number);
|
||||
break;
|
||||
case SESSION_HOTL_CREATION_TIME:
|
||||
rc = rc && (session_read_buf (file, &creation_time, sizeof (struct timeval)));
|
||||
break;
|
||||
default:
|
||||
weechat_log_printf (_("session: warning: ignoring value from "
|
||||
"history (object id: %d)\n"),
|
||||
|
||||
@@ -195,7 +195,8 @@ enum t_session_hotlist
|
||||
SESSION_HOTL_END = 0,
|
||||
SESSION_HOTL_PRIORITY,
|
||||
SESSION_HOTL_SERVER,
|
||||
SESSION_HOTL_BUFFER_NUMBER
|
||||
SESSION_HOTL_BUFFER_NUMBER,
|
||||
SESSION_HOTL_CREATION_TIME
|
||||
};
|
||||
|
||||
int session_save (char *filename);
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "backtrace.h"
|
||||
#include "command.h"
|
||||
#include "fifo.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "session.h"
|
||||
#include "utf8.h"
|
||||
@@ -755,6 +756,9 @@ weechat_dump (int crash)
|
||||
|
||||
weechat_log_printf ("\n");
|
||||
irc_ignore_print_log ();
|
||||
|
||||
weechat_log_printf ("\n");
|
||||
hotlist_print_log ();
|
||||
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf ("****** End of dump ******\n");
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "alias.h"
|
||||
#include "command.h"
|
||||
#include "fifo.h"
|
||||
#include "hotlist.h"
|
||||
#include "log.h"
|
||||
#include "utf8.h"
|
||||
#include "util.h"
|
||||
@@ -106,6 +107,11 @@ int cfg_look_infobar_delay_highlight;
|
||||
int cfg_look_hotlist_names_count;
|
||||
int cfg_look_hotlist_names_level;
|
||||
int cfg_look_hotlist_names_length;
|
||||
int cfg_look_hotlist_sort;
|
||||
char *cfg_look_hotlist_sort_values[] =
|
||||
{ "group_time_asc", "group_time_desc",
|
||||
"group_number_asc", "group_number_desc",
|
||||
"number_asc", "number_desc" };
|
||||
int cfg_look_day_change;
|
||||
char *cfg_look_day_change_timestamp;
|
||||
char *cfg_look_read_marker;
|
||||
@@ -261,6 +267,11 @@ t_config_option weechat_options_look[] =
|
||||
N_("max length of names in hotlist (0 = no limit)"),
|
||||
OPTION_TYPE_INT, 0, 32, 0,
|
||||
NULL, NULL, &cfg_look_hotlist_names_length, NULL, config_change_buffer_content },
|
||||
{ "look_hotlist_sort", N_("hotlist sort type"),
|
||||
N_("hotlist sort type (group_time_asc (default), group_time_desc, "
|
||||
"group_number_asc, group_number_desc, number_asc, number_desc)"),
|
||||
OPTION_TYPE_INT_WITH_STRING, 0, 0, 0,
|
||||
"group_time_asc", cfg_look_hotlist_sort_values, &cfg_look_hotlist_sort, NULL, config_change_hotlist },
|
||||
{ "look_day_change", N_("display special message when day changes"),
|
||||
N_("display special message when day changes"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
@@ -1160,6 +1171,17 @@ config_change_buffer_content ()
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_hotlist: called when hotlist changes
|
||||
*/
|
||||
|
||||
void
|
||||
config_change_hotlist ()
|
||||
{
|
||||
hotlist_resort ();
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_read_marker: called when read marker is changed
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,13 @@
|
||||
#define CFG_LOOK_ALIGN_NICK_LEFT 1
|
||||
#define CFG_LOOK_ALIGN_NICK_RIGHT 2
|
||||
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_ASC 0
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_TIME_DESC 1
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_ASC 2
|
||||
#define CFG_LOOK_HOTLIST_SORT_GROUP_NUMBER_DESC 3
|
||||
#define CFG_LOOK_HOTLIST_SORT_NUMBER_ASC 4
|
||||
#define CFG_LOOK_HOTLIST_SORT_NUMBER_DESC 5
|
||||
|
||||
#define CFG_IRC_DISPLAY_AWAY_OFF 0
|
||||
#define CFG_IRC_DISPLAY_AWAY_LOCAL 1
|
||||
#define CFG_IRC_DISPLAY_AWAY_CHANNEL 2
|
||||
@@ -123,6 +130,7 @@ extern int cfg_look_infobar_delay_highlight;
|
||||
extern int cfg_look_hotlist_names_count;
|
||||
extern int cfg_look_hotlist_names_level;
|
||||
extern int cfg_look_hotlist_names_length;
|
||||
extern int cfg_look_hotlist_sort;
|
||||
extern int cfg_look_day_change;
|
||||
extern char *cfg_look_day_change_timestamp;
|
||||
extern char *cfg_look_read_marker;
|
||||
@@ -254,6 +262,7 @@ extern void config_change_save_on_exit ();
|
||||
extern void config_change_title ();
|
||||
extern void config_change_buffers ();
|
||||
extern void config_change_buffer_content ();
|
||||
extern void config_change_hotlist ();
|
||||
extern void config_change_read_marker ();
|
||||
extern void config_change_charset ();
|
||||
extern void config_change_one_server_buffer ();
|
||||
|
||||
@@ -236,7 +236,7 @@ gui_status_draw (t_gui_buffer *buffer, int erase)
|
||||
}
|
||||
|
||||
/* display list of other active windows (if any) with numbers */
|
||||
if (hotlist)
|
||||
if (weechat_hotlist)
|
||||
{
|
||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
@@ -245,7 +245,7 @@ gui_status_draw (t_gui_buffer *buffer, int erase)
|
||||
gui_window_wprintw (GUI_CURSES(ptr_win)->win_status, _("Act: "));
|
||||
|
||||
names_count = 0;
|
||||
for (ptr_hotlist = hotlist; ptr_hotlist;
|
||||
for (ptr_hotlist = weechat_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
switch (ptr_hotlist->priority)
|
||||
|
||||
@@ -1080,11 +1080,11 @@ gui_action_jump_smart (t_gui_window *window, char *args)
|
||||
|
||||
if (window->buffer->text_search == TEXT_SEARCH_DISABLED)
|
||||
{
|
||||
if (hotlist)
|
||||
if (weechat_hotlist)
|
||||
{
|
||||
if (!hotlist_initial_buffer)
|
||||
hotlist_initial_buffer = window->buffer;
|
||||
gui_window_switch_to_buffer (window, hotlist->buffer);
|
||||
gui_window_switch_to_buffer (window, weechat_hotlist->buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
else
|
||||
@@ -1373,9 +1373,9 @@ gui_action_hotlist_clear (t_gui_window *window, char *args)
|
||||
/* make C compiler happy */
|
||||
(void) args;
|
||||
|
||||
if (hotlist)
|
||||
if (weechat_hotlist)
|
||||
{
|
||||
hotlist_free_all ();
|
||||
hotlist_free_all (&weechat_hotlist, &last_weechat_hotlist);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
hotlist_initial_buffer = window->buffer;
|
||||
|
||||
@@ -186,13 +186,13 @@ gui_add_to_line (t_gui_buffer *buffer, int type, time_t date, char *nick, char *
|
||||
buffer->notify_level)
|
||||
{
|
||||
if (buffer->last_line->line_with_highlight)
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, NULL, SERVER(buffer), buffer, 0);
|
||||
else if (BUFFER_IS_PRIVATE(buffer) && (buffer->last_line->line_with_message))
|
||||
hotlist_add (HOTLIST_PRIVATE, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_PRIVATE, NULL, SERVER(buffer), buffer, 0);
|
||||
else if (buffer->last_line->line_with_message)
|
||||
hotlist_add (HOTLIST_MSG, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_MSG, NULL, SERVER(buffer), buffer, 0);
|
||||
else
|
||||
hotlist_add (HOTLIST_LOW, SERVER(buffer), buffer, 0);
|
||||
hotlist_add (HOTLIST_LOW, NULL, SERVER(buffer), buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ irc_dcc_redraw (int highlight)
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
if (highlight && gui_add_hotlist && (ptr_buffer->num_displayed == 0))
|
||||
{
|
||||
hotlist_add (highlight, NULL, ptr_buffer, 0);
|
||||
hotlist_add (highlight, NULL, NULL, ptr_buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ irc_recv_cmd_invite (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
if (gui_add_hotlist
|
||||
&& ((server->buffer->num_displayed == 0) || (gui_buffer_is_scrolled (server->buffer))))
|
||||
{
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, server, server->buffer, 0);
|
||||
hotlist_add (HOTLIST_HIGHLIGHT, NULL, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
@@ -1061,7 +1061,7 @@ irc_recv_cmd_notice (t_irc_server *server, char *host, char *nick, char *argumen
|
||||
if (gui_add_hotlist
|
||||
&& ((server->buffer->num_displayed == 0) || (gui_buffer_is_scrolled (server->buffer))))
|
||||
{
|
||||
hotlist_add (HOTLIST_PRIVATE, server, server->buffer, 0);
|
||||
hotlist_add (HOTLIST_PRIVATE, NULL, server, server->buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user