Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 1228:9a68fe4515dc
Improve MUC nickname completion
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 20 May 2007 22:01:20 +0200 |
parents | 79c396678f1b |
children | e9ea1497ac9d |
comparison
equal
deleted
inserted
replaced
1227:79c396678f1b | 1228:9a68fe4515dc |
---|---|
2813 | 2813 |
2814 if (!completion_started) { | 2814 if (!completion_started) { |
2815 guint dynlist; | 2815 guint dynlist; |
2816 GSList *list = compl_get_category_list(compl_categ, &dynlist); | 2816 GSList *list = compl_get_category_list(compl_categ, &dynlist); |
2817 if (list) { | 2817 if (list) { |
2818 guint n; | |
2818 char *prefix = g_strndup(row, ptr_inputline-row); | 2819 char *prefix = g_strndup(row, ptr_inputline-row); |
2819 // Init completion | 2820 // Init completion |
2820 new_completion(prefix, list); | 2821 n = new_completion(prefix, list); |
2821 g_free(prefix); | 2822 g_free(prefix); |
2823 if (n == 0 && nrow == -1) { | |
2824 // This is a MUC room and we can't complete from the beginning of the | |
2825 // line. Let's try a bit harder and complete the current word. | |
2826 row = prev_char(ptr_inputline, inputLine); | |
2827 while (row >= inputLine) { | |
2828 if (!iswalnum(get_char(row)) && get_char(row) != '_') { | |
2829 row = next_char((char*)row); | |
2830 break; | |
2831 } | |
2832 if (row == inputLine) | |
2833 break; | |
2834 row = prev_char((char*)row, inputLine); | |
2835 } | |
2836 // There's no need to try again if row == inputLine | |
2837 if (row > inputLine) { | |
2838 prefix = g_strndup(row, ptr_inputline-row); | |
2839 new_completion(prefix, list); | |
2840 g_free(prefix); | |
2841 } | |
2842 } | |
2822 // Free the list if it's a dynamic one | 2843 // Free the list if it's a dynamic one |
2823 if (dynlist) { | 2844 if (dynlist) { |
2824 GSList *slp; | 2845 GSList *slp; |
2825 for (slp = list; slp; slp = g_slist_next(slp)) | 2846 for (slp = list; slp; slp = g_slist_next(slp)) |
2826 g_free(slp->data); | 2847 g_free(slp->data); |
2827 g_slist_free(list); | 2848 g_slist_free(list); |
2828 | |
2829 } | 2849 } |
2830 // Now complete | 2850 // Now complete |
2831 cchar = complete(); | 2851 cchar = complete(); |
2832 if (cchar) | 2852 if (cchar) |
2833 scr_insert_text(cchar); | 2853 scr_insert_text(cchar); |