-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Console.ReadLine() to return at Tab #800
Comments
I don't understand the request. Console.ReadKey() does return a ConsoleKeyInfo for Tab when Tab is pressed. You can see it's explicitly handled here: When I run this: using System;
class Program
{
static void Main()
{
Console.WriteLine("Ready...");
while (true)
{
ConsoleKeyInfo k = Console.ReadKey(intercept: true);
Console.WriteLine(k.Key + ": " + (int)k.KeyChar);
}
}
} and then type a bunch of tabs, I see:
|
Using search I got into the file https://github.com/dotnet/corefx/blob/c7a4807728206d959e1878242c0bd6d35948fc2d/src/System.Console/src/System/ConsolePal.Unix.cs#L91 |
I'm not sure what you're asking. That ReadKey method you linked to in that file calls StdinReader.ReadKey: |
@stephentoub Thanks for clarify! I really confused ReadKey and Readline methods in CoreFX repo. |
I corrected my request. |
This seems like weird request as TAB does not constitute end of line e.g. if the function returns it would give less than line. |
@wfurt It seems you say about implementing a power line editor class which allows customizations and hooks/handlers. Looks good to me. |
So it would seem like implementing a modified variant of Assuming you would like to see this functionality added to |
Ideally extensible line editor. |
Yes. #35063 meant this. The "TAB" in C++ STL is called "delim" so I used that name. |
…230.1 (dotnet#800) [main] Update dependencies from dotnet/arcade
We have discussed this potential feature again and concluded that we are going to close the request. Features related to tab/word completion and/or other key handling behaviors are commonly needed in shells, and that is the layer where we think the feature is best implemented. With the Unix Console.ReadKey rewrite (#72193) complete in .NET 7.0, we expect that key-level functionality should now be much more reliable to implement upstack as well. Upstack implementations would be wrappers around |
/cc @SteveL-MSFT @daxian-dbw for information. It seems we could to unify PowerShell ReadLine method. |
AB#1115512
On Windows PowerShell implements tab completions in command line (without PSReadline).
https://github.com/PowerShell/PowerShell/blob/0f7efddd22a4a44f61a2f22de86f5d6b6aa47564/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs#L753
On Unix PowerShell can not do this because Console API doesn't support read line complete when the Tab button is pressed.
https://github.com/dotnet/corefx/blob/a10890f4ffe0fadf090c922578ba0e606ebdd16c/src/System.Console/src/System/IO/StdInReader.cs#L149
Once feature request is implemented, in PowerShell repo we can use the same code on all systems, enhance supported features on Unix and remove explicit P/Invokes.
Feature request
Enhance Console API so that Console.ReadLine() works like Windows ReadConsole:
Additional
Bash benefits from Readline library https://en.wikipedia.org/wiki/GNU_Readline
The text was updated successfully, but these errors were encountered: