133 |
133 |
134 GSList *keyseqlist; |
134 GSList *keyseqlist; |
135 static void add_keyseq(char *seqstr, guint mkeycode, gint value); |
135 static void add_keyseq(char *seqstr, guint mkeycode, gint value); |
136 |
136 |
137 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
137 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
138 unsigned int prefix_flags, int force_show); |
138 unsigned int prefix_flags, int force_show, |
|
139 unsigned mucnicklen); |
139 |
140 |
140 #ifdef HAVE_ASPELL_H |
141 #ifdef HAVE_ASPELL_H |
141 #define ASPELLBADCHAR 5 |
142 #define ASPELLBADCHAR 5 |
142 AspellConfig *spell_config; |
143 AspellConfig *spell_config; |
143 AspellSpeller *spell_checker; |
144 AspellSpeller *spell_checker; |
710 |
711 |
711 if (Curses) { |
712 if (Curses) { |
712 wprintw(logWnd, "\n%s", buffer_locale); |
713 wprintw(logWnd, "\n%s", buffer_locale); |
713 update_panels(); |
714 update_panels(); |
714 scr_WriteInWindow(NULL, buf_specialwindow, timestamp, |
715 scr_WriteInWindow(NULL, buf_specialwindow, timestamp, |
715 HBB_PREFIX_SPECIAL, FALSE); |
716 HBB_PREFIX_SPECIAL, FALSE, 0); |
716 } else { |
717 } else { |
717 printf("%s\n", buffer_locale); |
718 printf("%s\n", buffer_locale); |
718 // ncurses are not initialized yet, so we call directly hbuf routine |
719 // ncurses are not initialized yet, so we call directly hbuf routine |
719 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
720 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, |
720 HBB_PREFIX_SPECIAL, 0, 0); |
721 HBB_PREFIX_SPECIAL, 0, 0, 0); |
721 } |
722 } |
722 |
723 |
723 g_free(convbuf1); |
724 g_free(convbuf1); |
724 g_free(convbuf2); |
725 g_free(convbuf2); |
725 g_free(buffer); |
726 g_free(buffer); |
897 } |
898 } |
898 |
899 |
899 // Make sure we are at the right position |
900 // Make sure we are at the right position |
900 wmove(win_entry->win, n, getprefixwidth()-1); |
901 wmove(win_entry->win, n, getprefixwidth()-1); |
901 wprintw(win_entry->win, "%s", line->text); // Display text line |
902 wprintw(win_entry->win, "%s", line->text); // Display text line |
|
903 wclrtoeol(win_entry->win); |
|
904 |
|
905 //The MUC nick - overwrite with propper color |
|
906 if (line->mucnicklen) { |
|
907 //Store the char after the nick |
|
908 char tmp = line->text[line->mucnicklen]; |
|
909 //TODO choose the color in proper way |
|
910 wattrset(win_entry->win, get_color(COLOR_RED_BOLD_FG)); |
|
911 wmove(win_entry->win, n, getprefixwidth()-1); |
|
912 //Terminate the string after the nick |
|
913 line->text[line->mucnicklen] = '\0'; |
|
914 wprintw(win_entry->win, "%s", line->text); |
|
915 //Return the char |
|
916 line->text[line->mucnicklen] = tmp; |
|
917 } |
902 |
918 |
903 // Return the color back |
919 // Return the color back |
904 if (line->flags & (HBB_PREFIX_HLIGHT_OUT | HBB_PREFIX_HLIGHT |
920 if ((line->flags & (HBB_PREFIX_HLIGHT_OUT | HBB_PREFIX_HLIGHT |
905 | HBB_PREFIX_INFO | HBB_PREFIX_IN)) |
921 | HBB_PREFIX_INFO | HBB_PREFIX_IN)) || (line->mucnicklen)) |
906 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
922 wattrset(win_entry->win, get_color(COLOR_GENERAL)); |
907 wclrtoeol(win_entry->win); |
|
908 g_free(line->text); |
923 g_free(line->text); |
909 g_free(line); |
924 g_free(line); |
910 } else { |
925 } else { |
911 wclrtobot(win_entry->win); |
926 wclrtobot(win_entry->win); |
912 break; |
927 break; |
1004 // Write some text in the winId window (this usually is a jid). |
1019 // Write some text in the winId window (this usually is a jid). |
1005 // Use winId == NULL for the special status buffer. |
1020 // Use winId == NULL for the special status buffer. |
1006 // Lines are splitted when they are too long to fit in the chat window. |
1021 // Lines are splitted when they are too long to fit in the chat window. |
1007 // If this window doesn't exist, it is created. |
1022 // If this window doesn't exist, it is created. |
1008 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
1023 void scr_WriteInWindow(const char *winId, const char *text, time_t timestamp, |
1009 unsigned int prefix_flags, int force_show) |
1024 unsigned int prefix_flags, int force_show, |
|
1025 unsigned mucnicklen) |
1010 { |
1026 { |
1011 winbuf *win_entry; |
1027 winbuf *win_entry; |
1012 char *text_locale; |
1028 char *text_locale; |
1013 int dont_show = FALSE; |
1029 int dont_show = FALSE; |
1014 int special; |
1030 int special; |
1041 else |
1057 else |
1042 num_history_blocks = get_max_history_blocks(); |
1058 num_history_blocks = get_max_history_blocks(); |
1043 |
1059 |
1044 text_locale = from_utf8(text); |
1060 text_locale = from_utf8(text); |
1045 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
1061 hbuf_add_line(&win_entry->bd->hbuf, text_locale, timestamp, prefix_flags, |
1046 maxX - Roster_Width - getprefixwidth(), num_history_blocks); |
1062 maxX - Roster_Width - getprefixwidth(), num_history_blocks, mucnicklen); |
1047 g_free(text_locale); |
1063 g_free(text_locale); |
1048 |
1064 |
1049 if (win_entry->bd->cleared) { |
1065 if (win_entry->bd->cleared) { |
1050 win_entry->bd->cleared = FALSE; |
1066 win_entry->bd->cleared = FALSE; |
1051 if (g_list_next(win_entry->bd->top)) |
1067 if (g_list_next(win_entry->bd->top)) |
1692 redrawwin(stdscr); |
1708 redrawwin(stdscr); |
1693 } |
1709 } |
1694 } |
1710 } |
1695 |
1711 |
1696 inline void scr_WriteMessage(const char *bjid, const char *text, |
1712 inline void scr_WriteMessage(const char *bjid, const char *text, |
1697 time_t timestamp, guint prefix_flags) |
1713 time_t timestamp, guint prefix_flags, |
|
1714 unsigned mucnicklen) |
1698 { |
1715 { |
1699 char *xtext; |
1716 char *xtext; |
1700 |
1717 |
1701 if (!timestamp) timestamp = time(NULL); |
1718 if (!timestamp) timestamp = time(NULL); |
1702 |
1719 |
1703 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
1720 xtext = ut_expand_tabs(text); // Expand tabs and filter out some chars |
1704 |
1721 |
1705 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE); |
1722 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE, mucnicklen); |
1706 |
1723 |
1707 if (xtext != (char*)text) |
1724 if (xtext != (char*)text) |
1708 g_free(xtext); |
1725 g_free(xtext); |
1709 } |
1726 } |
1710 |
1727 |
1711 // If prefix is NULL, HBB_PREFIX_IN is supposed. |
1728 // If prefix is NULL, HBB_PREFIX_IN is supposed. |
1712 void scr_WriteIncomingMessage(const char *jidfrom, const char *text, |
1729 void scr_WriteIncomingMessage(const char *jidfrom, const char *text, |
1713 time_t timestamp, guint prefix) |
1730 time_t timestamp, guint prefix, unsigned mucnicklen) |
1714 { |
1731 { |
1715 if (!(prefix & |
1732 if (!(prefix & |
1716 ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_HLIGHT_OUT & |
1733 ~HBB_PREFIX_NOFLAG & ~HBB_PREFIX_HLIGHT & ~HBB_PREFIX_HLIGHT_OUT & |
1717 ~HBB_PREFIX_PGPCRYPT)) |
1734 ~HBB_PREFIX_PGPCRYPT)) |
1718 prefix |= HBB_PREFIX_IN; |
1735 prefix |= HBB_PREFIX_IN; |
1719 |
1736 |
1720 scr_WriteMessage(jidfrom, text, timestamp, prefix); |
1737 scr_WriteMessage(jidfrom, text, timestamp, prefix, mucnicklen); |
1721 } |
1738 } |
1722 |
1739 |
1723 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix) |
1740 void scr_WriteOutgoingMessage(const char *jidto, const char *text, guint prefix) |
1724 { |
1741 { |
1725 GSList *roster_elt; |
1742 GSList *roster_elt; |
1726 roster_elt = roster_find(jidto, jidsearch, |
1743 roster_elt = roster_find(jidto, jidsearch, |
1727 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
1744 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
1728 |
1745 |
1729 scr_WriteMessage(jidto, text, 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT); |
1746 scr_WriteMessage(jidto, text, 0, prefix|HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT, 0); |
1730 |
1747 |
1731 // Show jidto's buffer unless the buddy is not in the buddylist |
1748 // Show jidto's buffer unless the buddy is not in the buddylist |
1732 if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1) |
1749 if (roster_elt && g_list_position(buddylist, roster_elt->data) != -1) |
1733 scr_ShowWindow(jidto, FALSE); |
1750 scr_ShowWindow(jidto, FALSE); |
1734 } |
1751 } |