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 1366 invoked from network); 11 Aug 2022 23:09:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2022 23:09:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1660259358; b=Ocg3tGBVw8KhYmu09kpn6KnKJ5KfKm+6wwfWZQuF+EYignmumN/sr5CJapXzzJ3+hPrEbz1vtB LFQK+FxNHzHYqXN45R88ZAzbJj1bxg7Im6xsg7HG3yqTAJpzu8fpers/8v7H7gTSCgJn6OUtUV evkMYM6/hDaje5qkOVQMowgSOMoh6tx6F2UFB5SorzKR9ruQTY3lRR8MR/pGfmjx2z9mqMYeHF 44ipXm+At5oHvn8UiJF5Kg4eWq3LPSpoVeNEAcqS5VdYLJSkjH6YLHoE48KDBfj6APt5lrvO8O +E107d+4JrY1MyQ0voD8YM+QADv3EuedpOkV/hnsjXlreA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oa1-f47.google.com) smtp.remote-ip=209.85.160.47; 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=1660259358; bh=z+msx1dj/NxYS4OBqXkZQ7/HE5fRaV7flSRD8f5y0vg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:DKIM-Signature:DKIM-Signature; b=Veq+AWP+PmEoLQUcnPuHBjIWLzHdcfHF/3IWhy6YbBXErxi6S+Po6RjG+FTmTzb8QM4mzBKZTE ERslV1eU72gF7odfToqY98CW4k+19/TpWyw8MaEJm6gL/XOxxrdh5/vAGajBPE2UVOgzoLNYCW nRQd878WTeuc72wl2KSOt2B8RT7kN86in0JG1twiRax34hWv6ksMJ7TnRPTT0r3kMIdva/C/dm l5rO1kUBYghYZB0YFmaqGBesTf0aLDWwhQDWUSADz2wkm9CBFFJcoWA1VXP3scavfObThuWfNc P/a7snPEtW2RtJVDAEa0tAGxVLPMWHp1LOOoBVnlu70QbQ==; 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-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=oZh/Ez06uNyywDEqh+dX3MmXNt7hfJbCv1tptawcVtI=; b=GRZn+rGMaIvqcMXtUarFgAgn+5 TqatTtd94+505LI64WEk0wXJO9VYHt9Zvervx5IMIVX/aPKIKPBJ5C/IbSyW43A97hOm8iklHW6wp /Quh2B+STv0jQa4l54uUu1IADeGJXy7Q2zOfHSm/PkBiFSiplZTZ42A6WqHlMkBMBZvRUJIOFmcAU A1NgvKqSeQUN58F3NQUIy6kmAUC41GDyPnKuKjqe/74yvY703KDX0jaQNXagKeEsqgrSZh1K5036d EZqZ/g9YlPcaX8x7azCShJ9SFcSH3ID216/9y16jHHPlv7gMO09yA1+Jtr5Xe0RN8jkyBICBh/qM6 ZSidn1ZQ==; Received: from authenticated user by zero.zsh.org with local id 1oMHIj-0006nj-Su; Thu, 11 Aug 2022 23:09:17 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oa1-f47.google.com) smtp.remote-ip=209.85.160.47; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-oa1-f47.google.com ([209.85.160.47]:37783) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1oMHIW-0006SS-Va; Thu, 11 Aug 2022 23:09:05 +0000 Received: by mail-oa1-f47.google.com with SMTP id 586e51a60fabf-10ec41637b3so23258721fac.4 for ; Thu, 11 Aug 2022 16:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=oZh/Ez06uNyywDEqh+dX3MmXNt7hfJbCv1tptawcVtI=; b=UbE3q7aqE+G/055mB8E+WKtEYEo66o/8iaA6bY6KrIA+32DfGOrwLE/VGOXQWx4Lwf 4swVJ5gGohCmDK+7nXGE4+brIoxcFljCx5xX1ZWtV5XlV19xafVcRlk/QgmBZcrbuAep rGKGn8ALEFP1I8x7m1Ku+Eo3uwVC+nDN00cIes/QyLqwncAXtvi4HcZ99m2QREqNlmDs gAPcAdJ1C45Yjb0A5m7Jb+8YuBZ8AuyHIduYmUhSkdzM5sdnXqyhCHFxVOdf14tsmDnr ohzIQq6b9z0pQuHuhpt3SqB1KmIENIBywnGp0iVJtzW26s+WqLb+k1cvNqu9qnLOERqK OEdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=oZh/Ez06uNyywDEqh+dX3MmXNt7hfJbCv1tptawcVtI=; b=NmHpQrnRyoTrUTZcaqEqRsWGaYS5gdmck6Ect6u4nSJFD5YHA2aYElUhUQgia0ugdB 3jZSeadfRaioNVJxSZs2eguAKJg1+C03gYSQd4V1Imh9kEJPxTryUJGj7m4EZhGmMihi mN4ucsf4OKOUie5GQ3VqrJlbpq0fjD8e55e+uS/Yb8aDuvOJxDe/X+6Gs51mxG5avJgO PdwHollzko7j19uIvlzawwWEbsgoQh8yohKv+hRyEex+Hk6qBp8aXkEukffIIZeCqtgV RA0+pb22KD71xehiqyPj4DeHxQnhPVTKcoBYXyzSzQBFwnXE/9ktMqYfqtkdCJ8YzzDa G/Tg== X-Gm-Message-State: ACgBeo0u3KHNXT08VhBFN10Dz7UOJ+FQogAuyyen3Ts60Sl/HbdIME0I yagnvog2pSTVM84lLIhlMJj2rUuipXY= X-Google-Smtp-Source: AA6agR7+YkhzDphHDh2O7QyZ0CGXaAbpicmr0FWz07bAmk+pDuEfZn71kmmluAfW7AB9khKs8/Gn8g== X-Received: by 2002:a05:6870:f60b:b0:118:1d8e:35eb with SMTP id ek11-20020a056870f60b00b001181d8e35ebmr559475oab.138.1660259343517; Thu, 11 Aug 2022 16:09:03 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id z36-20020a056870d6a400b0010e81e27b99sm99136oap.17.2022.08.11.16.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Aug 2022 16:09:02 -0700 (PDT) From: Felipe Contreras To: zsh-workers@zsh.org Cc: Felipe Contreras Subject: [PATCH v2] prompt: support generic non-visible regions Date: Thu, 11 Aug 2022 18:09:01 -0500 Message-Id: <20220811230901.471640-1-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 50469 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: readline uses \001 (start of header) and \002 (start of text) as markers to delimit a non-visible character zone, which are necessary to calculate the width of a prompt. In zsh we do this with %{ and %}, but we could support \001 and \002 as well, so that a function which generates output for the prompt can use colors in a way that works for both bash and zsh. This additionally has the benefit of allowing prompts without PROMPT_PERCENT to use colors correctly. Signed-off-by: Felipe Contreras --- No changes since v1 other than the commit message. Src/prompt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Src/prompt.c b/Src/prompt.c index 092de63a4..803937029 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -886,6 +886,12 @@ putpromptchar(int doprint, int endchar, zattr *txtchangep) bv->bp += strlen(bv->bp); } } + } else if(*bv->fm == 0x01) { // start non-visible characters + addbufspc(1); + *bv->bp++ = Inpar; + } else if(*bv->fm == 0x02) { // end non-visible characters + addbufspc(1); + *bv->bp++ = Outpar; } else { char c = *bv->fm == Meta ? *++bv->fm ^ 32 : *bv->fm; -- 2.37.1