Skip to content

Commit

Permalink
Prevent "Options" propsheet from reverting cursor shape settings (#2663)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
zadjii-msft authored and msftbot[bot] committed Sep 9, 2019
1 parent badbbc4 commit ce34c73
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
41 changes: 28 additions & 13 deletions src/propsheet/OptionsPage.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/propsheet/OptionsPage.h
Expand Up @@ -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
Expand All @@ -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);
13 changes: 13 additions & 0 deletions src/propsheet/TerminalPage.cpp
Expand Up @@ -3,6 +3,7 @@

#include "precomp.h"
#include "TerminalPage.h"
#include "OptionsPage.h" // For InitializeCursorSize
#include "ColorControl.h"
#include <functional>

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/propsheet/console.rc
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/propsheet/dialogs.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/propsheet/globals.cpp
Expand Up @@ -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);
1 change: 1 addition & 0 deletions src/propsheet/globals.h
Expand Up @@ -53,3 +53,4 @@ extern COLORREF g_fakeBackgroundColor;
extern COLORREF g_fakeCursorColor;

extern HWND g_hTerminalDlg;
extern HWND g_hOptionsDlg;

0 comments on commit ce34c73

Please sign in to comment.