hackathon week is my favorite week
This is basically the complete #8797.
This commit is contained in:
parent
84e95cf06a
commit
80a4fedc16
|
@ -836,11 +836,16 @@ namespace winrt::TerminalApp::implementation
|
||||||
aaa.Action(ShortcutAction::SendInput);
|
aaa.Action(ShortcutAction::SendInput);
|
||||||
SendInputArgs args{ fmt::format(L"{} {}", prefix.c_str(), opt.c_str()) };
|
SendInputArgs args{ fmt::format(L"{} {}", prefix.c_str(), opt.c_str()) };
|
||||||
aaa.Args(args);
|
aaa.Args(args);
|
||||||
Command cmd{opt, aaa};
|
Command cmd{ opt, aaa };
|
||||||
actions.Append(cmd);
|
actions.Append(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandPalette().SetCommands(actions);
|
CommandPalette().SetCommands(actions);
|
||||||
|
// EnableCommandPaletteMode will make sure to trigger
|
||||||
|
// _updateFilteredActions, which we need to update the command
|
||||||
|
// list.
|
||||||
|
CommandPalette().EnableCommandPaletteMode(CommandPaletteLaunchMode::Action);
|
||||||
|
CommandPalette().Visibility(Visibility::Visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,6 +500,10 @@ void AppCommandlineArgs::_buildSelectListParser()
|
||||||
// _newTabShort.subcommand = _app.add_subcommand("nt", RS_A(L"CmdNTDesc"));
|
// _newTabShort.subcommand = _app.add_subcommand("nt", RS_A(L"CmdNTDesc"));
|
||||||
|
|
||||||
auto setupSubcommand = [this](auto& subcommand) {
|
auto setupSubcommand = [this](auto& subcommand) {
|
||||||
|
subcommand->add_option("--prefix",
|
||||||
|
_selectListPrefix,
|
||||||
|
"prefix to append to the input");
|
||||||
|
|
||||||
// When ParseCommand is called, if this subcommand was provided, this
|
// When ParseCommand is called, if this subcommand was provided, this
|
||||||
// callback function will be triggered on the same thread. We can be sure
|
// callback function will be triggered on the same thread. We can be sure
|
||||||
// that `this` will still be safe - this function just lets us know this
|
// that `this` will still be safe - this function just lets us know this
|
||||||
|
@ -528,7 +532,7 @@ void AppCommandlineArgs::_buildSelectListParser()
|
||||||
// lines.push_back(winrt::to_hstring{ line });
|
// lines.push_back(winrt::to_hstring{ line });
|
||||||
// }
|
// }
|
||||||
auto hstringLines = winrt::single_threaded_vector<winrt::hstring>(std::move(lines));
|
auto hstringLines = winrt::single_threaded_vector<winrt::hstring>(std::move(lines));
|
||||||
SelectListArgs args{ L"Foo", hstringLines };
|
SelectListArgs args{ winrt::to_hstring(_selectListPrefix), hstringLines };
|
||||||
aaa.Args(args);
|
aaa.Args(args);
|
||||||
_startupActions.push_back(aaa);
|
_startupActions.push_back(aaa);
|
||||||
});
|
});
|
||||||
|
|
|
@ -163,19 +163,25 @@ winrt::hstring _getStdin()
|
||||||
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
if (hIn)
|
if (hIn)
|
||||||
{
|
{
|
||||||
std::array<char, 4096> _buffer{};
|
std::stringstream ss;
|
||||||
|
|
||||||
DWORD read{};
|
DWORD read{};
|
||||||
|
do
|
||||||
const auto readFail{ !ReadFile(hIn, _buffer.data(), gsl::narrow_cast<DWORD>(_buffer.size()), &read, nullptr) };
|
|
||||||
if (readFail) // reading failed (we must check this first, because read will also be 0.)
|
|
||||||
{
|
{
|
||||||
const auto lastError = GetLastError();
|
std::array<char, 4096> _buffer{};
|
||||||
// else we call convertUTF8ChunkToUTF16 with an empty string_view to convert possible remaining partials to U+FFFD
|
const auto readFail{ !ReadFile(hIn, _buffer.data(), gsl::narrow_cast<DWORD>(_buffer.size()), &read, nullptr) };
|
||||||
return winrt::hstring{};
|
// reading failed (we must check this first, because read will also be 0.)
|
||||||
}
|
if (readFail)
|
||||||
|
{
|
||||||
|
const auto lastError = GetLastError();
|
||||||
|
return winrt::hstring{};
|
||||||
|
}
|
||||||
|
ss << std::string_view{ _buffer.data(), read };
|
||||||
|
|
||||||
return winrt::to_hstring(std::string_view{ _buffer.data(), read });
|
} while (read == 4096);
|
||||||
|
// keep reading until we don't read enough to fill the buffer. The
|
||||||
|
// subsequent read will return ERROR_BROKEN_PIPE.
|
||||||
|
|
||||||
|
return winrt::to_hstring(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return winrt::hstring{};
|
return winrt::hstring{};
|
||||||
|
|
Loading…
Reference in a new issue