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 29607 invoked from network); 11 Aug 2022 14:08:00 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2022 14:08:00 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1660226880; b=MmIkumAXdQak1ISYItB2CH1Rh+rUQdi5K0r8AEd44RJil6Fi0GNKwAavEdurZ70BQJ6SYLAbUJ nxqS7ym6sQoQ48KcHaD9RNJagoLVMfHgKt0jgA/rXRYbakobZ1aBt5meconbtqLjQtKsKUmYGI ZctdQHR52zx7zidaOWVPrxKcKJ/iD/6qi9oHRgDckXrsJ8LnlCB8nslFYwMY2R83X2cEft3nOF LQ8DH69ZJDPqvzwkWkJOP6xnqFGWrx6pb8KDXU/8C3METx5lfT72+aKSIFyE3ClBAuPYKSwTRu FveUww3xd4pysOcVK6Ne/lUBlFgXG+c/6+AzleJTGA+07A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ot1-f42.google.com) smtp.remote-ip=209.85.210.42; 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=1660226880; bh=ZhiBIqkdnRZ9yizM5ICHbg99rk7mFby+eyOmMY2uX6Y=; 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:References: In-Reply-To:MIME-Version:DKIM-Signature:DKIM-Signature; b=KK8Hgsq5CJ32QC/qWlKYD7NPgRu2aqHskn9sfe68VhzHOlTgTdeNd79L0R/4jrDFT7k/8N5D/e g2ca3LNLtqSnVTMMgLZO570yXdslgxzisdsK3z2Mc+KOZDyrJCA3F1ooFymSYJ5bCeqpaT/u9Q PDfU7IU5Z+fmQ6RIvoX46poAKsVGUaWNh3CsiYyotgg+DAixWHvWaKiLy62C/MTO8jHCn/tNGp fW3Dcd7YgI8J1qwrDhe8vDMcgNn//m4MfR+A+s9aKuTFhf0CH8CFkEcah9ff1ZYb0/lYjWLjy/ mHVHhI+oCjKPgi17OnOkMYu8eSKTMGYWDUi0rOI1aV86jA==; 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:References:In-Reply-To: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=113i5khCwI920JIPRlOEWJaYRmWU7rjGTMctAPs6cj4=; b=SkEpxc7f7u/146DG/j25jvjEGJ 4i6LrGKW+Q/ShVLTFxrSJKye7HqVbCbp6HOCDn/dMxFByHZvcDz3kgnrh9kn8REV81TGT9poh+lwv ZPhgv2b1uOt+8KUu0Uzyq3gHgCrBG2gVXTmu5Bj/WRvulqNYFAG/9R1JY48cjQqs1E9IicrukyfVP pm8syUDbweBYn6a55wUOlaVBweud6LFXk2iatkq5E1B1q6GuUAYYcioNaFAKNArCNcENi30B7QzPR 6pB0h1wNYwHNBvhcFp7t+VJGmdc86Z5fgUq1iAjOR+7dxNrbjEUW9EGMQoNNyC5Pv4oWwHkdPBBtP BmQYX8yA==; Received: from authenticated user by zero.zsh.org with local id 1oM8qs-00070p-Ky; Thu, 11 Aug 2022 14:07:58 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ot1-f42.google.com) smtp.remote-ip=209.85.210.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ot1-f42.google.com ([209.85.210.42]:38698) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oM8le-0006Yf-5A; Thu, 11 Aug 2022 14:02:35 +0000 Received: by mail-ot1-f42.google.com with SMTP id cb12-20020a056830618c00b00616b871cef3so12793049otb.5; Thu, 11 Aug 2022 07:02:33 -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:references:in-reply-to :mime-version:from:to:cc; bh=113i5khCwI920JIPRlOEWJaYRmWU7rjGTMctAPs6cj4=; b=mrUN263DRzgQ4Er96K4DFhEZTvGECjtTanKuvAu6e7EYMbV9SWxznhMs1wvj+XXy7C 1+ToUYEr7XaXm+yRO14IaRZnoS11CPPfdGgndNfwv4v5NSUxpkJSy1gRuDz2IM/e1ToT Mt9YsriU6FK8S8aQbRKymKFwxxLVvPNpi0tYPwpioYSP8VIemZobwgB0U1P0oFY4TToQ xQ0PVgbDqA76TmBNNYVTpV+q2nxdbe4mQpA61WtprKiT5XC79thIBBVp6PHt7m5BXrgZ ArPnNehTqtW0PQCQWW4tC7r6oUfvVRNmayCUR8f+5XShQpX4mST9b2K6D1hRe7dqvR9K 84JQ== 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:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc; bh=113i5khCwI920JIPRlOEWJaYRmWU7rjGTMctAPs6cj4=; b=48Y+qAVzLiNziT3X2NvXyws98OYcAjZJucWCgTvcoNsM2IIbfYqhJz4Nq6M8qHvm7z 7gCru+sETCs2U+RfQEQ/B+fElOJVOxPE/2vSamQqQDCXXGY3/irkXb+82M1nVPbt0kUA 63jd0RECtxPHu22ZdibXjGNUr/9fes5SfES77tUTQkg859464C/I0MweQyNpeMw87mob DE1VjkwxinfC1HjsORKusniRiwi1jlvXC6j66LVz4gUDV4czZ0NqR/4fiOnIoFfV+ouD GpedZ7cM7m2CxpCAov8Fy8qOua1pUaQg4Lg01pjv9UsbqF2YvCIyV5/9E055FqBsI9+F RvPw== X-Gm-Message-State: ACgBeo3VLkYrUHYU5yFZidfaKc3hECUiqJSNUq3BKHrMYSWHMGqgbC6x 6mZ+iIphjCWNBz9MKXaNQjVUCEbFxpLmGoDXxII= X-Google-Smtp-Source: AA6agR7g3GaLO8wOfkAM+EGBJ/iSzXfuSm4QuKv0HrTvLOTOwL4QEiavbTc089RasQCKCxshxJWNFE0vnOKnc6BtydU= X-Received: by 2002:a05:6830:1be4:b0:636:d697:42e8 with SMTP id k4-20020a0568301be400b00636d69742e8mr8382300otb.248.1660226552771; Thu, 11 Aug 2022 07:02:32 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:1189:0:0:0:0:0 with HTTP; Thu, 11 Aug 2022 07:02:32 -0700 (PDT) In-Reply-To: References: <20220810115120.182853-1-felipe.contreras@gmail.com> From: Mikael Magnusson Date: Thu, 11 Aug 2022 16:02:32 +0200 Message-ID: Subject: Re: [PATCH] prompt: support generic non-visible regions To: Felipe Contreras Cc: zsh-workers@zsh.org, Oliver Kiddle , dana Content-Type: text/plain; charset="UTF-8" X-Seq: 50452 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 8/10/22, Felipe Contreras wrote: > 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%}' Sure, this agrees 100% with what I was saying, but the statement in the commit still doesn't make sense. You've proven that you can use %{ or \001 to do what %F{} does, but the commit message states the opposite which is not true. >> 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. You could also have a $START_INVIS and $END_INVIS parameter depending on what shell you're in. Well, I don't have a strong opinion either way, but it doesn't seem worth it to me. If we support this, people might ask "but you support \001, why not this other xyz prompt feature from bash?" -- Mikael Magnusson