diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/chatwin.c | 4 | ||||
-rw-r--r-- | src/ui/console.c | 12 | ||||
-rw-r--r-- | src/ui/mucwin.c | 1 | ||||
-rw-r--r-- | src/ui/privwin.c | 2 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | src/ui/win_types.h | 1 | ||||
-rw-r--r-- | src/ui/window_list.c | 43 | ||||
-rw-r--r-- | src/ui/window_list.h | 3 |
8 files changed, 60 insertions, 8 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index ffffb2e1..260b9f06 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -292,7 +292,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr //1) only send IQ once //2) sort incoming messages on timestamp //for now if experimental MAM is enabled we dont show no history from sql either - + // MUCPMs also get printed here. In their case we don't save any logs (because nick owners can change) and thus we shouldn't read logs // (and if we do we need to check the resourcepart) if (!prefs_get_boolean(PREF_MAM) && prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY) && message->type == PROF_MSG_TYPE_CHAT) { @@ -311,6 +311,8 @@ chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_cr win_print_incoming(window, display_name, message); } + wins_add_urls_ac(window, message); + if (prefs_get_boolean(PREF_BEEP)) { beep(); } diff --git a/src/ui/console.c b/src/ui/console.c index 58b33204..d2158862 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -2051,13 +2051,15 @@ cons_correction_setting(void) } void -cons_avatar_setting(void) +cons_executable_setting(void) { - char *pref = prefs_get_string(PREF_AVATAR_CMD); + char *avatar = prefs_get_string(PREF_AVATAR_CMD); + cons_show("Avatar command (/executable avatar) : %s", avatar); + prefs_free_string(avatar); - cons_show("Avatar command (/avatar cmd) : %s", pref); - - prefs_free_string(pref); + char *exec = prefs_get_string(PREF_URL_OPEN_CMD); + cons_show("urlopen command (/executable urlopen) : %s", exec); + prefs_free_string(exec); } void diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index ae98eb43..cb0167d0 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -557,6 +557,7 @@ mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList } win_insert_last_read_position_marker((ProfWin*)mucwin, mucwin->roomjid); + wins_add_urls_ac(window, message); if (g_slist_length(mentions) > 0) { _mucwin_print_mention(window, message->plain, message->from_jid->resourcepart, mynick, mentions, ch, flags); diff --git a/src/ui/privwin.c b/src/ui/privwin.c index cbe32500..c18588fb 100644 --- a/src/ui/privwin.c +++ b/src/ui/privwin.c @@ -79,6 +79,8 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) } } + wins_add_urls_ac(window, message); + if (prefs_get_boolean(PREF_BEEP)) { beep(); } diff --git a/src/ui/ui.h b/src/ui/ui.h index a4878106..6e8083da 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -319,7 +319,7 @@ void cons_winpos_setting(void); void cons_color_setting(void); void cons_os_setting(void); void cons_correction_setting(void); -void cons_avatar_setting(void); +void cons_executable_setting(void); void cons_slashguard_setting(void); void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); void cons_show_contact_offline(PContact contact, char *resource, char *status); diff --git a/src/ui/win_types.h b/src/ui/win_types.h index 81944bc0..5da1765a 100644 --- a/src/ui/win_types.h +++ b/src/ui/win_types.h @@ -138,6 +138,7 @@ typedef enum { typedef struct prof_win_t { win_type_t type; ProfLayout *layout; + Autocomplete urls_ac; } ProfWin; typedef struct prof_console_win_t { diff --git a/src/ui/window_list.c b/src/ui/window_list.c index b1c01c41..e506a957 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -534,7 +534,7 @@ wins_close_by_num(int i) } } } - + autocomplete_free(window->urls_ac); break; } case WIN_MUC: @@ -546,6 +546,7 @@ wins_close_by_num(int i) if (mucwin->last_msg_timestamp) { g_date_time_unref(mucwin->last_msg_timestamp); } + autocomplete_free(window->urls_ac); break; } case WIN_PRIVATE: @@ -553,6 +554,7 @@ wins_close_by_num(int i) ProfPrivateWin *privwin = (ProfPrivateWin*)window; autocomplete_remove(wins_ac, privwin->fulljid); autocomplete_remove(wins_close_ac, privwin->fulljid); + autocomplete_free(window->urls_ac); break; } case WIN_XML: @@ -624,6 +626,7 @@ wins_new_chat(const char *const barejid) autocomplete_add(wins_close_ac, nick); } } + newwin->urls_ac = autocomplete_new(); return newwin; } @@ -638,6 +641,8 @@ wins_new_muc(const char *const roomjid) g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, roomjid); autocomplete_add(wins_close_ac, roomjid); + newwin->urls_ac = autocomplete_new(); + return newwin; } @@ -649,6 +654,7 @@ wins_new_config(const char *const roomjid, DataForm *form, ProfConfWinCallback s g_list_free(keys); ProfWin *newwin = win_create_config(roomjid, form, submit, cancel, userdata); g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); + return newwin; } @@ -662,6 +668,8 @@ wins_new_private(const char *const fulljid) g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin); autocomplete_add(wins_ac, fulljid); autocomplete_add(wins_close_ac, fulljid); + newwin->urls_ac = autocomplete_new(); + return newwin; } @@ -1141,3 +1149,36 @@ wins_get_next_unread(void) g_list_free(values); return NULL; } + +void +wins_add_urls_ac(const ProfWin *const win, const ProfMessage *const message) +{ + GRegex *regex; + GMatchInfo *match_info; + + regex = g_regex_new("https?://\\S+", 0, 0, NULL); + g_regex_match (regex, message->plain, 0, &match_info); + + while (g_match_info_matches (match_info)) + { + gchar *word = g_match_info_fetch (match_info, 0); + + autocomplete_add(win->urls_ac, word); + // for people who run profanity a long time, we don't want to waste a lot of memory + autocomplete_remove_older_than_max(win->urls_ac, 20); + + g_free (word); + g_match_info_next (match_info, NULL); + } + + g_match_info_free (match_info); + g_regex_unref (regex); +} + +char* +wins_get_url(const char *const search_str, gboolean previous, void *context) +{ + ProfWin *win = (ProfWin*)context; + + return autocomplete_complete(win->urls_ac, search_str, FALSE, previous); +} diff --git a/src/ui/window_list.h b/src/ui/window_list.h index bec59721..6547354d 100644 --- a/src/ui/window_list.h +++ b/src/ui/window_list.h @@ -98,4 +98,7 @@ void win_reset_search_attempts(void); char* win_close_autocomplete(const char *const search_str, gboolean previous, void *context); void win_close_reset_search_attempts(void); +void wins_add_urls_ac(const ProfWin *const win, const ProfMessage *const message); +char* wins_get_url(const char *const search_str, gboolean previous, void *context); + #endif |