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 29426 invoked from network); 10 Dec 2022 04:30:33 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Dec 2022 04:30:33 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1670646633; b=XpSKY+HIvXjhzwX1a5+K8e0SxM12FLr/Ie0/kroQ/SrkqUpuiHLvKNbQKmJU2GX2U8ZdknnrUJ OF8vyW3pUIxiPvH++twu+P5h/QADDjI/JwwmJ0m5PhTg3zq+1VkiHLV6tW1QgAeNSj0TZE14qO zTz5LY96ZKIyAUiRwIAMT+Ym08PwymW/vCwOM2bnMUICIeCI7tOrYO1AI36ymOFaT19+Cp/piP rtfLxvcRBvERvCaOk9NnKBpfrOilgEqoAp8KICYPnW47/rNkKwuBz6IBT0REm3kOyW9gblfpmt tYpvkKBBg8woZlpSPONiCGdM9tpKadhBmWNqUAKM6SxUkg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; 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=1670646633; bh=qcYN9UeSmnmI/R0N7UF/pBNJtCWrWclPlwncZ/j8Ak0=; 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=p8rMp7JExmMtGAwL5lShGeaX9yj92MifGm7XNuMAq5UZ3TALaWlpJBkw0PxWWrbsiBxtCUUpKo Y0Wt3ATFpm57bsO81Tt9V6BcZDpGzH56lgcFKs9HJgV7hCJc/+sa3dwvqq5C903GChkc8O5F1+ FuV/KBD5oj0KjRU7/xo1fZCDzD3OyvoYagfuJP7FFj8wZ57tzN/b1s1brg8gG+//Nuq3DLTFAq OHxr0ZBGJp95fFAY0JhAmRmw3RYd/HAJT92s+35qDKUgSEDUi9yYKEp0S1/9jrL5bmWzr6D4aB M0IQ3eCT1PXTu0+g2V8tubQ/IVUMAv3JI9I+Xh71cDDXgQ==; 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=lVMIsjozZsNTxP78QR0ifYa12i8x5vlvS0q9RNqQt1g=; b=QIPreWPfWtGwXJG48SJJWvIoNR 79gxV35L8Unw7lKqwN3AJ/gt1t+tRPBs7w3IPyRvdSZegWUepfQ1v5AUJ8MDtT25wUiSl/loHRyCQ 0bY+bR1fP1c+dI9LuJRKlxDBT07fv0bQCQySQkdqtr9QRKVA9n9+1wnkHK7h/KsS7VNbM/XVmZLSY gISV7qToNgbNonmtzJQiX1e7QLhfiVJdL0yKb/UeFm38OFava36RHjQihvdNyHxn7IohnSiUXIYBW Jph3T34iFeq6qSD07GsSt1VhJnyNgCuhzM51xIn6fPinrn74BPrnPbNx5ob+M3WVf5RPyl+wZ5oVJ 9W1SaRnw==; Received: by zero.zsh.org with local id 1p3rVP-0008Ci-K2; Sat, 10 Dec 2022 04:30:31 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f53.google.com) smtp.remote-ip=209.85.218.53; 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-f53.google.com ([209.85.218.53]:36846) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1p3rV9-0007uw-Lq; Sat, 10 Dec 2022 04:30:17 +0000 Received: by mail-ej1-f53.google.com with SMTP id qk9so15915742ejc.3 for ; Fri, 09 Dec 2022 20:30:14 -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=lVMIsjozZsNTxP78QR0ifYa12i8x5vlvS0q9RNqQt1g=; b=Kr+kwKEBJqsTQ1anVT2lcgeLauxNyuODzUqLeDE8jgkpHc3foIzySAwUmjSj8GQgC6 pJyDpSLSJmR841jzqGS34Js47SjUt3TAHdvHNOynOfiItQs/ZlX9BFTl5C9e0U/kMRrD TzNAKhOz+VxmS4+YsB3j++KjUhnifRDiOSR0VAuzfqD7UgpQZyaXw6smPG9twyFtjdzw Qa6m+ZMweLs4IiadvrdORCK620IrBoOjlkje2XFJFJSGjrJYtzpDIIgmG6wGN/SpGj4t hzvWNAlBXquiQmjTjjIV/n/TIyCMcPsz+vq3KxNu/NqheVLRYNcbWLHXOSD5AKmr7xh8 6xCQ== 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=lVMIsjozZsNTxP78QR0ifYa12i8x5vlvS0q9RNqQt1g=; b=niErdj2cNFdYZvWttUyP9PH+2pSMowUIFh3igMk3v2SKTMMUxAIgGa5mLtbzWmx/3v j+kSvAf3bk1u/ak0RVJkobfp9HPfLfi5JnehCx++lk5VB+5dugtvda0k3BcL2PUFPuue pyNzfvinUqRrXqUURcs97dJ8BrnuuD/ou6THpx87Ok9hzPPdqRSKzr9b/Wbj3qnm0fye gzuRXYdbo3Khl1NofkrNtUIkNTqO0M7EwSmFbuCIqWQGroNfLFRnHgbAdLgfgluXFDHY 0JXgeAjT/d7KzEn3c6/6VUNSoC+N6g0j95w7K8Kx91ORwdNUT89jgnInb9ng8/zrbzKR k8Gw== X-Gm-Message-State: ANoB5plg+TC9jViyq3RIZsjjyq8LFTgR2RPI8t6QBrhz46ju7HddDavB sYugy9Jpg2ShQTqJ5Pt5aA885yKk6hc7lIi0UPTrgQ== X-Google-Smtp-Source: AA0mqf5z5dukC5iAnAWumgTrZeu86NeMDI+7NTPj/TzM0mS1znzF1Jco/BcQ6EhxZ1f74y1GtX8cjBcLb8KTLVuuvIo= X-Received: by 2002:a17:906:50a:b0:7c0:b995:8f8b with SMTP id j10-20020a170906050a00b007c0b9958f8bmr25103936eja.55.1670646614335; Fri, 09 Dec 2022 20:30:14 -0800 (PST) MIME-Version: 1.0 References: <9e3026aa-39a1-dd50-4d29-a64724d4eaaf@irit.fr> <20221208082103.zg44mrv77jrizsaj@chazelas.org> <20221208100215.k2qcqdqgjlzwbdh7@chazelas.org> In-Reply-To: From: Bart Schaefer Date: Fri, 9 Dec 2022 20:30:03 -0800 Message-ID: Subject: Re: Get cursor position (Was: [bug report] prompt can erase messages written on the terminal by background processes) To: Philippe Altherr Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 51162 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 Fri, Dec 9, 2022 at 4:46 AM Philippe Altherr wrote: > > I just stumbled on the module zsh/param/private, which makes it possible (but I won't claim that it's very practical): >[...] > It's a bit strange that the initialization is needed. Private variables don't hide global variables of the same name, nor prevent their assignment, but prevent their initial declaration. This isn't exactly an effect of private, it's the previously observed effect that there is no way to "unlocal" a parameter in the current scope, so you have to add it to the desired scope before declaring it local. > assign() { > print -v "$1" "$2" > } You don't actually need a named function or print -v here, although I guess "print -v" is shorter to write than "typeset -g". curpos() { set -o localoptions -o extendedglob eval "${1-x}= ${2-y}=" zmodload zsh/param/private local -P -a match mbegin mend local -P answer IFS= read -rsdR -t0.2 answer$'?\e[6n' && [[ $answer = (#b)$'\e['(<->)';'(<->) ]] && () { typeset -g "$1"="$2" } ${1-x} "$match[2]" && () { typeset -g "$1"="$2" } ${2-y} "$match[1]" } I'm torn about that eval-as-delcarator. My first thought would be to use typeset -gi ${1-x} ${2-y} but the eval avoids changing any declared flags on existing parameters in the enclosing scope. On the other hand both that eval and the use of "print -v" force the variables to be scalar, whereas "typeset -g" throws errors on assignment mismatch.