能否将GDB TUI模式的默认垂直布局改为水平布局?
Absolutely, you can customize the GDB TUI layout to arrange the source, assembly, and command windows horizontally (left to right) instead of the default vertical stack. Here's how to do it step by step:
1. Define a Custom Horizontal Layout
First, enter TUI mode if you haven’t already (press Ctrl+X A or run tui enable in GDB). Then use the tui new-layout command to create your desired layout:
tui new-layout horizontal_src_asm_cmd src 1 asm 1 cmd 1 horizontal
Let’s break down what this command does:
horizontal_src_asm_cmd: A custom name for your layout (feel free to use any name you prefer)src 1: The source window takes up 1 unit of space (adjust this number to give more/less width to the source pane)asm 1: The assembly window takes up 1 unit of spacecmd 1: The command window takes up 1 unit of spacehorizontal: Arranges all three windows in a left-to-right horizontal row
2. Apply the Custom Layout
Once you’ve defined the layout, activate it with:
tui apply-layout horizontal_src_asm_cmd
You’ll immediately see the windows shift to your new arrangement: source on the left, assembly in the middle, command on the right.
3. Set the Custom Layout as Default (Optional)
If you want this layout to load automatically every time you start GDB, add these lines to your .gdbinit file (create the file in your home directory if it doesn’t exist):
tui enable tui new-layout horizontal_src_asm_cmd src 1 asm 1 cmd 1 horizontal tui apply-layout horizontal_src_asm_cmd
4. Adjust Window Sizes (Optional)
To prioritize one window (e.g., give more space to the source pane), tweak the numbers in the layout definition. For example, make the source window twice as wide as the others:
tui new-layout horizontal_src_asm_cmd src 2 asm 1 cmd 1 horizontal tui apply-layout horizontal_src_asm_cmd
Switching Back to Default Layout
If you ever want to revert to the original vertical stack, run:
tui apply-layout default
内容的提问来源于stack exchange,提问作者isamateur

