📄 tuiwin.c
字号:
{ int _numToScroll = numToScroll; if (_numToScroll == 0) _numToScroll = 1; /* ** If we are scrolling the source or disassembly window, do a ** "psuedo" scroll since not all of the source is in memory, ** only what is in the viewport. If winToScroll is the ** command window do nothing since the term should handle it. */ if (winToScroll == srcWin || winToScroll == disassemWin) tuiHorizontalSourceScroll (winToScroll, RIGHT_SCROLL, _numToScroll); } return;} /* tuiScrollRight *//* ** tui_scroll(). ** Scroll a window. Arguments are passed through a va_list. */voidtui_scroll (TuiScrollDirection direction, TuiWinInfoPtr winToScroll, int numToScroll){ switch (direction) { case FORWARD_SCROLL: tuiScrollForward (winToScroll, numToScroll); break; case BACKWARD_SCROLL: tuiScrollBackward (winToScroll, numToScroll); break; case LEFT_SCROLL: tuiScrollLeft (winToScroll, numToScroll); break; case RIGHT_SCROLL: tuiScrollRight (winToScroll, numToScroll); break; default: break; }}/* ** tuiRefreshAll(). */voidtuiRefreshAll (void){ TuiWinType type; clearok (curscr, TRUE); refreshAll (winList); for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++) { if (winList[type] && winList[type]->generic.isVisible) { switch (type) { case SRC_WIN: case DISASSEM_WIN: tuiShowSourceContent (winList[type]); checkAndDisplayHighlightIfNeeded (winList[type]); tuiEraseExecInfoContent (winList[type]); tuiUpdateExecInfo (winList[type]); break; case DATA_WIN: tuiRefreshDataWin (); break; default: break; } } } tuiShowLocatorContent ();}/* ** tuiResizeAll(). ** Resize all the windows based on the the terminal size. This ** function gets called from within the readline sinwinch handler. */voidtuiResizeAll (void){ int heightDiff, widthDiff; int screenheight, screenwidth; rl_get_screen_size (&screenheight, &screenwidth); widthDiff = screenwidth - termWidth (); heightDiff = screenheight - termHeight (); if (heightDiff || widthDiff) { TuiLayoutType curLayout = currentLayout (); TuiWinInfoPtr winWithFocus = tuiWinWithFocus (); TuiWinInfoPtr firstWin, secondWin; TuiGenWinInfoPtr locator = locatorWinInfoPtr (); TuiWinType winType; int newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2; /* turn keypad off while we resize */ if (winWithFocus != cmdWin) keypad (cmdWin->generic.handle, FALSE); tui_update_gdb_sizes (); setTermHeightTo (screenheight); setTermWidthTo (screenwidth); if (curLayout == SRC_DISASSEM_COMMAND || curLayout == SRC_DATA_COMMAND || curLayout == DISASSEM_DATA_COMMAND) numWinsDisplayed++; splitDiff = heightDiff / numWinsDisplayed; cmdSplitDiff = splitDiff; if (heightDiff % numWinsDisplayed) { if (heightDiff < 0) cmdSplitDiff--; else cmdSplitDiff++; } /* now adjust each window */ clear (); refresh (); switch (curLayout) { case SRC_COMMAND: case DISASSEM_COMMAND: firstWin = (TuiWinInfoPtr) (sourceWindows ())->list[0]; firstWin->generic.width += widthDiff; locator->width += widthDiff; /* check for invalid heights */ if (heightDiff == 0) newHeight = firstWin->generic.height; else if ((firstWin->generic.height + splitDiff) >= (screenheight - MIN_CMD_WIN_HEIGHT - 1)) newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1; else if ((firstWin->generic.height + splitDiff) <= 0) newHeight = MIN_WIN_HEIGHT; else newHeight = firstWin->generic.height + splitDiff; _makeInvisibleAndSetNewHeight (firstWin, newHeight); cmdWin->generic.origin.y = locator->origin.y + 1; cmdWin->generic.width += widthDiff; newHeight = screenheight - cmdWin->generic.origin.y; _makeInvisibleAndSetNewHeight (cmdWin, newHeight); _makeVisibleWithNewHeight (firstWin); _makeVisibleWithNewHeight (cmdWin); if (firstWin->generic.contentSize <= 0) tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT); break; default: if (curLayout == SRC_DISASSEM_COMMAND) { firstWin = srcWin; firstWin->generic.width += widthDiff; secondWin = disassemWin; secondWin->generic.width += widthDiff; } else { firstWin = dataWin; firstWin->generic.width += widthDiff; secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0]; secondWin->generic.width += widthDiff; } /* Change the first window's height/width */ /* check for invalid heights */ if (heightDiff == 0) newHeight = firstWin->generic.height; else if ((firstWin->generic.height + secondWin->generic.height + (splitDiff * 2)) >= (screenheight - MIN_CMD_WIN_HEIGHT - 1)) newHeight = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2; else if ((firstWin->generic.height + splitDiff) <= 0) newHeight = MIN_WIN_HEIGHT; else newHeight = firstWin->generic.height + splitDiff; _makeInvisibleAndSetNewHeight (firstWin, newHeight); if (firstWin == dataWin && widthDiff != 0) firstWin->detail.dataDisplayInfo.regsColumnCount = tuiCalculateRegsColumnCount ( firstWin->detail.dataDisplayInfo.regsDisplayType); locator->width += widthDiff; /* Change the second window's height/width */ /* check for invalid heights */ if (heightDiff == 0) newHeight = secondWin->generic.height; else if ((firstWin->generic.height + secondWin->generic.height + (splitDiff * 2)) >= (screenheight - MIN_CMD_WIN_HEIGHT - 1)) { newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1; if (newHeight % 2) newHeight = (newHeight / 2) + 1; else newHeight /= 2; } else if ((secondWin->generic.height + splitDiff) <= 0) newHeight = MIN_WIN_HEIGHT; else newHeight = secondWin->generic.height + splitDiff; secondWin->generic.origin.y = firstWin->generic.height - 1; _makeInvisibleAndSetNewHeight (secondWin, newHeight); /* Change the command window's height/width */ cmdWin->generic.origin.y = locator->origin.y + 1; _makeInvisibleAndSetNewHeight ( cmdWin, cmdWin->generic.height + cmdSplitDiff); _makeVisibleWithNewHeight (firstWin); _makeVisibleWithNewHeight (secondWin); _makeVisibleWithNewHeight (cmdWin); if (firstWin->generic.contentSize <= 0) tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT); if (secondWin->generic.contentSize <= 0) tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT); break; } /* ** Now remove all invisible windows, and their content so that they get ** created again when called for with the new size */ for (winType = SRC_WIN; (winType < MAX_MAJOR_WINDOWS); winType++) { if (winType != CMD_WIN && m_winPtrNotNull (winList[winType]) && !winList[winType]->generic.isVisible) { freeWindow (winList[winType]); winList[winType] = (TuiWinInfoPtr) NULL; } } tuiSetWinResizedTo (TRUE); /* turn keypad back on, unless focus is in the command window */ if (winWithFocus != cmdWin) keypad (cmdWin->generic.handle, TRUE); } return;} /* tuiResizeAll *//* ** tuiSigwinchHandler() ** SIGWINCH signal handler for the tui. This signal handler is ** always called, even when the readline package clears signals ** because it is set as the old_sigwinch() (TUI only) */voidtuiSigwinchHandler (int signal){ /* ** Say that a resize was done so that the readline can do it ** later when appropriate. */ tuiSetWinResizedTo (TRUE); return;} /* tuiSigwinchHandler *//*************************** STATIC LOCAL FUNCTIONS**************************//* ** _tuiScrollForward_command(). */static void_tuiScrollForward_command (char *arg, int fromTTY){ int numToScroll = 1; TuiWinInfoPtr winToScroll; /* Make sure the curses mode is enabled. */ tui_enable (); if (arg == (char *) NULL) _parseScrollingArgs (arg, &winToScroll, (int *) NULL); else _parseScrollingArgs (arg, &winToScroll, &numToScroll); tui_scroll (FORWARD_SCROLL, winToScroll, numToScroll);}/* ** _tuiScrollBackward_command(). */static void_tuiScrollBackward_command (char *arg, int fromTTY){ int numToScroll = 1; TuiWinInfoPtr winToScroll; /* Make sure the curses mode is enabled. */ tui_enable (); if (arg == (char *) NULL) _parseScrollingArgs (arg, &winToScroll, (int *) NULL); else _parseScrollingArgs (arg, &winToScroll, &numToScroll); tui_scroll (BACKWARD_SCROLL, winToScroll, numToScroll);}/* ** _tuiScrollLeft_command(). */static void_tuiScrollLeft_command (char *arg, int fromTTY){ int numToScroll; TuiWinInfoPtr winToScroll; /* Make sure the curses mode is enabled. */ tui_enable (); _parseScrollingArgs (arg, &winToScroll, &numToScroll); tui_scroll (LEFT_SCROLL, winToScroll, numToScroll);}/* ** _tuiScrollRight_command(). */static void_tuiScrollRight_command (char *arg, int fromTTY){ int numToScroll; TuiWinInfoPtr winToScroll; /* Make sure the curses mode is enabled. */ tui_enable (); _parseScrollingArgs (arg, &winToScroll, &numToScroll); tui_scroll (RIGHT_SCROLL, winToScroll, numToScroll);}/* ** _tuiSetFocus(). ** Set focus to the window named by 'arg' */static void_tuiSetFocus (char *arg, int fromTTY){ if (arg != (char *) NULL) { char *bufPtr = (char *) xstrdup (arg); int i; TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL; for (i = 0; (i < strlen (bufPtr)); i++) bufPtr[i] = toupper (arg[i]); if (subset_compare (bufPtr, "NEXT")) winInfo = tuiNextWin (tuiWinWithFocus ()); else if (subset_compare (bufPtr, "PREV")) winInfo = tuiPrevWin (tuiWinWithFocus ()); else winInfo = partialWinByName (bufPtr); if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible) warning ("Invalid window specified. \n\The window name specified must be valid and visible.\n"); else { tuiSetWinFocusTo (winInfo); keypad (cmdWin->generic.handle, (winInfo != cmdWin)); } if (dataWin && dataWin->generic.isVisible) tuiRefreshDataWin (); tuiFree (bufPtr); printf_filtered ("Focus set to %s window.\n", winName ((TuiGenWinInfoPtr) tuiWinWithFocus ())); } else warning ("Incorrect Number of Arguments.\n%s", FOCUS_USAGE); return;} /* _tuiSetFocus *//* ** _tuiSetFocus_command() */static void_tuiSetFocus_command (char *arg, int fromTTY){ /* Make sure the curses mode is enabled. */ tui_enable (); _tuiSetFocus (arg, fromTTY);}/* ** _tuiAllWindowsInfo(). */static void_tuiAllWindowsInfo (char *arg, int fromTTY){ TuiWinType type; TuiWinInfoPtr winWithFocus = tuiWinWithFocus (); for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) if (winList[type] && winList[type]->generic.isVisible) { if (winWithFocus == winList[type]) printf_filtered (" %s\t(%d lines) <has focus>\n", winName (&winList[type]->generic), winList[type]->generic.height); else printf_filtered (" %s\t(%d lines)\n", winName (&winList[type]->generic), winList[type]->generic.height); } return;} /* _tuiAllWindowsInfo *//* ** _tuiRefreshAll_command(). */static void_tuiRefreshAll_command (char *arg, int fromTTY){ /* Make sure the curses mode is enabled. */ tui_enable (); tuiRefreshAll ();}/* ** _tuiSetWinTabWidth_command(). ** Set the height of the specified window. */static void_tuiSetTabWidth_command (char *arg, int fromTTY){ /* Make sure the curses mode is enabled. */ tui_enable (); if (arg != (char *) NULL) { int ts; ts = atoi (arg); if (ts > 0) tuiSetDefaultTabLen (ts); else warning ("Tab widths greater than 0 must be specified.\n"); } return;} /* _tuiSetTabWidth_command *//* ** _tuiSetWinHeight(). ** Set the height of the specified window. */static void_tuiSetWinHeight (char *arg, int fromTTY){ /* Make sure the curses mode is enabled. */ tui_enable (); if (arg != (char *) NULL) { char *buf = xstrdup (arg); char *bufPtr = buf; char *wname = (char *) NULL; int newHeight, i; TuiWinInfoPtr winInfo; wname = bufPtr; bufPtr = strchr (bufPtr, ' '); if (bufPtr != (char *) NULL) { *bufPtr = (char) 0; /* ** Validate the window name */ for (i = 0; i < strlen (wname); i++) wname[i] = toupper (wname[i]); winInfo = partialWinByName (wname); if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible) warning ("Invalid window specified. \n\The window name specified must be valid and visible.\n"); else { /* Process the size */ while (*(++bufPtr) == ' ') ; if (*bufPtr != (char) 0) { int negate = FALSE; int fixedSize = TRUE; int inputNo;; if (*bufPtr == '+' || *bufPtr == '-') { if (*bufPtr == '-') negate = TRUE; fixedSize = FALSE; bufPtr++; } inputNo = atoi (bufPtr); if (inputNo > 0) { if (negate) inputNo *= (-1); if (fixedSize) newHeight = inputNo; else newHeight = winInfo->generic.height + inputNo; /* ** Now change the window's height, and adjust all ** other windows around it */ if (_tuiAdjustWinHeights (winInfo, newHeight) == TUI_FAILURE) warning ("Invalid window height specified.\n%s", WIN_HEIGHT_USAGE); else tui_update_gdb_sizes (); } else warning ("Invalid window height specified.\n%s", WIN_HEIGHT_USAGE); } } } else printf_filtered (WIN_HEIGHT_USAGE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -