Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp809309rdb; Fri, 17 Nov 2023 13:29:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHr0ZeYUPiXQgib+e6Fp6Snbz4O9T+zxg+YOBSpXJOzidfFYonvxVslX4dSOHxcILhxsr16 X-Received: by 2002:a17:902:8646:b0:1ca:b26a:9729 with SMTP id y6-20020a170902864600b001cab26a9729mr817412plt.38.1700256593094; Fri, 17 Nov 2023 13:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700256593; cv=none; d=google.com; s=arc-20160816; b=e31TZZtWbRjqxi5sEYKdxNaCbl/FJofQ8Wib98FJH+9/u9VqvpjZx9cPxe2AjFhmG7 7jY7NTvPYIU86qeI1r10nnKixmqP+wUq176XpahqU3uwCT727ffpQcI6Ce+cgntJjV+C +d5IpRFeNfQknWU3FJgbErisS/yuYrH/9rTaJObDXhKVnNUJlmSdBe0zL/J1k/ZueZFt qpOxWuVIbuybfgK8V1W3c/9fcs6d57ukHabeWyY0qK1JyQJgA7sVPZVzEs8vFvtpZXWa EwJ4GgoQPk9Zrcf7lua1bcWNiJHjte5jfpoI/lMuzVH31X6ShrRkp3a9xdDOd/MtjKBc IyOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=QYf6vvs7/US2fopFUYiPvKGeix259clpc+5ExD+/usI=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=pRmoLuMziKeh5xMfCHQzvAJcr75Ix4gPSmkwidCgN/n6b1owUEC6GRGA6/NDSyDtsA aHZbDKsT3inPifvJA8ReoSZ/a/Gri+ROjKHtTOF7VK2rJqLN9On3ePfzvmtK4Egduv5p uknUQxHAdVjpYCZoz5H0z13gckUpxGRGsTNfinq3dau9ENCpgkbWg43wnExEsFgI8b5l yFQ4LWbFWUe4FMAsVvGajNXqFo/IP4AtQ3KH5ehTodGcmKQ7qQLRLl/UB0lnpm9zoDY0 WE0M6Zjc/UmC1Espuwz78TrqGkfCggA5fy1AVp+byYou+LytOJ9hm7p4ipk6Ocm4+4NS zRzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Tb9RdeVb; spf=pass (google.com: domain of linux-bluetooth+bounces-108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-108-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id jg22-20020a17090326d600b001c7218c4db8si2497917plb.119.2023.11.17.13.29.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 13:29:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Tb9RdeVb; spf=pass (google.com: domain of linux-bluetooth+bounces-108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-108-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 72A89B213CB for ; Fri, 17 Nov 2023 21:28:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C59FC4F8AA; Fri, 17 Nov 2023 21:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tb9RdeVb" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA90B2729 for ; Fri, 17 Nov 2023 13:18:22 -0800 (PST) Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-daec4e4c5eeso2333460276.1 for ; Fri, 17 Nov 2023 13:18:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700255901; x=1700860701; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=QYf6vvs7/US2fopFUYiPvKGeix259clpc+5ExD+/usI=; b=Tb9RdeVbMqmKVZzuWC0A5Cn1NVt7MJcsWHSwWm+7SlawHUgj5Z7C7BDIdTzwPDLMid 9MpBsFb7i4CyFyYB2Y403Hy/TSUqoLB8sSmLuikp74sAFQF7RiI1VM2lc1hzgstx2o/3 jaD1jxYlb4URy4Kk9SPYGVOFb3h3Mvnl0gT0ccVWqJs1lgiIECVbBGSNNg3bAcuXxT5j tFGRdV6lmcnBnRa2D0v63P2vRowOq9Pxv02gwyY4bYyyD+Y4YIJqJ38txKkmu/asY1Yg ERAhrLBN1gzxrl1vbQrO25V5wA0T65LHU4gy+vvmXH/URtfhgLsT4sb5Hzs/plGF0mM3 vJDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700255901; x=1700860701; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QYf6vvs7/US2fopFUYiPvKGeix259clpc+5ExD+/usI=; b=LauC0cx0IBT4+ahy2RjXFdFp4yWZ1vbG19c5pqHcH8RQFDzRgF3iQ4vm9hxRKnzAdY rF6OuU2YCcXeizZ/543Qt95HIgf4X0DNsuvPkQpFU5xYEKmN44qjOJtzIogYELR6vDfs 6ti1lg5xkmgueEd1W8tVa6Rlrtp84YsR0G0aUawu/QOC4JVvlaZ3x5cz9JkE0W4gznYV /nBHAQI3uWuf4laduSHmOfZaZsJOeQHfNV82UDw0ImIxPW2vjmQ6UJRgn9z/J1HJWkW6 xz02rIke1suYLmKKGLomMgOxgSuvJQECTJHgQ7fze9k4XAreiqEE9TMgy4vzvNFSAA8c 42bg== X-Gm-Message-State: AOJu0YwOnj57Hey6hMtvDeNDKC/kYEdW5vknLLCn7OMJrlwnZLH/1pYT GgjfDACdpnV8nJM3QdEJBuUEhmsC5iQOsA== X-Received: by 2002:a25:258c:0:b0:da0:c6ae:ad0e with SMTP id l134-20020a25258c000000b00da0c6aead0emr611342ybl.21.1700255900625; Fri, 17 Nov 2023 13:18:20 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id w4-20020a254904000000b00da3b52e3cf5sm607009yba.10.2023.11.17.13.18.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 13:18:20 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1] shared/shell: Remove readline color escapes Date: Fri, 17 Nov 2023 16:18:19 -0500 Message-ID: <20231117211819.257212-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz This removes readline color escapes from color defines and instead only used them with prompt since they are only really usefull when readline is rendering the text, so it can calculate the prompt lenth properly. Fixes: https://github.com/bluez/bluez/issues/10 --- src/shared/shell.c | 6 +++++- src/shared/shell.h | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/shared/shell.c b/src/shared/shell.c index fbccff5b54d9..fcce2d3aa5a4 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -1419,10 +1419,14 @@ 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); + asprintf(&prompt, "\001%s\002", string); + + rl_set_prompt(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 #include -#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