Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] Crash when accessing WIDGETSTYLE from SIGINT trap
- X-seq: zsh-workers 44911
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Subject: Re: [BUG] Crash when accessing WIDGETSTYLE from SIGINT trap
- Date: Wed, 13 Nov 2019 17:11:04 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=xregVOCknnVTToVZj+jTGtA4I4c4EwOYZKE8cIMZ+Y4=; b=G5QDf6gPYi+mMhu8GvMNBQfkOIZq4WsLEnzbs2zAdX87BCgeXuIpIzZYEcKMngWFKW wfBjwcL1EcdKYW5xNmVDIqkNxY/Mme/f0Hl/k28wpev6TZ9wLY7/QaK2MSHbV2j896Fx ybqAcNLF0wa6Bo9Wva3/Kt4BvZxC9UzhiLdM4QOpAfn9f9S7NBwjpJzRET6RmGNVi8ol ozGXo25EzpAItQYbwiHqno7/XAVuz61w+STjSOADWnjxzyjQ94D8d5UzX1T7RfItACd5 Fj6MaKmJRuy4YJzUZomXGNxCMuFeAGcyWROiMjTIDWQvRSw0C17YNpJiq9uYwiUVnG57 WP4Q==
- In-reply-to: <CAHYJk3SZC9n2Rm9mjPiuB607g9-Q6o1aoC4s+HyMHcP996ZeTw@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20191111143952eucas1p2784d9821f292f2c9c136b19da5a56ade@eucas1p2.samsung.com> <CAN=4vMoahC2c4XHV9vE+Ohkx9rO00unZ0rC=E39yWfoSm4KKiw@mail.gmail.com> <1573484293.4561.8.camel@samsung.com> <CAN=4vMp55vKoDiFDD4kijNc_xBJLve6GUifTQJVfCEecadyMCA@mail.gmail.com> <CAHYJk3SZC9n2Rm9mjPiuB607g9-Q6o1aoC4s+HyMHcP996ZeTw@mail.gmail.com>
On Tue, Nov 12, 2019 at 3:56 PM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> Have you tried restoring the long prompt in zle-line-init instead?
No, I haven't. zle-line-init is a bit too late. Prompt is already
expanded and printed out at that point. I could still change PROMPT
there and call `zle reset-prompt` but it would be slower than changing
PROMPT in precmd. As I mentioned, I've found a workaround for the bug
that causes the first element of precmd_functions to get skipped over
after Ctrl-C, so the part of my code that restores long prompt works
correctly in all cases where I've tried it.
The unresolved problem is that my code calls set-short-prompt in some
cases when it shouldn't after Ctrl-C. zle can effectively be in two
states and I don't know how to distinguish between the two when my
SIGINT trap triggers.
Normal state: Keyboard input goes into BUFFER. When Ctrl-C is pressed
in this state, new prompt is created. When my SIGINT trap triggers, I
want to shorten prompt.
Before Ctrl-C:
/tmp% echo hello█
After Ctrl-C:
/tmp% echo hello
/tmp% █
Modal state: Keyboard input goes into some place other than BUFFER.
When Ctrl-C is pressed, zle state changes to normal but a new prompt
is not created. When my SIGINT trap triggers, I want to do nothing.
(This is where my current code works incorrectly because it always
shortens prompt on SIGINT.)
Before Ctrl-C:
/tmp% grep -
zsh: do you wish to see all 180 possibilities (45 lines)? █
After Ctrl-C:
/tmp% grep -█
Before Ctrl-C:
/tmp% echo hello
bck-i-search: hell█
After Ctrl-C:
/tmp% █
How can I distinguish between these states? How can I figure out from
within a SIGINT trap whether zle will or won't create new prompt after
my trap function returns?
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author