Auto prompt detection on enter

This commit is contained in:
Mike Griese
2022-03-23 08:40:05 -05:00
parent dce45f3c20
commit 29478a6702
8 changed files with 32 additions and 3 deletions

View File

@@ -25,6 +25,9 @@ namespace Microsoft.Terminal.Core
Windows.Foundation.IReference<Microsoft.Terminal.Core.Color> TabColor;
Windows.Foundation.IReference<Microsoft.Terminal.Core.Color> StartingTabColor;
Boolean AutoMarkPrompts;
};
}

View File

@@ -48,7 +48,8 @@ Terminal::Terminal() :
_selection{ std::nullopt },
_taskbarState{ 0 },
_taskbarProgress{ 0 },
_trimBlockSelection{ false }
_trimBlockSelection{ false },
_autoMarkPrompts{ false }
{
auto dispatch = std::make_unique<TerminalDispatch>(*this);
auto engine = std::make_unique<OutputStateMachineEngine>(std::move(dispatch));
@@ -121,6 +122,7 @@ void Terminal::UpdateSettings(ICoreSettings settings)
_suppressApplicationTitle = settings.SuppressApplicationTitle();
_startingTitle = settings.StartingTitle();
_trimBlockSelection = settings.TrimBlockSelection();
_autoMarkPrompts = settings.AutoMarkPrompts();
_terminalInput->ForceDisableWin32InputMode(settings.ForceVTInput());
@@ -676,6 +678,14 @@ bool Terminal::SendKeyEvent(const WORD vkey,
return false;
}
//if (_autoMarkPrompts && vkey == VK_RETURN && !_inAltBuffer())
//{
// DispatchTypes::ScrollMark mark;
// mark.category = DispatchTypes::MarkCategory::Prompt;
// mark.color = til::color(255, 255, 255); // should this be configurable?
// AddMark(mark);
//}
KeyEvent keyEv{ keyDown, 1, vkey, sc, ch, states.Value() };
return _terminalInput->HandleKey(&keyEv);
}
@@ -730,6 +740,15 @@ bool Terminal::SendCharEvent(const wchar_t ch, const WORD scanCode, const Contro
vkey = _VirtualKeyFromCharacter(ch);
}
if (_autoMarkPrompts && vkey == VK_RETURN && !_inAltBuffer())
{
DispatchTypes::ScrollMark mark;
mark.category = DispatchTypes::MarkCategory::Prompt;
mark.color = til::color(255, 255, 255); // should this be configurable?
AddMark(mark);
}
// Unfortunately, the UI doesn't give us both a character down and a
// character up event, only a character received event. So fake sending both
// to the terminal input translator. Unless it's in win32-input-mode, it'll

View File

@@ -304,6 +304,7 @@ private:
bool _suppressApplicationTitle;
bool _bracketedPasteMode;
bool _trimBlockSelection;
bool _autoMarkPrompts;
size_t _taskbarState;
size_t _taskbarProgress;

View File

@@ -76,7 +76,8 @@ Author(s):
X(Model::BellStyle, BellStyle, "bellStyle", BellStyle::Audible) \
X(bool, UseAtlasEngine, "experimental.useAtlasEngine", false) \
X(Windows::Foundation::Collections::IVector<winrt::hstring>, BellSound, "bellSound", nullptr) \
X(bool, Elevate, "elevate", false)
X(bool, Elevate, "elevate", false) \
X(bool, AutoMarkPrompts, "experimental.autoMarkPrompts", false)
// Intentionally omitted Profile settings:
// * Name

View File

@@ -83,5 +83,6 @@ namespace Microsoft.Terminal.Settings.Model
INHERITABLE_PROFILE_SETTING(Windows.Foundation.Collections.IVector<String>, BellSound);
INHERITABLE_PROFILE_SETTING(Boolean, Elevate);
INHERITABLE_PROFILE_SETTING(Boolean, AutoMarkPrompts);
}
}

View File

@@ -265,6 +265,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
}
_Elevate = profile.Elevate();
_AutoMarkPrompts = profile.AutoMarkPrompts();
}
// Method Description:

View File

@@ -154,6 +154,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
INHERITABLE_SETTING(Model::TerminalSettings, bool, Elevate, false);
INHERITABLE_SETTING(Model::TerminalSettings, bool, AutoMarkPrompts, false);
private:
std::optional<std::array<Microsoft::Terminal::Core::Color, COLOR_TABLE_SIZE>> _ColorTable;
gsl::span<Microsoft::Terminal::Core::Color> _getColorTableImpl();

View File

@@ -45,7 +45,8 @@
X(bool, SuppressApplicationTitle) \
X(bool, ForceVTInput, false) \
X(winrt::hstring, StartingTitle) \
X(bool, DetectURLs, true)
X(bool, DetectURLs, true) \
X(bool, AutoMarkPrompts)
// --------------------------- Control Settings ---------------------------
// All of these settings are defined in IControlSettings.