linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] shared/shell: Fix colors not using proper escape sequence
@ 2019-03-14 14:51 Luiz Augusto von Dentz
  2019-03-14 14:51 ` [PATCH BlueZ 2/2] shared/shell: Highlight user prompt input Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2019-03-14 14:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

According to readline documentation \001 and \002 has to be used to
delimit characters which takes no space:

  'Applications may indicate that the prompt contains characters that
  take up no physical screen space when displayed by bracketing a
  sequence of such characters with the special markers
  `RL_PROMPT_START_IGNORE' and `RL_PROMPT_END_IGNORE'.'
---
 src/shared/shell.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/shared/shell.h b/src/shared/shell.h
index 8b7cb7f30..e14d58381 100644
--- a/src/shared/shell.h
+++ b/src/shared/shell.h
@@ -22,14 +22,14 @@
  */
 #include <getopt.h>
 
-#define COLOR_OFF	"\x1B[0m"
-#define COLOR_RED	"\x1B[0;91m"
-#define COLOR_GREEN	"\x1B[0;92m"
-#define COLOR_YELLOW	"\x1B[0;93m"
-#define COLOR_BLUE	"\x1B[0;94m"
-#define COLOR_BOLDGRAY	"\x1B[1;30m"
-#define COLOR_BOLDWHITE	"\x1B[1;37m"
-#define COLOR_HIGHLIGHT	"\x1B[1;39m"
+#define COLOR_OFF	"\001\x1B[0m\002"
+#define COLOR_RED	"\001\x1B[0;91m\002"
+#define COLOR_GREEN	"\001\x1B[0;92m\002"
+#define COLOR_YELLOW	"\001\x1B[0;93m\002"
+#define COLOR_BLUE	"\001\x1B[0;94m\002"
+#define COLOR_BOLDGRAY	"\001\x1B[1;30m\002"
+#define COLOR_BOLDWHITE	"\001\x1B[1;37m\002"
+#define COLOR_HIGHLIGHT	"\001\x1B[1;39m\002"
 
 struct bt_shell_menu;
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH BlueZ 2/2] shared/shell: Highlight user prompt input
  2019-03-14 14:51 [PATCH BlueZ 1/2] shared/shell: Fix colors not using proper escape sequence Luiz Augusto von Dentz
@ 2019-03-14 14:51 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2019-03-14 14:51 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes them more evident compared to regular output which is now
possible since coloring prompts should not produce artifacs anymore.
---
 src/shared/shell.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index d7fbf46aa..eac654f40 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -592,7 +592,8 @@ void bt_shell_prompt_input(const char *label, const char *msg,
 
 		prompt = new0(struct bt_shell_prompt_input, 1);
 
-		if (asprintf(&prompt->str, "[%s] %s ", label, msg) < 0) {
+		if (asprintf(&str, COLOR_HIGHLIGHT "[%s] %s " COLOR_OFF, label,
+								msg) < 0) {
 			free(prompt);
 			return;
 		}
@@ -605,7 +606,8 @@ void bt_shell_prompt_input(const char *label, const char *msg,
 		return;
 	}
 
-	if (asprintf(&str, "[%s] %s ", label, msg) < 0)
+	if (asprintf(&str, COLOR_HIGHLIGHT "[%s] %s " COLOR_OFF, label,
+								msg) < 0)
 		return;
 
 	prompt_input(str, func, user_data);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-14 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 14:51 [PATCH BlueZ 1/2] shared/shell: Fix colors not using proper escape sequence Luiz Augusto von Dentz
2019-03-14 14:51 ` [PATCH BlueZ 2/2] shared/shell: Highlight user prompt input Luiz Augusto von Dentz

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 NNTP newsgroup(s).