1 /* TUI display registers in window. 2 3 Copyright (C) 1998-2024 Free Software Foundation, Inc. 4 5 Contributed by Hewlett-Packard Company. 6 7 This file is part of GDB. 8 9 This program is free software; you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation; either version 3 of the License, or 12 (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 21 22 #ifndef TUI_TUI_REGS_H 23 #define TUI_TUI_REGS_H 24 25 #include "tui/tui-data.h" 26 #include "reggroups.h" 27 28 /* Information about the display of a single register. */ 29 30 struct tui_register_info 31 { tui_register_infotui_register_info32 tui_register_info (int regno, const frame_info_ptr &frame) 33 : m_regno (regno) 34 { 35 update (frame); 36 highlight = false; 37 } 38 39 DISABLE_COPY_AND_ASSIGN (tui_register_info); 40 41 tui_register_info (tui_register_info &&) = default; 42 43 void update (const frame_info_ptr &frame); 44 45 void rerender (WINDOW *handle, int field_width); 46 visibletui_register_info47 bool visible () const 48 { return y > 0; } 49 50 /* Location. */ 51 int x = 0; 52 int y = 0; 53 bool highlight = false; 54 std::string content; 55 56 private: 57 58 /* The register number. */ 59 const int m_regno; 60 }; 61 62 /* The TUI registers window. */ 63 struct tui_data_window : public tui_win_info 64 { tui_data_windowtui_data_window65 tui_data_window () 66 { 67 update_register_data (nullptr); 68 } 69 70 DISABLE_COPY_AND_ASSIGN (tui_data_window); 71 nametui_data_window72 const char *name () const override 73 { 74 return DATA_NAME; 75 } 76 77 void check_register_values (const frame_info_ptr &frame); 78 79 void set_register_group (const reggroup *group); 80 get_current_grouptui_data_window81 const reggroup *get_current_group () const 82 { 83 return m_current_group; 84 } 85 86 protected: 87 88 void do_scroll_vertical (int num_to_scroll) override; do_scroll_horizontaltui_data_window89 void do_scroll_horizontal (int num_to_scroll) override 90 { 91 } 92 93 void rerender () override; 94 95 private: 96 97 /* Display the registers in the content from 'start_element_no' 98 until the end of the register content or the end of the display 99 height. No checking for displaying past the end of the registers 100 is done here. */ 101 void display_registers_from (int start_element_no); 102 103 /* Display the registers starting at line line_no in the data 104 window. Answers the line number that the display actually 105 started from. If nothing is displayed (-1) is returned. */ 106 int display_registers_from_line (int line_no); 107 108 /* Return the index of the first element displayed. If none are 109 displayed, then return -1. */ 110 int first_data_item_displayed (); 111 112 /* Display the registers in the content from 'start_element_no' on 113 'start_line_no' until the end of the register content or the end 114 of the display height. This function checks that we won't 115 display off the end of the register display. */ 116 void display_reg_element_at_line (int start_element_no, int start_line_no); 117 118 void update_register_data (const reggroup *group); 119 120 /* Answer the number of the last line in the regs display. If there 121 are no registers (-1) is returned. */ 122 int last_regs_line_no () const; 123 124 /* Answer the line number that the register element at element_no is 125 on. If element_no is greater than the number of register 126 elements there are, -1 is returned. */ 127 int line_from_reg_element_no (int element_no) const; 128 129 /* Answer the index of the first element in line_no. If line_no is 130 past the register area (-1) is returned. */ 131 int first_reg_element_no_inline (int line_no) const; 132 133 void erase_data_content (); 134 135 /* Information about each register in the current register group. */ 136 std::vector<tui_register_info> m_regs_content; 137 int m_regs_column_count = 0; 138 const reggroup *m_current_group = nullptr; 139 140 /* Width of each register's display area. */ 141 int m_item_width = 0; 142 143 /* Architecture of frame whose registers are being displayed, or 144 nullptr if the display is empty (i.e., there is no frame). */ 145 gdbarch *m_gdbarch = nullptr; 146 }; 147 148 #endif /* TUI_TUI_REGS_H */ 149