mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge pull request #2254 from RaiKoHoff/grepWin_Integration
Filevar tag "fill-column" changes to support multi-column marker
This commit is contained in:
commit
7645c2a5db
@ -1 +1 @@
|
||||
1
|
||||
2
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<assemblyIdentity
|
||||
name="Notepad3"
|
||||
processorArchitecture="*"
|
||||
version="5.20.421.1"
|
||||
version="5.20.421.2"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Notepad3 BETA</description>
|
||||
|
||||
@ -1284,15 +1284,22 @@ void LoadSettings()
|
||||
GET_INT_VALUE_FROM_INISECTION(WordWrapMode, 0, 0, 1);
|
||||
GET_INT_VALUE_FROM_INISECTION(WordWrapIndent, 0, 0, 6);
|
||||
|
||||
GET_BOOL_VALUE_FROM_INISECTION(WordWrap, true); Globals.fvBackup.bWordWrap = Settings.WordWrap;
|
||||
GET_BOOL_VALUE_FROM_INISECTION(TabsAsSpaces, false); Globals.fvBackup.bTabsAsSpaces = Settings.TabsAsSpaces;
|
||||
GET_BOOL_VALUE_FROM_INISECTION(TabIndents, true); Globals.fvBackup.bTabIndents = Settings.TabIndents;
|
||||
GET_INT_VALUE_FROM_INISECTION(TabWidth, 4, 1, 1024); Globals.fvBackup.iTabWidth = Settings.TabWidth;
|
||||
GET_INT_VALUE_FROM_INISECTION(IndentWidth, 4, 0, 1024); Globals.fvBackup.iIndentWidth = Settings.IndentWidth;
|
||||
GET_INT_VALUE_FROM_INISECTION(LongLinesLimit, 80, 0, LONG_LINES_MARKER_LIMIT); Globals.fvBackup.iLongLinesLimit = Settings.LongLinesLimit;
|
||||
GET_BOOL_VALUE_FROM_INISECTION(WordWrap, true); Globals.fvCurFile.bWordWrap = Settings.WordWrap;
|
||||
GET_BOOL_VALUE_FROM_INISECTION(TabsAsSpaces, false); Globals.fvCurFile.bTabsAsSpaces = Settings.TabsAsSpaces;
|
||||
GET_BOOL_VALUE_FROM_INISECTION(TabIndents, true); Globals.fvCurFile.bTabIndents = Settings.TabIndents;
|
||||
GET_INT_VALUE_FROM_INISECTION(TabWidth, 4, 1, 1024); Globals.fvCurFile.iTabWidth = Settings.TabWidth;
|
||||
GET_INT_VALUE_FROM_INISECTION(IndentWidth, 4, 0, 1024); Globals.fvCurFile.iIndentWidth = Settings.IndentWidth;
|
||||
|
||||
GET_BOOL_VALUE_FROM_INISECTION(MarkLongLines, (Globals.iCfgVersionRead < CFG_VER_0002)); Defaults.MarkLongLines = false; // new default
|
||||
GET_INT_VALUE_FROM_INISECTION(LongLineMode, EDGE_LINE, EDGE_LINE, EDGE_MULTILINE);
|
||||
GET_INT_VALUE_FROM_INISECTION(LongLinesLimit, 80, 0, LONG_LINES_MARKER_LIMIT);
|
||||
Globals.iWrapCol = Settings.LongLinesLimit;
|
||||
StringCchPrintf(Defaults.MultiEdgeLines, COUNTOF(Defaults.MultiEdgeLines), L"%i", Settings.LongLinesLimit);
|
||||
|
||||
_itow_s(Settings.LongLinesLimit, Defaults.MultiEdgeLines, COUNTOF(Defaults.MultiEdgeLines), 10);
|
||||
IniSectionGetString(IniSecSettings, L"MultiEdgeLines", Defaults.MultiEdgeLines, Settings.MultiEdgeLines, COUNTOF(Settings.MultiEdgeLines));
|
||||
size_t const n = NormalizeColumnVector(NULL, Settings.MultiEdgeLines, COUNTOF(Settings.MultiEdgeLines));
|
||||
StringCchCopy(Globals.fvCurFile.wchMultiEdgeLines, COUNTOF(Globals.fvCurFile.wchMultiEdgeLines), Settings.MultiEdgeLines);
|
||||
if (n > 1) { Settings.LongLineMode = EDGE_MULTILINE; }
|
||||
|
||||
Defaults.WordWrapSymbols = 2;
|
||||
int const iWS = IniSectionGetInt(IniSecSettings, L"WordWrapSymbols", Defaults.WordWrapSymbols);
|
||||
@ -1316,8 +1323,6 @@ void LoadSettings()
|
||||
GET_BOOL_VALUE_FROM_INISECTION(BackspaceUnindents, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(WarnInconsistentIndents, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(AutoDetectIndentSettings, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(MarkLongLines, (Globals.iCfgVersionRead < CFG_VER_0002)); Defaults.MarkLongLines = false; // new default
|
||||
GET_INT_VALUE_FROM_INISECTION(LongLineMode, EDGE_LINE, EDGE_LINE, EDGE_BACKGROUND);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(ShowSelectionMargin, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(ShowLineNumbers, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(ShowCodeFolding, true); FocusedView.ShowCodeFolding = Settings.ShowCodeFolding;
|
||||
@ -1334,9 +1339,12 @@ void LoadSettings()
|
||||
GET_BOOL_VALUE_FROM_INISECTION(ViewWhiteSpace, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(ViewEOLs, false);
|
||||
|
||||
auto const iPrefEncIniSetting = (cpi_enc_t)Encoding_MapIniSetting(false, (int)CPI_PREFERRED_ENCODING);
|
||||
GET_ENC_VALUE_FROM_INISECTION(DefaultEncoding, iPrefEncIniSetting, CPI_NONE, INT_MAX);
|
||||
Settings.DefaultEncoding = ((Settings.DefaultEncoding == CPI_NONE) ? CPI_PREFERRED_ENCODING : (cpi_enc_t)Encoding_MapIniSetting(true, (int)Settings.DefaultEncoding));
|
||||
auto const iDefaultEncoding = (cpi_enc_t)Encoding_MapIniSetting(false, (int)CPI_PREFERRED_ENCODING);
|
||||
GET_ENC_VALUE_FROM_INISECTION(DefaultEncoding, iDefaultEncoding, CPI_NONE, INT_MAX);
|
||||
Settings.DefaultEncoding = ((Settings.DefaultEncoding == CPI_NONE) ? CPI_PREFERRED_ENCODING :
|
||||
(cpi_enc_t)Encoding_MapIniSetting(true, (int)Settings.DefaultEncoding));
|
||||
Globals.fvCurFile.iEncoding = Settings.DefaultEncoding;
|
||||
|
||||
GET_BOOL_VALUE_FROM_INISECTION(UseDefaultForFileEncoding, false);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(LoadASCIIasUTF8, true);
|
||||
GET_BOOL_VALUE_FROM_INISECTION(UseReliableCEDonly, true);
|
||||
@ -1559,19 +1567,6 @@ void LoadSettings()
|
||||
// define scintilla internal codepage
|
||||
int const iSciDefaultCodePage = SC_CP_UTF8; // default UTF8
|
||||
|
||||
// remove internal support for Chinese, Japan, Korean DBCS use UTF-8 instead
|
||||
/*
|
||||
if (Settings.DefaultEncoding == CPI_ANSI_DEFAULT)
|
||||
{
|
||||
// check for Chinese, Japan, Korean DBCS code pages and switch accordingly
|
||||
int acp = (int)GetACP();
|
||||
if (acp == 932 || acp == 936 || acp == 949 || acp == 950) {
|
||||
iSciDefaultCodePage = acp;
|
||||
}
|
||||
Settings.DefaultEncoding = Encoding_GetByCodePage(iSciDefaultCodePage);
|
||||
}
|
||||
*/
|
||||
|
||||
// set flag for encoding default
|
||||
Encoding_SetDefaultFlag(Settings.DefaultEncoding);
|
||||
|
||||
@ -1775,6 +1770,7 @@ static bool _SaveSettings(bool bForceSaveSettings)
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ViewWhiteSpace);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ViewEOLs);
|
||||
|
||||
// encoding: internal<->external mapping
|
||||
Settings.DefaultEncoding = (cpi_enc_t)Encoding_MapIniSetting(false, (int)Settings.DefaultEncoding);
|
||||
SAVE_VALUE_IF_NOT_EQ_DEFAULT(Int, DefaultEncoding);
|
||||
Settings.DefaultEncoding = (cpi_enc_t)Encoding_MapIniSetting(true, (int)Settings.DefaultEncoding);
|
||||
|
||||
@ -2337,11 +2337,13 @@ static INT_PTR CALLBACK LongLineSettingsDlgProc(HWND hwnd, UINT umsg, WPARAM wPa
|
||||
BOOL fTranslated;
|
||||
/*UINT const iCol = */ GetDlgItemInt(hwnd, IDC_MULTIEDGELINE, &fTranslated, FALSE);
|
||||
if (fTranslated) {
|
||||
if (Settings.LongLineMode == EDGE_BACKGROUND) {
|
||||
CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_BACKGRDCOLOR);
|
||||
}
|
||||
else {
|
||||
CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
|
||||
switch (Settings.LongLineMode) {
|
||||
case EDGE_BACKGROUND:
|
||||
CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_BACKGRDCOLOR);
|
||||
break;
|
||||
default:
|
||||
CheckRadioButton(hwnd, IDC_SHOWEDGELINE, IDC_BACKGRDCOLOR, IDC_SHOWEDGELINE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -4266,7 +4268,8 @@ int Toolbar_SetButtons(HANDLE hwnd, int cmdBase, LPCWSTR lpszButtons, LPCTBBUTTO
|
||||
p = tchButtons;
|
||||
while (*p) {
|
||||
int iCmd;
|
||||
if (swscanf_s(p, L"%i", &iCmd) == 1) {
|
||||
//if (swscanf_s(p, L"%i", &iCmd) == 1) {
|
||||
if (StrToIntEx(p, STIF_DEFAULT, &iCmd)) {
|
||||
iCmd = (iCmd == 0) ? 0 : iCmd + cmdBase - 1;
|
||||
for (int i = 0; i < ctbb; i++) {
|
||||
if (ptbb[i].idCommand == iCmd) {
|
||||
|
||||
@ -1124,8 +1124,7 @@ bool EditLoadFile(
|
||||
CloseHandle(hFile);
|
||||
|
||||
if (cbData == 0) {
|
||||
FileVars_Init(NULL, 0, &Globals.fvCurFile);
|
||||
status->iEncoding = Settings.DefaultEncoding;
|
||||
FileVars_GetFromData(NULL, 0, &Globals.fvCurFile); // init-reset
|
||||
status->iEOLMode = Settings.DefaultEOLMode;
|
||||
EditSetNewText(hwnd, "", 0, bClearUndoHistory);
|
||||
SciCall_SetEOLMode(Settings.DefaultEOLMode);
|
||||
@ -1160,7 +1159,7 @@ bool EditLoadFile(
|
||||
bool const bIsUTF8Sig = IsUTF8Signature(lpData);
|
||||
Encoding_Forced(bIsUTF8Sig ? CPI_UTF8SIGN : CPI_UTF8);
|
||||
|
||||
FileVars_Init(NULL, 0, &Globals.fvCurFile);
|
||||
FileVars_GetFromData(NULL, 0, &Globals.fvCurFile); // init-reset
|
||||
status->iEncoding = Encoding_Forced(CPI_GET);
|
||||
status->iEOLMode = Settings.DefaultEOLMode;
|
||||
|
||||
@ -1243,7 +1242,7 @@ bool EditLoadFile(
|
||||
status->bUnicodeErr = true;
|
||||
}
|
||||
|
||||
FileVars_Init(lpDataUTF8, convCnt - 1, &Globals.fvCurFile);
|
||||
FileVars_GetFromData(lpDataUTF8, convCnt - 1, &Globals.fvCurFile);
|
||||
EditSetNewText(hwnd, lpDataUTF8, convCnt - 1, bClearUndoHistory);
|
||||
EditDetectEOLMode(lpDataUTF8, convCnt - 1, status);
|
||||
FreeMem(lpDataUTF8);
|
||||
@ -1272,7 +1271,7 @@ bool EditLoadFile(
|
||||
EditDetectEOLMode(lpData, cbData, status);
|
||||
}
|
||||
}
|
||||
else if (bIsCP_UTF7 || encDetection.bIs7BitASCII)
|
||||
else if (!IS_ENC_ENFORCED() && (bIsCP_UTF7 || encDetection.bIs7BitASCII))
|
||||
{
|
||||
// load UTF-7/ASCII(7-bit) as ANSI/UTF-8
|
||||
EditSetNewText(hwnd, lpData, cbData, bClearUndoHistory);
|
||||
|
||||
@ -160,7 +160,7 @@ inline bool IsDBCSCodePage(UINT cp) {
|
||||
#define FV_ENCODING 64
|
||||
#define FV_MODE 128
|
||||
|
||||
bool FileVars_Init(const char* lpData, size_t cbData, LPFILEVARS lpfv);
|
||||
bool FileVars_GetFromData(const char* lpData, size_t cbData, LPFILEVARS lpfv);
|
||||
bool FileVars_Apply(LPFILEVARS lpfv);
|
||||
bool FileVars_ParseInt(char* pszData, char* pszName, int* piValue);
|
||||
bool FileVars_ParseStr(char* pszData, char* pszName, char* pszValue, int cchValue);
|
||||
|
||||
@ -53,6 +53,10 @@ extern "C" {
|
||||
|
||||
//=============================================================================
|
||||
|
||||
extern "C" void Style_SetMultiEdgeLine(const int colVec[], const size_t count);
|
||||
|
||||
//=============================================================================
|
||||
|
||||
static WCHAR wchEncodingInfo[MAX_PATH] = { L'\0' };
|
||||
|
||||
static void _SetEncodingTitleInfo(const ENC_DET_T* pEncDetInfo);
|
||||
@ -65,6 +69,7 @@ extern "C" const char* Encoding_GetTitleInfoA() {
|
||||
return chEncodingInfo;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -975,11 +980,12 @@ static void _SetFileVars(char* buffer, size_t cch, LPFILEVARS lpfv)
|
||||
lpfv->bWordWrap = (i) ? false : true;
|
||||
lpfv->mask |= FV_WORDWRAP;
|
||||
}
|
||||
}
|
||||
|
||||
if (FileVars_ParseInt(buffer, "fill-column", &i)) {
|
||||
lpfv->iLongLinesLimit = clampi(i, 0, LONG_LINES_MARKER_LIMIT);
|
||||
lpfv->mask |= FV_LONGLINESLIMIT;
|
||||
}
|
||||
char columns[SMALL_BUFFER];
|
||||
if (FileVars_ParseStr(buffer, "fill-column", columns, COUNTOF(columns))) {
|
||||
NormalizeColumnVector(columns, lpfv->wchMultiEdgeLines, COUNTOF(lpfv->wchMultiEdgeLines));
|
||||
lpfv->mask |= FV_LONGLINESLIMIT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -988,20 +994,24 @@ static void _SetFileVars(char* buffer, size_t cch, LPFILEVARS lpfv)
|
||||
|
||||
if (!bHasSignature && !Settings.NoEncodingTags && !bDisableFileVar) {
|
||||
|
||||
if (FileVars_ParseStr(buffer, "encoding", lpfv->tchEncoding, COUNTOF(lpfv->tchEncoding)))
|
||||
if (FileVars_ParseStr(buffer, "encoding", lpfv->chEncoding, COUNTOF(lpfv->chEncoding))) {
|
||||
lpfv->mask |= FV_ENCODING;
|
||||
else if (FileVars_ParseStr(buffer, "charset", lpfv->tchEncoding, COUNTOF(lpfv->tchEncoding)))
|
||||
}
|
||||
else if (FileVars_ParseStr(buffer, "charset", lpfv->chEncoding, COUNTOF(lpfv->chEncoding))) {
|
||||
lpfv->mask |= FV_ENCODING;
|
||||
else if (FileVars_ParseStr(buffer, "coding", lpfv->tchEncoding, COUNTOF(lpfv->tchEncoding)))
|
||||
}
|
||||
else if (FileVars_ParseStr(buffer, "coding", lpfv->chEncoding, COUNTOF(lpfv->chEncoding))) {
|
||||
lpfv->mask |= FV_ENCODING;
|
||||
}
|
||||
}
|
||||
if (lpfv->mask & FV_ENCODING) {
|
||||
lpfv->iEncoding = Encoding_MatchA(lpfv->tchEncoding);
|
||||
lpfv->iEncoding = Encoding_MatchA(lpfv->chEncoding);
|
||||
}
|
||||
|
||||
if (!Flags.NoFileVariables && !bDisableFileVar) {
|
||||
if (FileVars_ParseStr(buffer, "mode", lpfv->tchMode, COUNTOF(lpfv->tchMode)))
|
||||
if (FileVars_ParseStr(buffer, "mode", lpfv->chMode, COUNTOF(lpfv->chMode))) {
|
||||
lpfv->mask |= FV_MODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1009,7 +1019,7 @@ static void _SetFileVars(char* buffer, size_t cch, LPFILEVARS lpfv)
|
||||
//
|
||||
// FileVars_Init()
|
||||
//
|
||||
extern "C" bool FileVars_Init(const char* lpData, size_t cbData, LPFILEVARS lpfv)
|
||||
extern "C" bool FileVars_GetFromData(const char* lpData, size_t cbData, LPFILEVARS lpfv)
|
||||
{
|
||||
ZeroMemory(lpfv, sizeof(FILEVARS));
|
||||
lpfv->bTabIndents = Settings.TabIndents;
|
||||
@ -1017,8 +1027,8 @@ extern "C" bool FileVars_Init(const char* lpData, size_t cbData, LPFILEVARS lpfv
|
||||
lpfv->bWordWrap = Settings.WordWrap;
|
||||
lpfv->iTabWidth = Settings.TabWidth;
|
||||
lpfv->iIndentWidth = Settings.IndentWidth;
|
||||
lpfv->iLongLinesLimit = Settings.LongLinesLimit;
|
||||
lpfv->iEncoding = Settings.DefaultEncoding;
|
||||
StringCchCopy(lpfv->wchMultiEdgeLines, COUNTOF(lpfv->wchMultiEdgeLines), Settings.MultiEdgeLines);
|
||||
|
||||
if ((Flags.NoFileVariables && Settings.NoEncodingTags) || !lpData || !cbData) { return true; }
|
||||
|
||||
@ -1061,9 +1071,9 @@ extern "C" bool FileVars_Apply(LPFILEVARS lpfv) {
|
||||
int const _iWrapMode = _bWordWrap ? ((Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR) : SC_WRAP_NONE;
|
||||
SciCall_SetWrapMode(_iWrapMode);
|
||||
|
||||
int const _iLongLinesLimit = (lpfv->mask & FV_LONGLINESLIMIT) ? lpfv->iLongLinesLimit : Settings.LongLinesLimit;
|
||||
SciCall_SetEdgeColumn(_iLongLinesLimit);
|
||||
Globals.iWrapCol = _iLongLinesLimit;
|
||||
int edgeColumns[SMALL_BUFFER];
|
||||
size_t const cnt = ReadVectorFromString(lpfv->wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
Style_SetMultiEdgeLine(edgeColumns, cnt);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1147,8 +1157,8 @@ extern "C" bool FileVars_ParseStr(char* pszData, char* pszName, char* pszValue,
|
||||
pvStart = StrStrIA(pvStart, pszName); // next
|
||||
}
|
||||
|
||||
if (pvStart) {
|
||||
|
||||
if (pvStart)
|
||||
{
|
||||
bool bQuoted = false;
|
||||
while (*pvStart && StrChrIA(":=\"' \t", *pvStart)) {
|
||||
if (*pvStart == '\'' || *pvStart == '"')
|
||||
@ -1181,8 +1191,8 @@ extern "C" bool FileVars_ParseStr(char* pszData, char* pszName, char* pszValue,
|
||||
//
|
||||
extern "C" bool FileVars_IsUTF8(LPFILEVARS lpfv) {
|
||||
if (lpfv->mask & FV_ENCODING) {
|
||||
if (StringCchCompareNIA(lpfv->tchEncoding, COUNTOF(lpfv->tchEncoding), "utf-8", CSTRLEN("utf-8")) == 0 ||
|
||||
StringCchCompareNIA(lpfv->tchEncoding, COUNTOF(lpfv->tchEncoding), "utf8", CSTRLEN("utf8")) == 0)
|
||||
if (StringCchCompareNIA(lpfv->chEncoding, COUNTOF(lpfv->chEncoding), "utf-8", CSTRLEN("utf-8")) == 0 ||
|
||||
StringCchCompareNIA(lpfv->chEncoding, COUNTOF(lpfv->chEncoding), "utf8", CSTRLEN("utf8")) == 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -1231,7 +1241,7 @@ extern "C" ENC_DET_T Encoding_DetectEncoding(LPWSTR pszFile, const char* lpData,
|
||||
{
|
||||
ENC_DET_T encDetRes = INIT_ENC_DET_T;
|
||||
|
||||
FileVars_Init(lpData, cbData, &Globals.fvCurFile);
|
||||
FileVars_GetFromData(lpData, cbData, &Globals.fvCurFile);
|
||||
|
||||
bool const bBOM_LE = Has_UTF16_LE_BOM(lpData, cbData);
|
||||
bool const bBOM_BE = Has_UTF16_BE_BOM(lpData, cbData);
|
||||
|
||||
@ -2578,8 +2578,9 @@ size_t ReadVectorFromString(LPCWSTR wchStrg, int iVector[], size_t iCount, int i
|
||||
p = wchTmpBuff;
|
||||
while (*p) {
|
||||
int iValue;
|
||||
if (swscanf_s(p, L"%i", &iValue) == 1) {
|
||||
if (n < iCount) {
|
||||
if (n < iCount) {
|
||||
//if (swscanf_s(p, L"%i", &iValue) == 1) {
|
||||
if (StrToIntEx(p, STIF_DEFAULT, &iValue)) {
|
||||
iVector[n++] = clampi(iValue, iMin, iMax);
|
||||
}
|
||||
}
|
||||
@ -2593,6 +2594,27 @@ size_t ReadVectorFromString(LPCWSTR wchStrg, int iVector[], size_t iCount, int i
|
||||
return n;
|
||||
}
|
||||
|
||||
size_t NormalizeColumnVector(LPSTR chStrg_in, LPWSTR wchStrg_out, size_t iCount)
|
||||
{
|
||||
if (chStrg_in) {
|
||||
MultiByteToWideChar(CP_UTF8, 0, chStrg_in, -1, wchStrg_out, (int)iCount);
|
||||
}
|
||||
StrTrim(wchStrg_out, L"\"'");
|
||||
|
||||
int* intVector = (int*)AllocMem(iCount * sizeof(int), HEAP_ZERO_MEMORY);
|
||||
if (!intVector) { return 0; }
|
||||
|
||||
size_t const cnt = ReadVectorFromString(wchStrg_out, intVector, iCount, 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
|
||||
WCHAR col[32];
|
||||
wchStrg_out[0] = L'\0';
|
||||
for (size_t i = 0; i < cnt; ++i) {
|
||||
StringCchPrintf(col, COUNTOF(col), ((i == 0) ? L"%i" : L" %i"), intVector[i]);
|
||||
StringCchCat(wchStrg_out, iCount, col);
|
||||
}
|
||||
FreeMem(intVector);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
||||
@ -554,6 +554,7 @@ void UrlUnescapeEx(LPWSTR lpURL, LPWSTR lpUnescaped, DWORD* pcchUnescaped);
|
||||
|
||||
int ReadStrgsFromCSV(LPCWSTR wchCSVStrg, prefix_t sMatrix[], int iCount, int iLen, LPCWSTR sDefault);
|
||||
size_t ReadVectorFromString(LPCWSTR wchStrg, int iVector[], size_t iCount, int iMin, int iMax, int iDefault, bool ordered);
|
||||
size_t NormalizeColumnVector(LPSTR chStrg_in, LPWSTR wchStrg_out, size_t iCount);
|
||||
|
||||
inline bool Char2IntW(LPCWSTR str, int* value) {
|
||||
LPWSTR end;
|
||||
|
||||
@ -615,7 +615,6 @@ static void _InitGlobals()
|
||||
ZeroMemory(&Flags, sizeof(FLAGS_T));
|
||||
|
||||
ZeroMemory(&(Globals.fvCurFile), sizeof(FILEVARS));
|
||||
ZeroMemory(&(Globals.fvBackup), sizeof(FILEVARS));
|
||||
|
||||
Globals.hDlgIcon256 = NULL;
|
||||
Globals.hDlgIcon128 = NULL;
|
||||
@ -629,7 +628,7 @@ static void _InitGlobals()
|
||||
Globals.uConsoleCodePage = 0;
|
||||
Globals.iAvailLngCount = 1;
|
||||
Globals.iPrefLANGID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
|
||||
Globals.iWrapCol = 0;
|
||||
Globals.iWrapCol = 80;
|
||||
Globals.CallTipType = CT_NONE;
|
||||
|
||||
Globals.CmdLnFlag_PosParam = false;
|
||||
@ -1724,7 +1723,7 @@ static void _SetWrapStartIndent()
|
||||
//
|
||||
static void _SetWrapIndentMode()
|
||||
{
|
||||
int const wrap_mode = (!Settings.WordWrap ? SC_WRAP_NONE : ((Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR));
|
||||
int const wrap_mode = (!Globals.fvCurFile.bWordWrap ? SC_WRAP_NONE : ((Settings.WordWrapMode == 0) ? SC_WRAP_WHITESPACE : SC_WRAP_CHAR));
|
||||
|
||||
SciCall_SetWrapMode(wrap_mode);
|
||||
|
||||
@ -3369,7 +3368,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
CheckCmd(hmenu, IDM_VIEW_USE2NDDEFAULT, Style_GetUse2ndDefault());
|
||||
|
||||
CheckCmd(hmenu, IDM_VIEW_WORDWRAP, Settings.WordWrap);
|
||||
CheckCmd(hmenu, IDM_VIEW_WORDWRAP, Globals.fvCurFile.bWordWrap);
|
||||
CheckCmd(hmenu, IDM_VIEW_LONGLINEMARKER, Settings.MarkLongLines);
|
||||
CheckCmd(hmenu, IDM_VIEW_TABSASSPACES, Globals.fvCurFile.bTabsAsSpaces);
|
||||
CheckCmd(hmenu, IDM_VIEW_SHOWINDENTGUIDES, Settings.ShowIndentGuides);
|
||||
@ -4967,6 +4966,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_VIEW_WORDWRAP:
|
||||
Settings.WordWrap = !Settings.WordWrap;
|
||||
Globals.fvCurFile.bWordWrap = Settings.WordWrap;
|
||||
_SetWrapIndentMode(Globals.hwndEdit);
|
||||
EditEnsureSelectionVisible();
|
||||
break;
|
||||
@ -4990,52 +4990,51 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
Settings.MarkLongLines = !Settings.MarkLongLines;
|
||||
size_t cnt = 0;
|
||||
int edgeCol[MIDSZ_BUFFER] = { L'\0' };
|
||||
int edgeColumns[SMALL_BUFFER] = { 0 };
|
||||
if (Settings.MarkLongLines) {
|
||||
cnt = ReadVectorFromString(Settings.MultiEdgeLines, edgeCol, MIDSZ_BUFFER, 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
cnt = ReadVectorFromString(Globals.fvCurFile.wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
}
|
||||
Style_SetMultiEdgeLine(Globals.hwndEdit, edgeCol, cnt);
|
||||
Style_SetMultiEdgeLine(edgeColumns, cnt);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case IDM_VIEW_LONGLINESETTINGS:
|
||||
{
|
||||
int _iLongLinesLimit = Settings.LongLinesLimit;
|
||||
int _iLongLinesLimit = Defaults.LongLinesLimit;
|
||||
|
||||
WCHAR wchColumnList[MIDSZ_BUFFER];
|
||||
StringCchCopy(wchColumnList, COUNTOF(wchColumnList), Settings.MultiEdgeLines);
|
||||
if (LongLineSettingsDlg(hwnd, IDD_MUI_LONGLINES, Globals.fvCurFile.wchMultiEdgeLines)) {
|
||||
|
||||
if (LongLineSettingsDlg(hwnd, IDD_MUI_LONGLINES, wchColumnList)) {
|
||||
|
||||
int edgeCol[MIDSZ_BUFFER];
|
||||
size_t const cnt = ReadVectorFromString(wchColumnList, edgeCol, MIDSZ_BUFFER, 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
int edgeColumns[SMALL_BUFFER];
|
||||
size_t const cnt = ReadVectorFromString(Globals.fvCurFile.wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
|
||||
if (cnt == 0) {
|
||||
Settings.MarkLongLines = false;
|
||||
}
|
||||
else if (cnt == 1) {
|
||||
_iLongLinesLimit = edgeCol[0];
|
||||
_iLongLinesLimit = edgeColumns[0];
|
||||
Settings.MarkLongLines = true;
|
||||
//~Settings.LongLineMode = EDGE_LINE|EDGE_BACKGROUND; // set by Dlg
|
||||
}
|
||||
else {
|
||||
_iLongLinesLimit = edgeCol[cnt - 1];
|
||||
_iLongLinesLimit = edgeColumns[cnt - 1];
|
||||
Settings.MarkLongLines = true;
|
||||
Settings.LongLineMode = EDGE_MULTILINE;
|
||||
}
|
||||
Globals.iWrapCol = _iLongLinesLimit;
|
||||
Settings.LongLinesLimit = _iLongLinesLimit;
|
||||
Globals.fvCurFile.iLongLinesLimit = _iLongLinesLimit;
|
||||
|
||||
Settings.MultiEdgeLines[0] = L'\0'; // empty
|
||||
// new multi-edge lines setting
|
||||
WCHAR col[32];
|
||||
Settings.MultiEdgeLines[0] = L'\0';
|
||||
for (size_t i = 0; i < cnt; ++i) {
|
||||
StringCchPrintf(col, COUNTOF(col), ((i == 0) ? L"%i" : L" %i"), edgeCol[i]);
|
||||
StringCchPrintf(col, COUNTOF(col), ((i == 0) ? L"%i" : L" %i"), edgeColumns[i]);
|
||||
StringCchCat(Settings.MultiEdgeLines, COUNTOF(Settings.MultiEdgeLines), col);
|
||||
}
|
||||
// make current too
|
||||
StringCchCopy(Globals.fvCurFile.wchMultiEdgeLines, COUNTOF(Globals.fvCurFile.wchMultiEdgeLines), Settings.MultiEdgeLines);
|
||||
|
||||
Style_SetMultiEdgeLine(Globals.hwndEdit, edgeCol, cnt);
|
||||
Style_SetMultiEdgeLine(edgeColumns, cnt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -5043,8 +5042,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_VIEW_TABSASSPACES:
|
||||
{
|
||||
Globals.fvCurFile.bTabsAsSpaces = !Globals.fvCurFile.bTabsAsSpaces;
|
||||
Settings.TabsAsSpaces = Globals.fvCurFile.bTabsAsSpaces;
|
||||
Settings.TabsAsSpaces = !Settings.TabsAsSpaces;
|
||||
Globals.fvCurFile.bTabsAsSpaces = Settings.TabsAsSpaces;
|
||||
SciCall_SetUseTabs(!Globals.fvCurFile.bTabsAsSpaces);
|
||||
}
|
||||
break;
|
||||
@ -7962,7 +7961,7 @@ static void _UpdateToolbarDelayed()
|
||||
EnableTool(Globals.hwndToolbar, IDT_FILE_SAVE, IsSaveNeeded(ISN_GET) /*&& !bReadOnly*/);
|
||||
EnableTool(Globals.hwndToolbar, IDT_FILE_RECENT, (MRU_Count(Globals.pFileMRU) > 0));
|
||||
|
||||
CheckTool(Globals.hwndToolbar, IDT_VIEW_WORDWRAP, Settings.WordWrap);
|
||||
CheckTool(Globals.hwndToolbar, IDT_VIEW_WORDWRAP, Globals.fvCurFile.bWordWrap);
|
||||
CheckTool(Globals.hwndToolbar, IDT_VIEW_CHASING_DOCTAIL, FileWatching.MonitoringLog);
|
||||
CheckTool(Globals.hwndToolbar, IDT_VIEW_PIN_ON_TOP, Settings.AlwaysOnTop);
|
||||
|
||||
@ -9297,7 +9296,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
|
||||
SetDlgItemText(Globals.hwndMain,IDC_FILENAME,Globals.CurrentFile);
|
||||
SetDlgItemInt(Globals.hwndMain,IDC_REUSELOCK,GetTickCount(),false);
|
||||
if (!s_flagKeepTitleExcerpt) { StringCchCopy(s_wchTitleExcerpt, COUNTOF(s_wchTitleExcerpt), L""); }
|
||||
FileVars_Init(NULL,0,&Globals.fvCurFile);
|
||||
FileVars_GetFromData(NULL,0,&Globals.fvCurFile); // init-reset
|
||||
|
||||
EditSetNewText(Globals.hwndEdit, "", 0, true);
|
||||
|
||||
@ -9363,7 +9362,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
|
||||
Globals.dwLastError = GetLastError();
|
||||
fSuccess = (hFile != INVALID_HANDLE_VALUE);
|
||||
if (fSuccess) {
|
||||
FileVars_Init(NULL,0,&Globals.fvCurFile);
|
||||
FileVars_GetFromData(NULL,0,&Globals.fvCurFile); // init/reset
|
||||
EditSetNewText(Globals.hwndEdit,"",0, true);
|
||||
Style_SetDefaultLexer(Globals.hwndEdit);
|
||||
SciCall_SetEOLMode(Settings.DefaultEOLMode);
|
||||
@ -9373,9 +9372,9 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
|
||||
Encoding_HasChanged(fioStatus.iEncoding);
|
||||
}
|
||||
else {
|
||||
fioStatus.iEncoding = Settings.DefaultEncoding;
|
||||
Encoding_Current(Settings.DefaultEncoding);
|
||||
Encoding_HasChanged(Settings.DefaultEncoding);
|
||||
fioStatus.iEncoding = Globals.fvCurFile.iEncoding;
|
||||
Encoding_Current(Globals.fvCurFile.iEncoding);
|
||||
Encoding_HasChanged(Globals.fvCurFile.iEncoding);
|
||||
}
|
||||
s_bFileReadOnly = false;
|
||||
}
|
||||
|
||||
27
src/Styles.c
27
src/Styles.c
@ -1332,12 +1332,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
|
||||
StringCchCopy(pCurrentStandard->Styles[STY_CARET].szValue,
|
||||
COUNTOF(pCurrentStandard->Styles[STY_CARET].szValue),wchSpecificStyle);
|
||||
|
||||
size_t cnt = 0;
|
||||
int edgeCol[MIDSZ_BUFFER] = { L'\0' };
|
||||
if (Settings.MarkLongLines) {
|
||||
cnt = ReadVectorFromString(Settings.MultiEdgeLines, edgeCol, MIDSZ_BUFFER, 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
}
|
||||
Style_SetMultiEdgeLine(hwnd, edgeCol, cnt);
|
||||
int edgeColumns[MIDSZ_BUFFER] = { 0 };
|
||||
size_t const cnt = ReadVectorFromString(Globals.fvCurFile.wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true);
|
||||
Style_SetMultiEdgeLine(edgeColumns, cnt);
|
||||
|
||||
Style_SetExtraLineSpace(hwnd, pCurrentStandard->Styles[STY_X_LN_SPACE].szValue,
|
||||
COUNTOF(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue));
|
||||
@ -1595,14 +1592,16 @@ void Style_SetReadonly(HWND hwnd, bool bReadonly)
|
||||
//
|
||||
// Style_SetLongLineEdge()
|
||||
//
|
||||
void Style_SetMultiEdgeLine(HWND hwnd, const int colVec[], const size_t count)
|
||||
void Style_SetMultiEdgeLine(const int colVec[], const size_t count)
|
||||
{
|
||||
UNUSED(hwnd);
|
||||
COLORREF rgb;
|
||||
|
||||
int const iLongLineLimit = (count > 0) ? colVec[count - 1] : Defaults.LongLinesLimit;
|
||||
int const iLongLineLimit = (count > 0) ? colVec[count - 1] : Settings.LongLinesLimit;
|
||||
int const mLongLineMode = (count > 1) ? EDGE_MULTILINE : Settings.LongLineMode;
|
||||
|
||||
Settings.LongLinesLimit = iLongLineLimit; // normalize
|
||||
Globals.iWrapCol = iLongLineLimit; // long line limit should be explicit wrap column too
|
||||
|
||||
if (mLongLineMode == EDGE_BACKGROUND) {
|
||||
if (!Style_StrGetColor(GetCurrentStdLexer()->Styles[STY_LONG_LN_MRK].szValue, BACKGROUND_LAYER, &rgb)) { // edge back
|
||||
rgb = GetSysColor(COLOR_3DSHADOW);
|
||||
@ -2006,11 +2005,11 @@ bool Style_SetLexerFromFile(HWND hwnd,LPCWSTR lpszFile)
|
||||
PEDITLEXER pLexNew = NULL;
|
||||
PEDITLEXER pLexSniffed = NULL;
|
||||
|
||||
if ((Globals.fvCurFile.mask & FV_MODE) && Globals.fvCurFile.tchMode[0]) {
|
||||
if ((Globals.fvCurFile.mask & FV_MODE) && Globals.fvCurFile.chMode[0]) {
|
||||
|
||||
PEDITLEXER pLexMode;
|
||||
WCHAR wchMode[MICRO_BUFFER] = { L'\0' };
|
||||
MultiByteToWideCharEx(Encoding_SciCP, 0, Globals.fvCurFile.tchMode, -1, wchMode, MICRO_BUFFER);
|
||||
MultiByteToWideCharEx(Encoding_SciCP, 0, Globals.fvCurFile.chMode, -1, wchMode, MICRO_BUFFER);
|
||||
|
||||
if (!Flags.NoCGIGuess && (StringCchCompareNI(wchMode,COUNTOF(wchMode),L"cgi", CSTRLEN(L"cgi")) == 0 ||
|
||||
StringCchCompareNI(wchMode,COUNTOF(wchMode),L"fcgi", CSTRLEN(L"fcgi")) == 0)) {
|
||||
@ -2679,8 +2678,7 @@ bool Style_StrGetAlpha(LPCWSTR lpszStyle, int* iOutValue, bool bAlpha1st)
|
||||
*p = L'\0';
|
||||
TrimSpcW(tch);
|
||||
int iValue = 0;
|
||||
int itok = swscanf_s(tch, L"%i", &iValue);
|
||||
if (itok == 1) {
|
||||
if (StrToIntEx(tch, STIF_DEFAULT, &iValue)) {
|
||||
*iOutValue = clampi(iValue, SC_ALPHA_TRANSPARENT, SC_ALPHA_OPAQUE);
|
||||
return true;
|
||||
}
|
||||
@ -2703,7 +2701,8 @@ bool Style_StrGetAlpha(LPCWSTR lpszStyle, int* iOutValue, bool bAlpha1st)
|
||||
// if (p)
|
||||
// *p = L'\0';
|
||||
// TrimStringW(tch);
|
||||
// if (1 == swscanf_s(tch, L"%i", val)) { return true; }
|
||||
// //if (1 == swscanf_s(tch, L"%i", val)) { return true; }
|
||||
// if (StrToIntEx(tch, STIF_DEFAULT, val)) { return true; }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
@ -86,7 +86,7 @@ bool Style_SelectColor(HWND hwnd,bool,LPWSTR lpszStyle,int cchStyle,bool);
|
||||
void Style_SetStyles(HWND hwnd,int iStyle,LPCWSTR lpszStyle,bool);
|
||||
bool Style_IsCurLexerStandard();
|
||||
float Style_GetBaseFontSize();
|
||||
void Style_SetMultiEdgeLine(HWND hwnd, const int colVec[], const size_t count);
|
||||
void Style_SetMultiEdgeLine(const int colVec[], const size_t count);
|
||||
PEDITLEXER Style_GetCurrentLexerPtr();
|
||||
int Style_GetCurrentLexerRID();
|
||||
void Style_GetLexerDisplayName(PEDITLEXER pLexer, LPWSTR lpszName, int cchName);
|
||||
|
||||
@ -171,10 +171,10 @@ typedef struct _filevars
|
||||
int iTabWidth;
|
||||
int iIndentWidth;
|
||||
int iWrapColumn;
|
||||
int iLongLinesLimit;
|
||||
char tchEncoding[64];
|
||||
char chEncoding[64];
|
||||
cpi_enc_t iEncoding;
|
||||
char tchMode[32];
|
||||
char chMode[32];
|
||||
WCHAR wchMultiEdgeLines[SMALL_BUFFER];
|
||||
|
||||
} FILEVARS, *LPFILEVARS;
|
||||
|
||||
@ -327,7 +327,6 @@ typedef struct _globals_t
|
||||
LPMRULIST pMRUreplace;
|
||||
CALLTIPTYPE CallTipType;
|
||||
FILEVARS fvCurFile;
|
||||
FILEVARS fvBackup;
|
||||
int iWrapCol;
|
||||
|
||||
bool CmdLnFlag_PosParam;
|
||||
|
||||
@ -9,11 +9,11 @@
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 20
|
||||
#define VERSION_REV 421
|
||||
#define VERSION_BUILD 1
|
||||
#define VERSION_BUILD 2
|
||||
#define SCINTILLA_VER 432
|
||||
#define ONIGURUMA_REGEX_VER 6.9.5
|
||||
#define UCHARDET_VER 2018.09.27
|
||||
#define TINYEXPR_VER 2018.05.11
|
||||
#define UTHASH_VER 2.1.0
|
||||
#define VERSION_PATCH BETA
|
||||
#define VERSION_COMMIT_ID dkt1-amr
|
||||
#define VERSION_COMMIT_ID t7820-rk
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/******************************************************************************
|
||||
* *
|
||||
/******************************************************************************
|
||||
* *
|
||||
* encoding: CP-437
|
||||
* fill-column: "3 17 31 53 77" *
|
||||
* Notepad3 *
|
||||
* *
|
||||
* Notepad3.c *
|
||||
|
||||
Loading…
Reference in New Issue
Block a user