From 8a39a981bd8d576de0d343b8c2eee47655d8c720 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 30 May 2024 22:54:05 -0400 Subject: gdb/tui: change some macros to functions Change the `TUI_*` macros to access known windows to functions. Define them in their respective files, because trying to define them in tui-data.h would end up causing include cycles. This makes static analysis (detection of unused include files in this case) more accurate, and I think in general we should avoid hiding code behind macros if not necessary. Change-Id: I1e38cee843984c48ab34030b19dac0d726f851af Approved-By: Tom Tromey --- gdb/tui/tui-io.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'gdb/tui/tui-io.c') diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 09fba02..299a809 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -165,7 +165,7 @@ do_tui_putc (WINDOW *w, char c) static void update_cmdwin_start_line () { - TUI_CMD_WIN->start_line = getcury (TUI_CMD_WIN->handle.get ()); + tui_cmd_win ()->start_line = getcury (tui_cmd_win ()->handle.get ()); } /* Print a character in the curses command window. The output is @@ -175,7 +175,7 @@ update_cmdwin_start_line () static void tui_putc (char c) { - do_tui_putc (TUI_CMD_WIN->handle.get (), c); + do_tui_putc (tui_cmd_win ()->handle.get (), c); update_cmdwin_start_line (); } @@ -458,7 +458,7 @@ void tui_puts (const char *string, WINDOW *w) { if (w == nullptr) - w = TUI_CMD_WIN->handle.get (); + w = tui_cmd_win ()->handle.get (); while (true) { @@ -509,7 +509,7 @@ tui_puts (const char *string, WINDOW *w) string = next; } - if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ()) + if (tui_cmd_win () != nullptr && w == tui_cmd_win ()->handle.get ()) update_cmdwin_start_line (); } @@ -553,7 +553,7 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) } } - if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ()) + if (tui_cmd_win () != nullptr && w == tui_cmd_win ()->handle.get ()) update_cmdwin_start_line (); if (saw_nl) wrefresh (w); @@ -583,8 +583,8 @@ tui_redisplay_readline (void) int c_pos = -1; int c_line = -1; - WINDOW *w = TUI_CMD_WIN->handle.get (); - int start_line = TUI_CMD_WIN->start_line; + WINDOW *w = tui_cmd_win ()->handle.get (); + int start_line = tui_cmd_win ()->start_line; wmove (w, start_line, 0); int height = 1; if (prompt != nullptr) @@ -624,17 +624,17 @@ tui_redisplay_readline (void) waddch (w, c); } if (c == '\n') - TUI_CMD_WIN->start_line = getcury (w); + tui_cmd_win ()->start_line = getcury (w); int col = getcurx (w); if (col < prev_col) height++; prev_col = col; } wclrtobot (w); - TUI_CMD_WIN->start_line = getcury (w); + tui_cmd_win ()->start_line = getcury (w); if (c_line >= 0) wmove (w, c_line, c_pos); - TUI_CMD_WIN->start_line -= height - 1; + tui_cmd_win ()->start_line -= height - 1; wrefresh (w); fflush(stdout); @@ -709,7 +709,7 @@ tui_mld_puts (const struct match_list_displayer *displayer, const char *s) static void tui_mld_flush (const struct match_list_displayer *displayer) { - wrefresh (TUI_CMD_WIN->handle.get ()); + wrefresh (tui_cmd_win ()->handle.get ()); } /* TUI version of displayer.erase_entire_line. */ @@ -717,7 +717,7 @@ tui_mld_flush (const struct match_list_displayer *displayer) static void tui_mld_erase_entire_line (const struct match_list_displayer *displayer) { - WINDOW *w = TUI_CMD_WIN->handle.get (); + WINDOW *w = tui_cmd_win ()->handle.get (); int cur_y = getcury (w); wmove (w, cur_y, 0); @@ -755,7 +755,7 @@ gdb_wgetch (WINDOW *win) static int tui_mld_getc (FILE *fp) { - WINDOW *w = TUI_CMD_WIN->handle.get (); + WINDOW *w = tui_cmd_win ()->handle.get (); int c = gdb_wgetch (w); return c; @@ -1037,7 +1037,7 @@ tui_inject_newline_into_command_window () { gdb_assert (tui_active); - WINDOW *w = TUI_CMD_WIN->handle.get (); + WINDOW *w = tui_cmd_win ()->handle.get (); /* When hitting return with an empty input, gdb executes the last command. If we emit a newline, this fills up the command window @@ -1062,8 +1062,8 @@ tui_inject_newline_into_command_window () int px, py; getyx (w, py, px); px += rl_end - rl_point; - py += px / TUI_CMD_WIN->width; - px %= TUI_CMD_WIN->width; + py += px / tui_cmd_win ()->width; + px %= tui_cmd_win ()->width; wmove (w, py, px); tui_putc ('\n'); } @@ -1097,7 +1097,7 @@ tui_getc_1 (FILE *fp) int ch; WINDOW *w; - w = TUI_CMD_WIN->handle.get (); + w = tui_cmd_win ()->handle.get (); #ifdef TUI_USE_PIPE_FOR_READLINE /* Flush readline output. */ -- cgit v1.1