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,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11458 invoked from network); 31 Dec 2022 05:44:34 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 31 Dec 2022 05:44:34 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1672465474; b=Yo9M6mrfrGUNQBW1I2yfNbKGQSjzmzepWkQUk/N64a1JYCP3QGg8yKXQZqOiVoWtxagPv1Y6Kk RdHBIaWiDpDMXu2NenQUBZZ4bhOZ7VMg253sBYyM28kaE9lmR2D/W9aoD2wCdIfdz+bWH6UE19 N7WLJBEklkLlnHZApZszHrode4a0rkRByto9fZ88a520wNWWZqymgOwyNTwW+ytwsMhSb6Vhu/ NTgmMXRsYux2yHHfnO/QTkPVOYQnPeW/HpXKIVP1rahsxMTppKwJ2w2ArOhCpJpDLsqG3HRrW1 RrLwKEoDYyTK3y2Zjs2bMuScWW7cM1mfzf4sNk4eKttqkg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yw1-f171.google.com) smtp.remote-ip=209.85.128.171; 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=1672465474; bh=bGsq69FnVIhjWNQBuLIwsNWycN2rv0POVXA8xIMSSSo=; 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=cxT2jV/QQ2eESFy8g5h9CEgJj/2/dYRKfPAR674NRvM3zN/m5XoVez1f184fvrKvH1lCS9GuPn xXOhw4s0Vl/wiXNM7xZDWBuH1MpfpxGkwmn4C/LNNFrqQMaGwhCxuAuKUBRtL8UzpR60oHTMXJ IT3051VkqgY+SMeBKeTh0gQKQc/pJiodjg6Ag3ShGgVU4IsWfIW1zMpC6uJgds4Fy8gvmcOdtL y+rqJXOFRxIyZsiTAuP6+f1yDeizcVD/7dUyvydPtewK+/1Cfai1GtXLU/DFUvVQWgDhw4/Kpo I0ONDKT2PQozjF/wMjxI0BlhPGBpt/B6z9HWkDkz9AL+Eg==; 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=pCVx2q+OYcxB8DAndKqrSSKLiIigB6xj9n4gIVV27z0=; b=UxaYBSkrMwgAVaYqEVa3ZWESdI qmaYkFn8pV2Z1EDIOA5ISKUur3Z5W94qkNNB71vMuSu/XTIcorjyMxaFbbXWPo30zb6G9T3k62XPK SlCMNghq3ZwkYYTg4BqfS9vF4CmICA9A5JAxyCwwNHz8t6pZaPb7BOiIqArAQc7VQ715Bv9nYngLo w9ESBG6sNAZvif4br2MWR3Hb1mO2Ynx63m/snPahLaiNIsxWVmWgS1x2sGEpw8er2EgK9IcS6nBeN wFxBkYfzdBfRO7sH2u4zKjVijgQRdzfCOPgM4b3BJmRzhuGDnJ91H8Se9j82YrqZLNZIdEL+WpLyM +Ylow1+g==; Received: by zero.zsh.org with local id 1pBUfZ-000O4H-LZ; Sat, 31 Dec 2022 05:44:33 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yw1-f171.google.com) smtp.remote-ip=209.85.128.171; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-yw1-f171.google.com ([209.85.128.171]:42569) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pBUfH-000Nlh-3N; Sat, 31 Dec 2022 05:44:16 +0000 Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-45c11d1bfc8so321097647b3.9 for ; Fri, 30 Dec 2022 21:44:14 -0800 (PST) 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:subject:date:message-id:reply-to; bh=pCVx2q+OYcxB8DAndKqrSSKLiIigB6xj9n4gIVV27z0=; b=KmMK2jh3bJQeNi320TP0Qus+PfZ3n4vMD9iW9UZAqNiOinLQIKjPlwrCxzUZqGe1RS yryWpDc4SBQLNLZnq3B5S/cN1yXiAo74xQ3T6DqpigrzHX/bUMu5EI813aU0KOOPS0LC q3PzLQZK7DtlYbNYJ5EQY6rmpCGvLuaSrCSrhPTCbDVOnVjTU5TdSKNySYTxK+hTPuJE dVrZXgwgo1iGRegKQVSRHCdfAcdfqf5GdOinOrWuWVNhnAZvsWAOvXmhjjeT+t8PlwX/ 4xUNTH8H3/jqkn+7NmNxWQfCQma3oyVx4YAAS5pm5vS+0N4oPZQ/3xpSeHzXcs2fZcYu uMMA== 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:subject:date:message-id :reply-to; bh=pCVx2q+OYcxB8DAndKqrSSKLiIigB6xj9n4gIVV27z0=; b=jYDEUg5kno+mIwojp1LKjWSEPZSS481Yqt0ne12DRlHe/HulXWPcChxKr4wf6uVA1k lsTq2Iejo0vgKo4NH/lnxi50O+hKWPguxE6wpJwb0EWKpabZQtq0lj9PYpm/L6n6ZEA4 pp7FQxknKLV2iuOEZVX0nbrpYelvwFmMwKbP2ILqwi7pdz52ylyGnkyut6+MOfZ1vnz9 Z8hWJEA+xJY9xFD1F9b5I8tbVTtV7HstH1HG3fSgoXqj8awYQEGchF1xjv5zTK4a7Ffr 8xZn+UJhHu717ejyioLOagDDG92NL6Q5fhD3cLoxubdYGv83BZ0wzgVXp0o0g0EpC5x/ oLYQ== X-Gm-Message-State: AFqh2kr22Zn3iaS94GVXYM2YUMprpniL4mWVWvysqVac6GAseUjh9Aqw bFsRBc9SRxTWi47AwvMw2zfcL3sjXYx0ue1mHWw= X-Google-Smtp-Source: AMrXdXs9rmZzGzMFfYtI6rMkchPtmk5WAylAHtQ+HhNWAdTxv2VI/mihS9p1zKOjd+qcCCytcvGWUBJFEm1y7e3tOL8= X-Received: by 2002:a81:610a:0:b0:47b:bada:70a0 with SMTP id v10-20020a81610a000000b0047bbada70a0mr2531275ywb.504.1672465453967; Fri, 30 Dec 2022 21:44:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: OG Code Poet Date: Fri, 30 Dec 2022 21:44:03 -0800 Message-ID: Subject: Re: Read a line from user without clearing screen below the prompt while allowing user to use arrow keys to make edits in middle of line To: Bart Schaefer Cc: Zsh hackers list Content-Type: multipart/alternative; boundary="0000000000004871a605f11935a8" X-Seq: 51267 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: --0000000000004871a605f11935a8 Content-Type: text/plain; charset="UTF-8" I had tried tput cup $LINES $((COLUMNS-1)) and tput cup $LINES $COLUMNS. Vared seems to clear the entire line of cursor, not just from cursor position to the end of line. Not sure if this has something to do with xterm-256color and tmux-256color, unlike the description of tput el "clear to end of line". On all the terminals I have tested this on, they clear from beginning of current line to the end. My machine is: Apple Silicon macOS 13.1. Did that really work on your machine? On Fri, Dec 30, 2022 at 9:20 PM Bart Schaefer wrote: > On Fri, Dec 30, 2022 at 7:52 PM OG Code Poet wrote: > > > > Here's some more context. > > So ... vared sends the clear-to-end-of-screen before printing the > prompt, then starts ZLE and clears again after ZLE exits. This means > your job, in creating a workaround, is to move the cursor to the lower > right corner of the screen before calling vared, move it to the > desired position before printing the prompt, and move back to the > lower right again before ending ZLE. > > This translates approximately to: > > to-lower-right() { tput cup $LINES $((COLUMNS-1)) } > zle -N to-lower-right > tput sc > to-lower-right > vared -f to-lower-right -p "%{$(tput cup 0 0)%}Enter something: " ... > tput rc > > Other tricks may be needed to keep a newline from being output when > pressing ENTER to accept the edit. > > If this is unsatisfactory, you could try using zcurses to manage the > display, which I think would allow you to always redraw whatever vared > erased. > --0000000000004871a605f11935a8 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I had tried=C2=A0tput cup $LINES $((COLUMNS-1)) and=C2=A0t= put cup $LINES $COLUMNS. Vared seems to clear the entire line of cursor, no= t just=C2=A0from cursor=C2=A0position to the end of line. Not sure if this = has something to do with xterm-256color and tmux-256color, unlike the descr= iption of tput el "clear to end of line". On all the terminals I = have tested this on, they clear from beginning of current line to the end. = My machine is: Apple Silicon macOS 13.1. Did that really work on your machi= ne?

On Fri, Dec 30, 2022 at 9:20 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
On Fri, Dec 30, 2022 at 7:52 PM OG Code Poet <ogcodepoet@gmail.com>= wrote:
>
> Here's some more context.

So ... vared sends the clear-to-end-of-screen before printing the
prompt, then starts ZLE and clears again after ZLE exits.=C2=A0 This means<= br> your job, in creating a workaround, is to move the cursor to the lower
right corner of the screen before calling vared, move it to the
desired position before printing the prompt, and move back to the
lower right again before ending ZLE.

This translates approximately to:

to-lower-right() { tput cup $LINES $((COLUMNS-1)) }
zle -N to-lower-right
tput sc
to-lower-right
vared -f to-lower-right -p "%{$(tput cup 0 0)%}Enter something: "= ...
tput rc

Other tricks may be needed to keep a newline from being output when
pressing ENTER to accept the edit.

If this is unsatisfactory, you could try using zcurses to manage the
display, which I think would allow you to always redraw whatever vared
erased.
--0000000000004871a605f11935a8--