This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: Avoid clear/refresh TUI windows several times


Hi!

When the TUI changes of layout, windows are first cleared, curses is flushed,
the new layout is drawn and curses is flushed again.  This results in window
flashing on slow terminals.

I've committed this patch to cleanup a little bit more the TUI and avoid
the window clear/refresh (mostly code removal).

	Stephane

2002-08-24  Stephane Carrez  <stcarrez@nerim.fr>

	* tuiSourceWin.c (tui_show_source_line): New function.
	(tuiShowSourceContent): Call it and avoid clearing the window before
	redrawing it.
	(tuiClearAllSourceWinsContent): Remove.
	* tuiSourceWin.h (tuiClearAllSourceWinsContent): Don't declare.
	* tuiWin.h (tuiClearWinFocus, tuiClearWinFocusFrom): Don't declare.
	* tuiWin.c (tuiClearWinFocus, tuiClearWinFocusFrom): Remove.
	(tuiRefreshAll): Don't clear the window.
	(_makeVisibleWithNewHeight): Don't clear locator line.
	(tuiResizeAll): Remove unused locals.
	(_tuiAdjustWinHeights): Likewise.
	(_makeInvisibleAndSetNewHeight): Likewise.
	(_newHeightOk): Likewise.
	* tuiLayout.c (showLayout): Don't clear source windows.
	(tuiSetLayout): Don't clear the window.
	(_initAndMakeWin): Likewise for status line.
	* tuiGeneralWin.c (makeVisible): Don't clear or refresh the window.
	(makeWindow): Likewise.
	(tuiClearWin): Remove.
	* tuiGeneralWin.h (tuiClearWin): Don't declare.

Index: tuiGeneralWin.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiGeneralWin.c,v
retrieving revision 1.10
diff -u -p -r1.10 tuiGeneralWin.c
--- tuiGeneralWin.c	24 Aug 2002 10:15:54 -0000	1.10
+++ tuiGeneralWin.c	24 Aug 2002 12:17:33 -0000
@@ -191,43 +191,8 @@ makeWindow (TuiGenWinInfoPtr winInfo, in
 	boxWin (winInfo, NO_HILITE);
       winInfo->isVisible = TRUE;
       scrollok (handle, TRUE);
-      tuiRefreshWin (winInfo);
-
-#ifndef FOR_TEST
-      if (			/*!m_WinIsAuxillary(winInfo->type) && */
-	   (winInfo->type != CMD_WIN) &&
-	   (winInfo->content == (OpaquePtr) NULL))
-	{
-	  mvwaddstr (handle, 1, 1, winName (winInfo));
-	  tuiRefreshWin (winInfo);
-	}
-#endif /*FOR_TEST */
     }
-
-  return;
-}				/* makeWindow */
-
-
-/*
-   ** tuiClearWin().
-   **        Clear the window of all contents without calling wclear.
- */
-void
-tuiClearWin (TuiGenWinInfoPtr winInfo)
-{
-  if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL)
-    {
-      int curRow, curCol;
-
-      for (curRow = 0; (curRow < winInfo->height); curRow++)
-	for (curCol = 0; (curCol < winInfo->width); curCol++)
-	  mvwaddch (winInfo->handle, curRow, curCol, ' ');
-
-      tuiRefreshWin (winInfo);
-    }
-
-  return;
-}				/* tuiClearWin */
+}
 
 
 /*
@@ -252,13 +217,11 @@ makeVisible (TuiGenWinInfoPtr winInfo, i
 	   (winInfo->type != CMD_WIN && !m_winIsAuxillary (winInfo->type)));
 	  winInfo->isVisible = TRUE;
 	}
-      tuiRefreshWin (winInfo);
     }
   else if (!visible &&
 	   winInfo->isVisible && winInfo->handle != (WINDOW *) NULL)
     {
       winInfo->isVisible = FALSE;
-      tuiClearWin (winInfo);
       tuiDelwin (winInfo->handle);
       winInfo->handle = (WINDOW *) NULL;
     }
Index: tuiGeneralWin.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiGeneralWin.h,v
retrieving revision 1.4
diff -u -p -r1.4 tuiGeneralWin.h
--- tuiGeneralWin.h	24 Aug 2002 10:15:54 -0000	1.4
+++ tuiGeneralWin.h	24 Aug 2002 12:17:33 -0000
@@ -1,5 +1,5 @@
 /* General window behavior.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Hewlett-Packard Company.
 
    This file is part of GDB.
@@ -25,7 +25,6 @@
 /*
    ** Functions
  */
-extern void tuiClearWin (TuiGenWinInfoPtr);
 extern void unhighlightWin (TuiWinInfoPtr);
 extern void makeVisible (TuiGenWinInfoPtr, int);
 extern void makeAllVisible (int);
Index: tuiLayout.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiLayout.c,v
retrieving revision 1.15
diff -u -p -r1.15 tuiLayout.c
--- tuiLayout.c	1 Mar 2002 06:19:28 -0000	1.15
+++ tuiLayout.c	24 Aug 2002 12:17:33 -0000
@@ -111,7 +111,6 @@ showLayout (TuiLayoutType layout)
          ** should free the content and reallocate on next display of
          ** source/asm
        */
-      tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT);
       freeAllSourceWinsContent ();
       clearSourceWindows ();
       if (layout == SRC_DATA_COMMAND || layout == DISASSEM_DATA_COMMAND)
@@ -146,9 +145,7 @@ showLayout (TuiLayoutType layout)
 	    }
 	}
     }
-
-  return;
-}				/* showLayout */
+}
 
 
 /*
@@ -195,8 +192,6 @@ tuiSetLayout (TuiLayoutType layoutType,
 	{
 	  if (newLayout != curLayout)
 	    {
-	      if (winWithFocus != cmdWin)
-		tuiClearWinFocus ();
 	      showLayout (newLayout);
 	      /*
 	         ** Now determine where focus should be
@@ -291,7 +286,7 @@ tuiSetLayout (TuiLayoutType layoutType,
     status = TUI_FAILURE;
 
   return status;
-}				/* tuiSetLayout */
+}
 
 /*
    ** tuiAddWinToLayout().
@@ -1033,13 +1028,9 @@ _initAndMakeWin (Opaque * winInfoPtr, Tu
 	    ((TuiWinInfoPtr) opaqueWinInfo)->canHighlight = TRUE;
 	}
       makeWindow (generic, boxIt);
-      if (winType == LOCATOR_WIN)
-	tuiClearLocatorDisplay ();
     }
   *winInfoPtr = opaqueWinInfo;
-
-  return;
-}				/* _initAndMakeWin */
+}
 
 
 /*
Index: tuiSourceWin.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiSourceWin.c,v
retrieving revision 1.12
diff -u -p -r1.12 tuiSourceWin.c
--- tuiSourceWin.c	24 Aug 2002 10:15:54 -0000	1.12
+++ tuiSourceWin.c	24 Aug 2002 12:17:33 -0000
@@ -260,22 +260,6 @@ tuiClearSourceContent (TuiWinInfoPtr win
 
 
 /*
-   ** tuiClearAllSourceWinsContent().
- */
-void
-tuiClearAllSourceWinsContent (int displayPrompt)
-{
-  int i;
-
-  for (i = 0; i < (sourceWindows ())->count; i++)
-    tuiClearSourceContent ((TuiWinInfoPtr) (sourceWindows ())->list[i],
-			   displayPrompt);
-
-  return;
-}				/* tuiClearAllSourceWinsContent */
-
-
-/*
    ** tuiEraseSourceContent().
  */
 void
@@ -334,33 +318,51 @@ tuiEraseAllSourceWinsContent (int displa
 }				/* tuiEraseAllSourceWinsContent */
 
 
+/* Redraw the complete line of a source or disassembly window.  */
+static void
+tui_show_source_line (TuiWinInfoPtr winInfo, int lineno)
+{
+  TuiWinElementPtr line;
+  int x, y;
+
+  line = (TuiWinElementPtr) winInfo->generic.content[lineno - 1];
+  if (line->whichElement.source.isExecPoint)
+    wattron (winInfo->generic.handle, A_STANDOUT);
+
+  mvwaddstr (winInfo->generic.handle, lineno, 1,
+             line->whichElement.source.line);
+  if (line->whichElement.source.isExecPoint)
+    wattroff (winInfo->generic.handle, A_STANDOUT);
+
+  /* Clear to end of line but stop before the border.  */
+  getyx (winInfo->generic.handle, y, x);
+  while (x + 1 < winInfo->generic.width)
+    {
+      waddch (winInfo->generic.handle, ' ');
+      getyx (winInfo->generic.handle, y, x);
+    }
+}
+
 /*
    ** tuiShowSourceContent().
  */
 void
 tuiShowSourceContent (TuiWinInfoPtr winInfo)
 {
-  int curLine, i, curX;
-
-  tuiEraseSourceContent (winInfo, (winInfo->generic.contentSize <= 0));
   if (winInfo->generic.contentSize > 0)
     {
-      char *line;
+      int lineno;
 
-      for (curLine = 1; (curLine <= winInfo->generic.contentSize); curLine++)
-	mvwaddstr (
-		    winInfo->generic.handle,
-		    curLine,
-		    1,
-		    ((TuiWinElementPtr)
-	  winInfo->generic.content[curLine - 1])->whichElement.source.line);
+      for (lineno = 1; lineno <= winInfo->generic.contentSize; lineno++)
+        tui_show_source_line (winInfo, lineno);
     }
+  else
+    tuiEraseSourceContent (winInfo, TRUE);
+
   checkAndDisplayHighlightIfNeeded (winInfo);
   tuiRefreshWin (&winInfo->generic);
   winInfo->generic.contentInUse = TRUE;
-
-  return;
-}				/* tuiShowSourceContent */
+}
 
 
 /*
Index: tuiSourceWin.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiSourceWin.h,v
retrieving revision 1.8
diff -u -p -r1.8 tuiSourceWin.h
--- tuiSourceWin.h	24 Aug 2002 10:15:54 -0000	1.8
+++ tuiSourceWin.h	24 Aug 2002 12:17:33 -0000
@@ -1,5 +1,5 @@
 /* TUI display source/assembly window.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Hewlett-Packard Company.
 
    This file is part of GDB.
@@ -31,7 +31,6 @@ extern void tuiUpdateSourceWindowsWithAd
 extern void tuiUpdateSourceWindowsWithLine (struct symtab *, int);
 extern void tuiUpdateSourceWindowsFromLocator (void);
 extern void tuiClearSourceContent (TuiWinInfoPtr, int);
-extern void tuiClearAllSourceWinsContent (int);
 extern void tuiEraseSourceContent (TuiWinInfoPtr, int);
 extern void tuiEraseAllSourceWinsContent (int);
 extern void tuiSetSourceContentNil (TuiWinInfoPtr, char *);
Index: tuiWin.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiWin.c,v
retrieving revision 1.19
diff -u -p -r1.19 tuiWin.c
--- tuiWin.c	1 Mar 2002 06:19:28 -0000	1.19
+++ tuiWin.c	24 Aug 2002 12:17:34 -0000
@@ -398,37 +398,6 @@ Usage: w <#lines>\n");
 
 
 /*
-   ** tuiClearWinFocusFrom
-   **        Clear the logical focus from winInfo
- */
-void
-tuiClearWinFocusFrom (TuiWinInfoPtr winInfo)
-{
-  if (m_winPtrNotNull (winInfo))
-    {
-      if (winInfo->generic.type != CMD_WIN)
-	unhighlightWin (winInfo);
-      tuiSetWinWithFocus ((TuiWinInfoPtr) NULL);
-    }
-
-  return;
-}				/* tuiClearWinFocusFrom */
-
-
-/*
-   ** tuiClearWinFocus().
-   **        Clear the window that has focus.
- */
-void
-tuiClearWinFocus (void)
-{
-  tuiClearWinFocusFrom (tuiWinWithFocus ());
-
-  return;
-}				/* tuiClearWinFocus */
-
-
-/*
    ** tuiSetWinFocusTo
    **        Set the logical focus to winInfo
  */
@@ -607,9 +576,6 @@ tuiRefreshAll (void)
 	    {
 	    case SRC_WIN:
 	    case DISASSEM_WIN:
-	      tuiClearWin (&winList[type]->generic);
-	      if (winList[type]->detail.sourceInfo.hasLocator)
-		tuiClearLocatorDisplay ();
 	      tuiShowSourceContent (winList[type]);
 	      checkAndDisplayHighlightIfNeeded (winList[type]);
 	      tuiEraseExecInfoContent (winList[type]);
@@ -623,11 +589,8 @@ tuiRefreshAll (void)
 	    }
 	}
     }
-  tuiClearLocatorDisplay ();
   tuiShowLocatorContent ();
-
-  return;
-}				/* tuiRefreshAll */
+}
 
 
 /*
@@ -650,7 +613,7 @@ tuiResizeAll (void)
       TuiWinInfoPtr firstWin, secondWin;
       TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
       TuiWinType winType;
-      int i, newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2;
+      int newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2;
 
       /* turn keypad off while we resize */
       if (winWithFocus != cmdWin)
@@ -1168,7 +1131,7 @@ _tuiAdjustWinHeights (TuiWinInfoPtr prim
       status = TUI_SUCCESS;
       if (newHeight != primaryWinInfo->generic.height)
 	{
-	  int i, diff;
+	  int diff;
 	  TuiWinInfoPtr winInfo;
 	  TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
 	  TuiLayoutType curLayout = currentLayout ();
@@ -1316,7 +1279,6 @@ static void
 _makeInvisibleAndSetNewHeight (TuiWinInfoPtr winInfo, int height)
 {
   int i;
-  struct symtab *s;
   TuiGenWinInfoPtr genWinInfo;
 
 
@@ -1365,9 +1327,7 @@ _makeInvisibleAndSetNewHeight (TuiWinInf
     default:
       break;
     }
-
-  return;
-}				/* _makeInvisibleAndSetNewHeight */
+}
 
 
 /*
@@ -1379,7 +1339,6 @@ _makeInvisibleAndSetNewHeight (TuiWinInf
 static void
 _makeVisibleWithNewHeight (TuiWinInfoPtr winInfo)
 {
-  int i;
   struct symtab *s;
 
   m_beVisible (&winInfo->generic);
@@ -1421,7 +1380,6 @@ _makeVisibleWithNewHeight (TuiWinInfoPtr
       if (m_hasLocator (winInfo))
 	{
 	  m_beVisible (locatorWinInfoPtr ());
-	  tuiClearLocatorDisplay ();
 	  tuiShowLocatorContent ();
 	}
       break;
@@ -1450,7 +1408,7 @@ _newHeightOk (TuiWinInfoPtr primaryWinIn
 
   if (ok)
     {
-      int diff, curHeight;
+      int diff;
       TuiLayoutType curLayout = currentLayout ();
 
       diff = (newHeight - primaryWinInfo->generic.height) * (-1);
Index: tuiWin.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiWin.h,v
retrieving revision 1.5
diff -u -p -r1.5 tuiWin.h
--- tuiWin.h	21 Jul 2001 19:44:38 -0000	1.5
+++ tuiWin.h	24 Aug 2002 12:17:34 -0000
@@ -1,5 +1,5 @@
 /* TUI window generic functions.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Hewlett-Packard Company.
 
    This file is part of GDB.
@@ -37,8 +37,6 @@ extern void tuiScrollLeft (TuiWinInfoPtr
 extern void tuiScrollRight (TuiWinInfoPtr, int);
 extern void tui_scroll (TuiScrollDirection, TuiWinInfoPtr, int);
 extern void tuiSetWinFocusTo (TuiWinInfoPtr);
-extern void tuiClearWinFocusFrom (TuiWinInfoPtr);
-extern void tuiClearWinFocus (void);
 extern void tuiResizeAll (void);
 extern void tuiRefreshAll (void);
 extern void tuiSigwinchHandler (int);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]