From: Mark Somerville Date: 2011-10-06T00:26:55+09:00 Subject: Re: Readline question - completely replace input? --SkvwRMAIpAhPCcCJ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 04, 2011 at 10:07:52PM +0900, Marc Heiler wrote: > Hi. >=20 > This is a strange question perhaps ... >=20 > I use Readline.readline to fetch user input. >=20 > Now if the user types: >=20 >=20 > "abc" >=20 > And then presses tab, I want this to complete to: >=20 > "do_action foobar" >=20 > So, yes, the original input "abc" no longer has anything to do with the > end result. :) >=20 > Is this possible? So far I am using Readline only to do something like: >=20 >=20 > "do" >=20 > expand into >=20 > "do_action " >=20 > But it would be kind of neat to both append something specifically after > TAB was pressed, and to also completely change the original input at the > same time. This is certainly possible using rb-readline[1] (pure Ruby port of GNU Readline), but I doubt that the C binding to GNU Readline provides enough hooks. As a rough starting point, you could look at rl_bind_key() to redefine the behaviour of \t. Some methods and variables to look at are: rl_insert() rl_redisplay() @_rl_last_v_pos @rl_point @rl_done 1 - https://github.com/luislavena/rb-readline --SkvwRMAIpAhPCcCJ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJOjHXtAAoJEKzyw1w4idTP6iQP/1zLI2PvhBZKpG5dDV7uE5HV cSRcCDG2m3WHZo7QnEHN1ylKjO2GPbxFQT0BipDSTtlsKFcYrC7W08pVeu1bsTRU Fy7DvAd2Nra8a1jiaGl45snPGshlx0PKJ28NzIdzXJtmFVUYRsueqTJzUh3/+NHD O0hCuqnDzQxSvZ6oI2+bY6hJIy/aUbIDyksTUYYmA/iWJIK7nt2RFnbLbtlpukpQ HK+/D5qG33w623IJgdSdBc8083lKxYbC81c5D6T+FQB+KjBSnYJ6NMu6GtMp/uM1 oQ8UIHp5NKc2sB9bHw99QnP8oI61U0MW7OL5Pm7OOVIgL1wx6oRQbiyOMKf6JOdG hKKTtUMuu+pu8mNUloCoRF2AdUVQnYeYIkNlWPmNn2kphGTs+YzowTfj3JKOKkE1 rXaNnojgqBQl2LwHTSfjYw00Oo4iZ/FMSoqFeJTLovmQO3RJp3r5tqYfQy0377F+ vYCszt/HEf/WC26gQqmKoC+cBDiCllMW75ygzRyUQG/pXClVIM+Y7XCjlk8WsBG6 pSXGgt/3pf1zT533gXcwHHAmVDUrIXesVRnqI1c/HWWxDGGaYk4hTrPvEe8XyOfa Nmc52B8KI9N7uwCYGrpuceBidC4DV4X+qQjrO3XBUle6Jj+q5vysYzTwfW5zi3ee 56KXhXrCK6tVpYc4BUN0 =zrmV -----END PGP SIGNATURE----- --SkvwRMAIpAhPCcCJ--