Merge pull request #2151 from RaiKoHoff/NewFeatures

Update (master changes)
This commit is contained in:
Rainer Kottenhoff 2020-03-21 17:02:31 +01:00 committed by GitHub
commit 963e3c51dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 211 additions and 119 deletions

View File

@ -7,7 +7,9 @@ SettingsVersion=4
;IMEInteraction=0
;AutoReloadTimeout=2000
;DateTimeLong=
;TimeStampRegExLong=
;DateTimeShort=
;TimeStampRegExShort=
;DefaultDirectory=
;DefaultExtension=txt
;DefaultWindowPosition=
@ -36,7 +38,6 @@ SettingsVersion=4
;ShellAppUserModelID=Rizonesoft.Notepad3
;ShellUseSystemMRU=1
;StickyWindowPosition=0
;TimeStamp=\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $
;UseOldStyleBraceMatching=0
;WebTemplate1=https://google.com/search?q=%s
;WebTemplate2=https://en.wikipedia.org/w/index.php?search=%s

View File

@ -1 +1 @@
1
2

View File

@ -278,7 +278,7 @@ Notepad3 \t[/?] [...[文字コード]] [...[改行コード]] [/e] [/g] [/m] [/l
/n\t新しいウィンドウで開く (/ns ファイルは単一のインスタンス)\r\n\
/r\tひとつウインドウを再利用 (/rs 同じく単一のインスタンス\r\n\
/p\tウィンドウの位置とサイズを指定 [/p x,y,sizex,y[,max]] (/p0, /ps,\r\n\t/pf,l,t,r,b,m)\r\n\
\tor /p <left>,<top>,<width>,<height>,<max> [all integers]\r\n\
\tor /p <left>,<top>,<width>,<height>,<max> [すべて整数]\r\n\
/t\tタイトルバーの文字列を指定 [/t text]\r\n\
/i\tシステムトレイ内に起動\r\n\
/o\t常に手前に表示\r\n\

View File

@ -284,7 +284,7 @@ BEGIN
MENUITEM "Zaznacz wyraz lub wiersz\tCtrl+Spc", IDM_EDIT_SELECTWORD
MENUITEM "Multiwybór-wszystko pasujące\tCtrl+Shift+Spc", IDM_EDIT_SELECTALLMATCHES
MENUITEM SEPARATOR
MENUITEM "Split Undo &Transaction at Line-Breaks", IDM_VIEW_SPLIT_UNDOTYPSEQ_LNBRK
MENUITEM "Podział operacji cofania przy przenoszeniu wierszy", IDM_VIEW_SPLIT_UNDOTYPSEQ_LNBRK
END
MENUITEM SEPARATOR
POPUP "Zakładki"

View File

@ -278,7 +278,7 @@ Options:\r\n\
/n\tAlways open a new window (/ns single file instance).\r\n\
/r\tReuse window (/rs single file instance).\r\n\
/p\tSet window position and size (/p0, /ps, /pf,l,t,r,b,m)\r\n\
\tor /p <left>,<top>,<width>,<height>,<max> [all integers].\r\n\
\tor /p <lewy>,<góra>,<szer.>,<wys.>,<maks> [wszystkie liczby].\r\n\
/t\tSet window title.\r\n\
/i\tStart as tray icon.\r\n\
/o\tKeep window on top.\r\n\

View File

@ -3,7 +3,7 @@
<assemblyIdentity
name="Notepad3"
processorArchitecture="*"
version="5.20.321.1"
version="5.20.321.2"
type="win32"
/>
<description>Notepad3 NF</description>

View File

@ -1324,7 +1324,6 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) {
if (lParam & GCS_RESULTSTR) {
AddWString(imc.GetCompositionString(GCS_RESULTSTR), CharacterSource::imeResult);
initialCompose = true;
}
if (lParam & GCS_COMPSTR) {

View File

@ -810,17 +810,18 @@ extern "C" bool CreateIniFile()
HANDLE hFile = CreateFile(Globals.IniFile,
GENERIC_READ, FILE_SHARE_READ,
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
Globals.dwLastError = GetLastError();
MsgBoxLastError(L"Read Access to Settings-File failed!", Globals.dwLastError);
return result;
if (hFile != INVALID_HANDLE_VALUE) {
DWORD dwFSHigh = 0UL;
dwFileSize = GetFileSize(hFile, &dwFSHigh);
CloseHandle(hFile);
}
else {
dwFileSize = INVALID_FILE_SIZE;
}
DWORD dwFSHigh = 0UL;
dwFileSize = GetFileSize(hFile, &dwFSHigh);
CloseHandle(hFile);
}
if ((dwFileSize == 0) && (dwFileSize != INVALID_FILE_SIZE)) {
if (dwFileSize == 0) {
result = IniFileSetString(Globals.IniFile, L"Notepad3", NULL, NULL);
Globals.bIniFileFromScratch = true;
}
@ -934,8 +935,6 @@ void LoadSettings()
IniSectionGetString(IniSecSettings2, L"PreferredLanguageLocaleName", Defaults2.PreferredLanguageLocaleName,
Settings2.PreferredLanguageLocaleName, COUNTOF(Settings2.PreferredLanguageLocaleName));
StringCchCopyW(Globals.InitialPreferredLanguage, COUNTOF(Globals.InitialPreferredLanguage), Settings2.PreferredLanguageLocaleName);
// --------------------------------------------------------------------------
StringCchCopyW(Defaults2.DefaultExtension, COUNTOF(Defaults2.DefaultExtension), L"txt");
@ -1084,14 +1083,20 @@ void LoadSettings()
Settings2.LineCommentPostfixStrg, COUNTOF(Settings2.LineCommentPostfixStrg));
StrTrimW(Settings2.LineCommentPostfixStrg, L"\"");
StringCchCopyW(Defaults2.TimeStamp, COUNTOF(Defaults2.TimeStamp), L"\\$Date:[^\\$]+\\$ | $Date: %Y/%m/%d %H:%M:%S $");
IniSectionGetString(IniSecSettings2, L"TimeStamp", Defaults2.TimeStamp, Settings2.TimeStamp, COUNTOF(Settings2.TimeStamp));
Defaults2.DateTimeShort[0] = L'\0';
IniSectionGetString(IniSecSettings2, L"DateTimeShort", Defaults2.DateTimeShort, Settings2.DateTimeShort, COUNTOF(Settings2.DateTimeShort));
//Defaults2.DateFormatLong = 0;
//Settings2.DateFormatLong = clampi(IniSectionGetInt(IniSecSettings2, L"DateFormatLong", Defaults2.DateFormatLong), 0, 100);
//Defaults2.DateFormatShort = 0;
//Settings2.DateFormatShort = clampi(IniSectionGetInt(IniSecSettings2, L"DateFormatShort", Defaults2.DateFormatShort), 0, 100);
Defaults2.DateTimeLong[0] = L'\0';
IniSectionGetString(IniSecSettings2, L"DateTimeLong", Defaults2.DateTimeLong, Settings2.DateTimeLong, COUNTOF(Settings2.DateTimeLong));
Defaults2.TimeStampRegExLong[0] = L'\0';
IniSectionGetString(IniSecSettings2, L"TimeStampRegExLong", Defaults2.TimeStampRegExLong, Settings2.TimeStampRegExLong, COUNTOF(Settings2.TimeStampRegExLong));
Defaults2.DateTimeShort[0] = L'\0';
IniSectionGetString(IniSecSettings2, L"DateTimeShort", Defaults2.DateTimeShort, Settings2.DateTimeShort, COUNTOF(Settings2.DateTimeShort));
Defaults2.TimeStampRegExShort[0] = L'\0';
IniSectionGetString(IniSecSettings2, L"TimeStampRegExShort", Defaults2.TimeStampRegExShort, Settings2.TimeStampRegExShort, COUNTOF(Settings2.TimeStampRegExShort));
StringCchCopyW(Defaults2.WebTemplate1, COUNTOF(Defaults2.WebTemplate1), L"https://google.com/search?q=%s");
IniSectionGetString(IniSecSettings2, L"WebTemplate1", Defaults2.WebTemplate1, Settings2.WebTemplate1, COUNTOF(Settings2.WebTemplate1));

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <limits.h>
#include <shellapi.h>
#include <time.h>
#include "Styles.h"
#include "Dialogs.h"
@ -2243,6 +2244,176 @@ void EditModifyNumber(HWND hwnd,bool bIncrease) {
}
//=============================================================================
//
// _GetDateFormatProc() - date format information provided by the EnumDateFormatsExEx()
//
static unsigned int _DateFmtIdx = 0;
static BOOL CALLBACK _GetDateFormatProc(LPWSTR lpDateFormatString, CALID CalendarID, LPARAM lParam)
{
UNUSED(CalendarID);
static unsigned int count = 0;
LPWSTR const pwchFind = (LPWSTR)lParam;
if (StrIsEmpty(pwchFind)) {
count = 0; // begin
StringCchCopy(pwchFind, SMALL_BUFFER, lpDateFormatString); // default
if (count == _DateFmtIdx) { return FALSE; } // found
}
else if (count == _DateFmtIdx) {
StringCchCopy(pwchFind, SMALL_BUFFER, lpDateFormatString);
return FALSE; // found
}
++count;
return TRUE;
}
//=============================================================================
//
// _GetCurrentDateTimeString()
//
static void _GetCurrentDateTimeString(LPWSTR pwchDateTimeStrg, size_t cchBufLen, bool bShortFmt)
{
WCHAR wchTemplate[SMALL_BUFFER] = { L'\0' };
StringCchCopyW(wchTemplate, COUNTOF(wchTemplate), bShortFmt ? Settings2.DateTimeShort : Settings2.DateTimeLong);
SYSTEMTIME st;
GetLocalTime(&st);
if (StrIsNotEmpty(wchTemplate))
{
struct tm sst;
sst.tm_isdst = -1;
sst.tm_sec = (int)st.wSecond;
sst.tm_min = (int)st.wMinute;
sst.tm_hour = (int)st.wHour;
sst.tm_mday = (int)st.wDay;
sst.tm_mon = (int)st.wMonth - 1;
sst.tm_year = (int)st.wYear - 1900;
sst.tm_wday = (int)st.wDayOfWeek;
mktime(&sst);
wcsftime(pwchDateTimeStrg, cchBufLen, wchTemplate, &sst);
}
else {
WCHAR wchFormat[SMALL_BUFFER] = { L'\0' };
_DateFmtIdx = 0; // (bShortFmt ? Settings2.DateFormatShort : Settings2.DateFormatLong);
EnumDateFormatsExEx(_GetDateFormatProc, Settings2.PreferredLanguageLocaleName, (bShortFmt ? DATE_SHORTDATE : DATE_LONGDATE), (LPARAM)wchFormat);
WCHAR wchDate[SMALL_BUFFER] = { L'\0' };
GetDateFormatEx(Settings2.PreferredLanguageLocaleName, DATE_AUTOLAYOUT, &st, wchFormat, wchDate, COUNTOF(wchDate), NULL);
WCHAR wchTime[SMALL_BUFFER] = { L'\0' };
GetTimeFormatEx(Settings2.PreferredLanguageLocaleName, TIME_NOSECONDS, &st, NULL, wchTime, COUNTOF(wchTime));
StringCchPrintf(pwchDateTimeStrg, cchBufLen, L"%s %s", wchTime, wchDate);
}
}
//=============================================================================
//
// EditInsertTimestamps()
//
void EditInsertTimestamps(bool bShortFmt)
{
//~~~_BEGIN_UNDO_ACTION_;
WCHAR wchDateTime[SMALL_BUFFER] = { L'\0' };
_GetCurrentDateTimeString(wchDateTime, COUNTOF(wchDateTime), bShortFmt);
char chDateTime[MIDSZ_BUFFER] = { '\0' };
WideCharToMultiByteEx(Encoding_SciCP, 0, wchDateTime, -1, chDateTime, COUNTOF(chDateTime), NULL, NULL);
EditReplaceSelection(chDateTime, false);
//~~~_END_UNDO_ACTION_;
}
//=============================================================================
//
// EditUpdateTimestamps()
//
void EditUpdateTimestamps()
{
//WCHAR wchTempBuf[SMALL_BUFFER] = { L'\0' };
WCHAR wchFindLong[SMALL_BUFFER] = { L'\0' };
WCHAR wchFindShort[SMALL_BUFFER] = { L'\0' };
if (StrIsNotEmpty(Settings2.TimeStampRegExLong)) {
StringCchCopy(wchFindLong, COUNTOF(wchFindLong), Settings2.TimeStampRegExLong);
StrTrim(wchFindLong, L" ");
}
if (StrIsNotEmpty(Settings2.TimeStampRegExShort)) {
StringCchCopy(wchFindShort, COUNTOF(wchFindShort), Settings2.TimeStampRegExShort);
StrTrim(wchFindShort, L" ");
}
if (StrIsEmpty(wchFindLong))
{
_DateFmtIdx = 0; // Settings2.DateFormatLong;
EnumDateFormatsExEx(_GetDateFormatProc, Settings2.PreferredLanguageLocaleName, DATE_LONGDATE, (LPARAM)wchFindLong);
// TODO: replace Format by corresponding RegEx Pattern
//StringCchCopy(wchFindLong, COUNTOF(wchFindLong), wchTempBuf);
}
if (StrIsEmpty(wchFindShort))
{
_DateFmtIdx = 0; // Settings2.DateFormatShort;
EnumDateFormatsExEx(_GetDateFormatProc, Settings2.PreferredLanguageLocaleName, DATE_SHORTDATE, (LPARAM)wchFindShort);
// TODO: replace Format by corresponding RegEx Pattern
//StringCchCopy(wchFindShort, COUNTOF(wchFindShort), wchTempBuf);
}
// -----------------------------------------------
WCHAR wchReplaceLong[SMALL_BUFFER] = { L'\0' };
_GetCurrentDateTimeString(wchReplaceLong, COUNTOF(wchReplaceLong), false);
EDITFINDREPLACE efrTS_L = EFR_INIT_DATA;
efrTS_L.hwnd = Globals.hwndEdit;
efrTS_L.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchFindLong, -1, efrTS_L.szFind, COUNTOF(efrTS_L.szFind), NULL, NULL);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchReplaceLong, -1, efrTS_L.szReplace, COUNTOF(efrTS_L.szReplace), NULL, NULL);
if (!SciCall_IsSelectionEmpty())
{
EditReplaceAllInSelection(Globals.hwndEdit, &efrTS_L, true);
}
else {
EditReplaceAll(Globals.hwndEdit, &efrTS_L, true);
}
// -----------------------------------------------
WCHAR wchReplaceShort[SMALL_BUFFER] = { L'\0' };
_GetCurrentDateTimeString(wchReplaceLong, COUNTOF(wchReplaceLong), true);
EDITFINDREPLACE efrTS_S = EFR_INIT_DATA;
efrTS_S.hwnd = Globals.hwndEdit;
efrTS_S.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchFindShort, -1, efrTS_S.szFind, COUNTOF(efrTS_S.szFind), NULL, NULL);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchReplaceShort, -1, efrTS_S.szReplace, COUNTOF(efrTS_S.szReplace), NULL, NULL);
if (!SciCall_IsSelectionEmpty())
{
EditReplaceAllInSelection(Globals.hwndEdit, &efrTS_S, true);
}
else {
EditReplaceAll(Globals.hwndEdit, &efrTS_S, true);
}
}
//=============================================================================
//
// EditTabsToSpaces()

View File

@ -53,7 +53,9 @@ void EditChar2Hex(HWND hwnd);
void EditHex2Char(HWND hwnd);
void EditFindMatchingBrace();
void EditSelectToMatchingBrace();
void EditModifyNumber(HWND hwnd,bool);
void EditModifyNumber(HWND hwnd, bool bIncrease);
void EditUpdateTimestamps();
void EditInsertTimestamps(bool bShortFmt);
void EditTabsToSpaces(int nTabWidth,bool);
void EditSpacesToTabs(int nTabWidth,bool);

View File

@ -26,7 +26,6 @@
#include <string.h>
//#include <pathcch.h>
//#include <locale.h>
#include <time.h>
#include "Edit.h"
#include "Styles.h"
@ -982,7 +981,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
SetTimer(hwnd, IDT_TIMER_MRKALL, USER_TIMER_MINIMUM, (TIMERPROC)MQ_ExecuteNext);
if (Globals.bPrefLngNotAvail) {
InfoBoxLng(MB_ICONWARNING, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, Globals.InitialPreferredLanguage);
InfoBoxLng(MB_ICONWARNING, L"MsgPrefLanguageNotAvailable", IDS_WARN_PREF_LNG_NOT_AVAIL, Settings2.PreferredLanguageLocaleName);
}
MSG msg;
@ -4441,49 +4440,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_EDIT_INSERT_SHORTDATE:
case IDM_EDIT_INSERT_LONGDATE:
{
//~~~_BEGIN_UNDO_ACTION_;
WCHAR tchDateTime[128] = { L'\0' };
WCHAR tchTemplate[128] = { L'\0' };
SYSTEMTIME st;
//int iSelStart;
GetLocalTime(&st);
StringCchCopyW(tchTemplate, COUNTOF(tchTemplate),
(iLoWParam == IDM_EDIT_INSERT_SHORTDATE) ? Settings2.DateTimeShort : Settings2.DateTimeLong);
if (StringCchLenW(tchTemplate,0) > 0)
{
struct tm sst;
sst.tm_isdst = -1;
sst.tm_sec = (int)st.wSecond;
sst.tm_min = (int)st.wMinute;
sst.tm_hour = (int)st.wHour;
sst.tm_mday = (int)st.wDay;
sst.tm_mon = (int)st.wMonth - 1;
sst.tm_year = (int)st.wYear - 1900;
sst.tm_wday = (int)st.wDayOfWeek;
mktime(&sst);
wcsftime(tchDateTime,COUNTOF(tchDateTime),tchTemplate,&sst);
}
else {
WCHAR tchDate[64] = { L'\0' };
WCHAR tchTime[64] = { L'\0' };
GetDateFormat(LOCALE_USER_DEFAULT,(
iLoWParam == IDM_EDIT_INSERT_SHORTDATE) ? DATE_SHORTDATE : DATE_LONGDATE,
&st,NULL,tchDate,COUNTOF(tchDate));
GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,tchTime,COUNTOF(tchTime));
StringCchPrintf(tchDateTime,COUNTOF(tchDateTime),L"%s %s",tchTime,tchDate);
}
char chDateTime[128] = { '\0' };
WideCharToMultiByteEx(Encoding_SciCP,0,tchDateTime,-1,chDateTime,COUNTOF(chDateTime),NULL,NULL);
EditReplaceSelection(chDateTime, false);
//~~~_END_UNDO_ACTION_;
}
EditInsertTimestamps((iLoWParam == IDM_EDIT_INSERT_SHORTDATE));
break;
@ -5853,54 +5810,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case CMD_TIMESTAMPS:
{
WCHAR wchFind[128] = { L'\0' };
WCHAR wchTemplate[128] = { L'\0' };
WCHAR wchReplace[128] = { L'\0' };
SYSTEMTIME st;
struct tm sst;
EDITFINDREPLACE efrTS = EFR_INIT_DATA;
efrTS.hwnd = Globals.hwndEdit;
efrTS.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX);
StringCchCopyW(wchFind, COUNTOF(wchFind), Settings2.TimeStamp);
WCHAR *pwchSep = StrChr(wchFind, L'|');
if (pwchSep) {
StringCchCopy(wchTemplate,COUNTOF(wchTemplate),pwchSep + 1);
*pwchSep = 0;
}
StrTrim(wchFind,L" ");
StrTrim(wchTemplate,L" ");
if (StringCchLenW(wchFind,COUNTOF(wchFind)) == 0 || StringCchLenW(wchTemplate,COUNTOF(wchTemplate)) == 0)
break;
GetLocalTime(&st);
sst.tm_isdst = -1;
sst.tm_sec = (int)st.wSecond;
sst.tm_min = (int)st.wMinute;
sst.tm_hour = (int)st.wHour;
sst.tm_mday = (int)st.wDay;
sst.tm_mon = (int)st.wMonth - 1;
sst.tm_year = (int)st.wYear - 1900;
sst.tm_wday = (int)st.wDayOfWeek;
mktime(&sst);
wcsftime(wchReplace,COUNTOF(wchReplace),wchTemplate,&sst);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchFind, -1, efrTS.szFind,COUNTOF(efrTS.szFind),NULL,NULL);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchReplace, -1, efrTS.szReplace, COUNTOF(efrTS.szReplace), NULL, NULL);
if (!SciCall_IsSelectionEmpty()) {
EditReplaceAllInSelection(Globals.hwndEdit, &efrTS, true);
}
else {
EditReplaceAll(Globals.hwndEdit, &efrTS, true);
}
}
EditUpdateTimestamps();
break;

View File

@ -356,7 +356,6 @@ typedef struct _globals_t
unsigned idxSelectedTheme;
WCHAR SelectedThemeName[128];
WCHAR InitialPreferredLanguage[LOCALE_NAME_MAX_LENGTH + 1];
FR_STATES FindReplaceMatchFoundState;
@ -555,9 +554,14 @@ typedef struct _settings2_t
WCHAR LineCommentPostfixStrg[64];
WCHAR ExtendedWhiteSpaceChars[ANSI_CHAR_BUFFER + 1];
WCHAR AutoCompleteWordCharSet[ANSI_CHAR_BUFFER + 1];
WCHAR TimeStamp[128];
//int DateFormatLong;
//int DateFormatShort;
WCHAR DateTimeShort[128];
WCHAR TimeStampRegExShort[256];
WCHAR DateTimeLong[128];
WCHAR TimeStampRegExLong[256];
WCHAR WebTemplate1[MAX_PATH];
WCHAR WebTemplate2[MAX_PATH];
WCHAR AdministrationTool[MAX_PATH];

View File

@ -9,7 +9,7 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
#define VERSION_REV 321
#define VERSION_BUILD 1
#define VERSION_BUILD 2
#define SCINTILLA_VER 432
#define ONIGURUMA_REGEX_VER 6.9.4
#define UCHARDET_VER 2018.09.27