• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revision7134f2eb9230f86adb8839ac9cc737c7f4b47b59 (tree)
Time2020-07-02 12:21:15
AuthorTom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

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.

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,26 @@
11 2020-07-01 Tom Tromey <tom@tromey.com>
22
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+
324 * tui/tui-regs.c (tui_data_window::show_register_group)
425 (tui_data_window::check_register_values): Update.
526 * tui/tui-regs.h (struct tui_data_item_window) <regno>: Rename
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -102,7 +102,7 @@ public:
102102 }
103103
104104 /* Disable output until the next call to doupdate. */
105- virtual void no_refresh ()
105+ void no_refresh ()
106106 {
107107 if (handle != nullptr)
108108 wnoutrefresh (handle.get ());
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -272,8 +272,6 @@ tui_data_window::show_register_group (struct reggroup *group,
272272 void
273273 tui_data_window::display_registers_from (int start_element_no)
274274 {
275- int j, item_win_width, cur_y;
276-
277275 int max_len = 0;
278276 for (auto &&data_item_win : m_regs_content)
279277 {
@@ -282,26 +280,28 @@ tui_data_window::display_registers_from (int start_element_no)
282280 if (len > max_len)
283281 max_len = len;
284282 }
285- item_win_width = max_len + 1;
283+ m_item_width = max_len + 1;
286284 int i = start_element_no;
287285
288- m_regs_column_count = (width - 2) / item_win_width;
286+ m_regs_column_count = (width - 2) / m_item_width;
289287 if (m_regs_column_count == 0)
290288 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;
292290
293291 /* Now create each data "sub" window, and write the display into
294292 it. */
295- cur_y = 1;
293+ int cur_y = 1;
296294 while (i < m_regs_content.size () && cur_y <= height - 2)
297295 {
298- for (j = 0;
296+ for (int j = 0;
299297 j < m_regs_column_count && i < m_regs_content.size ();
300298 j++)
301299 {
302300 /* 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);
305305 i++; /* Next register. */
306306 }
307307 cur_y++; /* Next row. */
@@ -372,10 +372,7 @@ tui_data_window::first_data_item_displayed ()
372372 {
373373 for (int i = 0; i < m_regs_content.size (); i++)
374374 {
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)
379376 return i;
380377 }
381378
@@ -387,8 +384,8 @@ tui_data_window::first_data_item_displayed ()
387384 void
388385 tui_data_window::delete_data_content_windows ()
389386 {
390- for (auto &&win : m_regs_content)
391- win.handle.reset (nullptr);
387+ for (auto &win : m_regs_content)
388+ win.visible = false;
392389 }
393390
394391
@@ -451,24 +448,6 @@ tui_data_window::do_scroll_vertical (int num_to_scroll)
451448 }
452449 }
453450
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-
472451 /* This function check all displayed registers for changes in values,
473452 given a particular frame. If the values have changed, they are
474453 updated with the new value and highlighted. */
@@ -490,32 +469,28 @@ tui_data_window::check_register_values (struct frame_info *frame)
490469 &data_item_win.highlight);
491470
492471 if (data_item_win.highlight || was_hilighted)
493- data_item_win.rerender ();
472+ data_item_win.rerender (handle.get (), m_item_width);
494473 }
495474 }
475+
476+ tui_wrefresh (handle.get ());
496477 }
497478
498479 /* Display a register in a window. If hilite is TRUE, then the value
499480 will be displayed in reverse video. */
500481 void
501-tui_data_item_window::rerender ()
482+tui_data_item_window::rerender (WINDOW *handle, int field_width)
502483 {
503- int i;
504-
505- scrollok (handle.get (), FALSE);
506484 if (highlight)
507485 /* We ignore the return value, casting it to void in order to avoid
508486 a compiler warning. The warning itself was introduced by a patch
509487 to ncurses 5.7 dated 2009-08-29, changing this macro to expand
510488 to code that causes the compiler to generate an unused-value
511489 warning. */
512- (void) wstandout (handle.get ());
490+ (void) wstandout (handle);
513491
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 ()));
519494
520495 if (highlight)
521496 /* We ignore the return value, casting it to void in order to avoid
@@ -523,21 +498,7 @@ tui_data_item_window::rerender ()
523498 to ncurses 5.7 dated 2009-08-29, changing this macro to expand
524499 to code that causes the compiler to generate an unused-value
525500 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);
541502 }
542503
543504 /* Helper for "tui reg next", wraps a call to REGGROUP_NEXT, but adds wrap
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -26,7 +26,7 @@
2626
2727 /* A data item window. */
2828
29-struct tui_data_item_window : public tui_gen_win_info
29+struct tui_data_item_window
3030 {
3131 tui_data_item_window () = default;
3232
@@ -34,23 +34,15 @@ struct tui_data_item_window : public tui_gen_win_info
3434
3535 tui_data_item_window (tui_data_item_window &&) = default;
3636
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);
5038
39+ /* Location. */
40+ int x = 0;
41+ int y = 0;
5142 /* The register number. */
5243 int regno = -1;
5344 bool highlight = false;
45+ bool visible = false;
5446 std::string content;
5547 };
5648
@@ -61,10 +53,6 @@ struct tui_data_window : public tui_win_info
6153
6254 DISABLE_COPY_AND_ASSIGN (tui_data_window);
6355
64- void refresh_window () override;
65-
66- void no_refresh () override;
67-
6856 const char *name () const override
6957 {
7058 return DATA_NAME;
@@ -138,6 +126,9 @@ private:
138126 std::vector<tui_data_item_window> m_regs_content;
139127 int m_regs_column_count = 0;
140128 struct reggroup *m_current_group = nullptr;
129+
130+ /* Width of each register's display area. */
131+ int m_item_width = 0;
141132 };
142133
143134 #endif /* TUI_TUI_REGS_H */