public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2] shared/shell: Remove readline color escapes
@ 2023-11-17 22:05 Luiz Augusto von Dentz
  2023-11-17 23:00 ` [BlueZ,v2] " bluez.test.bot
  2023-11-20 14:50 ` [PATCH BlueZ v2] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2023-11-17 22:05 UTC (permalink / raw)
  To: linux-bluetooth

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

This removes readline color escapes from color defines and instead only
used them with prompt since they are only really useful when readline
is rendering the text, so it can calculate the prompt length properly.

Fixes: https://github.com/bluez/bluez/issues/10
---
 src/shared/shell.c | 10 +++++++++-
 src/shared/shell.h | 16 ++++++++--------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index fbccff5b54d9..68499b464b69 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1419,10 +1419,18 @@ bool bt_shell_add_submenu(const struct bt_shell_menu *menu)
 
 void bt_shell_set_prompt(const char *string)
 {
+	char *prompt;
+
 	if (!data.init || data.mode)
 		return;
 
-	rl_set_prompt(string);
+	if (asprintf(&prompt, "\001%s\002", string) < 0)
+		rl_set_prompt(string);
+	else {
+		rl_set_prompt(prompt);
+		free(prompt);
+	}
+
 	rl_redisplay();
 }
 
diff --git a/src/shared/shell.h b/src/shared/shell.h
index 87fb5c415f20..a9a635bda959 100644
--- a/src/shared/shell.h
+++ b/src/shared/shell.h
@@ -10,14 +10,14 @@
 #include <getopt.h>
 #include <stdbool.h>
 
-#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"
+#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"
 
 struct bt_shell_menu;
 
-- 
2.42.0


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

* RE: [BlueZ,v2] shared/shell: Remove readline color escapes
  2023-11-17 22:05 [PATCH BlueZ v2] shared/shell: Remove readline color escapes Luiz Augusto von Dentz
@ 2023-11-17 23:00 ` bluez.test.bot
  2023-11-20 14:50 ` [PATCH BlueZ v2] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-11-17 23:00 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

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

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=802082

---Test result---

Test Summary:
CheckPatch                    PASS      0.43 seconds
GitLint                       PASS      0.30 seconds
BuildEll                      PASS      24.42 seconds
BluezMake                     PASS      560.91 seconds
MakeCheck                     PASS      10.27 seconds
MakeDistcheck                 PASS      152.66 seconds
CheckValgrind                 PASS      212.26 seconds
CheckSmatch                   WARNING   317.05 seconds
bluezmakeextell               PASS      97.32 seconds
IncrementalBuild              PASS      511.49 seconds
ScanBuild                     PASS      944.20 seconds

Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):


---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ v2] shared/shell: Remove readline color escapes
  2023-11-17 22:05 [PATCH BlueZ v2] shared/shell: Remove readline color escapes Luiz Augusto von Dentz
  2023-11-17 23:00 ` [BlueZ,v2] " bluez.test.bot
@ 2023-11-20 14:50 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2023-11-20 14:50 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Fri, 17 Nov 2023 17:05:06 -0500 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This removes readline color escapes from color defines and instead only
> used them with prompt since they are only really useful when readline
> is rendering the text, so it can calculate the prompt length properly.
> 
> Fixes: https://github.com/bluez/bluez/issues/10
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2] shared/shell: Remove readline color escapes
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=d8fc0dd5942e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-11-20 14:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17 22:05 [PATCH BlueZ v2] shared/shell: Remove readline color escapes Luiz Augusto von Dentz
2023-11-17 23:00 ` [BlueZ,v2] " bluez.test.bot
2023-11-20 14:50 ` [PATCH BlueZ v2] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox