public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Simplify source window clearing
Date: Wed, 17 Jul 2019 18:39:00 -0000	[thread overview]
Message-ID: <20190717183900.71796.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f31ec9af48578adb0baf8db3e10da871d6ee3eca

commit f31ec9af48578adb0baf8db3e10da871d6ee3eca
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Jun 28 22:55:45 2019 -0600

    Simplify source window clearing
    
    When a TUI source window is empty, it displays a "No Source Available"
    message.  The function tui_set_source_content_nil also made sure to
    put this message into the window's "content" field.
    
    However, I believe this isn't really necessary.  Instead, it's simpler
    to just empty the contents and let curses handle the refreshing.
    
    gdb/ChangeLog
    2019-07-17  Tom Tromey  <tom@tromey.com>
    
    	* tui/tui-winsource.c (tui_erase_source_content): Clear the
    	window's contents.
    	* tui/tui-source.h (tui_set_source_content_nil): Don't declare.
    	* tui/tui-source.c (tui_set_source_content_nil): Remove.

Diff:
---
 gdb/ChangeLog           |  7 ++++++
 gdb/tui/tui-source.c    | 63 -------------------------------------------------
 gdb/tui/tui-source.h    |  3 ---
 gdb/tui/tui-winsource.c |  8 +------
 4 files changed, 8 insertions(+), 73 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ee17d50..4b5a876 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
 2019-07-17  Tom Tromey  <tom@tromey.com>
 
+	* tui/tui-winsource.c (tui_erase_source_content): Clear the
+	window's contents.
+	* tui/tui-source.h (tui_set_source_content_nil): Don't declare.
+	* tui/tui-source.c (tui_set_source_content_nil): Remove.
+
+2019-07-17  Tom Tromey  <tom@tromey.com>
+
 	* tui/tui-data.h (UNDEFINED_ITEM): Remove define.
 	(struct tui_data_item_window): Update.
 
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 2fcb42d..d3cce1c 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -209,69 +209,6 @@ tui_set_source_content (tui_source_window_base *win_info,
 }
 
 
-/* elz: This function sets the contents of the source window to empty
-   except for a line in the middle with a warning message about the
-   source not being available.  This function is called by
-   tui_erase_source_contents(), which in turn is invoked when the
-   source files cannot be accessed.  */
-
-void
-tui_set_source_content_nil (struct tui_source_window_base *win_info,
-			    const char *warning_string)
-{
-  int line_width;
-  int n_lines;
-  int curr_line = 0;
-
-  line_width = win_info->width - 1;
-  n_lines = win_info->height - 2;
-
-  /* Set to empty each line in the window, except for the one which
-     contains the message.  */
-  while (curr_line < win_info->content.size ())
-    {
-      /* Set the information related to each displayed line to null:
-         i.e. the line number is 0, there is no bp, it is not where
-         the program is stopped.  */
-
-      struct tui_source_element *element = &win_info->content[curr_line];
-
-      element->line_or_addr.loa = LOA_LINE;
-      element->line_or_addr.u.line_no = 0;
-      element->is_exec_point = false;
-      element->break_mode = 0;
-
-      /* Set the contents of the line to blank.  */
-      element->line[0] = (char) 0;
-
-      /* If the current line is in the middle of the screen, then we
-         want to display the 'no source available' message in it.
-         Note: the 'weird' arithmetic with the line width and height
-         comes from the function tui_erase_source_content().  We need
-         to keep the screen and the window's actual contents in
-         synch.  */
-
-      if (curr_line == (n_lines / 2 + 1))
-	{
-	  int xpos;
-	  int warning_length = strlen (warning_string);
-	  char *src_line;
-
-	  if (warning_length >= ((line_width - 1) / 2))
-	    xpos = 1;
-	  else
-	    xpos = (line_width - 1) / 2 - warning_length;
-
-	  src_line = xstrprintf ("%s%s", n_spaces (xpos), warning_string);
-	  xfree (element->line);
-	  element->line = src_line;
-	}
-
-      curr_line++;
-    }
-}
-
-
 /* Function to display source in the source window.  This function
    initializes the horizontal scroll to 0.  */
 void
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index e4b2313..fc129ab 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -27,9 +27,6 @@
 struct symtab;
 struct tui_win_info;
 
-extern void tui_set_source_content_nil (struct tui_source_window_base *,
-					const char *);
-
 extern enum tui_status tui_set_source_content (tui_source_window_base *,
 					       struct symtab *, 
 					       int, int);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 65aa516..2be2049 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -250,13 +250,7 @@ tui_erase_source_content (struct tui_source_window_base *win_info)
 		 x_pos,
 		 (char *) no_src_str);
 
-      /* elz: Added this function call to set the real contents of
-	 the window to what is on the screen, so that later calls
-	 to refresh, do display the correct stuff, and not the old
-	 image.  */
-
-      tui_set_source_content_nil (win_info, no_src_str);
-
+      win_info->content.clear ();
       win_info->refresh_window ();
     }
 }


                 reply	other threads:[~2019-07-17 18:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190717183900.71796.qmail@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).