+ auto-select High-DPI Toolbar if screen resolution is Full-HD (1920x1080) or higher

+ no save of unchanged custom color defaults
+ some more cleanup of global and static vars
This commit is contained in:
Rainer Kottenhoff 2018-10-09 08:59:49 +02:00
parent 4ee6fb3da9
commit 1021002e5d
3 changed files with 333 additions and 334 deletions

View File

@ -386,7 +386,7 @@ void _InitTextBuffer(HWND hwnd, const char* lpstrText, DocPos textLen, bool bS
// EditSetNewText()
//
extern bool bFreezeAppTitle;
extern FILEVARS fvCurFile;
extern FILEVARS g_fvCurFile;
void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
{
@ -394,7 +394,7 @@ void EditSetNewText(HWND hwnd,char* lpstrText,DWORD cbText)
_ClearTextBuffer(hwnd);
FileVars_Apply(hwnd,&fvCurFile);
FileVars_Apply(hwnd,&g_fvCurFile);
_InitTextBuffer(hwnd, lpstrText, cbText, true);
@ -1068,7 +1068,7 @@ bool EditLoadFile(
bool const bIsUTF8Sig = ((cbData >= 3) ? IsUTF8Signature(lpData) : false);
if (cbData == 0) {
FileVars_Init(NULL,0,&fvCurFile);
FileVars_Init(NULL,0,&g_fvCurFile);
*iEOLMode = Settings.DefaultEOLMode;
*iEncoding = !Encoding_IsNONE(iForcedEncoding) ? iForcedEncoding : (Settings.LoadASCIIasUTF8 ? CPI_UTF8 : iPreferedEncoding);
EditSetNewText(hwnd,"",0);
@ -1116,7 +1116,7 @@ bool EditLoadFile(
if (convCnt != 0) {
FreeMem(lpData);
EditSetNewText(hwnd,"",0);
FileVars_Init(lpDataUTF8,convCnt - 1,&fvCurFile);
FileVars_Init(lpDataUTF8,convCnt - 1,&g_fvCurFile);
EditSetNewText(hwnd,lpDataUTF8,convCnt - 1);
*iEOLMode = EditDetectEOLMode(hwnd,lpDataUTF8);
FreeMem(lpDataUTF8);
@ -1132,17 +1132,17 @@ bool EditLoadFile(
else { // === ALL OTHERS ===
FileVars_Init(lpData,cbData,&fvCurFile);
FileVars_Init(lpData,cbData,&g_fvCurFile);
// === UTF-8 ===
bool const bHardRulesUTF8 = Encoding_IsUTF8(iForcedEncoding) || (FileVars_IsUTF8(&fvCurFile) && !Settings.NoEncodingTags);
bool const bHardRulesUTF8 = Encoding_IsUTF8(iForcedEncoding) || (FileVars_IsUTF8(&g_fvCurFile) && !Settings.NoEncodingTags);
bool const bForcedNonUTF8 = !Encoding_IsNONE(iForcedEncoding) && !Encoding_IsUTF8(iForcedEncoding);
bool const bValidUTF8 = IsValidUTF8(lpData, cbData);
bool const bAnalysisUTF8 = Encoding_IsUTF8(iAnalyzedEncoding) && bIsReliable;
bool const bSoftHintUTF8 = Encoding_IsUTF8(iAnalyzedEncoding) || Encoding_IsUTF8(iPreferedEncoding); // non-reliable analysis = soft-hint
bool const bRejectUTF8 = bSkipUTFDetection || bForcedNonUTF8 || (FileVars_IsNonUTF8(&fvCurFile) && !Settings.NoEncodingTags);
bool const bRejectUTF8 = bSkipUTFDetection || bForcedNonUTF8 || (FileVars_IsNonUTF8(&g_fvCurFile) && !Settings.NoEncodingTags);
//if (bHardRulesUTF8 || (!bRejectUTF8 && bValidUTF8 && (bIsUTF8Sig || bAnalysisUTF8)))
if (bHardRulesUTF8 || (!bRejectUTF8 && bValidUTF8 && (bIsUTF8Sig || bAnalysisUTF8 || bSoftHintUTF8))) // soft-hint = prefer UTF-8
@ -1166,10 +1166,10 @@ bool EditLoadFile(
if (!Encoding_IsNONE(iForcedEncoding))
*iEncoding = iForcedEncoding;
else {
*iEncoding = FileVars_GetEncoding(&fvCurFile);
*iEncoding = FileVars_GetEncoding(&g_fvCurFile);
if (Encoding_IsNONE(*iEncoding))
{
*iEncoding = ((fvCurFile.mask & FV_ENCODING) ? CPI_ANSI_DEFAULT : iPreferedEncoding);
*iEncoding = ((g_fvCurFile.mask & FV_ENCODING) ? CPI_ANSI_DEFAULT : iPreferedEncoding);
}
}
@ -7887,7 +7887,7 @@ extern int g_iTabWidthG;
extern int g_iIndentWidthG;
extern bool g_bWordWrapG;
extern int g_iLongLinesLimitG;
extern int iWrapCol;
extern int g_iWrapCol;
bool FileVars_Apply(HWND hwnd,LPFILEVARS lpfv) {
@ -7934,7 +7934,7 @@ bool FileVars_Apply(HWND hwnd,LPFILEVARS lpfv) {
SendMessage(hwnd,SCI_SETEDGECOLUMN,Settings.LongLinesLimit,0);
iWrapCol = 0;
g_iWrapCol = 0;
return(true);
}

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@
#include "Styles.h"
extern const int FontQuality[4];
extern const int g_FontQuality[4];
extern bool g_bCodeFoldingAvailable;
extern bool g_bIniFileFromScratch;
@ -120,7 +120,9 @@ static PEDITLEXER s_pLexCurrent = &lexStandard;
static bool s_fWarnedNoIniFile = false;
static COLORREF s_colorCustom[16];
static COLORREF s_colorDefault[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static COLORREF s_colorCustom[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
static bool s_bAutoSelect = true;
#define STYLESELECTDLG_X 304
@ -237,36 +239,42 @@ void Style_Load()
WCHAR *pIniSection = AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY);
if (pIniSection) {
int const cchIniSection = (int)len;
// Custom colors
s_colorCustom[0] = RGB(0x00, 0x00, 0x00);
s_colorCustom[1] = RGB(0x0A, 0x24, 0x6A);
s_colorCustom[2] = RGB(0x3A, 0x6E, 0xA5);
s_colorCustom[3] = RGB(0x00, 0x3C, 0xE6);
s_colorCustom[4] = RGB(0x00, 0x66, 0x33);
s_colorCustom[5] = RGB(0x60, 0x80, 0x20);
s_colorCustom[6] = RGB(0x64, 0x80, 0x00);
s_colorCustom[7] = RGB(0xA4, 0x60, 0x00);
s_colorCustom[8] = RGB(0xFF, 0xFF, 0xFF);
s_colorCustom[9] = RGB(0xFF, 0xFF, 0xE2);
s_colorCustom[10] = RGB(0xFF, 0xF1, 0xA8);
s_colorCustom[11] = RGB(0xFF, 0xC0, 0x00);
s_colorCustom[12] = RGB(0xFF, 0x40, 0x00);
s_colorCustom[13] = RGB(0xC8, 0x00, 0x00);
s_colorCustom[14] = RGB(0xB0, 0x00, 0xB0);
s_colorCustom[15] = RGB(0xB2, 0x8B, 0x40);
// Default colors
s_colorDefault[0] = RGB(0x00, 0x00, 0x00);
s_colorDefault[1] = RGB(0x0A, 0x24, 0x6A);
s_colorDefault[2] = RGB(0x3A, 0x6E, 0xA5);
s_colorDefault[3] = RGB(0x00, 0x3C, 0xE6);
s_colorDefault[4] = RGB(0x00, 0x66, 0x33);
s_colorDefault[5] = RGB(0x60, 0x80, 0x20);
s_colorDefault[6] = RGB(0x64, 0x80, 0x00);
s_colorDefault[7] = RGB(0xA4, 0x60, 0x00);
s_colorDefault[8] = RGB(0xFF, 0xFF, 0xFF);
s_colorDefault[9] = RGB(0xFF, 0xFF, 0xE2);
s_colorDefault[10] = RGB(0xFF, 0xF1, 0xA8);
s_colorDefault[11] = RGB(0xFF, 0xC0, 0x00);
s_colorDefault[12] = RGB(0xFF, 0x40, 0x00);
s_colorDefault[13] = RGB(0xC8, 0x00, 0x00);
s_colorDefault[14] = RGB(0xB0, 0x00, 0xB0);
s_colorDefault[15] = RGB(0xB2, 0x8B, 0x40);
LoadIniSection(L"Custom Colors", pIniSection, cchIniSection);
for (int i = 0; i < 16; i++) {
WCHAR wch[32] = { L'\0' };
StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1);
int itok = 0;
if (IniSectionGetString(pIniSection, tch, L"", wch, COUNTOF(wch))) {
if (wch[0] == L'#') {
unsigned int irgb;
int itok = swscanf_s(CharNext(wch), L"%x", &irgb);
if (itok == 1)
itok = swscanf_s(CharNext(wch), L"%x", &irgb);
if (itok == 1) {
s_colorCustom[i] = RGB((irgb & 0xFF0000) >> 16, (irgb & 0xFF00) >> 8, irgb & 0xFF);
}
}
}
if (itok != 1) {
s_colorCustom[i] = s_colorDefault[i];
}
}
LoadIniSection(L"Styles", pIniSection, cchIniSection);
@ -284,7 +292,6 @@ void Style_Load()
s_cxStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeX", STYLESELECTDLG_X), 0, 8192);
s_cyStyleSelectDlg = clampi(IniSectionGetInt(pIniSection, L"SelectDlgSizeY", STYLESELECTDLG_Y), 0, 8192);
for (int iLexer = 0; iLexer < COUNTOF(g_pLexArray); iLexer++) {
LexFunctionPtr_t const pLexFunction = g_pLexArray[iLexer]->pFctPtr;
@ -332,11 +339,13 @@ void Style_Save()
if (pIniSection) {
// Custom colors
for (int i = 0; i < 16; i++) {
WCHAR wch[32] = { L'\0' };
StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1);
StringCchPrintf(wch, COUNTOF(wch), L"#%02X%02X%02X",
(int)GetRValue(s_colorCustom[i]), (int)GetGValue(s_colorCustom[i]), (int)GetBValue(s_colorCustom[i]));
IniSectionSetString(pIniSection, tch, wch);
if (s_colorCustom[i] != s_colorDefault[i]) {
WCHAR wch[32] = { L'\0' };
StringCchPrintf(tch, COUNTOF(tch), L"%02i", i + 1);
StringCchPrintf(wch, COUNTOF(wch), L"#%02X%02X%02X",
(int)GetRValue(s_colorCustom[i]), (int)GetGValue(s_colorCustom[i]), (int)GetBValue(s_colorCustom[i]));
IniSectionSetString(pIniSection, tch, wch);
}
}
SaveIniSection(L"Custom Colors", pIniSection);
ZeroMemory(pIniSection, len * sizeof(WCHAR));
@ -1415,7 +1424,7 @@ bool Style_HasLexerForExt(LPCWSTR lpszExt)
//
// Style_SetLexerFromFile()
//
extern FILEVARS fvCurFile;
extern FILEVARS g_fvCurFile;
void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
{
@ -1424,12 +1433,12 @@ void Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
PEDITLEXER pLexNew = NULL;
PEDITLEXER pLexSniffed = NULL;
if ((fvCurFile.mask & FV_MODE) && fvCurFile.tchMode[0]) {
if ((g_fvCurFile.mask & FV_MODE) && g_fvCurFile.tchMode[0]) {
WCHAR wchMode[32] = { L'\0' };
PEDITLEXER pLexMode;
MultiByteToWideCharStrg(Encoding_SciCP, fvCurFile.tchMode, wchMode);
MultiByteToWideCharStrg(Encoding_SciCP, g_fvCurFile.tchMode, wchMode);
if (!Flags.NoCGIGuess && (StringCchCompareNI(wchMode,COUNTOF(wchMode),L"cgi", CSTRLEN(L"cgi")) == 0 ||
StringCchCompareNI(wchMode,COUNTOF(wchMode),L"fcgi", CSTRLEN(L"fcgi")) == 0)) {
@ -2379,7 +2388,7 @@ bool Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle, LPCWSTR sLexerNam
bool bIsUnderline = (StrStrI(lpszStyle, L"underline")) ? true : false;
bool bIsStrikeout = (StrStrI(lpszStyle, L"strikeout")) ? true : false;
int iQuality = FontQuality[Settings2.SciFontQuality];
int iQuality = g_FontQuality[Settings2.SciFontQuality];
switch (iQuality) {
case SC_EFF_QUALITY_NON_ANTIALIASED:
iQuality = NONANTIALIASED_QUALITY;
@ -2765,7 +2774,7 @@ void Style_SetStyles(HWND hwnd, int iStyle, LPCWSTR lpszStyle, bool bInitDefault
SendMessage(hwnd, SCI_SETFONTQUALITY, wQuality, 0);
}
else if (bInitDefault) {
WPARAM wQuality = (WPARAM)FontQuality[Settings2.SciFontQuality];
WPARAM wQuality = (WPARAM)g_FontQuality[Settings2.SciFontQuality];
if (wQuality == SC_EFF_QUALITY_DEFAULT) {
// undefined, use general settings, except for special fonts
if (StringCchCompareXI(wchFontName, L"Calibri") == 0 ||