From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 22253 invoked from network); 10 Aug 2022 19:56:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Aug 2022 19:56:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1660161403; b=NE8nkYBzPN+8P26Ut/EZOhnpGLg5L/QC5nWsCku63JYNtT+N3i2Wo8js/sp2RtodzpVeSvw/1C t+D8miJaSGAjOJqQj7nhe3NStVNYO/RUIqauxIKrABMPAIsVQ8UIRbOf+sOaLqUJaFo1k5EAB+ sHHyCutHdu4rscxZrGSbEmVXAVKTYTOvXWGOx9603MzIhCzTlMLXOP00Fe+FzPTulbD4b6W+qF mVCWZ+F9CENvDYK7ya3vWyxmIoUAx9erzeELWtNxNtix8jzVviDCUzWYdmN67bo71zIWd0SpDy z8NZXEQXgetgFtM7XoATtTccNLBV7XFhhyeX9vmpFTY5Rg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ed1-f54.google.com) smtp.remote-ip=209.85.208.54; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1660161403; bh=wVyX5oAmAmvlZOpwjSkLi4DaYJRHd1YGLTjuKyhwnuI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=DRPYq6kFPMJmRvHeOMGGBrc7Vskm36Jsf0VrULea+IdywesEylpEpVYCADdlE1kApwnTtiFLBq lAmGNs3iz0IYX8N9+SkEEwNzbOzw47PZMxexVcdeiLy4HYlT+12LUNtoQr8Qcc+Q8HIA1iBhwf Il392nKNhe0AgmGmwpiUaON7IkZZ6ag15XWtOD3MfdtUVrciglcdG46p7dKksgkUevzkpQjpIw ji2AIOVyHqpar/rsUwaz76orvLE5uYtmpsD/rEtuLdNafIP9clx2xBDWkf9Kfogko0gE3tIho0 ruNJL0SnyM7KjJH3YVQpF75CJEYTAIyBWVXOIS3hg4N5+A==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=RjrOdz1HajX7Zab7oJ6q0NF3MVKAPPKEiBKpS7oulxo=; b=VZtElvtgXI9n1VscfmC6agFCnh 6XeiZY24xF8G6SKX54lvefnbWVbHjBEOKvnMCj/2GRmf6rQlrXXtFXKAkKpcSIyIUNLf17u2Zbsia B+C65krF3eCpedYty7GQPxu0oLzoVkXPeH+UUwGyOleIQWhgSwRceBcaJec3NeJSCs3Zu+PvkCQfQ JRvrin5i4jjzkdE3ldaMqsQlqAUoN77JCy8uVc2j1exmn0oEoTV1gfoSOlL+5274+yeXpr4jjTGAI dsY73AMMuOZkO8wXtI3NZDn0PVIV1Ab7KDzPgribAdXvaJjEZH9zQqabCqeeyvlJuo0lQQoeowBdv Q4KRUp3w==; Received: from authenticated user by zero.zsh.org with local id 1oLrop-0006P1-50; Wed, 10 Aug 2022 19:56:43 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ed1-f54.google.com) smtp.remote-ip=209.85.208.54; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ed1-f54.google.com ([209.85.208.54]:38718) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oLroW-00064t-2y; Wed, 10 Aug 2022 19:56:24 +0000 Received: by mail-ed1-f54.google.com with SMTP id a89so20463462edf.5; Wed, 10 Aug 2022 12:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=RjrOdz1HajX7Zab7oJ6q0NF3MVKAPPKEiBKpS7oulxo=; b=b7oyJba2yF2qxO+7es+Yaa54viQ2jnTckAv5Xp3fX5lFGeCs3opKuk+G2tGtQj6LJB GyUf9YXkrD+XdQfvHm/OiXZplZCjXmNICGqEgrwnWkUsaKEIVm6XirFkQ36fYCeJ+VMm f2R/demEZgPRrCtCLXKhEnaeya0+8b3J+z9eLT/p2TKJypHXKjnKBtECY4WKuH0xl9PM qQ95H2nTp657buXElQR/yJvKLjd51i/7sqChOxi0pjs3F/p0zISAQktkScy2/0MctMxI +ulwWnKN73fhNuCyfd7+Wox7tlkpDwTdBOjlSvS7u5+CnzZZT+HhN+mXIKZDKMG43hoD qZfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=RjrOdz1HajX7Zab7oJ6q0NF3MVKAPPKEiBKpS7oulxo=; b=6nYRVor8r9LfxyUMWuqv3imYWbmQLCY9/QS8A9hdt/3aRU4UfJ8kyr8ylUF6V40pVX mYmWWnvKYNuCitFz/RSjG12RuBIDXB7puJFe/fACci0DyUC3aTHxNEhyUb8Oe6j3qeLR 0R0bdbHb+7cBfwAEtkftuCpqgN6bedrsnNBKwmVxBxXTwlurzhEWI5ybpl6qKhHMjyzA v3y4HCDuVZP3Icqx7hEmi+gqi3+eD1Mnlzk46fRJFHlBC0RebSlah8+14+DXNMCICZqh PJNxcj+Pi4M4hPrhT5qyWjvUWlK2rP0233IC+drf/aaJ9u+zQHaR+8l+kMZAyGfVxE0f HnRA== X-Gm-Message-State: ACgBeo0/ruK/c5q3MPFc2MLaDctfRNRPKVOlgv+dds2+Aju8uyEwHnLo 14u2xWBnr9Ou4eV1OE2ea3TVcZzG/kcfHV5S8jo30rD4xtQ= X-Google-Smtp-Source: AA6agR4w24YW9Xc07aCyPfgotNsZhEZJmT1dfbPLvXDVYgjfpgZduu3i5WqEznSHKZ1OkmclG7B36vMOb9kq/0Jl1lg= X-Received: by 2002:a05:6402:1cc4:b0:440:5af8:41c9 with SMTP id ds4-20020a0564021cc400b004405af841c9mr19879522edb.339.1660161383253; Wed, 10 Aug 2022 12:56:23 -0700 (PDT) MIME-Version: 1.0 References: <20220810115120.182853-1-felipe.contreras@gmail.com> In-Reply-To: From: Felipe Contreras Date: Wed, 10 Aug 2022 14:56:12 -0500 Message-ID: Subject: Re: [PATCH] prompt: support generic non-visible regions To: Mikael Magnusson Cc: zsh-workers@zsh.org, Oliver Kiddle , dana Content-Type: text/plain; charset="UTF-8" X-Seq: 50451 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: On Wed, Aug 10, 2022 at 1:59 PM Mikael Magnusson wrote: > > On 8/10/22, Felipe Contreras wrote: > > readline assumes anything between \001 (start of header) and \002 (start > > of text) is non-visible characters. > > > > In zsh we do this with `%F{color}`, but we could support > > `\001\e[31m\002` as well. > > > > Signed-off-by: Felipe Contreras > > --- > > > > I don't know if this is the right way to do it, but in my limited > > testing it seems to work fine. > > The commit message seems a bit confused, %F has nothing to do with > marking characters as 0-width, rather everything between %{ and %} > will be treated as such. You can use %{%} (or \001 and \002) to set > colors via the specific \e [ Ps m code, but also to send any other > codes handled by the terminal. If I do PS1='%F{red}foo' putpromptchar() will call set_colour_attribute(), which eventually calls this: if (!bv->dontcount) { addbufspc(1); *bv->bp++ = Inpar; } tputs(tgoto(tcstr[tc], colour, colour), 1, putstr); if (!bv->dontcount) { addbufspc(1); *bv->bp++ = Outpar; } I can do the same thing fputs() is doing with PS1=$'\e[31mfoo', but now zsh will think my prompt is bigger than it actually is and the shell will be screwed. So I have to put that inside %{%}. Therefore "%F{red}" = $'%{\e[31m%}' > That aside, I don't really see a reason to add support for > bash-specific prompt sequences that are more cumbersome to use than > the already existing zsh ones. Bash prompts are already completely > incompatible anyway. The prompts are not compatible, but the functions used in those prompts can be. __git_ps1_test () { local branch='master' local red=$'\001\e[31m\002' local clear=$'\001\e[m\002' echo "${red}${branch}${clear}" } The function above works perfectly fine in bash and zsh with my patch, and I can add $(__git_ps1_test) to both of my prompts. -- Felipe Contreras