git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Illustration PATCH] add -i: accept single-keypress input

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 4, 2009, 05:10 UTC
Message-ID
<7vljsm9492.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<200902031035.04978.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 11 quoted lines
> Junio C Hamano wrote:
>
>> Hmm, you could trigger the action immediately after seeing _enough_ number
>> of characters to disambiguate instead of stop-and-prompt, I guess?  That
>> way, you would get a single-key merely as a degenerate case when the
>> choices are all distinct.
>
> I don't think that's very nice.  On the one hand, you'd really want to
> allow the user to delete some of the input again if he decides to do
> something else instead, and we'd either need readline or need to
> reinvent it for that....

But doesn't the original "single-keypress" theme shares that problem anyway? It trades the ability to "delete some of the it again if he decides to" away, in exchange for something else (probably "quicker input" or "perceived ease of use").

Show 5 quoted lines
> ....  On the other hand, some possible choices might
> be a valid prefix of some _other_ choices, at which point you need a
> terminator (such as the <enter>) anyway.  I expect this to be fairly
> common since many of the list_and_choose() prompts are numbered, so
> that 1 and 10 run into this problem.

I think that is independent, is an easy to fix (e.g. 1..9 A B C...Z), and is a chicken-and-egg issue. If the input mechanism had "enough leading letters to disambiguate" semantics from the beginning, I am reasonably sure that list_and_choose() would have implemented its choice as not small integers but distinct letters.

Previous: Thomas RastNext: Thomas Rast
Message 10 of 13 in “add -p: Term::ReadKey and more”
  1. 0/4 add -p: Term::ReadKey and moreThomas Rast, Feb 2, 2009
  2. 1/4 add -p: change prompt separator for 'g'Thomas Rast, Feb 2, 2009
  3. 2/4 add -p: trap Ctrl-D in 'goto' modeThomas Rast, Feb 2, 2009
  4. 3/4 add -p: optionally prompt for single charactersThomas Rast, Feb 2, 2009
  5. 4/4 add -p: print errors in help colorsThomas Rast, Feb 2, 2009
  6. Jeff KingFeb 3, 2009
  7. add -i: accept single-keypress inputThomas Rast, Feb 3, 2009
  8. Junio C HamanoFeb 3, 2009
  9. Thomas RastFeb 3, 2009
  10. Junio C HamanoFeb 4, 2009
  11. Thomas RastFeb 4, 2009
  12. Thomas RastFeb 4, 2009
  13. Junio C HamanoFeb 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.