GNU Binutils with patches for OS216
Revision | 7134f2eb9230f86adb8839ac9cc737c7f4b47b59 (tree) |
---|---|
Time | 2020-07-02 12:21:15 |
Author | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
Don't derive tui_data_item_window from tui_gen_win_info
There's no deep reason that tui_data_item_window should derive from
tui_gen_win_info -- it currently uses a curses window to render, but
that isn't truly needed, and it adds some hacks to other parts of the
TUI.
This patch changes tui_data_item_window so that it doesn't have a base
class, and updates the register window. This simplifies the code and
enables a subsequent cleanup.
gdb/ChangeLog
2020-07-01 Tom Tromey <tom@tromey.com>
* tui/tui-regs.c (tui_data_window::display_registers_from)
(tui_data_window::display_registers_from)
(tui_data_window::first_data_item_displayed)
(tui_data_window::delete_data_content_windows): Update.
(tui_data_window::refresh_window, tui_data_window::no_refresh):
Remove.
(tui_data_window::check_register_values): Update.
(tui_data_item_window::rerender): Add parameters. Update.
(tui_data_item_window::refresh_window): Remove.
* tui/tui-data.h (struct tui_gen_win_info) <no_refresh>: No longer
virtual.
* tui/tui-regs.h (struct tui_data_item_window): Don't derive from
tui_gen_win_info.
<refresh_window, max_height, min_height>: Remove.
<rerender>: Add parameters.
<x, y, visible>: New members.
(struct tui_data_window) <refresh_window, no_refresh>: Remove.
<m_item_width>: New member.
@@ -1,5 +1,26 @@ | ||
1 | 1 | 2020-07-01 Tom Tromey <tom@tromey.com> |
2 | 2 | |
3 | + * tui/tui-regs.c (tui_data_window::display_registers_from) | |
4 | + (tui_data_window::display_registers_from) | |
5 | + (tui_data_window::first_data_item_displayed) | |
6 | + (tui_data_window::delete_data_content_windows): Update. | |
7 | + (tui_data_window::refresh_window, tui_data_window::no_refresh): | |
8 | + Remove. | |
9 | + (tui_data_window::check_register_values): Update. | |
10 | + (tui_data_item_window::rerender): Add parameters. Update. | |
11 | + (tui_data_item_window::refresh_window): Remove. | |
12 | + * tui/tui-data.h (struct tui_gen_win_info) <no_refresh>: No longer | |
13 | + virtual. | |
14 | + * tui/tui-regs.h (struct tui_data_item_window): Don't derive from | |
15 | + tui_gen_win_info. | |
16 | + <refresh_window, max_height, min_height>: Remove. | |
17 | + <rerender>: Add parameters. | |
18 | + <x, y, visible>: New members. | |
19 | + (struct tui_data_window) <refresh_window, no_refresh>: Remove. | |
20 | + <m_item_width>: New member. | |
21 | + | |
22 | +2020-07-01 Tom Tromey <tom@tromey.com> | |
23 | + | |
3 | 24 | * tui/tui-regs.c (tui_data_window::show_register_group) |
4 | 25 | (tui_data_window::check_register_values): Update. |
5 | 26 | * tui/tui-regs.h (struct tui_data_item_window) <regno>: Rename |
@@ -102,7 +102,7 @@ public: | ||
102 | 102 | } |
103 | 103 | |
104 | 104 | /* Disable output until the next call to doupdate. */ |
105 | - virtual void no_refresh () | |
105 | + void no_refresh () | |
106 | 106 | { |
107 | 107 | if (handle != nullptr) |
108 | 108 | wnoutrefresh (handle.get ()); |
@@ -272,8 +272,6 @@ tui_data_window::show_register_group (struct reggroup *group, | ||
272 | 272 | void |
273 | 273 | tui_data_window::display_registers_from (int start_element_no) |
274 | 274 | { |
275 | - int j, item_win_width, cur_y; | |
276 | - | |
277 | 275 | int max_len = 0; |
278 | 276 | for (auto &&data_item_win : m_regs_content) |
279 | 277 | { |
@@ -282,26 +280,28 @@ tui_data_window::display_registers_from (int start_element_no) | ||
282 | 280 | if (len > max_len) |
283 | 281 | max_len = len; |
284 | 282 | } |
285 | - item_win_width = max_len + 1; | |
283 | + m_item_width = max_len + 1; | |
286 | 284 | int i = start_element_no; |
287 | 285 | |
288 | - m_regs_column_count = (width - 2) / item_win_width; | |
286 | + m_regs_column_count = (width - 2) / m_item_width; | |
289 | 287 | if (m_regs_column_count == 0) |
290 | 288 | m_regs_column_count = 1; |
291 | - item_win_width = (width - 2) / m_regs_column_count; | |
289 | + m_item_width = (width - 2) / m_regs_column_count; | |
292 | 290 | |
293 | 291 | /* Now create each data "sub" window, and write the display into |
294 | 292 | it. */ |
295 | - cur_y = 1; | |
293 | + int cur_y = 1; | |
296 | 294 | while (i < m_regs_content.size () && cur_y <= height - 2) |
297 | 295 | { |
298 | - for (j = 0; | |
296 | + for (int j = 0; | |
299 | 297 | j < m_regs_column_count && i < m_regs_content.size (); |
300 | 298 | j++) |
301 | 299 | { |
302 | 300 | /* Create the window if necessary. */ |
303 | - m_regs_content[i].resize (1, item_win_width, | |
304 | - x + (item_win_width * j) + 1, y + cur_y); | |
301 | + m_regs_content[i].x = (m_item_width * j) + 1; | |
302 | + m_regs_content[i].y = cur_y; | |
303 | + m_regs_content[i].visible = true; | |
304 | + m_regs_content[i].rerender (handle.get (), m_item_width); | |
305 | 305 | i++; /* Next register. */ |
306 | 306 | } |
307 | 307 | cur_y++; /* Next row. */ |
@@ -372,10 +372,7 @@ tui_data_window::first_data_item_displayed () | ||
372 | 372 | { |
373 | 373 | for (int i = 0; i < m_regs_content.size (); i++) |
374 | 374 | { |
375 | - struct tui_gen_win_info *data_item_win; | |
376 | - | |
377 | - data_item_win = &m_regs_content[i]; | |
378 | - if (data_item_win->is_visible ()) | |
375 | + if (m_regs_content[i].visible) | |
379 | 376 | return i; |
380 | 377 | } |
381 | 378 |
@@ -387,8 +384,8 @@ tui_data_window::first_data_item_displayed () | ||
387 | 384 | void |
388 | 385 | tui_data_window::delete_data_content_windows () |
389 | 386 | { |
390 | - for (auto &&win : m_regs_content) | |
391 | - win.handle.reset (nullptr); | |
387 | + for (auto &win : m_regs_content) | |
388 | + win.visible = false; | |
392 | 389 | } |
393 | 390 | |
394 | 391 |
@@ -451,24 +448,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll) | ||
451 | 448 | } |
452 | 449 | } |
453 | 450 | |
454 | -/* See tui-regs.h. */ | |
455 | - | |
456 | -void | |
457 | -tui_data_window::refresh_window () | |
458 | -{ | |
459 | - tui_gen_win_info::refresh_window (); | |
460 | - for (auto &&win : m_regs_content) | |
461 | - win.refresh_window (); | |
462 | -} | |
463 | - | |
464 | -void | |
465 | -tui_data_window::no_refresh () | |
466 | -{ | |
467 | - tui_gen_win_info::no_refresh (); | |
468 | - for (auto &&win : m_regs_content) | |
469 | - win.no_refresh (); | |
470 | -} | |
471 | - | |
472 | 451 | /* This function check all displayed registers for changes in values, |
473 | 452 | given a particular frame. If the values have changed, they are |
474 | 453 | updated with the new value and highlighted. */ |
@@ -490,32 +469,28 @@ tui_data_window::check_register_values (struct frame_info *frame) | ||
490 | 469 | &data_item_win.highlight); |
491 | 470 | |
492 | 471 | if (data_item_win.highlight || was_hilighted) |
493 | - data_item_win.rerender (); | |
472 | + data_item_win.rerender (handle.get (), m_item_width); | |
494 | 473 | } |
495 | 474 | } |
475 | + | |
476 | + tui_wrefresh (handle.get ()); | |
496 | 477 | } |
497 | 478 | |
498 | 479 | /* Display a register in a window. If hilite is TRUE, then the value |
499 | 480 | will be displayed in reverse video. */ |
500 | 481 | void |
501 | -tui_data_item_window::rerender () | |
482 | +tui_data_item_window::rerender (WINDOW *handle, int field_width) | |
502 | 483 | { |
503 | - int i; | |
504 | - | |
505 | - scrollok (handle.get (), FALSE); | |
506 | 484 | if (highlight) |
507 | 485 | /* We ignore the return value, casting it to void in order to avoid |
508 | 486 | a compiler warning. The warning itself was introduced by a patch |
509 | 487 | to ncurses 5.7 dated 2009-08-29, changing this macro to expand |
510 | 488 | to code that causes the compiler to generate an unused-value |
511 | 489 | warning. */ |
512 | - (void) wstandout (handle.get ()); | |
490 | + (void) wstandout (handle); | |
513 | 491 | |
514 | - wmove (handle.get (), 0, 0); | |
515 | - for (i = 1; i < width; i++) | |
516 | - waddch (handle.get (), ' '); | |
517 | - wmove (handle.get (), 0, 0); | |
518 | - waddstr (handle.get (), content.c_str ()); | |
492 | + mvwaddnstr (handle, y, x, content.c_str (), field_width - 1); | |
493 | + waddstr (handle, n_spaces (field_width - content.size ())); | |
519 | 494 | |
520 | 495 | if (highlight) |
521 | 496 | /* We ignore the return value, casting it to void in order to avoid |
@@ -523,21 +498,7 @@ tui_data_item_window::rerender () | ||
523 | 498 | to ncurses 5.7 dated 2009-08-29, changing this macro to expand |
524 | 499 | to code that causes the compiler to generate an unused-value |
525 | 500 | warning. */ |
526 | - (void) wstandend (handle.get ()); | |
527 | - refresh_window (); | |
528 | -} | |
529 | - | |
530 | -void | |
531 | -tui_data_item_window::refresh_window () | |
532 | -{ | |
533 | - if (handle != nullptr) | |
534 | - { | |
535 | - /* This seems to be needed because the data items are nested | |
536 | - windows, which according to the ncurses man pages aren't well | |
537 | - supported. */ | |
538 | - touchwin (handle.get ()); | |
539 | - tui_wrefresh (handle.get ()); | |
540 | - } | |
501 | + (void) wstandend (handle); | |
541 | 502 | } |
542 | 503 | |
543 | 504 | /* Helper for "tui reg next", wraps a call to REGGROUP_NEXT, but adds wrap |
@@ -26,7 +26,7 @@ | ||
26 | 26 | |
27 | 27 | /* A data item window. */ |
28 | 28 | |
29 | -struct tui_data_item_window : public tui_gen_win_info | |
29 | +struct tui_data_item_window | |
30 | 30 | { |
31 | 31 | tui_data_item_window () = default; |
32 | 32 |
@@ -34,23 +34,15 @@ struct tui_data_item_window : public tui_gen_win_info | ||
34 | 34 | |
35 | 35 | tui_data_item_window (tui_data_item_window &&) = default; |
36 | 36 | |
37 | - void rerender () override; | |
38 | - | |
39 | - void refresh_window () override; | |
40 | - | |
41 | - int max_height () const override | |
42 | - { | |
43 | - return 1; | |
44 | - } | |
45 | - | |
46 | - int min_height () const override | |
47 | - { | |
48 | - return 1; | |
49 | - } | |
37 | + void rerender (WINDOW *handle, int field_width); | |
50 | 38 | |
39 | + /* Location. */ | |
40 | + int x = 0; | |
41 | + int y = 0; | |
51 | 42 | /* The register number. */ |
52 | 43 | int regno = -1; |
53 | 44 | bool highlight = false; |
45 | + bool visible = false; | |
54 | 46 | std::string content; |
55 | 47 | }; |
56 | 48 |
@@ -61,10 +53,6 @@ struct tui_data_window : public tui_win_info | ||
61 | 53 | |
62 | 54 | DISABLE_COPY_AND_ASSIGN (tui_data_window); |
63 | 55 | |
64 | - void refresh_window () override; | |
65 | - | |
66 | - void no_refresh () override; | |
67 | - | |
68 | 56 | const char *name () const override |
69 | 57 | { |
70 | 58 | return DATA_NAME; |
@@ -138,6 +126,9 @@ private: | ||
138 | 126 | std::vector<tui_data_item_window> m_regs_content; |
139 | 127 | int m_regs_column_count = 0; |
140 | 128 | struct reggroup *m_current_group = nullptr; |
129 | + | |
130 | + /* Width of each register's display area. */ | |
131 | + int m_item_width = 0; | |
141 | 132 | }; |
142 | 133 | |
143 | 134 | #endif /* TUI_TUI_REGS_H */ |