changeset 143:300bb88f631f

[/trunk] Changeset 155 by mikael * Check top_panel() occurences etc. for cursor problems... * Replace scr_DrawRoaster() by "update_roster = TRUE" when possible to have some optimization. * Comments, clean up...
author mikael
date Fri, 29 Apr 2005 14:44:02 +0000
parents bb6fe91589b9
children 204225d03bb2
files mcabber/src/TODO mcabber/src/screen.c
diffstat 2 files changed, 57 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/TODO	Fri Apr 29 05:53:24 2005 +0000
+++ b/mcabber/src/TODO	Fri Apr 29 14:44:02 2005 +0000
@@ -8,7 +8,6 @@
 * Small but perhaps annoying: when we are on a group entry, w/
   offline buddies hidden and this group is removed from the list.
   Then the cursor goes back to the first item of the buddylist.
-* We should check all top_panel etc. for cursor problems...
 
 
 TODO:
--- a/mcabber/src/screen.c	Fri Apr 29 05:53:24 2005 +0000
+++ b/mcabber/src/screen.c	Fri Apr 29 14:44:02 2005 +0000
@@ -187,7 +187,7 @@
   strncpy(tmp->name, title, 1024);
   scr_clear_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL);
 
-  if ((!dont_show)) {
+  if (!dont_show) {
     currentWindow = tmp;
   } else {
     if (currentWindow)
@@ -195,9 +195,9 @@
     else
       top_panel(chatPanel);
   }
+  update_panels();
 
   list_add_tail(&tmp->list, &window_list);
-  update_panels();
 
   return tmp;
 }
@@ -218,6 +218,8 @@
   return NULL;
 }
 
+//  scr_UpdateWindow()
+// (Re-)Display the given chat window.
 void scr_UpdateWindow(window_entry_t *win_entry)
 {
   int n;
@@ -278,6 +280,8 @@
   g_free(lines);
 }
 
+//  scr_ShowWindow()
+// Display the chat window with the given identifier.
 void scr_ShowWindow(const char *winId)
 {
   window_entry_t *win_entry = scr_SearchWindow(winId);
@@ -304,6 +308,8 @@
   top_panel(inputPanel);
 }
 
+//  scr_ShowBuddyWindow()
+// Display the chat window buffer for the current buddy.
 void scr_ShowBuddyWindow(void)
 {
   const gchar *jid;
@@ -315,6 +321,7 @@
 
   if (!jid) {
     top_panel(chatPanel);
+    top_panel(inputPanel);
     currentWindow = NULL;
     return;
   }
@@ -323,6 +330,10 @@
 }
 
 
+//  scr_WriteInWindow()
+// Write some text in the winId window (this usually is a jid).
+// Lines are splitted when they are too long to fit in the chat window.
+// If this window doesn't exist, it is created.
 void scr_WriteInWindow(const char *winId, const char *text, int TimeStamp,
         const char *prefix, int force_show)
 {
@@ -443,6 +454,8 @@
   return;
 }
 
+//  scr_DrawRoster()
+// Actually, display the buddylist on the screen.
 void scr_DrawRoster(void)
 {
   static guint offset = 0;
@@ -564,7 +577,6 @@
 int scr_Getch(void)
 {
   int ch;
-  // keypad(inputWnd, TRUE);
   ch = wgetch(inputWnd);
   return ch;
 }
@@ -584,9 +596,11 @@
   return inputWnd;
 }
 
+//  scr_RosterTop()
+// Go to the first buddy in the buddylist
 void scr_RosterTop(void)
 {
-  enum imstatus prev_st;
+  enum imstatus prev_st = imstatus_size; // undef
 
   if (current_buddy) {
     prev_st = buddy_getstatus(BUDDATA(current_buddy));
@@ -598,16 +612,21 @@
     buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
 
   // We should rebuild the buddylist but not everytime
+  // Here we check if we were locking a buddy who is actually offline,
+  // and hide_offline_buddies is TRUE.  In which case we need to rebuild.
   if (current_buddy && prev_st == offline &&
           buddylist_get_hide_offline_buddies())
     buddylist_build();
   if (chatmode)
     scr_ShowBuddyWindow();
+  update_roster = TRUE;
 }
 
+//  scr_RosterBottom()
+// Go to the last buddy in the buddylist
 void scr_RosterBottom(void)
 {
-  enum imstatus prev_st;
+  enum imstatus prev_st = imstatus_size; // undef
 
   if (current_buddy) {
     prev_st = buddy_getstatus(BUDDATA(current_buddy));
@@ -615,32 +634,42 @@
       buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
   }
   current_buddy = g_list_last(buddylist);
+  // Lock the buddy in the buddylist if we're in chat mode
   if (chatmode && current_buddy)
     buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
 
   // We should rebuild the buddylist but not everytime
+  // Here we check if we were locking a buddy who is actually offline,
+  // and hide_offline_buddies is TRUE.  In which case we need to rebuild.
   if (current_buddy && prev_st == offline &&
           buddylist_get_hide_offline_buddies())
     buddylist_build();
+
   if (chatmode)
     scr_ShowBuddyWindow();
+  update_roster = TRUE;
 }
 
+//  scr_RosterUp()
+// Go to the previous buddy in the buddylist
 void scr_RosterUp(void)
 {
-  enum imstatus prev_st;
+  enum imstatus prev_st = imstatus_size; // undef
 
   if (current_buddy) {
     if (g_list_previous(current_buddy)) {
       prev_st = buddy_getstatus(BUDDATA(current_buddy));
       buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
       current_buddy = g_list_previous(current_buddy);
+      // Lock the buddy in the buddylist if we're in chat mode
       if (chatmode)
         buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
       // We should rebuild the buddylist but not everytime
+      // Here we check if we were locking a buddy who is actually offline,
+      // and hide_offline_buddies is TRUE.  In which case we need to rebuild.
       if (prev_st == offline && buddylist_get_hide_offline_buddies())
         buddylist_build();
-      scr_DrawRoster();
+      update_roster = TRUE;
     }
   }
 
@@ -648,9 +677,11 @@
     scr_ShowBuddyWindow();
 }
 
+//  scr_RosterDown()
+// Go to the next buddy in the buddylist
 void scr_RosterDown(void)
 {
-  enum imstatus prev_st;
+  enum imstatus prev_st = imstatus_size; // undef
 
   if (current_buddy) {
     if (g_list_next(current_buddy)) {
@@ -660,9 +691,11 @@
       if (chatmode)
         buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
       // We should rebuild the buddylist but not everytime
+      // Here we check if we were locking a buddy who is actually offline,
+      // and hide_offline_buddies is TRUE.  In which case we need to rebuild.
       if (prev_st == offline && buddylist_get_hide_offline_buddies())
         buddylist_build();
-      scr_DrawRoster();
+      update_roster = TRUE;
     }
   }
 
@@ -670,6 +703,8 @@
     scr_ShowBuddyWindow();
 }
 
+//  scr_ScrollUp()
+// Scroll up the current buddy window, half a screen.
 void scr_ScrollUp(void)
 {
   const gchar *jid;
@@ -713,6 +748,8 @@
   doupdate();
 }
 
+//  scr_ScrollDown()
+// Scroll down the current buddy window, half a screen.
 void scr_ScrollDown(void)
 {
   const gchar *jid;
@@ -751,6 +788,8 @@
   doupdate();
 }
 
+//  scr_Clear()
+// Clear the current buddy window (used for the /clear command)
 void scr_Clear(void)
 {
   const gchar *jid;
@@ -802,6 +841,8 @@
   doupdate();
 }
 
+//  scr_set_chatmode()
+// Public fonction to (un)set chatmode...
 inline void scr_set_chatmode(int enable)
 {
   chatmode = enable;
@@ -842,6 +883,10 @@
   return row;
 }
 
+//  scr_insert_text()
+// Insert the given text at the current cursor position.
+// The cursor is moved.  We don't check if the cursor still is in the screen
+// after, the caller should do that.
 void scr_insert_text(const char *text)
 {
   char tmpLine[INPUTLINE_LENGTH+1];
@@ -857,6 +902,9 @@
   strcpy(ptr_inputline, tmpLine);
 }
 
+//  scr_handle_tab()
+// Function called when tab is pressed.
+// Initiate or continue a completion...
 void scr_handle_tab(void)
 {
   int nrow;