From cac0b2aa98c252321fd141bd75dd9ddda6eb0bcd Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 26 Sep 2018 23:46:27 +0200 Subject: [PATCH] + structuring of Settings (part II) --- .../App/DefaultData/settings/Notepad3.ini | Bin 5924 -> 5876 bytes src/Dialogs.c | 4 +- src/Edit.c | 50 ++--- src/Notepad3.c | 187 ++++++++++-------- src/SciCall.h | 2 - src/Styles.c | 10 +- src/TypeDefs.h | 11 ++ 7 files changed, 148 insertions(+), 116 deletions(-) diff --git a/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini b/np3portableapp/Notepad3Portable/App/DefaultData/settings/Notepad3.ini index 60a9589c091e8e0cbc4b2eb0b409cd2cc359cff3..9662e4903d2ea057840db06c8f8e4646e87370a9 100644 GIT binary patch delta 31 ncmZ3Y_eFPu0^`I-LYpTr&f=dW$ip1Z;4}H5fc$1H!C$NZzbOkO delta 110 zcmeyOyF_n;0%K$_Ln1>NLn=cs5SIX9CPN-WIzusoErTHgF9R1)93meCluriYJfIpk kpsE}o8==Y#tSXright, rc->bottom))); + return SendMessage(hwnd, WM_SIZE, SIZE_RESTORED, MAKELPARAM(rc->right, rc->bottom)); } diff --git a/src/Edit.c b/src/Edit.c index a1e9df358..71fc95e3a 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -91,16 +91,11 @@ extern bool g_bNoEncodingTags; extern bool g_bUseLimitedAutoCCharSet; extern bool g_bIsCJKInputCodePage; -extern bool g_bAutoCompleteWords; -extern bool g_bAutoCLexerKeyWords; -extern bool g_bAccelWordNavigation; - extern int g_iReplacedOccurrences; extern int g_iMarkOccurrences; extern int g_iMarkOccurrencesCount; extern bool g_bMarkOccurrencesMatchVisible; -extern bool g_bHyperlinkHotspot; extern bool g_bCodeFoldingAvailable; extern bool g_bShowCodeFolding; @@ -3835,10 +3830,10 @@ void EditWrapToColumn(HWND hwnd,DocPos nColumn/*,int nTabWidth*/) DocPos iLineLength = 0; //#define W_DELIMITER L"!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~" // underscore counted as part of word - //WCHAR* W_DELIMITER = g_bAccelWordNavigation ? W_DelimCharsAccel : W_DelimChars; + //WCHAR* W_DELIMITER = Settings.AccelWordNavigation ? W_DelimCharsAccel : W_DelimChars; //#define ISDELIMITER(wc) StrChr(W_DELIMITER,wc) - //WCHAR* W_WHITESPACE = g_bAccelWordNavigation ? W_WhiteSpaceCharsAccelerated : W_WhiteSpaceCharsDefault; + //WCHAR* W_WHITESPACE = Settings.AccelWordNavigation ? W_WhiteSpaceCharsAccelerated : W_WhiteSpaceCharsDefault; //#define ISWHITE(wc) StrChr(W_WHITESPACE,wc) #define ISWHITE(wc) StrChr(L" \t\f",wc) @@ -6372,15 +6367,15 @@ bool EditToggleView(HWND hwnd, bool bToggleView) if (!bHideNonMatchedLines) { bSaveFoldingAvailable = g_bCodeFoldingAvailable; bSaveShowFolding = g_bShowCodeFolding; - bSaveHyperlinkHotspots = g_bHyperlinkHotspot; - g_bHyperlinkHotspot = false; + bSaveHyperlinkHotspots = Settings.HyperlinkHotspot; + Settings.HyperlinkHotspot = false; } else { g_bCodeFoldingAvailable = bSaveFoldingAvailable; g_bShowCodeFolding = bSaveShowFolding; - g_bHyperlinkHotspot = bSaveHyperlinkHotspots; + Settings.HyperlinkHotspot = bSaveHyperlinkHotspots; } - EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_HYPERLINKHOTSPOTS, g_bHyperlinkHotspot); + EnableCmd(GetMenu(Globals.hwndMain), IDM_VIEW_HYPERLINKHOTSPOTS, Settings.HyperlinkHotspot); bHideNonMatchedLines = bHideNonMatchedLines ? false : true; // toggle @@ -6453,7 +6448,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos // exit if selection is not a word and Match whole words only is enabled if (bMatchWords) { DocPos iSelStart2 = 0; - const char* delims = (g_bAccelWordNavigation ? DelimCharsAccel : DelimChars); + const char* delims = (Settings.AccelWordNavigation ? DelimCharsAccel : DelimChars); while ((iSelStart2 <= iSelCount) && pszText[iSelStart2]) { if (StrChrIA(delims, pszText[iSelStart2])) { return; @@ -6508,7 +6503,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos //============================================================================= // -// EditCompleteWord() +// EditAutoCompleteWord() // Auto-complete words (by Aleksandar Lekov) // @@ -6561,24 +6556,30 @@ static const char* __fastcall _strNextLexKeyWord(const char* strg, const char* c bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) { - UNUSED(hwnd); - if (SciCall_IsIMEModeCJK()) { SciCall_AutoCCancel(); return false; } + DocPos const iMinWdChCnt = 2; // min number of typed chars before AutoC + char const* const pchAllowdWordChars = ((g_bIsCJKInputCodePage || g_bUseLimitedAutoCCharSet) ? AutoCompleteWordCharSet : - (g_bAccelWordNavigation ? WordCharsAccelerated : WordCharsDefault)); + (Settings.AccelWordNavigation ? WordCharsAccelerated : WordCharsDefault)); SciCall_SetWordChars(pchAllowdWordChars); DocPos const iDocEndPos = Sci_GetDocEndPosition(); DocPos const iCurrentPos = SciCall_GetCurrentPos(); + DocPos const iCol = SciCall_GetColumn(iCurrentPos); DocPos const iPosBefore = SciCall_PositionBefore(iCurrentPos); DocPos const iWordStartPos = SciCall_WordStartPosition(iPosBefore, true); + if ((iWordStartPos == iPosBefore) || (iCol < iMinWdChCnt) || ((iCurrentPos - iWordStartPos) < iMinWdChCnt)) { + EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); + return true; + } + DocPos iPos = iWordStartPos; bool bWordAllNumbers = true; while ((iPos < iCurrentPos) && bWordAllNumbers && (iPos != iDocEndPos)) { @@ -6588,11 +6589,12 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) } iPos = SciCall_PositionAfter(iPos); } - if ((iWordStartPos == iPosBefore) || bWordAllNumbers || ((iCurrentPos - iWordStartPos) < 2)) { - EditSetAccelWordNav(hwnd, g_bAccelWordNavigation); + if (bWordAllNumbers) { + EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); return true; } + char pRoot[_MAX_AUTOC_WORD_LEN]; DocPos const iRootLen = (iCurrentPos - iWordStartPos); StringCchCopyNA(pRoot, COUNTOF(pRoot), SciCall_GetRangePointer(iWordStartPos, iRootLen), (size_t)iRootLen); @@ -6602,7 +6604,7 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) PWLIST pListHead = NULL; - if (g_bAutoCompleteWords) + if (Settings.AutoCompleteWords) { struct Sci_TextToFind ft = { { 0, 0 }, 0, { 0, 0 } }; ft.lpstrText = pRoot; @@ -6645,7 +6647,7 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) if (pwlNewWord) { FreeMem(pwlNewWord); pwlNewWord = NULL; } } // -------------------------------------------------------------------------- - if (g_bAutoCLexerKeyWords) + if (Settings.AutoCLexerKeyWords) // -------------------------------------------------------------------------- { PKEYWORDLIST const pKeyWordList = Style_GetCurrentLexerPtr()->pKeyWords; @@ -6694,7 +6696,7 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) SciCall_AutoCSetChooseSingle(autoInsert); //SciCall_AutoCSetOrder(SC_ORDER_PERFORMSORT); // already sorted SciCall_AutoCSetFillups("\t\n\r"); - //SciCall_AutoCSetFillups(g_bAccelWordNavigation ? WhiteSpaceCharsDefault : WhiteSpaceCharsAccelerated); + //SciCall_AutoCSetFillups(Settings.AccelWordNavigation ? WhiteSpaceCharsDefault : WhiteSpaceCharsAccelerated); ++iWListSize; // zero termination char* const pList = AllocMem(iWListSize, HEAP_ZERO_MEMORY); @@ -6715,7 +6717,7 @@ bool EditAutoCompleteWord(HWND hwnd, bool autoInsert) } } - EditSetAccelWordNav(hwnd, g_bAccelWordNavigation); + EditSetAccelWordNav(hwnd, Settings.AccelWordNavigation); return true; } @@ -7742,8 +7744,8 @@ bool EditSortDlg(HWND hwnd,int* piSortFlags) void EditSetAccelWordNav(HWND hwnd,bool bAccelWordNav) { UNUSED(hwnd); - g_bAccelWordNavigation = bAccelWordNav; - if (g_bAccelWordNavigation) { + Settings.AccelWordNavigation = bAccelWordNav; + if (Settings.AccelWordNavigation) { SciCall_SetWordChars(WordCharsAccelerated); SciCall_SetWhitespaceChars(WhiteSpaceCharsAccelerated); SciCall_SetPunctuationChars(PunctuationCharsAccelerated); diff --git a/src/Notepad3.c b/src/Notepad3.c index 701d3a2b0..d8ea7a432 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -124,13 +124,6 @@ static WCHAR s_tchLastSaveCopyDir[MAX_PATH + 1] = { L'\0' }; bool g_bWordWrapG; -bool bMatchBraces; -bool bAutoIndent; -bool bAutoCloseTags; -bool bShowIndentGuides; -bool bHiliteCurrentLine; -bool g_bHyperlinkHotspot; -bool bScrollPastEOF; bool g_bTabsAsSpaces; bool bTabsAsSpacesG; bool g_bTabIndents; @@ -156,9 +149,6 @@ bool g_bMarkOccurrencesMatchVisible; bool g_bMarkOccurrencesMatchCase; bool g_bMarkOccurrencesMatchWords; bool g_bMarkOccurrencesCurrentWord; -bool g_bAutoCompleteWords; -bool g_bAutoCLexerKeyWords; -bool g_bAccelWordNavigation; bool g_bCodeFoldingAvailable; bool g_bShowCodeFolding; bool bViewWhiteSpace; @@ -1187,8 +1177,8 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) // Check for /c [if no file is specified] -- even if a file is specified /*else */if (s_flagNewFromClipboard) { if (SendMessage(Globals.hwndEdit, SCI_CANPASTE, 0, 0)) { - bool bAutoIndent2 = bAutoIndent; - bAutoIndent = 0; + bool bAutoIndent2 = Settings.AutoIndent; + Settings.AutoIndent = 0; EditJumpTo(Globals.hwndEdit, -1, 0); _BEGIN_UNDO_ACTION_; if (SendMessage(Globals.hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { @@ -1197,7 +1187,7 @@ HWND InitInstance(HINSTANCE hInstance,LPWSTR pszCmdLine,int nCmdShow) SendMessage(Globals.hwndEdit, SCI_PASTE, 0, 0); SendMessage(Globals.hwndEdit, SCI_NEWLINE, 0, 0); _END_UNDO_ACTION_; - bAutoIndent = bAutoIndent2; + Settings.AutoIndent = bAutoIndent2; if (s_flagJumpTo) EditJumpTo(Globals.hwndEdit, iInitialLine, iInitialColumn); else @@ -1674,7 +1664,7 @@ static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(_CARET_SYMETRY), 0); SendMessage(hwndEditCtrl, SCI_SETVIRTUALSPACEOPTIONS, (WPARAM)(Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : SCVS_RECTANGULARSELECTION), 0); - SendMessage(hwndEditCtrl, SCI_SETENDATLASTLINE, (WPARAM)((bScrollPastEOF) ? 0 : 1), 0); + SendMessage(hwndEditCtrl, SCI_SETENDATLASTLINE, (WPARAM)((Settings.ScrollPastEOF) ? 0 : 1), 0); // Tabs SendMessage(hwndEditCtrl, SCI_SETUSETABS, (WPARAM)!g_bTabsAsSpaces, 0); @@ -1684,7 +1674,7 @@ static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) SendMessage(hwndEditCtrl, SCI_SETINDENT, (WPARAM)g_iIndentWidth, 0); // Indent Guides - Style_SetIndentGuides(hwndEditCtrl, bShowIndentGuides); + Style_SetIndentGuides(hwndEditCtrl, Settings.ShowIndentGuides); // Word Wrap _SetWrapIndentMode(hwndEditCtrl); @@ -1710,7 +1700,7 @@ static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) // word delimiter handling EditInitWordDelimiter(hwndEditCtrl); - EditSetAccelWordNav(hwndEditCtrl, g_bAccelWordNavigation); + EditSetAccelWordNav(hwndEditCtrl, Settings.AccelWordNavigation); UpdateMarginWidth(); } @@ -2050,6 +2040,9 @@ LRESULT MsgEndSession(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // Terminate file watching InstallFileWatching(NULL); + // remember window position + s_WinInfo = GetMyWindowPlacement(hwnd, NULL); + DragAcceptFiles(hwnd, true); #ifdef _EXTRA_DRAG_N_DROP_HANDLER_ RevokeDragAndDrop(pDropTarget); @@ -2219,7 +2212,7 @@ LRESULT MsgThemeChanged(HWND hwnd, WPARAM wParam ,LPARAM lParam) EditToggleView(Globals.hwndEdit, true); } MarkAllOccurrences(0, true); - EditUpdateUrlHotspots(Globals.hwndEdit, 0, Sci_GetDocEndPosition(), g_bHyperlinkHotspot); + EditUpdateUrlHotspots(Globals.hwndEdit, 0, Sci_GetDocEndPosition(), Settings.HyperlinkHotspot); UpdateUI(); UpdateToolbar(); @@ -2879,17 +2872,17 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) CheckCmd(hmenu,IDM_VIEW_WORDWRAP,Settings.WordWrap); CheckCmd(hmenu,IDM_VIEW_LONGLINEMARKER,g_bMarkLongLines); CheckCmd(hmenu,IDM_VIEW_TABSASSPACES,g_bTabsAsSpaces); - CheckCmd(hmenu,IDM_VIEW_SHOWINDENTGUIDES,bShowIndentGuides); - CheckCmd(hmenu,IDM_VIEW_AUTOINDENTTEXT,bAutoIndent); + CheckCmd(hmenu,IDM_VIEW_SHOWINDENTGUIDES,Settings.ShowIndentGuides); + CheckCmd(hmenu,IDM_VIEW_AUTOINDENTTEXT,Settings.AutoIndent); CheckCmd(hmenu,IDM_VIEW_LINENUMBERS,g_bShowLineNumbers); CheckCmd(hmenu,IDM_VIEW_MARGIN,g_bShowSelectionMargin); CheckCmd(hmenu,IDM_VIEW_CHASING_DOCTAIL, g_bChasingDocTail); EnableCmd(hmenu,IDM_EDIT_COMPLETEWORD,!e && !ro); - CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,g_bAutoCompleteWords && !ro); - CheckCmd(hmenu,IDM_VIEW_AUTOCLEXKEYWORDS, g_bAutoCLexerKeyWords && !ro); + CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,Settings.AutoCompleteWords && !ro); + CheckCmd(hmenu,IDM_VIEW_AUTOCLEXKEYWORDS, Settings.AutoCLexerKeyWords && !ro); - CheckCmd(hmenu,IDM_VIEW_ACCELWORDNAV,g_bAccelWordNavigation); + CheckCmd(hmenu,IDM_VIEW_ACCELWORDNAV,Settings.AccelWordNavigation); CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_ONOFF, (g_iMarkOccurrences > 0)); CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_VISIBLE, g_bMarkOccurrencesMatchVisible); @@ -2920,17 +2913,17 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) CheckCmd(hmenu,IDM_VIEW_SHOWBLANKS,bViewWhiteSpace); CheckCmd(hmenu,IDM_VIEW_SHOWEOLS,bViewEOLs); CheckCmd(hmenu,IDM_VIEW_WORDWRAPSYMBOLS,Settings.ShowWordWrapSymbols); - CheckCmd(hmenu,IDM_VIEW_MATCHBRACES,bMatchBraces); + CheckCmd(hmenu,IDM_VIEW_MATCHBRACES,Settings.MatchBraces); CheckCmd(hmenu,IDM_VIEW_TOOLBAR,bShowToolbar); EnableCmd(hmenu,IDM_VIEW_CUSTOMIZETB,bShowToolbar); CheckCmd(hmenu,IDM_VIEW_STATUSBAR,bShowStatusbar); i = SciCall_GetLexer(); //EnableCmd(hmenu,IDM_VIEW_AUTOCLOSETAGS,(i == SCLEX_HTML || i == SCLEX_XML)); - CheckCmd(hmenu, IDM_VIEW_AUTOCLOSETAGS, bAutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/); - CheckCmd(hmenu, IDM_VIEW_HILITECURRENTLINE, bHiliteCurrentLine); - CheckCmd(hmenu, IDM_VIEW_HYPERLINKHOTSPOTS, g_bHyperlinkHotspot); - CheckCmd(hmenu, IDM_VIEW_SCROLLPASTEOF, bScrollPastEOF); + CheckCmd(hmenu, IDM_VIEW_AUTOCLOSETAGS, Settings.AutoCloseTags /*&& (i == SCLEX_HTML || i == SCLEX_XML)*/); + CheckCmd(hmenu, IDM_VIEW_HILITECURRENTLINE, Settings.HighlightCurrentLine); + CheckCmd(hmenu, IDM_VIEW_HYPERLINKHOTSPOTS, Settings.HyperlinkHotspot); + CheckCmd(hmenu, IDM_VIEW_SCROLLPASTEOF, Settings.ScrollPastEOF); i = Flags.ReuseWindow; @@ -3044,7 +3037,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDT_TIMER_UPDATE_HOTSPOT: - EditUpdateVisibleUrlHotspot(g_bHyperlinkHotspot); + EditUpdateVisibleUrlHotspot(Settings.HyperlinkHotspot); break; case IDM_FILE_NEW: @@ -4663,13 +4656,13 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_SHOWINDENTGUIDES: - bShowIndentGuides = (bShowIndentGuides) ? false : true; - Style_SetIndentGuides(Globals.hwndEdit,bShowIndentGuides); + Settings.ShowIndentGuides = (Settings.ShowIndentGuides) ? false : true; + Style_SetIndentGuides(Globals.hwndEdit,Settings.ShowIndentGuides); break; case IDM_VIEW_AUTOINDENTTEXT: - bAutoIndent = (bAutoIndent) ? false : true; + Settings.AutoIndent = (Settings.AutoIndent) ? false : true; break; @@ -4685,18 +4678,18 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDM_VIEW_AUTOCOMPLETEWORDS: - g_bAutoCompleteWords = (g_bAutoCompleteWords) ? false : true; // toggle + Settings.AutoCompleteWords = (Settings.AutoCompleteWords) ? false : true; // toggle SciCall_AutoCCancel(); break; case IDM_VIEW_AUTOCLEXKEYWORDS: - g_bAutoCLexerKeyWords = (g_bAutoCLexerKeyWords) ? false : true; // toggle + Settings.AutoCLexerKeyWords = (Settings.AutoCLexerKeyWords) ? false : true; // toggle SciCall_AutoCCancel(); break; case IDM_VIEW_ACCELWORDNAV: - g_bAccelWordNavigation = (g_bAccelWordNavigation) ? false : true; // toggle - EditSetAccelWordNav(Globals.hwndEdit,g_bAccelWordNavigation); + Settings.AccelWordNavigation = (Settings.AccelWordNavigation) ? false : true; // toggle + EditSetAccelWordNav(Globals.hwndEdit,Settings.AccelWordNavigation); MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, true); break; @@ -4776,8 +4769,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_MATCHBRACES: - bMatchBraces = (bMatchBraces) ? false : true; - if (bMatchBraces) + Settings.MatchBraces = (Settings.MatchBraces) ? false : true; + if (Settings.MatchBraces) EditMatchBrace(Globals.hwndEdit); else SciCall_BraceHighLight(INVALID_POSITION, INVALID_POSITION); @@ -4785,18 +4778,18 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_VIEW_AUTOCLOSETAGS: - bAutoCloseTags = (bAutoCloseTags) ? false : true; + Settings.AutoCloseTags = (Settings.AutoCloseTags) ? false : true; break; case IDM_VIEW_HILITECURRENTLINE: - bHiliteCurrentLine = (bHiliteCurrentLine) ? false : true; - Style_SetCurrentLineBackground(Globals.hwndEdit, bHiliteCurrentLine); + Settings.HighlightCurrentLine = (Settings.HighlightCurrentLine) ? false : true; + Style_SetCurrentLineBackground(Globals.hwndEdit, Settings.HighlightCurrentLine); break; case IDM_VIEW_HYPERLINKHOTSPOTS: - g_bHyperlinkHotspot = (g_bHyperlinkHotspot) ? false : true; - Style_SetUrlHotSpot(Globals.hwndEdit, g_bHyperlinkHotspot); - if (g_bHyperlinkHotspot) { + Settings.HyperlinkHotspot = (Settings.HyperlinkHotspot) ? false : true; + Style_SetUrlHotSpot(Globals.hwndEdit, Settings.HyperlinkHotspot); + if (Settings.HyperlinkHotspot) { UpdateVisibleUrlHotspot(0); } else { @@ -4861,8 +4854,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDM_VIEW_SCROLLPASTEOF: - bScrollPastEOF = (bScrollPastEOF) ? false : true; - SciCall_SetEndAtLastLine(!bScrollPastEOF); + Settings.ScrollPastEOF = (Settings.ScrollPastEOF) ? false : true; + SciCall_SetEndAtLastLine(!Settings.ScrollPastEOF); break; case IDM_VIEW_TOOLBAR: @@ -5161,9 +5154,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // Newline with toggled auto indent setting case CMD_SHIFTCTRLENTER: - bAutoIndent = (bAutoIndent) ? 0 : 1; + Settings.AutoIndent = !Settings.AutoIndent; SciCall_NewLine(); - bAutoIndent = (bAutoIndent) ? 0 : 1; + Settings.AutoIndent = !Settings.AutoIndent; break; @@ -6247,7 +6240,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) //~InvalidateSelections(); // fixed in SCI ? // Brace Match - if (bMatchBraces) { + if (Settings.MatchBraces) { EditMatchBrace(Globals.hwndEdit); } @@ -6269,7 +6262,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) } } - if (g_bHyperlinkHotspot) { + if (Settings.HyperlinkHotspot) { UpdateVisibleUrlHotspot(Settings2.UpdateDelayHyperlinkStyling); } UpdateToolbar(); @@ -6280,7 +6273,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) if ((g_iMarkOccurrences > 0) && g_bMarkOccurrencesMatchVisible) { MarkAllOccurrences(Settings2.UpdateDelayMarkAllOccurrences, false); } - if (g_bHyperlinkHotspot) { + if (Settings.HyperlinkHotspot) { UpdateVisibleUrlHotspot(Settings2.UpdateDelayHyperlinkStyling); } } @@ -6314,10 +6307,10 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) switch (ich) { case '\r': case '\n': - if (bAutoIndent) { _HandleAutoIndent(ich); } + if (Settings.AutoIndent) { _HandleAutoIndent(ich); } break; case '>': - if (bAutoCloseTags) { _HandleAutoCloseTags(); } + if (Settings.AutoCloseTags) { _HandleAutoCloseTags(); } break; case '?': _HandleTinyExpr(); @@ -6326,7 +6319,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) break; } - if ((g_bAutoCompleteWords || g_bAutoCLexerKeyWords)) + if ((Settings.AutoCompleteWords || Settings.AutoCLexerKeyWords)) { if (!EditAutoCompleteWord(Globals.hwndEdit, false)) { return 0; } } @@ -6334,7 +6327,7 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) break; case SCN_AUTOCCHARDELETED: - if ((g_bAutoCompleteWords || g_bAutoCLexerKeyWords)) + if ((Settings.AutoCompleteWords || Settings.AutoCLexerKeyWords)) { if (!EditAutoCompleteWord(Globals.hwndEdit, false)) { return 0; } } @@ -6835,27 +6828,36 @@ void LoadSettings() Defaults.ShowWordWrapSymbols = false; Settings.ShowWordWrapSymbols = IniSectionGetBool(pIniSection, L"ShowWordWrapSymbols", Defaults.ShowWordWrapSymbols); + Defaults.MatchBraces = true; + Settings.MatchBraces = IniSectionGetBool(pIniSection, L"MatchBraces", Defaults.MatchBraces); + Defaults.AutoCloseTags = false; + Settings.AutoCloseTags = IniSectionGetBool(pIniSection, L"AutoCloseTags", Defaults.AutoCloseTags); - bMatchBraces = IniSectionGetBool(pIniSection, L"MatchBraces", true); + Defaults.HighlightCurrentLine = false; + Settings.HighlightCurrentLine = IniSectionGetBool(pIniSection, L"HighlightCurrentLine", Defaults.HighlightCurrentLine); - bAutoCloseTags = IniSectionGetBool(pIniSection, L"AutoCloseTags", false); + Defaults.HyperlinkHotspot = false; + Settings.HyperlinkHotspot = IniSectionGetBool(pIniSection, L"HyperlinkHotspot", Defaults.HyperlinkHotspot); - bHiliteCurrentLine = IniSectionGetBool(pIniSection, L"HighlightCurrentLine", false); + Defaults.ScrollPastEOF = false; + Settings.ScrollPastEOF = IniSectionGetBool(pIniSection, L"ScrollPastEOF", Defaults.ScrollPastEOF); - g_bHyperlinkHotspot = IniSectionGetBool(pIniSection, L"HyperlinkHotspot", false); + Defaults.AutoIndent = true; + Settings.AutoIndent = IniSectionGetBool(pIniSection, L"AutoIndent", Defaults.AutoIndent); - bScrollPastEOF = IniSectionGetBool(pIniSection, L"ScrollPastEOF", false); + Defaults.AutoCompleteWords = false; + Settings.AutoCompleteWords = IniSectionGetBool(pIniSection, L"AutoCompleteWords", Defaults.AutoCompleteWords); - bAutoIndent = IniSectionGetBool(pIniSection, L"AutoIndent", true); + Defaults.AutoCLexerKeyWords = false; + Settings.AutoCLexerKeyWords = IniSectionGetBool(pIniSection, L"AutoCLexerKeyWords", Defaults.AutoCLexerKeyWords); - g_bAutoCompleteWords = IniSectionGetBool(pIniSection, L"AutoCompleteWords", false); - - g_bAutoCLexerKeyWords = IniSectionGetBool(pIniSection, L"AutoCLexerKeyWords", false); + Defaults.AccelWordNavigation = false; + Settings.AccelWordNavigation = IniSectionGetBool(pIniSection, L"AccelWordNavigation", Defaults.AccelWordNavigation); - g_bAccelWordNavigation = IniSectionGetBool(pIniSection, L"AccelWordNavigation", false); + Defaults.ShowIndentGuides = false; + Settings.ShowIndentGuides = IniSectionGetBool(pIniSection, L"ShowIndentGuides", Defaults.ShowIndentGuides); - bShowIndentGuides = IniSectionGetBool(pIniSection, L"ShowIndentGuides", false); g_bTabsAsSpaces = IniSectionGetBool(pIniSection, L"TabsAsSpaces", false); bTabsAsSpacesG = g_bTabsAsSpaces; @@ -7179,9 +7181,6 @@ void SaveSettings(bool bSaveSettingsNow) { WCHAR wchTmp[MAX_PATH] = { L'\0' }; - // update window placement - s_WinInfo = GetMyWindowPlacement(Globals.hwndMain, NULL); - if (StringCchLenW(Globals.IniFile, COUNTOF(Globals.IniFile)) == 0) { return; } if (!s_bEnableSaveSettings) { return; } @@ -7266,18 +7265,37 @@ void SaveSettings(bool bSaveSettingsNow) if (Settings.ShowWordWrapSymbols != Defaults.ShowWordWrapSymbols) { IniSectionSetBool(pIniSection, L"ShowWordWrapSymbols", Settings.ShowWordWrapSymbols); } + if (Settings.MatchBraces != Defaults.MatchBraces) { + IniSectionSetBool(pIniSection, L"MatchBraces", Settings.MatchBraces); + } + if (Settings.AutoCloseTags != Defaults.AutoCloseTags) { + IniSectionSetBool(pIniSection, L"AutoCloseTags", Settings.AutoCloseTags); + } + if (Settings.HighlightCurrentLine != Defaults.HighlightCurrentLine) { + IniSectionSetBool(pIniSection, L"HighlightCurrentLine", Settings.HighlightCurrentLine); + } + if (Settings.HyperlinkHotspot != Defaults.HyperlinkHotspot) { + IniSectionSetBool(pIniSection, L"HyperlinkHotspot", Settings.HyperlinkHotspot); + } + if (Settings.ScrollPastEOF != Defaults.ScrollPastEOF) { + IniSectionSetBool(pIniSection, L"ScrollPastEOF", Settings.ScrollPastEOF); + } + if (Settings.AutoIndent != Defaults.AutoIndent) { + IniSectionSetBool(pIniSection, L"AutoIndent", Settings.AutoIndent); + } + if (Settings.AutoCompleteWords != Defaults.AutoCompleteWords) { + IniSectionSetBool(pIniSection, L"AutoCompleteWords", Settings.AutoCompleteWords); + } + if (Settings.AutoCLexerKeyWords != Defaults.AutoCLexerKeyWords) { + IniSectionSetBool(pIniSection, L"AutoCLexerKeyWords", Settings.AutoCLexerKeyWords); + } + if (Settings.AccelWordNavigation != Defaults.AccelWordNavigation) { + IniSectionSetBool(pIniSection, L"AccelWordNavigation", Settings.AccelWordNavigation); + } + if (Settings.ShowIndentGuides != Defaults.ShowIndentGuides) { + IniSectionSetBool(pIniSection, L"ShowIndentGuides", Settings.ShowIndentGuides); + } - - IniSectionSetBool(pIniSection, L"MatchBraces", bMatchBraces); - IniSectionSetBool(pIniSection, L"AutoCloseTags", bAutoCloseTags); - IniSectionSetBool(pIniSection, L"HighlightCurrentLine", bHiliteCurrentLine); - IniSectionSetBool(pIniSection, L"HyperlinkHotspot", g_bHyperlinkHotspot); - IniSectionSetBool(pIniSection, L"ScrollPastEOF", bScrollPastEOF); - IniSectionSetBool(pIniSection, L"AutoIndent", bAutoIndent); - IniSectionSetBool(pIniSection, L"AutoCompleteWords", g_bAutoCompleteWords); - IniSectionSetBool(pIniSection, L"AutoCLexerKeyWords", g_bAutoCLexerKeyWords); - IniSectionSetBool(pIniSection, L"AccelWordNavigation", g_bAccelWordNavigation); - IniSectionSetBool(pIniSection, L"ShowIndentGuides", bShowIndentGuides); IniSectionSetBool(pIniSection, L"TabsAsSpaces", bTabsAsSpacesG); IniSectionSetBool(pIniSection, L"TabIndents", bTabIndentsG); IniSectionSetBool(pIniSection, L"BackspaceUnindents", bBackspaceUnindents); @@ -7353,6 +7371,11 @@ void SaveSettings(bool bSaveSettingsNow) // Scintilla Styles Style_Save(); + // update window placement + if (bSaveSettingsNow) { + s_WinInfo = GetMyWindowPlacement(Globals.hwndMain, NULL); + } + int ResX = GetSystemMetrics(SM_CXSCREEN); int ResY = GetSystemMetrics(SM_CYSCREEN); @@ -10532,8 +10555,8 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) if (SendMessage(Globals.hwndEdit,SCI_CANPASTE,0,0)) { - bool bAutoIndent2 = bAutoIndent; - bAutoIndent = 0; + bool bAutoIndent2 = Settings.AutoIndent; + Settings.AutoIndent = 0; EditJumpTo(Globals.hwndEdit,-1,0); _BEGIN_UNDO_ACTION_; if (SendMessage(Globals.hwndEdit, SCI_GETLENGTH, 0, 0) > 0) { @@ -10543,7 +10566,7 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) SendMessage(Globals.hwndEdit,SCI_NEWLINE,0,0); _END_UNDO_ACTION_; EditEnsureSelectionVisible(Globals.hwndEdit); - bAutoIndent = bAutoIndent2; + Settings.AutoIndent = bAutoIndent2; } dwLastCopyTime = 0; } diff --git a/src/SciCall.h b/src/SciCall.h index 9951ebd4b..7a405349a 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -463,8 +463,6 @@ DeclareSciCallR0(IsIMEModeCJK, ISIMEMODECJK, bool) DeclareSciCallR0(IsSelectionEmpty, GETSELECTIONEMPTY, bool) DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool) -#define Sci_GetLine_Safe(ln, bu) - #define Sci_IsSingleLineSelection() (SciCall_LineFromPosition(SciCall_GetCurrentPos()) == SciCall_LineFromPosition(SciCall_GetAnchor())) #define Sci_IsForwardSelection() (SciCall_GetAnchor() <= SciCall_GetCurrentPos()) diff --git a/src/Styles.c b/src/Styles.c index 1cf74e242..8a5620461 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -134,8 +134,6 @@ static int g_cyStyleSelectDlg; extern int g_iDefaultCharSet; -extern bool bHiliteCurrentLine; -extern bool g_bHyperlinkHotspot; //============================================================================= @@ -814,7 +812,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SendMessage(hwnd, SCI_SETWHITESPACESIZE, iValue, 0); // current line background - Style_SetCurrentLineBackground(hwnd, bHiliteCurrentLine); + Style_SetCurrentLineBackground(hwnd, Settings.HighlightCurrentLine); // bookmark line or marker Style_SetBookmark(hwnd, g_bShowSelectionMargin); @@ -1023,9 +1021,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) EditApplyLexerStyle(hwnd, 0, -1); // update UI for hotspots - if (g_bHyperlinkHotspot) { - Style_SetUrlHotSpot(hwnd, g_bHyperlinkHotspot); - EditUpdateUrlHotspots(hwnd, 0, Sci_GetDocEndPosition(), g_bHyperlinkHotspot); + if (Settings.HyperlinkHotspot) { + Style_SetUrlHotSpot(hwnd, Settings.HyperlinkHotspot); + EditUpdateUrlHotspots(hwnd, 0, Sci_GetDocEndPosition(), Settings.HyperlinkHotspot); } UpdateToolbar(); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 8e1ae53eb..7376ca248 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -238,6 +238,17 @@ typedef struct _settings_t int WordWrapIndent; int WordWrapSymbols; bool ShowWordWrapSymbols; + bool MatchBraces; + bool AutoCloseTags; + bool HighlightCurrentLine; + bool HyperlinkHotspot; + bool ScrollPastEOF; + bool AutoIndent; + bool AutoCompleteWords; + bool AutoCLexerKeyWords; + bool AccelWordNavigation; + bool ShowIndentGuides; + EDITFINDREPLACE EFR_Data; WCHAR OpenWithDir[MAX_PATH + 1];