⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tuiwin.c

📁 gdb-6.0 linux 下的调试工具
💻 C
📖 第 1 页 / 共 3 页
字号:
      if (buf != (char *) NULL)	tuiFree (buf);    }  else    printf_filtered (WIN_HEIGHT_USAGE);  return;}				/* _tuiSetWinHeight *//*   ** _tuiSetWinHeight_command().   **        Set the height of the specified window, with va_list. */static void_tuiSetWinHeight_command (char *arg, int fromTTY){  /* Make sure the curses mode is enabled.  */  tui_enable ();  _tuiSetWinHeight (arg, fromTTY);}/*   ** _tuiXDBsetWinHeight().   **        XDB Compatibility command for setting the window height.  This will   **        increase or decrease the command window by the specified amount. */static void_tuiXDBsetWinHeight (char *arg, int fromTTY){  /* Make sure the curses mode is enabled.  */  tui_enable ();  if (arg != (char *) NULL)    {      int inputNo = atoi (arg);      if (inputNo > 0)	{			/* Add 1 for the locator */	  int newHeight = termHeight () - (inputNo + 1);	  if (!_newHeightOk (winList[CMD_WIN], newHeight) ||	      _tuiAdjustWinHeights (winList[CMD_WIN],				    newHeight) == TUI_FAILURE)	    warning ("Invalid window height specified.\n%s",		     XDBWIN_HEIGHT_USAGE);	}      else	warning ("Invalid window height specified.\n%s",		 XDBWIN_HEIGHT_USAGE);    }  else    warning ("Invalid window height specified.\n%s", XDBWIN_HEIGHT_USAGE);  return;}				/* _tuiXDBsetWinHeight *//*   ** _tuiSetWinHeight_command().   **        Set the height of the specified window, with va_list. */static void_tuiXDBsetWinHeight_command (char *arg, int fromTTY){  _tuiXDBsetWinHeight (arg, fromTTY);}/*   ** _tuiAdjustWinHeights().   **        Function to adjust all window heights around the primary */static TuiStatus_tuiAdjustWinHeights (TuiWinInfoPtr primaryWinInfo, int newHeight){  TuiStatus status = TUI_FAILURE;  if (_newHeightOk (primaryWinInfo, newHeight))    {      status = TUI_SUCCESS;      if (newHeight != primaryWinInfo->generic.height)	{	  int diff;	  TuiWinInfoPtr winInfo;	  TuiGenWinInfoPtr locator = locatorWinInfoPtr ();	  TuiLayoutType curLayout = currentLayout ();	  diff = (newHeight - primaryWinInfo->generic.height) * (-1);	  if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND)	    {	      TuiWinInfoPtr srcWinInfo;	      _makeInvisibleAndSetNewHeight (primaryWinInfo, newHeight);	      if (primaryWinInfo->generic.type == CMD_WIN)		{		  winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0];		  srcWinInfo = winInfo;		}	      else		{		  winInfo = winList[CMD_WIN];		  srcWinInfo = primaryWinInfo;		}	      _makeInvisibleAndSetNewHeight (winInfo,					     winInfo->generic.height + diff);	      cmdWin->generic.origin.y = locator->origin.y + 1;	      _makeVisibleWithNewHeight (winInfo);	      _makeVisibleWithNewHeight (primaryWinInfo);	      if (srcWinInfo->generic.contentSize <= 0)		tuiEraseSourceContent (srcWinInfo, EMPTY_SOURCE_PROMPT);	    }	  else	    {	      TuiWinInfoPtr firstWin, secondWin;	      if (curLayout == SRC_DISASSEM_COMMAND)		{		  firstWin = srcWin;		  secondWin = disassemWin;		}	      else		{		  firstWin = dataWin;		  secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];		}	      if (primaryWinInfo == cmdWin)		{		/*				   ** Split the change in height accross the 1st & 2nd windows				   ** adjusting them as well.				 */		  int firstSplitDiff = diff / 2;	/* subtract the locator */		  int secondSplitDiff = firstSplitDiff;		  if (diff % 2)		    {		      if (firstWin->generic.height >			  secondWin->generic.height)			if (diff < 0)			  firstSplitDiff--;			else			  firstSplitDiff++;		      else			{			  if (diff < 0)			    secondSplitDiff--;			  else			    secondSplitDiff++;			}		    }		  /* make sure that the minimum hieghts are honored */		  while ((firstWin->generic.height + firstSplitDiff) < 3)		    {		      firstSplitDiff++;		      secondSplitDiff--;		    }		  while ((secondWin->generic.height + secondSplitDiff) < 3)		    {		      secondSplitDiff++;		      firstSplitDiff--;		    }		  _makeInvisibleAndSetNewHeight (						  firstWin,				 firstWin->generic.height + firstSplitDiff);		  secondWin->generic.origin.y = firstWin->generic.height - 1;		  _makeInvisibleAndSetNewHeight (		    secondWin, secondWin->generic.height + secondSplitDiff);		  cmdWin->generic.origin.y = locator->origin.y + 1;		  _makeInvisibleAndSetNewHeight (cmdWin, newHeight);		}	      else		{		  if ((cmdWin->generic.height + diff) < 1)		    {		/*				   ** If there is no way to increase the command window				   ** take real estate from the 1st or 2nd window.				 */		      if ((cmdWin->generic.height + diff) < 1)			{			  int i;			  for (i = cmdWin->generic.height + diff;			       (i < 1); i++)			    if (primaryWinInfo == firstWin)			      secondWin->generic.height--;			    else			      firstWin->generic.height--;			}		    }		  if (primaryWinInfo == firstWin)		    _makeInvisibleAndSetNewHeight (firstWin, newHeight);		  else		    _makeInvisibleAndSetNewHeight (						    firstWin,						  firstWin->generic.height);		  secondWin->generic.origin.y = firstWin->generic.height - 1;		  if (primaryWinInfo == secondWin)		    _makeInvisibleAndSetNewHeight (secondWin, newHeight);		  else		    _makeInvisibleAndSetNewHeight (				      secondWin, secondWin->generic.height);		  cmdWin->generic.origin.y = locator->origin.y + 1;		  if ((cmdWin->generic.height + diff) < 1)		    _makeInvisibleAndSetNewHeight (cmdWin, 1);		  else		    _makeInvisibleAndSetNewHeight (				     cmdWin, cmdWin->generic.height + diff);		}	      _makeVisibleWithNewHeight (cmdWin);	      _makeVisibleWithNewHeight (secondWin);	      _makeVisibleWithNewHeight (firstWin);	      if (firstWin->generic.contentSize <= 0)		tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT);	      if (secondWin->generic.contentSize <= 0)		tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT);	    }	}    }  return status;}				/* _tuiAdjustWinHeights *//*   ** _makeInvisibleAndSetNewHeight().   **        Function make the target window (and auxillary windows associated   **        with the targer) invisible, and set the new height and location. */static void_makeInvisibleAndSetNewHeight (TuiWinInfoPtr winInfo, int height){  int i;  TuiGenWinInfoPtr genWinInfo;  m_beInvisible (&winInfo->generic);  winInfo->generic.height = height;  if (height > 1)    winInfo->generic.viewportHeight = height - 1;  else    winInfo->generic.viewportHeight = height;  if (winInfo != cmdWin)    winInfo->generic.viewportHeight--;  /* Now deal with the auxillary windows associated with winInfo */  switch (winInfo->generic.type)    {    case SRC_WIN:    case DISASSEM_WIN:      genWinInfo = winInfo->detail.sourceInfo.executionInfo;      m_beInvisible (genWinInfo);      genWinInfo->height = height;      genWinInfo->origin.y = winInfo->generic.origin.y;      if (height > 1)	genWinInfo->viewportHeight = height - 1;      else	genWinInfo->viewportHeight = height;      if (winInfo != cmdWin)	genWinInfo->viewportHeight--;      if (m_hasLocator (winInfo))	{	  genWinInfo = locatorWinInfoPtr ();	  m_beInvisible (genWinInfo);	  genWinInfo->origin.y = winInfo->generic.origin.y + height;	}      break;    case DATA_WIN:      /* delete all data item windows */      for (i = 0; i < winInfo->generic.contentSize; i++)	{	  genWinInfo = (TuiGenWinInfoPtr) & ((TuiWinElementPtr)		      winInfo->generic.content[i])->whichElement.dataWindow;	  tuiDelwin (genWinInfo->handle);	  genWinInfo->handle = (WINDOW *) NULL;	}      break;    default:      break;    }}/*   ** _makeVisibleWithNewHeight().   **        Function to make the windows with new heights visible.   **        This means re-creating the windows' content since the window   **        had to be destroyed to be made invisible. */static void_makeVisibleWithNewHeight (TuiWinInfoPtr winInfo){  struct symtab *s;  m_beVisible (&winInfo->generic);  checkAndDisplayHighlightIfNeeded (winInfo);  switch (winInfo->generic.type)    {    case SRC_WIN:    case DISASSEM_WIN:      freeWinContent (winInfo->detail.sourceInfo.executionInfo);      m_beVisible (winInfo->detail.sourceInfo.executionInfo);      if (winInfo->generic.content != (OpaquePtr) NULL)	{	  TuiLineOrAddress lineOrAddr;	  struct symtab_and_line cursal	    = get_current_source_symtab_and_line ();	  if (winInfo->generic.type == SRC_WIN)	    lineOrAddr.lineNo =	      winInfo->detail.sourceInfo.startLineOrAddr.lineNo;	  else	    lineOrAddr.addr =	      winInfo->detail.sourceInfo.startLineOrAddr.addr;	  freeWinContent (&winInfo->generic);	  tuiUpdateSourceWindow (winInfo,				 cursal.symtab, lineOrAddr, TRUE);	}      else if (deprecated_selected_frame != (struct frame_info *) NULL)	{	  TuiLineOrAddress line;	  struct symtab_and_line cursal = get_current_source_symtab_and_line ();	  s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));	  if (winInfo->generic.type == SRC_WIN)	    line.lineNo = cursal.line;	  else	    {	      find_line_pc (s, cursal.line, &line.addr);	    }	  tuiUpdateSourceWindow (winInfo, s, line, TRUE);	}      if (m_hasLocator (winInfo))	{	  m_beVisible (locatorWinInfoPtr ());	  tuiShowLocatorContent ();	}      break;    case DATA_WIN:      tuiDisplayAllData ();      break;    case CMD_WIN:      winInfo->detail.commandInfo.curLine = 0;      winInfo->detail.commandInfo.curch = 0;      wmove (winInfo->generic.handle,	     winInfo->detail.commandInfo.curLine,	     winInfo->detail.commandInfo.curch);      break;    default:      break;    }  return;}				/* _makeVisibleWithNewHeight */static int_newHeightOk (TuiWinInfoPtr primaryWinInfo, int newHeight){  int ok = (newHeight < termHeight ());  if (ok)    {      int diff;      TuiLayoutType curLayout = currentLayout ();      diff = (newHeight - primaryWinInfo->generic.height) * (-1);      if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND)	{	  ok = ((primaryWinInfo->generic.type == CMD_WIN &&		 newHeight <= (termHeight () - 4) &&		 newHeight >= MIN_CMD_WIN_HEIGHT) ||		(primaryWinInfo->generic.type != CMD_WIN &&		 newHeight <= (termHeight () - 2) &&		 newHeight >= MIN_WIN_HEIGHT));	  if (ok)	    {			/* check the total height */	      TuiWinInfoPtr winInfo;	      if (primaryWinInfo == cmdWin)		winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0];	      else		winInfo = cmdWin;	      ok = ((newHeight +		     (winInfo->generic.height + diff)) <= termHeight ());	    }	}      else	{	  int curTotalHeight, totalHeight, minHeight = 0;	  TuiWinInfoPtr firstWin, secondWin;	  if (curLayout == SRC_DISASSEM_COMMAND)	    {	      firstWin = srcWin;	      secondWin = disassemWin;	    }	  else	    {	      firstWin = dataWin;	      secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];	    }	  /*	     ** We could simply add all the heights to obtain the same result	     ** but below is more explicit since we subtract 1 for the	     ** line that the first and second windows share, and add one	     ** for the locator.	   */	  totalHeight = curTotalHeight =	    (firstWin->generic.height + secondWin->generic.height - 1)	    + cmdWin->generic.height + 1 /*locator */ ;	  if (primaryWinInfo == cmdWin)	    {	      /* locator included since first & second win share a line */	      ok = ((firstWin->generic.height +		     secondWin->generic.height + diff) >=		    (MIN_WIN_HEIGHT * 2) &&		    newHeight >= MIN_CMD_WIN_HEIGHT);	      if (ok)		{		  totalHeight = newHeight + (firstWin->generic.height +					  secondWin->generic.height + diff);		  minHeight = MIN_CMD_WIN_HEIGHT;		}	    }	  else	    {	      minHeight = MIN_WIN_HEIGHT;	      /*	         ** First see if we can increase/decrease the command	         ** window.  And make sure that the command window is	         ** at least 1 line	       */	      ok = ((cmdWin->generic.height + diff) > 0);	      if (!ok)		{		/*				   ** Looks like we have to increase/decrease one of				   ** the other windows				 */		  if (primaryWinInfo == firstWin)		    ok = (secondWin->generic.height + diff) >= minHeight;		  else		    ok = (firstWin->generic.height + diff) >= minHeight;		}	      if (ok)		{		  if (primaryWinInfo == firstWin)		    totalHeight = newHeight +		      secondWin->generic.height +		      cmdWin->generic.height + diff;		  else		    totalHeight = newHeight +		      firstWin->generic.height +		      cmdWin->generic.height + diff;		}	    }	  /*	     ** Now make sure that the proposed total height doesn't exceed	     ** the old total height.	   */	  if (ok)	    ok = (newHeight >= minHeight && totalHeight <= curTotalHeight);	}    }  return ok;}				/* _newHeightOk *//*   ** _parseScrollingArgs(). */static void_parseScrollingArgs (char *arg, TuiWinInfoPtr * winToScroll, int *numToScroll){  if (numToScroll)    *numToScroll = 0;  *winToScroll = tuiWinWithFocus ();  /*     ** First set up the default window to scroll, in case there is no     ** window name arg   */  if (arg != (char *) NULL)    {      char *buf, *bufPtr;      /* process the number of lines to scroll */      buf = bufPtr = xstrdup (arg);      if (isdigit (*bufPtr))	{	  char *numStr;	  numStr = bufPtr;	  bufPtr = strchr (bufPtr, ' ');	  if (bufPtr != (char *) NULL)	    {	      *bufPtr = (char) 0;	      if (numToScroll)		*numToScroll = atoi (numStr);	      bufPtr++;	    }	  else if (numToScroll)	    *numToScroll = atoi (numStr);	}      /* process the window name if one is specified */      if (bufPtr != (char *) NULL)	{	  char *wname;	  int i;	  if (*bufPtr == ' ')	    while (*(++bufPtr) == ' ')	      ;	  if (*bufPtr != (char) 0)	    wname = bufPtr;	  else	    wname = "?";	  	  /* Validate the window name */	  for (i = 0; i < strlen (wname); i++)	    wname[i] = toupper (wname[i]);	  *winToScroll = partialWinByName (wname);	  if (*winToScroll == (TuiWinInfoPtr) NULL ||	      !(*winToScroll)->generic.isVisible)	    warning ("Invalid window specified. \n\The window name specified must be valid and visible.\n");	  else if (*winToScroll == cmdWin)	    *winToScroll = (TuiWinInfoPtr) (sourceWindows ())->list[0];	}      tuiFree (buf);    }  return;}				/* _parseScrollingArgs */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -