public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Phi Debian <phi.debian@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: TUI enhancement suggestion.
Date: Tue, 9 Jun 2020 17:03:58 +0200	[thread overview]
Message-ID: <CAJOr74hae0-qguChBQvbfk5qk_Lc_C_FgO-RYA5ADL4xPQ6JZQ@mail.gmail.com> (raw)
In-Reply-To: <CAJOr74jYnKriMyjV6kzbfNGttuNxOxUrAuEit0jP3nvC6icC-A@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 302 bytes --]

Here is the patch I made, I spotted a little typo in a comment, I leave it
in there for now, and provide this as a demonstrator.

I never submitted a patch so I don't really know the best practice, I
cutted it on top of 9.2 (latest pull) then the patch)
I used

$ git format-patch -1 HEAD

Cheers,
Phi

[-- Attachment #2: 0001-Implement-point-underline.patch --]
[-- Type: text/x-patch, Size: 5680 bytes --]

From 395ae414f395d58bd07a44077d4586512924d451 Mon Sep 17 00:00:00 2001
From: Phi <phi@kernel-tools.com>
Date: Tue, 9 Jun 2020 11:59:47 +0200
Subject: [PATCH] Implement point underline

---
 gdb/tui/tui-io.c        | 18 ++++++++++++++++++
 gdb/tui/tui-io.h        |  3 +++
 gdb/tui/tui-win.c       | 31 +++++++++++++++++++++++++++++++
 gdb/tui/tui-win.h       |  3 +++
 gdb/tui/tui-winsource.c |  4 ++--
 gdb/ui-style.h          | 15 ++++++++++++++-
 6 files changed, 71 insertions(+), 3 deletions(-)

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index e7a8ac77bc..7dcc76bab8 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -294,6 +294,7 @@ tui_apply_style (WINDOW *w, ui_file_style style)
   /* Reset.  */
   wattron (w, A_NORMAL);
   wattroff (w, A_BOLD);
+  wattroff (w, A_UNDERLINE);
   wattroff (w, A_DIM);
   wattroff (w, A_REVERSE);
   if (last_color_pair != -1)
@@ -330,6 +331,10 @@ tui_apply_style (WINDOW *w, ui_file_style style)
     case ui_file_style::NORMAL:
       break;
 
+    case ui_file_style::UNDERLINE:
+      wattron (w, A_UNDERLINE); 
+      break;
+
     case ui_file_style::BOLD:
       wattron (w, A_BOLD);
       break;
@@ -423,6 +428,19 @@ tui_set_reverse_mode (WINDOW *w, bool reverse)
   tui_apply_style (w, style);
 }
 
+
+void
+tui_set_point_mode (WINDOW *w, bool mode)
+{ ui_file_style style = last_style;
+  if(point_underline==0)
+  { tui_set_reverse_mode(w,mode);
+  }
+  if(point_underline==1)
+  { style.set_underline(mode);
+    tui_apply_style (w, style);
+  }  
+}
+
 /* Print LENGTH characters from the buffer pointed to by BUF to the
    curses command window.  The output is buffered.  It is up to the
    caller to refresh the screen if necessary.  */
diff --git a/gdb/tui/tui-io.h b/gdb/tui/tui-io.h
index f28cf4e12d..8aa81b43d8 100644
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -51,6 +51,9 @@ extern gdb::unique_xmalloc_ptr<char> tui_expand_tabs (const char *);
 /* Enter/leave reverse video mode.  */
 extern void tui_set_reverse_mode (WINDOW *w, bool reverse);
 
+/* Enter/leave point (exec) video mode.  */
+extern void tui_set_point_mode (WINDOW *w, bool mode);
+
 /* Apply STYLE to the window.  */
 extern void tui_apply_style (WINDOW *w, ui_file_style style);
 
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a78837fe68..54336e1337 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -823,6 +823,29 @@ tui_show_compact_source (struct ui_file *file, int from_tty,
   printf_filtered (_("TUI source window compactness is %s.\n"), value);
 }
 
+
+bool point_underline = false;
+
+/* Callback for "set tui point-underline".  */
+
+static void
+tui_set_point_underline (const char *ignore, int from_tty,
+			struct cmd_list_element *c)
+{
+  if (TUI_SRC_WIN != nullptr)
+    TUI_SRC_WIN->refill ();
+}
+
+/* Callback for "show tui compact-source".  */
+
+static void
+tui_show_point_underline (struct ui_file *file, int from_tty,
+			 struct cmd_list_element *c, const char *value)
+{
+  printf_filtered (_("TUI source point underline is %s.\n"), value);
+}
+
+
 /* Set the tab width of the specified window.  */
 static void
 tui_set_tab_width_command (const char *arg, int from_tty)
@@ -1120,6 +1143,14 @@ the line numbers and uses less horizontal space."),
 			   tui_set_compact_source, tui_show_compact_source,
 			   &tui_setlist, &tui_showlist);
 
+  add_setshow_boolean_cmd ("point-underline", class_tui,
+			   &point_underline, _("\
+Set whether the TUI source point line is underline."), _("\
+Show whether the TUI source point line is underline."), _("\
+This variable controls whether the TUI source point line is underlined.\n"),
+			   tui_set_point_underline, tui_show_point_underline,
+			   &tui_setlist, &tui_showlist);  
+
   tui_border_style.changed.attach (tui_rehighlight_all);
   tui_active_border_style.changed.attach (tui_rehighlight_all);
 }
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index e379184630..d5fbfc5fea 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -57,4 +57,7 @@ struct cmd_list_element **tui_get_cmd_list (void);
 /* Whether compact source display should be used.  */
 extern bool compact_source;
 
+/* Whether underline point line should be used.  */
+extern bool point_underline;
+
 #endif /* TUI_TUI_WIN_H */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index db0add9968..c9f493292a 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -258,12 +258,12 @@ tui_source_window_base::show_source_line (int lineno)
 
   line = &m_content[lineno - 1];
   if (line->is_exec_point)
-    tui_set_reverse_mode (handle.get (), true);
+    tui_set_point_mode (handle.get (), true);
 
   wmove (handle.get (), lineno, TUI_EXECINFO_SIZE);
   tui_puts (line->line.c_str (), handle.get ());
   if (line->is_exec_point)
-    tui_set_reverse_mode (handle.get (), false);
+    tui_set_point_mode (handle.get (), false);
 
   /* Clear to end of line but stop before the border.  */
   x = getcurx (handle.get ());
diff --git a/gdb/ui-style.h b/gdb/ui-style.h
index 48ab52d5ea..5566f38c2f 100644
--- a/gdb/ui-style.h
+++ b/gdb/ui-style.h
@@ -135,7 +135,8 @@ struct ui_file_style
   {
     NORMAL = 0,
     BOLD,
-    DIM
+    DIM,
+    UNDERLINE
   };
 
   ui_file_style () = default;
@@ -210,6 +211,18 @@ struct ui_file_style
     m_background = c;
   }
 
+  /* Set the intensity of this style to bold  */
+  void set_bold (bool mode) 
+  { 
+    m_intensity=mode?BOLD:NORMAL;
+  }
+
+  /* Set the intensity of this style to bold  */
+  void set_underline (bool mode) 
+  { 
+    m_intensity=mode?UNDERLINE:NORMAL;
+  }
+
   /* Return the intensity of this style.  */
   intensity get_intensity () const
   {
-- 
2.25.1


  reply	other threads:[~2020-06-09 15:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09  7:55 Phi Debian
2020-06-09 13:04 ` Pedro Alves
2020-06-09 14:32   ` Phi Debian
2020-06-09 15:03     ` Phi Debian [this message]
2020-06-11 10:34       ` Pedro Alves
2020-06-11 13:55         ` Phi Debian
2020-06-15 14:20           ` Pedro Alves
2020-06-15 15:48             ` Hannes Domani
2020-06-15 16:56               ` Phi Debian
2020-06-15 19:30                 ` Pedro Alves
2020-06-15 19:47                   ` Phi Debian
2020-06-15 20:12                   ` Tom Tromey
2020-06-15 20:45                     ` Pedro Alves
2020-06-16  3:38                       ` Phi Debian
2020-06-16 11:02                         ` [PATCH] Add "set style tui-current-position on|off" default to off Pedro Alves
2020-06-16 14:33                           ` Eli Zaretskii
2022-11-15 10:09                           ` Andrew Burgess
2022-11-15 12:15                             ` Pedro Alves
2022-11-16 10:41                               ` Andrew Burgess
2022-11-17  6:30                                 ` Phi Debian
     [not found]   ` <CAJOr74jg==A7NM4qtWEq6neXqxpxxtUEVdDgsahfvRobW+Q0wA@mail.gmail.com>
     [not found]     ` <CAJOr74hQdi6Y4MpGy=J-3CTRA2PP08OebTO2hBFN5NyDRokb3Q@mail.gmail.com>
     [not found]       ` <CAJOr74gyyw4hJm9j0fzKQdzkJKzq=yiAXyZx_c2Q=RA8GTSN7Q@mail.gmail.com>
     [not found]         ` <ed9ea9c6-3d4d-6ba7-4672-bff2b2617012@redhat.com>
2020-06-10 20:25           ` TUI enhancement suggestion Phi Debian
2020-06-11 10:17             ` Pedro Alves

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=CAJOr74hae0-qguChBQvbfk5qk_Lc_C_FgO-RYA5ADL4xPQ6JZQ@mail.gmail.com \
    --to=phi.debian@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /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).