Discussion:
Adding the 'accept-line' Readline Binding
Bastien Dejean
2011-11-05 11:35:34 UTC
Permalink
Hi,

The following binding:

key({"Control"}, "j", function (w) w:insert_cmd("\n") end),

produce a 'vertical tab' character instead of the expected newline.

Any help?

Greetings,
--
Bastien
l***@rottenrei.be
2011-11-05 15:52:30 UTC
Permalink
Hi Bastien,
Post by Bastien Dejean
Hi,
key({"Control"}, "j", function (w) w:insert_cmd("\n") end),
produce a 'vertical tab' character instead of the expected newline.
How can you spot the difference?
Cheers!
Post by Bastien Dejean
Any help?
Greetings,
--
Bastien
_______________________________________________
luakit-dev mailing list
http://lists.luakit.org/mailman/listinfo/luakit-dev
--
Start using GPG! (http://www.gnupg.org/)
l***@rottenrei.be
2011-11-05 15:58:16 UTC
Permalink
Hi Bastien,
Post by Bastien Dejean
Hi,
key({"Control"}, "j", function (w) w:insert_cmd("\n") end),
produce a 'vertical tab' character instead of the expected newline.
On second thought, even if you get a correct character there, I don't
think that's what you want to do.

`w:insert_cmd()` will actually set any text you give it in the entry
box, but the entry box will not receive that as key events, so pressing
`<C-j>` will not submit the entry, even if you can insert a newline.
Instead you'd probably want to do something along the line of this
(untested) code:

key({"Control"}, "j", function (w, opts)
return lousy.bind.match_key(w, opts.binds, {}, "Return", opts)
end),

This should (in theory) simulate hitting the `"Return"` key.

Hope that's what you wanted to achieve.
Cheers!
Post by Bastien Dejean
Any help?
Greetings,
--
Bastien
_______________________________________________
luakit-dev mailing list
http://lists.luakit.org/mailman/listinfo/luakit-dev
--
Start using GPG! (http://www.gnupg.org/)
Bastien Dejean
2011-11-05 17:47:56 UTC
Permalink
Post by l***@rottenrei.be
`<C-j>` will not submit the entry, even if you can insert a newline.
Instead you'd probably want to do something along the line of this
key({"Control"}, "j", function (w, opts)
return lousy.bind.match_key(w, opts.binds, {}, "Return", opts)
end),
This should (in theory) simulate hitting the `"Return"` key.
Hope that's what you wanted to achieve.
Yes it is.
But the code doesn't work:
It seems that it sends 'Return', but since 'Control' is pressed, nothing
happens.
--
Bastien
l***@rottenrei.be
2011-11-06 13:28:57 UTC
Permalink
Post by Bastien Dejean
Post by l***@rottenrei.be
`<C-j>` will not submit the entry, even if you can insert a newline.
Instead you'd probably want to do something along the line of this
key({"Control"}, "j", function (w, opts)
return lousy.bind.match_key(w, opts.binds, {}, "Return", opts)
end),
This should (in theory) simulate hitting the `"Return"` key.
Hope that's what you wanted to achieve.
Yes it is.
It seems that it sends 'Return', but since 'Control' is pressed, nothing
happens.
It works for me. To reproduce: Paste the code above after
`add_binds("all"`. Start luakit. Enter follow mode. Tab to a link of
your choice. Press `<C-j>`. It follows the selected link.

Cheers!
Post by Bastien Dejean
--
Bastien
--
Start using GPG! (http://www.gnupg.org/)
Bastien Dejean
2011-11-06 17:18:15 UTC
Permalink
Post by l***@rottenrei.be
Post by Bastien Dejean
Post by l***@rottenrei.be
key({"Control"}, "j", function (w, opts)
return lousy.bind.match_key(w, opts.binds, {}, "Return", opts)
end),
Hope that's what you wanted to achieve.
Yes it is.
It works for me. To reproduce: Paste the code above after
`add_binds("all"`. Start luakit. Enter follow mode. Tab to a link of
your choice. Press `<C-j>`. It follows the selected link.
Ok, but:

:open foo<C-j>

yields nothing.
--
Bastien
l***@rottenrei.be
2011-11-06 19:17:45 UTC
Permalink
Post by Bastien Dejean
Post by l***@rottenrei.be
Post by Bastien Dejean
Post by l***@rottenrei.be
key({"Control"}, "j", function (w, opts)
return lousy.bind.match_key(w, opts.binds, {}, "Return", opts)
end),
Hope that's what you wanted to achieve.
Yes it is.
It works for me. To reproduce: Paste the code above after
`add_binds("all"`. Start luakit. Enter follow mode. Tab to a link of
your choice. Press `<C-j>`. It follows the selected link.
:open foo<C-j>
yields nothing.
Ah nice. Didn't catch that one. That's because the command mode does not
use a `Return` binding. Try this for size:

key({"Control"}, "j", function (w, opts)
local success = w.ibar.input:emit_signal("activate")
if not success then lousy.bind.match_key(w, opts.binds, {}, "Return", opts) end
end),

This simulates an "activation" of the entry widget (for modes like the
command mode) and if that does not work, simulates a "Return" (for e.g.
following)
Post by Bastien Dejean
--
Bastien
--
Start using GPG! (http://www.gnupg.org/)
Bastien Dejean
2011-11-06 20:50:31 UTC
Permalink
Post by l***@rottenrei.be
This simulates an "activation" of the entry widget (for modes like the
command mode) and if that does not work, simulates a "Return" (for e.g.
following)
Absolutely, great!

Greetings,
--
Bastien
Loading...