Skip to content
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

User should be able to save all the commands emitted #1013

Closed
ChristophePichaud opened this issue May 24, 2019 · 3 comments
Closed

User should be able to save all the commands emitted #1013

ChristophePichaud opened this issue May 24, 2019 · 3 comments
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason.

Comments

@ChristophePichaud
Copy link

Summary of the new feature/enhancement

When the user emits commands, either in powershell or cmd, terminal can save them in memory (it's already done for the buffer) and enable the user to save them in a text file using a 'Save Commands in Text' item in a menu or via a button.

Proposed technical implementation details (optional)

It should not be difficult to make a static classic with a static vector and makeing a push_back everytimes and commands is started... I think it's already done for the bufer accessible with upper keyword key... Once the UI item is cliked, open the common dialog "Save As" and make a range for on th vector for writing the strings in a text file.
In theory, its about 20 lines of code... The idea is to properly catch the command after a carriage return or on upper wrapper called OnExecute(const wstring& command) or ireating through the memory buffer... Two possibilities.

@ChristophePichaud ChristophePichaud added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 24, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 24, 2019
@mdtauk
Copy link

mdtauk commented May 25, 2019

These issues may be relevant #642 #644

@zadjii-msft
Copy link
Member

Yea, this actually probably isn't solvable by the Terminal at all. It's the responsibility of the shell to execute commands, as well as knowing what a command actually is. From the terminal's perspective, we're just sending keystrokes.

Lets look at an example: editing a file in vim. While working in vim, the user is going to type a lot of keystrokes, including carriage returns, but the large majority of them are actually not commands. How could the terminal differentiate between keystrokes for vim vs keystrokes for cmd?

What about another example, powershell.exe. Say you use the reverse search functionality in powershell.

If you do not want to browse the entire history of PowerShell commands using up / down arrows, you can search the command history using CTRL+R (reverse search) or CTRL+S (forward search). Press the key combination and start typing part of the command that you want to find in previously executed commands. The text you entered will be found in the command history in any position (unlike search in PowerShell using F8 or Shift+F8, which allows to look for the matches from the beginning of the line only) and a suitable variant will be highlighted.

In the above case, a user typed Ctrl+R, then some subset of the command, then hit enter, but executed a much longer command. How could the terminal possible know what command was actually executed?

This seems like it should be easy, but would actually very quickly devlove into a myriad number of special per-shell cases. This is a feature request that's probably better suited for PowerShell/PowerShell

@zadjii-msft zadjii-msft added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason. labels May 28, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 28, 2019
@ChristophePichaud
Copy link
Author

In readDataCooked.cpp in Terminal\src\host, in the function _handlePostCharInputLoop, there is a way to handle the history in cmd line. The feature is dedicated to cmd for the moment.
Are you interested in ?

NTSTATUS COOKED_READ_DATA::_handlePostCharInputLoop(const bool isUnicode, size_t& numBytes, ULONG& controlKeyState) noexcept
{
../..
if (FoundCR)
{
if (_commandHistory)
{
// add to command line recall list if we have a history list.
_commandHistory->Add({ _backupLimit // <-
::MessageBox(NULL, _backupLimit, L"command", MB_OK);
}
../..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason.
Projects
None yet
Development

No branches or pull requests

3 participants