Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 1961:39021fd6b0e1
Try to improve readmarks in some cases
This patch removes the readmark when entering chatmode if the mark is on the
last line. This should hopefully fix weird behavior seen under some
circumstances.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 15 Mar 2011 00:39:17 +0100 |
parents | b596bcff758e |
children | ec737f5f1d6f |
comparison
equal
deleted
inserted
replaced
1960:b596bcff758e | 1961:39021fd6b0e1 |
---|---|
1480 | 1480 |
1481 if (!dont_show) { | 1481 if (!dont_show) { |
1482 if (win_entry->bd->lock) | 1482 if (win_entry->bd->lock) |
1483 setmsgflg = TRUE; | 1483 setmsgflg = TRUE; |
1484 else | 1484 else |
1485 // If this is an outgoing message, update readmark | 1485 // If this is an outgoing message, remove the readmark |
1486 if (!special && (prefix_flags & (HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT))) | 1486 if (!special && (prefix_flags & (HBB_PREFIX_OUT|HBB_PREFIX_HLIGHT_OUT))) |
1487 hbuf_set_readmark(win_entry->bd->hbuf, FALSE); | 1487 hbuf_set_readmark(win_entry->bd->hbuf, FALSE); |
1488 // Show and refresh the window | 1488 // Show and refresh the window |
1489 top_panel(win_entry->panel); | 1489 top_panel(win_entry->panel); |
1490 scr_update_window(win_entry); | 1490 scr_update_window(win_entry); |
2393 scr_buffer_readmark(TRUE); | 2393 scr_buffer_readmark(TRUE); |
2394 alternate_buddy = current_buddy; | 2394 alternate_buddy = current_buddy; |
2395 } | 2395 } |
2396 current_buddy = newbuddy; | 2396 current_buddy = newbuddy; |
2397 // Lock the buddy in the buddylist if we're in chat mode | 2397 // Lock the buddy in the buddylist if we're in chat mode |
2398 if (chatmode) | 2398 if (chatmode) { |
2399 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); | 2399 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
2400 // Remove the readmark if it is at the end of the buffer | |
2401 scr_buffer_readmark(-1); | |
2402 } | |
2400 // We should rebuild the buddylist but not everytime | 2403 // We should rebuild the buddylist but not everytime |
2401 if (!(buddylist_get_filter() & 1<<prev_st)) | 2404 if (!(buddylist_get_filter() & 1<<prev_st)) |
2402 buddylist_build(); | 2405 buddylist_build(); |
2403 update_roster = TRUE; | 2406 update_roster = TRUE; |
2404 } | 2407 } |
2814 | 2817 |
2815 // Finished :) | 2818 // Finished :) |
2816 update_panels(); | 2819 update_panels(); |
2817 } | 2820 } |
2818 | 2821 |
2819 void scr_buffer_readmark(gboolean action) | 2822 // scr_buffer_readmark(action) |
2823 // Update the readmark flag for the current buffer | |
2824 // If action = 1, set the readmark flag on the last message | |
2825 // If action = 0, reset the readmark flag | |
2826 // If action = -1, remove the readmark flag iff it is on the last line | |
2827 void scr_buffer_readmark(gchar action) | |
2820 { | 2828 { |
2821 winbuf *win_entry; | 2829 winbuf *win_entry; |
2822 guint isspe; | 2830 guint isspe; |
2823 | 2831 |
2824 // Get win_entry | 2832 // Get win_entry |
2826 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; | 2834 isspe = buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL; |
2827 if (isspe) return; // Maybe not necessary | 2835 if (isspe) return; // Maybe not necessary |
2828 win_entry = scr_search_window(CURRENT_JID, isspe); | 2836 win_entry = scr_search_window(CURRENT_JID, isspe); |
2829 if (!win_entry) return; | 2837 if (!win_entry) return; |
2830 | 2838 |
2831 if (!win_entry->bd->lock) | 2839 if (!win_entry->bd->lock) { |
2832 hbuf_set_readmark(win_entry->bd->hbuf, action); | 2840 if (action >= 0) |
2841 hbuf_set_readmark(win_entry->bd->hbuf, action); | |
2842 else | |
2843 hbuf_remove_trailing_readmark(win_entry->bd->hbuf); | |
2844 } | |
2833 } | 2845 } |
2834 | 2846 |
2835 | 2847 |
2836 // scr_buffer_top_bottom() | 2848 // scr_buffer_top_bottom() |
2837 // Jump to the head/tail of the current buddy window | 2849 // Jump to the head/tail of the current buddy window |
3035 | 3047 |
3036 // scr_set_chatmode() | 3048 // scr_set_chatmode() |
3037 // Public function to (un)set chatmode... | 3049 // Public function to (un)set chatmode... |
3038 inline void scr_set_chatmode(int enable) | 3050 inline void scr_set_chatmode(int enable) |
3039 { | 3051 { |
3052 gboolean enter_chatmode = enable && chatmode == FALSE; | |
3040 chatmode = enable; | 3053 chatmode = enable; |
3041 scr_update_chat_status(TRUE); | 3054 scr_update_chat_status(TRUE); |
3055 if (enter_chatmode) | |
3056 scr_buffer_readmark(-1); | |
3042 } | 3057 } |
3043 | 3058 |
3044 // scr_get_chatmode() | 3059 // scr_get_chatmode() |
3045 // Public function to get chatmode state. | 3060 // Public function to get chatmode state. |
3046 inline int scr_get_chatmode(void) | 3061 inline int scr_get_chatmode(void) |