comparison mcabber/src/screen.c @ 508:5a2132ba2220

Add "/buffer up" and "/buffer down"
author Mikael Berthe <mikael@lilotux.net>
date Sat, 12 Nov 2005 14:48:35 +0100
parents ddec224c2318
children 1744664332cd
comparison
equal deleted inserted replaced
507:16dd9b91702f 508:5a2132ba2220
983 if (chatmode) 983 if (chatmode)
984 scr_ShowBuddyWindow(); 984 scr_ShowBuddyWindow();
985 } 985 }
986 986
987 // scr_BufferScrollUpDown() 987 // scr_BufferScrollUpDown()
988 // Scroll up/down the current buddy window, half a screen. 988 // Scroll up/down the current buddy window,
989 // (up if updown == -1, down if updown == 1) 989 // - half a screen if nblines is 0,
990 void scr_BufferScrollUpDown(int updown) 990 // - up if updown == -1, down if updown == 1
991 void scr_BufferScrollUpDown(int updown, unsigned int nblines)
991 { 992 {
992 window_entry_t *win_entry; 993 window_entry_t *win_entry;
993 int n, nblines; 994 int n, nbl;
994 GList *hbuf_top; 995 GList *hbuf_top;
995 996
996 // Get win_entry 997 // Get win_entry
997 if (!current_buddy) return; 998 if (!current_buddy) return;
998 win_entry = scr_SearchWindow(CURRENT_JID); 999 win_entry = scr_SearchWindow(CURRENT_JID);
999 if (!win_entry) return; 1000 if (!win_entry) return;
1000 1001
1001 // Scroll half a screen (or less) 1002 if (!nblines) {
1002 nblines = CHAT_WIN_HEIGHT/2-1; 1003 // Scroll half a screen (or less)
1004 nbl = CHAT_WIN_HEIGHT/2-1;
1005 } else {
1006 nbl = nblines;
1007 }
1003 hbuf_top = win_entry->top; 1008 hbuf_top = win_entry->top;
1004 1009
1005 if (updown == -1) { // UP 1010 if (updown == -1) { // UP
1006 if (!hbuf_top) { 1011 if (!hbuf_top) {
1007 hbuf_top = g_list_last(win_entry->hbuf); 1012 hbuf_top = g_list_last(win_entry->hbuf);
1008 if (!win_entry->cleared) 1013 if (!nblines && !win_entry->cleared)
1009 nblines *= 3; 1014 nbl *= 3;
1010 else 1015 else
1011 win_entry->cleared = FALSE; 1016 win_entry->cleared = FALSE;
1012 } 1017 }
1013 for (n=0 ; hbuf_top && n < nblines && g_list_previous(hbuf_top) ; n++) 1018 for (n=0 ; hbuf_top && n < nbl && g_list_previous(hbuf_top) ; n++)
1014 hbuf_top = g_list_previous(hbuf_top); 1019 hbuf_top = g_list_previous(hbuf_top);
1015 win_entry->top = hbuf_top; 1020 win_entry->top = hbuf_top;
1016 } else { // DOWN 1021 } else { // DOWN
1017 for (n=0 ; hbuf_top && n < nblines ; n++) 1022 for (n=0 ; hbuf_top && n < nbl ; n++)
1018 hbuf_top = g_list_next(hbuf_top); 1023 hbuf_top = g_list_next(hbuf_top);
1019 win_entry->top = hbuf_top; 1024 win_entry->top = hbuf_top;
1020 // Check if we are at the bottom 1025 // Check if we are at the bottom
1021 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++) 1026 for (n=0 ; hbuf_top && n < CHAT_WIN_HEIGHT-1 ; n++)
1022 hbuf_top = g_list_next(hbuf_top); 1027 hbuf_top = g_list_next(hbuf_top);
1666 case KEY_EOL: 1671 case KEY_EOL:
1667 case 11: // Ctrl-k 1672 case 11: // Ctrl-k
1668 *ptr_inputline = 0; 1673 *ptr_inputline = 0;
1669 break; 1674 break;
1670 case 16: // Ctrl-p 1675 case 16: // Ctrl-p
1671 scr_BufferScrollUpDown(-1); 1676 scr_BufferScrollUpDown(-1, 0);
1672 break; 1677 break;
1673 case 14: // Ctrl-n 1678 case 14: // Ctrl-n
1674 scr_BufferScrollUpDown(1); 1679 scr_BufferScrollUpDown(1, 0);
1675 break; 1680 break;
1676 case 17: // Ctrl-q 1681 case 17: // Ctrl-q
1677 scr_CheckAutoAway(TRUE); 1682 scr_CheckAutoAway(TRUE);
1678 scr_RosterUnreadMessage(1); // next unread message 1683 scr_RosterUnreadMessage(1); // next unread message
1679 break; 1684 break;