Prevent "Options" propsheet from reverting cursor shape settings (#2663)

* this actually fixes #1219

* the terminal page should check the checkbox on the options page

* Discard these changes from #2651

* Add comments, pull function out to helper
This commit is contained in:
Mike Griese 2019-09-09 09:45:05 -05:00 committed by msftbot[bot]
parent badbbc43a4
commit ce34c7320c
7 changed files with 50 additions and 14 deletions

View file

@ -3,6 +3,30 @@
#include "precomp.h"
void InitializeCursorSize(const HWND hOptionsDlg)
{
unsigned int newRadioValue = IDD_CURSOR_ADVANCED;
if (gpStateInfo->CursorType != 0)
{
// IDD_CURSOR_ADVANCED is used as a placeholder for when a
// non-legacy shape is selected.
newRadioValue = IDD_CURSOR_ADVANCED;
}
else if (gpStateInfo->CursorSize <= 25)
{
newRadioValue = IDD_CURSOR_SMALL;
}
else if (gpStateInfo->CursorSize <= 50)
{
newRadioValue = IDD_CURSOR_MEDIUM;
}
else
{
newRadioValue = IDD_CURSOR_LARGE;
}
CheckRadioButton(hOptionsDlg, IDD_CURSOR_SMALL, IDD_CURSOR_ADVANCED, newRadioValue);
}
bool OptionsCommandCallback(HWND hDlg, const unsigned int Item, const unsigned int Notification, HWND hControlWindow)
{
UINT Value;
@ -147,6 +171,9 @@ INT_PTR WINAPI SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lPara
switch (wMsg)
{
case WM_INITDIALOG:
// Initialize the global handle to this dialog
g_hOptionsDlg = hDlg;
CheckDlgButton(hDlg, IDD_HISTORY_NODUP, gpStateInfo->HistoryNoDup);
CheckDlgButton(hDlg, IDD_QUICKEDIT, gpStateInfo->QuickEdit);
CheckDlgButton(hDlg, IDD_INSERT, gpStateInfo->InsertMode);
@ -167,19 +194,7 @@ INT_PTR WINAPI SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lPara
CreateAndAssociateToolTipToControl(IDD_INTERCEPT_COPY_PASTE, hDlg, IDS_TOOLTIP_INTERCEPT_COPY_PASTE);
// initialize cursor radio buttons
if (gpStateInfo->CursorSize <= 25)
{
Item = IDD_CURSOR_SMALL;
}
else if (gpStateInfo->CursorSize <= 50)
{
Item = IDD_CURSOR_MEDIUM;
}
else
{
Item = IDD_CURSOR_LARGE;
}
CheckRadioButton(hDlg, IDD_CURSOR_SMALL, IDD_CURSOR_LARGE, Item);
InitializeCursorSize(hDlg);
SetDlgItemInt(hDlg, IDD_HISTORY_SIZE, gpStateInfo->HistoryBufferSize, FALSE);
SendDlgItemMessage(hDlg, IDD_HISTORY_SIZE, EM_LIMITTEXT, 3, 0);

View file

@ -6,7 +6,7 @@ Module Name:
- OptionsPage.h
Abstract:
- This module contains the definitions for console options dialog.
- This module contains the definitions for console options dialog.
Author(s):
Mike Griese (migrie) Oct-2016
@ -16,3 +16,4 @@ Author(s):
void ToggleV2OptionsControls(__in const HWND hDlg);
INT_PTR WINAPI SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam);
void InitializeCursorSize(const HWND hOptionsDlg);

View file

@ -3,6 +3,7 @@
#include "precomp.h"
#include "TerminalPage.h"
#include "OptionsPage.h" // For InitializeCursorSize
#include "ColorControl.h"
#include <functional>
@ -323,10 +324,22 @@ bool TerminalDlgCommand(const HWND hDlg, const WORD item, const WORD command) no
case IDD_TERMINAL_UNDERSCORE:
case IDD_TERMINAL_EMPTYBOX:
case IDD_TERMINAL_SOLIDBOX:
{
gpStateInfo->CursorType = item - IDD_TERMINAL_LEGACY_CURSOR;
UpdateApplyButton(hDlg);
// See GH#1219 - When the cursor state is something other than legacy,
// we need to manually check the "IDD_CURSOR_ADVANCED" radio button on
// the Options page. This will prevent the Options page from manually
// resetting the cursor to legacy.
if (g_hOptionsDlg != INVALID_HANDLE_VALUE)
{
InitializeCursorSize(g_hOptionsDlg);
}
handled = true;
break;
}
case IDD_DISABLE_SCROLLFORWARD:
gpStateInfo->TerminalScrolling = IsDlgButtonChecked(hDlg, IDD_DISABLE_SCROLLFORWARD);
UpdateApplyButton(hDlg);

View file

@ -42,6 +42,8 @@ BEGIN
WS_TABSTOP | WS_GROUP
AUTORADIOBUTTON "&Medium", IDD_CURSOR_MEDIUM, 14, 33, 84, 10,
AUTORADIOBUTTON "&Large", IDD_CURSOR_LARGE, 14, 43, 84, 10,
// IDD_CURSOR_ADVANCED is a hidden control, see GH#1219
AUTORADIOBUTTON "", IDD_CURSOR_ADVANCED, 14, 53, 0, 0,
GROUPBOX "Command History", -1, 115, 11, 120, 56, WS_GROUP
LTEXT "&Buffer Size:", -1, 119, 25, 78, 9
@ -106,6 +108,8 @@ BEGIN
WS_TABSTOP | WS_GROUP
AUTORADIOBUTTON "&Medium", IDD_CURSOR_MEDIUM, 14, 33, 84, 10,
AUTORADIOBUTTON "&Large", IDD_CURSOR_LARGE, 14, 43, 84, 10,
// IDD_CURSOR_ADVANCED is a hidden control, see GH#1219
AUTORADIOBUTTON "", IDD_CURSOR_ADVANCED, 14, 53, 0, 0,
GROUPBOX "Command History", -1, 115, 11, 120, 56, WS_GROUP
LTEXT "&Buffer Size:", -1, 119, 25, 78, 9

View file

@ -43,6 +43,7 @@ Revision History:
#define IDD_LANGUAGE_GROUPBOX 116
#define DID_SETTINGS_COMCTL5 117
#define DID_SETTINGS2_COMCTL5 118
#define IDD_CURSOR_ADVANCED 119
#define DID_FONTDLG 200
#define IDD_STATIC 201

View file

@ -55,3 +55,4 @@ COLORREF g_fakeBackgroundColor = RGB(12, 12, 12); // Default black
COLORREF g_fakeCursorColor = RGB(242, 242, 242); // Default bright white
HWND g_hTerminalDlg = static_cast<HWND>(INVALID_HANDLE_VALUE);
HWND g_hOptionsDlg = static_cast<HWND>(INVALID_HANDLE_VALUE);

View file

@ -53,3 +53,4 @@ extern COLORREF g_fakeBackgroundColor;
extern COLORREF g_fakeCursorColor;
extern HWND g_hTerminalDlg;
extern HWND g_hOptionsDlg;