From accbcdcb2e7770b401d7af688222ef15bd1aa748 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Thu, 17 Aug 2017 17:56:08 +0200 Subject: [PATCH] + fix: wrong shortcut in menu on word navigation (Ctrl+LEFT/RIGHT) + add: toggle option for accelerated word navigation (Ctrl+LEFT/RIGHT) according to issue #27 (https://github.com/rizonesoft/Notepad3/issues/27) - [Settings2] parameter "ExtendedWhiteSpaceChars=" defines a set of chars to be ignored (handled as whitespaces) to find the next beginning of a word if "Accelerated word navigation" is switched ON --- src/Edit.c | 9 ++++++ src/Notepad3.c | 57 +++++++++++++++++++++++++++---------- src/Notepad3.rc | Bin 180320 -> 180588 bytes src/resource.h | 73 +++++++++++++++++++++++++----------------------- 4 files changed, 90 insertions(+), 49 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index c27a6d95f..454a0c074 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -67,6 +67,10 @@ extern BOOL bLoadNFOasOEM; extern int iSrcEncoding; extern int iWeakSrcEncoding; +extern BOOL bAccelWordNavigation; +extern char* chExtendedWhiteSpaceChars; + + int g_DOSEncoding; // Supported Encodings @@ -265,6 +269,11 @@ HWND EditCreate(HWND hwndParent) SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_HOME + (SCMOD_SHIFT << 16)),SCI_VCHOMEWRAPEXTEND); SendMessage(hwnd,SCI_ASSIGNCMDKEY,(SCK_END + (SCMOD_SHIFT << 16)),SCI_LINEENDWRAPEXTEND); + if (bAccelWordNavigation) + SendMessage(hwnd, SCI_SETWHITESPACECHARS, 0, (LPARAM)chExtendedWhiteSpaceChars); + else + SendMessage(hwnd, SCI_SETCHARSDEFAULT, 0, 0); + // Init default values for printing EditPrintInit(); diff --git a/src/Notepad3.c b/src/Notepad3.c index 7afd05b16..ba10b376b 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -109,6 +109,9 @@ WCHAR tchToolbarButtons[512] = { L'\0' }; WCHAR tchToolbarBitmap[MAX_PATH] = { L'\0' }; WCHAR tchToolbarBitmapHot[MAX_PATH] = { L'\0' }; WCHAR tchToolbarBitmapDisabled[MAX_PATH] = { L'\0' }; + +char chExtendedWhiteSpaceChars[256] = { '\0' }; + int iPathNameFormat; BOOL fWordWrap; BOOL fWordWrapG; @@ -141,6 +144,7 @@ int iMarkOccurrences; BOOL bMarkOccurrencesMatchCase; BOOL bMarkOccurrencesMatchWords; BOOL bAutoCompleteWords; +BOOL bAccelWordNavigation; BOOL bShowCodeFolding; BOOL bViewWhiteSpace; BOOL bViewEOLs; @@ -297,9 +301,9 @@ WCHAR g_wchWorkingDirectory[MAX_PATH] = L""; - //Graphics for bookmark indicator - /* XPM */ - static char * bookmark_pixmap[] = { +//Graphics for bookmark indicator +/* XPM */ +static char * bookmark_pixmap[] = { "11 11 44 1", " c #EBE9ED", ". c #E5E3E7", @@ -355,9 +359,8 @@ WCHAR g_wchWorkingDirectory[MAX_PATH] = L""; " 23~~~~;4+ ", " 56=|7890 ", " a2bc}de ", - " "}; - - + " " +}; //============================================================================= // @@ -2297,6 +2300,7 @@ void MsgInitMenu(HWND hwnd,WPARAM wParam,LPARAM lParam) EnableCmd(hmenu,IDM_EDIT_COMPLETEWORD,i); CheckCmd(hmenu,IDM_VIEW_AUTOCOMPLETEWORDS,bAutoCompleteWords); + CheckCmd(hmenu,IDM_VIEW_ACCELWORDNAV,bAccelWordNavigation); switch (iMarkOccurrences) { @@ -4071,14 +4075,17 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) break; case IDM_VIEW_AUTOCOMPLETEWORDS: - if (bAutoCompleteWords) { - // close the autocompletion list - SendMessage(hwndEdit, SCI_AUTOCCANCEL, 0, 0); - bAutoCompleteWords = FALSE; - } - else { - bAutoCompleteWords = TRUE; - } + bAutoCompleteWords = (bAutoCompleteWords) ? FALSE : TRUE; // toggle + if (!bAutoCompleteWords) + SendMessage(hwndEdit, SCI_AUTOCCANCEL, 0, 0); // close the auto completion list + break; + + case IDM_VIEW_ACCELWORDNAV: + bAccelWordNavigation = (bAccelWordNavigation) ? FALSE : TRUE; // toggle + if (bAccelWordNavigation) + SendMessage(hwndEdit, SCI_SETWHITESPACECHARS, 0, (LPARAM)chExtendedWhiteSpaceChars); + else + SendMessage(hwndEdit, SCI_SETCHARSDEFAULT, 0, 0); break; case IDM_VIEW_MARKOCCURRENCES_OFF: @@ -4500,6 +4507,16 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) break; + case CMD_CTRLLEFT: + SendMessage(hwndEdit, SCI_WORDLEFT, 0, 0); + break; + + + case CMD_CTRLRIGHT: + SendMessage(hwndEdit, SCI_WORDRIGHT, 0, 0); + break; + + case CMD_CTRLBACK: { int iPos = (int)SendMessage(hwndEdit,SCI_GETCURRENTPOS,0,0); @@ -5687,6 +5704,9 @@ void LoadSettings() bAutoCompleteWords = IniSectionGetInt(pIniSection,L"AutoCompleteWords",0); if (bAutoCompleteWords) bAutoCompleteWords = 1; + bAccelWordNavigation = IniSectionGetInt(pIniSection, L"AccelWordNavigation", 0); + if (bAccelWordNavigation) bAccelWordNavigation = 1; + bShowIndentGuides = IniSectionGetInt(pIniSection,L"ShowIndentGuides",0); if (bShowIndentGuides) bShowIndentGuides = 1; @@ -5866,6 +5886,7 @@ void LoadSettings() iSciFontQuality = IniSectionGetInt(pIniSection,L"SciFontQuality",-1); iSciFontQuality = max(min(iSciFontQuality,3),-1); + LoadIniSection(L"Settings2",pIniSection,cchIniSection); bStickyWinPos = IniSectionGetInt(pIniSection,L"StickyWindowPosition",0); @@ -5885,6 +5906,13 @@ void LoadSettings() dwFileCheckInverval = IniSectionGetInt(pIniSection,L"FileCheckInverval",2000); dwAutoReloadTimeout = IniSectionGetInt(pIniSection,L"AutoReloadTimeout",2000); + WCHAR buffer[256]; + const WCHAR defextwsc[] = L".,;:|/-+$%&<>(){}[]=?#'*"; + IniSectionGetString(pIniSection, L"ExtendedWhiteSpaceChars", defextwsc, buffer, COUNTOF(buffer)); + if (!lstrlen(buffer)) lstrcpyn(buffer, defextwsc, COUNTOF(buffer)); + WideCharToMultiByte(CP_ACP, 0, buffer, -1, chExtendedWhiteSpaceChars, COUNTOF(chExtendedWhiteSpaceChars), NULL, NULL); + + LoadIniSection(L"Toolbar Images",pIniSection,cchIniSection); IniSectionGetString(pIniSection,L"BitmapDefault",L"", @@ -6002,6 +6030,7 @@ void SaveSettings(BOOL bSaveSettingsNow) { IniSectionSetInt(pIniSection, L"HighlightCurrentLine", bHiliteCurrentLine); IniSectionSetInt(pIniSection, L"AutoIndent", bAutoIndent); IniSectionSetInt(pIniSection, L"AutoCompleteWords", bAutoCompleteWords); + IniSectionSetInt(pIniSection, L"AccelWordNavigation", bAccelWordNavigation); IniSectionSetInt(pIniSection, L"ShowIndentGuides", bShowIndentGuides); IniSectionSetInt(pIniSection, L"TabsAsSpaces", bTabsAsSpacesG); IniSectionSetInt(pIniSection, L"TabIndents", bTabIndentsG); diff --git a/src/Notepad3.rc b/src/Notepad3.rc index a3231cbccd7713b6262aa5be88dd06e5c32e13af..964c34ac195559279bc2cc9126384a18ffbccc04 100644 GIT binary patch delta 349 zcmYk0KS%-r7{x!uOcbQfQxY2Num&T&&J)TYiqbU9#HBbY3i^XXDiKX#hd~5ES#N37 z#aVEuQ6iceOb`kQj%Fd}2I;at#2en@eZL2vBAc37Q>i$D$~c2c&JV4d!+OGod3O%V zV;?>)1&AIF`8yj9Jgdsb15U!cQE!rdpEm4a0Iw?vUbU+E(QGH+a6eWqnz^>IYO*5(j6jA9#iqkAb zapAH<9*Urq)0dx*im{(>3JohtPX<(LhQG#+^OsO}oWe9mAru;xU*cakjH$YKoT=Vq Is+za=Pm_v*K>z>% delta 207 zcmaFU#QmUwd&4r_$rpqqCKsF&ntVVv1k6^LST%W?o(h;PV8Ao^!5Nmx&n6m8X3q1NPm$5p0JkZ0nU{LCZWF_^s0IAC&z qNxZ| diff --git a/src/resource.h b/src/resource.h index 8f23ad3fc..84d9d55f8 100644 --- a/src/resource.h +++ b/src/resource.h @@ -171,41 +171,43 @@ #define CMD_ESCAPE 20000 #define CMD_SHIFTESC 20001 #define CMD_CTRLENTER 20002 -#define CMD_BACK 20003 -#define CMD_CTRLBACK 20004 -#define CMD_DEL 20005 -#define CMD_CTRLDEL 20006 -#define CMD_CTRLTAB 20007 -#define CMD_RECODEDEFAULT 20008 -#define CMD_RECODEANSI 20009 -#define CMD_RECODEOEM 20010 -#define CMD_RELOADASCIIASUTF8 20011 -#define CMD_RELOADNOFILEVARS 20012 -#define CMD_LEXDEFAULT 20013 -#define CMD_LEXHTML 20014 -#define CMD_LEXXML 20015 -#define CMD_TIMESTAMPS 20016 -#define CMD_WEBACTION1 20017 -#define CMD_WEBACTION2 20018 -#define CMD_FINDNEXTSEL 20019 -#define CMD_FINDPREVSEL 20020 -#define CMD_INCLINELIMIT 20021 -#define CMD_DECLINELIMIT 20022 -#define CMD_STRINGIFY 20023 -#define CMD_STRINGIFY2 20024 -#define CMD_EMBRACE 20025 -#define CMD_EMBRACE2 20026 -#define CMD_EMBRACE3 20027 -#define CMD_EMBRACE4 20028 -#define CMD_INCREASENUM 20029 -#define CMD_DECREASENUM 20030 -#define CMD_TOGGLETITLE 20031 -#define CMD_JUMP2SELSTART 20032 -#define CMD_JUMP2SELEND 20033 -#define CMD_COPYPATHNAME 20034 -#define CMD_COPYWINPOS 20035 -#define CMD_DEFAULTWINPOS 20036 -#define CMD_OPENINIFILE 20037 +#define CMD_CTRLLEFT 20003 +#define CMD_CTRLRIGHT 20004 +#define CMD_BACK 20005 +#define CMD_CTRLBACK 20006 +#define CMD_DEL 20007 +#define CMD_CTRLDEL 20008 +#define CMD_CTRLTAB 20009 +#define CMD_RECODEDEFAULT 20010 +#define CMD_RECODEANSI 20011 +#define CMD_RECODEOEM 20012 +#define CMD_RELOADASCIIASUTF8 20013 +#define CMD_RELOADNOFILEVARS 20014 +#define CMD_LEXDEFAULT 20015 +#define CMD_LEXHTML 20016 +#define CMD_LEXXML 20017 +#define CMD_TIMESTAMPS 20018 +#define CMD_WEBACTION1 20019 +#define CMD_WEBACTION2 20020 +#define CMD_FINDNEXTSEL 20021 +#define CMD_FINDPREVSEL 20022 +#define CMD_INCLINELIMIT 20023 +#define CMD_DECLINELIMIT 20024 +#define CMD_STRINGIFY 20025 +#define CMD_STRINGIFY2 20026 +#define CMD_EMBRACE 20027 +#define CMD_EMBRACE2 20028 +#define CMD_EMBRACE3 20029 +#define CMD_EMBRACE4 20030 +#define CMD_INCREASENUM 20031 +#define CMD_DECREASENUM 20032 +#define CMD_TOGGLETITLE 20033 +#define CMD_JUMP2SELSTART 20034 +#define CMD_JUMP2SELEND 20035 +#define CMD_COPYPATHNAME 20036 +#define CMD_COPYWINPOS 20037 +#define CMD_DEFAULTWINPOS 20038 +#define CMD_OPENINIFILE 20039 #define IDM_FILE_NEW 40000 #define IDM_FILE_OPEN 40001 #define IDM_FILE_REVERT 40002 @@ -376,6 +378,7 @@ #define IDM_VIEW_MARKOCCURRENCES_CASE 40451 #define IDM_VIEW_MARKOCCURRENCES_WORD 40452 #define IDM_VIEW_AUTOCOMPLETEWORDS 40453 +#define IDM_VIEW_ACCELWORDNAV 40454 #define IDM_HELP_ABOUT 40500 #define IDM_HELP_CMD 40501 #define IDM_TRAY_RESTORE 40600