zsh-users
 help / color / mirror / code / Atom feed
* Strange problem with bindkey keys passing through to apps
@ 2018-09-14 11:38 David Woodfall
  2018-09-14 12:43 ` Daniel Shahaf
  0 siblings, 1 reply; 6+ messages in thread
From: David Woodfall @ 2018-09-14 11:38 UTC (permalink / raw)
  To: Zsh Users

I have setup a bind to make a printf code to switch to previous
console. For screen some extra escapes are needed. This is in a plain
linux console, not in an xterm type of terminal.

The binds work fine except when I try to use them while running an
app - e.g. weechat, mutt - they fail and e.g. mutt will see it as the
bind to save the mail.

It seems that zsh isn't grabbing the keys for some reason and they
are falling through to the apps.

This is what my test and function look like:

if [ "$TERM" = "linux" ]; then
  zle -N _prev_cons
  _prev_cons() {
    printf '\e[15]'
  }

  bindkey -M viins "^[s"    _prev_cons
  bindkey -M vicmd "^[s"    _prev_cons
elif [[ $TERM =~ screen ]]; then
  zle -N _prev_cons
  _prev_cons() {
    printf '\eP\e[15]\e\\'
  }

  bindkey -M viins "^[s"    _prev_cons
  bindkey -M vicmd "^[s"    _prev_cons
fi

bindkey -L | grep _prev_cons shows them to exist.

Any ideas why these are passing through to apps and not grabbed by the shell?

-Dave

--

Linux is obsolete
  -- Andrew Tanenbaum

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange problem with bindkey keys passing through to apps
  2018-09-14 11:38 Strange problem with bindkey keys passing through to apps David Woodfall
@ 2018-09-14 12:43 ` Daniel Shahaf
       [not found]   ` <1536929114.231186.1508076776.2D392EA0@webmail.messagingengine.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2018-09-14 12:43 UTC (permalink / raw)
  To: David Woodfall, Zsh Users

David Woodfall wrote on Fri, 14 Sep 2018 12:38 +0100:
> The binds work fine except when I try to use them while running an
> app - e.g. weechat, mutt - they fail and e.g. mutt will see it as the
> bind to save the mail.
> 
> It seems that zsh isn't grabbing the keys for some reason and they
> are falling through to the apps.
> 
> Any ideas why these are passing through to apps and not grabbed by the shell?

That's how terminals work: input is sent only to the foreground process.
This is true not just for chorded keystrokes but for unchorded ones as
well: it's why when you open zsh from mutt (in this order) you can type
the command "mv" without composing a letter to somebody named "v".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange problem with bindkey keys passing through to apps
       [not found]   ` <1536929114.231186.1508076776.2D392EA0@webmail.messagingengine.com>
@ 2018-09-14 13:13     ` David Woodfall
  2018-09-14 13:19       ` David Woodfall
  2018-09-14 13:20       ` Daniel Shahaf
  0 siblings, 2 replies; 6+ messages in thread
From: David Woodfall @ 2018-09-14 13:13 UTC (permalink / raw)
  To: Zsh Users

On Friday 14 September 2018 12:45,
Daniel Shahaf <danielsh@apache.org> put forth the proposition:

> Re-sending from another address since your MTA bounced when I sent it
> the first time.  Please add zsh-users@ on reply if appropriate.

I managed to completely mess up my DNS. Seems OK now (hopefully).

> Daniel Shahaf wrote on Fri, 14 Sep 2018 12:43 +0000:
> > David Woodfall wrote on Fri, 14 Sep 2018 12:38 +0100:
> > > The binds work fine except when I try to use them while running an
> > > app - e.g. weechat, mutt - they fail and e.g. mutt will see it as the
> > > bind to save the mail.
> > >
> > > It seems that zsh isn't grabbing the keys for some reason and they
> > > are falling through to the apps.
> > >
> > > Any ideas why these are passing through to apps and not grabbed by the shell?
> >
> > That's how terminals work: input is sent only to the foreground process.
> > This is true not just for chorded keystrokes but for unchorded ones as
> > well: it's why when you open zsh from mutt (in this order) you can type
> > the command "mv" without composing a letter to somebody named "v".

I guess I was expecting something like in urxvt, when it grabs keys
and stops them reaching any applications. Screen does that too, even
in a plain console it grabs ctrl-a away from applications.

It's strange that it happens even when the applications don't have
binds for those keys though. I've now set one up in weechat for it,
but it will be annoying to have to do that for everything, that's if
they even do allow custom keybinds.

--

+#if defined(__alpha__) && defined(CONFIG_PCI)
+       /*
+        * The meaning of life, the universe, and everything. Plus
+        * this makes the year come out right.
+        */
+       year -= 42;
+#endif
  -- From the patch for 1.3.2: (kernel/time.c), submitted by Marcus Meissner

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange problem with bindkey keys passing through to apps
  2018-09-14 13:13     ` David Woodfall
@ 2018-09-14 13:19       ` David Woodfall
  2018-09-14 13:20       ` Daniel Shahaf
  1 sibling, 0 replies; 6+ messages in thread
From: David Woodfall @ 2018-09-14 13:19 UTC (permalink / raw)
  To: Zsh Users

On Friday 14 September 2018 14:13,
Dave Woodfall <dave@dawoodfall.net> put forth the proposition:

> On Friday 14 September 2018 12:45,
> Daniel Shahaf <danielsh@apache.org> put forth the proposition:
>
> > Re-sending from another address since your MTA bounced when I sent it
> > the first time.  Please add zsh-users@ on reply if appropriate.
>
> I managed to completely mess up my DNS. Seems OK now (hopefully).

It's still having problems. Sorry about that. My SMTP server was
rejecting everything for some reason.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange problem with bindkey keys passing through to apps
  2018-09-14 13:13     ` David Woodfall
  2018-09-14 13:19       ` David Woodfall
@ 2018-09-14 13:20       ` Daniel Shahaf
  2018-09-14 13:23         ` David Woodfall
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Shahaf @ 2018-09-14 13:20 UTC (permalink / raw)
  To: David Woodfall, Zsh Users

David Woodfall wrote on Fri, 14 Sep 2018 14:13 +0100:
> I guess I was expecting something like in urxvt, when it grabs keys
> and stops them reaching any applications. Screen does that too, even
> in a plain console it grabs ctrl-a away from applications.
> 

urxvt and screen are exactly the same thing, as far as zsh is concerned:
they are an app that runs *outside* zsh and creates a pseudo-terminal
for zsh to use.  That's why they're able to intercept keys before they get
to zsh.

> It's strange that it happens even when the applications don't have
> binds for those keys though. I've now set one up in weechat for it,
> but it will be annoying to have to do that for everything, that's if
> they even do allow custom keybinds.

It'll probably be easier to just always use screen when logging in to a
console, and to configure that bind in screen.  (There's a way to
configure screen as one's login shell, even.)

Or you might look into configuring a keybind at the console level.

Cheers,

Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Strange problem with bindkey keys passing through to apps
  2018-09-14 13:20       ` Daniel Shahaf
@ 2018-09-14 13:23         ` David Woodfall
  0 siblings, 0 replies; 6+ messages in thread
From: David Woodfall @ 2018-09-14 13:23 UTC (permalink / raw)
  To: Zsh Users

On Friday 14 September 2018 13:20,
Daniel Shahaf <danielsh@apache.org> put forth the proposition:

> David Woodfall wrote on Fri, 14 Sep 2018 14:13 +0100:
> > I guess I was expecting something like in urxvt, when it grabs keys
> > and stops them reaching any applications. Screen does that too, even
> > in a plain console it grabs ctrl-a away from applications.
> >
>
> urxvt and screen are exactly the same thing, as far as zsh is concerned:
> they are an app that runs *outside* zsh and creates a pseudo-terminal
> for zsh to use.  That's why they're able to intercept keys before they get
> to zsh.
>
> > It's strange that it happens even when the applications don't have
> > binds for those keys though. I've now set one up in weechat for it,
> > but it will be annoying to have to do that for everything, that's if
> > they even do allow custom keybinds.
>
> It'll probably be easier to just always use screen when logging in to a
> console, and to configure that bind in screen.  (There's a way to
> configure screen as one's login shell, even.)
>
> Or you might look into configuring a keybind at the console level.
>
> Cheers,
>
> Daniel

Thanks for the help.

I did do try in screen but found that e.g. vim and weechat still see
it. I think I need to look into application level keys for it, rather
than a normal bind.

--

Linux is addictive, I'm hooked!
  -- MaDsen Wikholm's .sig

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-14 13:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14 11:38 Strange problem with bindkey keys passing through to apps David Woodfall
2018-09-14 12:43 ` Daniel Shahaf
     [not found]   ` <1536929114.231186.1508076776.2D392EA0@webmail.messagingengine.com>
2018-09-14 13:13     ` David Woodfall
2018-09-14 13:19       ` David Woodfall
2018-09-14 13:20       ` Daniel Shahaf
2018-09-14 13:23         ` David Woodfall

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).