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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21762 invoked from network); 30 Dec 2022 17:57:11 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 30 Dec 2022 17:57:11 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1672423031; b=X6EilYgozr9cMckDijj54+8JY9IO1aBFOPDCxqCv9d+rZVdZRcTc5nVNxNl2jZpQf4Iin+2x7h kJpoMSIcuqb+BpRwbtoakNLnenPB7vwc7AN4m2n8ytTpoX4NCPQ2vx493FLp1R2IMgBmstGpDE fv8fSV2l1bwF/jp5js94UaQNRPsQ+er5kPfrZYkLpIUWx8rsHUrZEAInlndEm+Bp71VEnWYqif 01SwdBUY+ddj31VZ5C9uv4sJz4iMs1L0qyA7V3jfg2ncg10HmQKi9uKA22XX3Lua09xrYJ+HJg pndQd8f+MPdnUdyuWzl6ldQnlYrObHpuXaDNcMfgKxnkQA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f54.google.com) smtp.remote-ip=209.85.218.54; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1672423031; bh=GFpN4/3ZoeAwmY+H4Nf3Xf1Xx2ZMi3R69GNd8d71IL8=; 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=PlrrsdlobagthqzzOAGrUYPXJwhAIeNNT87ThDy+4z52LWQwNUimFX4qhkPPjRfqFCvcojtiWq hQ1TIRYxct+48J0JF1g+WTNBH0Gs18GelNlnbdUVqxxM4PT4deb20QVxgoQU+FQbK9faAnBm8J gyYMpiiV6Hbn8LfQ92MrTBN1MbWvuzr7hPgMT2VuKAORhOpCa2To7/RVkSK5ufJwvFLuFb5lcZ 8+IqcSJyg/btGPOPgNhWYSn9Cck2+iMh7u0eSRP95SEP4/78SdkwJsVHRwcysU1F47Uqm6lvft t5s66eF+FQDoxbHUqUlEaXgfljhxRP7eFfKDjnjwa11Kjw==; 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=4Oql2nOosEflmgUIE1ZNM3Cp4/EX+Xy7EgY6NS7jMT4=; b=YqDNby6BdUkvPui3j0X/O3tFZ0 AMVofJVF7yMEhZGDqNS0/exCsqpNeV1bmwQJ9p8fj9CijQLIoADOC9C7BdaVvbSVWGaHp8whll7DT 5z6BUkgMk9AndJvNV/COgq8BNDWYLvjkkt1qYrC/Ru2dE20DuNnQCL8Q+hNmkLsdVgzKHM54NOZrB HpWsQ+SMq/H5gaV1lWr0hcwzzMl422Gm2J3sbIqP1TETZdHvvwHg3B+sLQsVNBhZaMTYvfHw65/yj lIoDe3pJTAaQuGTb8VaH71lrTkE3d/dBc+mXQewEVJU+XmzKx3H/2ttBRYoO4xc9zS7yyQKKdcWJ1 Pp+P8xYg==; Received: by zero.zsh.org with local id 1pBJcy-0001Jn-UR; Fri, 30 Dec 2022 17:57:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f54.google.com) smtp.remote-ip=209.85.218.54; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f54.google.com ([209.85.218.54]:42561) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pBJcO-0000zo-KB; Fri, 30 Dec 2022 17:56:33 +0000 Received: by mail-ej1-f54.google.com with SMTP id tz12so52705718ejc.9 for ; Fri, 30 Dec 2022 09:56:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.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=4Oql2nOosEflmgUIE1ZNM3Cp4/EX+Xy7EgY6NS7jMT4=; b=RenkbEkvdJIkyOdg/+0VnGM+fXdDIPJqMBrzWTM9iyzarkJTxcbUzuIwJy85eUr2uj k92l37UKhtiD3XH2nnnitJX7h4vQD+pE9z6I26Nc12N8DT7xt8vFS5IyS5+7kAPfPKuy hJn1Mt8mH2jts7SDE/ayMnd1Z/uPcaICmqeM8iK4eSJE8Wuem73+4d/KO4BCdDPzsqa6 gvchfpALULTRcIqAo7WKPbg4pVSJoIcCp2cFvHNQ3sY/KAmCXtUHW5L6BVAVNzhRAyW9 9Yuwzd5VWW/yL0L176CPi9HSAnvg9EIhFheWzrFc87WP6LRhjYnXRowbaoEpl4kz+QVD qv/g== 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=4Oql2nOosEflmgUIE1ZNM3Cp4/EX+Xy7EgY6NS7jMT4=; b=vop2GcKPU0vdTBUlKw8hk7bW4E+ZagdI8VgB3yJnQ720BJ0fqKmR3bcN5Ah2VNZCBO 19mTuWHB6UUS/pqZ9Sil4wGcGd3+5S+Eb6FNOWq8wIzdJ8mhUnT0UPvI88PI9BCSftW6 vHXlvrr68SOG1sBAMZMu3izhd1+QWMSaarVafDOwoTf/jqgOf7N+Y+g5Qa26ov/qdUss zDD+YbekGgbgvrfRdWQf4Vi/v8NU/1lgB0sj8rmGyGDBrGsuXKJ2Ln0QmlufoWNhC6xy zEf1ZFJHzWrTSf50h7pvdDnxPYpADr2Pm9YQmTlfiAueAdX8nayZp8o5VBNd6wbxHxhH aZ3A== X-Gm-Message-State: AFqh2kpZWvayONyww36rtQgtLLxW82NlUqNZ63Drjw1vacf3Pl2G65Gi pPKbOeziBoAbSIhpdzxTfO6TQl316BVSFbcaBLaC8w== X-Google-Smtp-Source: AMrXdXuoKZeV36ukgEvpBhMWxn1cglyRX8n8GxkqWRXonQ/K0X67TlLGK/5K4XwY/z1W21wZKXJUU+18/2xOZyrauTU= X-Received: by 2002:a17:906:e2c4:b0:829:e4f0:bf2b with SMTP id gr4-20020a170906e2c400b00829e4f0bf2bmr2114331ejb.389.1672422991988; Fri, 30 Dec 2022 09:56:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Fri, 30 Dec 2022 09:56:21 -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: OG Code Poet Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 51261 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: (Leaving this on -workers because of the possible bug mentioned at the end.) On Thu, Dec 29, 2022 at 9:38 PM OG Code Poet wrote: > > Using Bash ``tput cup 0 0; read -e -p "Enter input: " userinput`` works well for getting a line of user input: > > * It does not clear screen below the prompt > * It allows user to use arrow keys to go to middle of line and edit a mistake they might have made while typing Bash is invoking the GNU "readline" library for the "read" builtin. Unlike ZLE, which despite having "line" in its name attempts to be a reasonable multi-line editor, readline is designed to do exactly what its name says, so it doesn't do any other screen prep. > How can this be achieved in zsh? Closest I can come up with is this: vared-finish() { tput rc } zle -N vared-finish tput sc vared -f vared-finish -c -p "%{$(tput cup 0 0)%}Enter input: " userinput However, this is not entirely satisfactory because the finish widget is not invoked if this is interrupted by ^C or ^G (send-break), and vared then clears the screen before exiting. This is possibly a bug? Shouldn't the finish widget(s) always be run when the line editor exits, even if it exits "abnormally"? (This affects the PS1 ZLE as well.)