Compare commits

..

No commits in common. "master" and "v8.8.4" have entirely different histories.

46 changed files with 287 additions and 1023 deletions

View File

@ -1,8 +1,3 @@
Notepad++ v8.8.5 regression-fix:
1. Fix "Edit with Notepad++" context menu not being installed correctly regression.
Notepad++ v8.8.4 vulnerability-fixes, bug-fixes & new enhancement: Notepad++ v8.8.4 vulnerability-fixes, bug-fixes & new enhancement:
1. Fix -notabbar & asNotepad.xml stop hiding tabbar regression (from v8.7.9). 1. Fix -notabbar & asNotepad.xml stop hiding tabbar regression (from v8.7.9).
@ -19,7 +14,7 @@ Notepad++ v8.8.4 vulnerability-fixes, bug-fixes & new enhancement:
Get more info on Get more info on
https://notepad-plus-plus.org/downloads/v8.8.5/ https://notepad-plus-plus.org/downloads/v8.8.4/
Included plugins: Included plugins:

View File

@ -1,6 +1,6 @@
echo off echo off
rem This file is part of Notepad++ project rem This file is part of Notepad++ project
rem Copyright (C)2025 Don HO <don.h@free.fr> rem Copyright (C)2021 Don HO <don.h@free.fr>
rem rem
rem This program is free software: you can redistribute it and/or modify rem This program is free software: you can redistribute it and/or modify
rem it under the terms of the GNU General Public License as published by rem it under the terms of the GNU General Public License as published by
@ -34,18 +34,18 @@ If ErrorLevel 1 goto End
%signBinary% ..\binarm64\notepad++.exe %signBinary% ..\binarm64\notepad++.exe
If ErrorLevel 1 goto End If ErrorLevel 1 goto End
REM %signBinarySha256% ..\bin\NppShell.x86.dll %signBinarySha256% ..\bin\NppShell.x86.dll
REM If ErrorLevel 1 goto End If ErrorLevel 1 goto End
REM
REM %signBinarySha256% ..\bin64\NppShell.msix %signBinarySha256% ..\bin64\NppShell.msix
REM If ErrorLevel 1 goto End If ErrorLevel 1 goto End
REM %signBinarySha256% ..\bin64\NppShell.x64.dll %signBinarySha256% ..\bin64\NppShell.x64.dll
REM If ErrorLevel 1 goto End If ErrorLevel 1 goto End
REM
REM %signBinarySha256% ..\binarm64\NppShell.msix %signBinarySha256% ..\binarm64\NppShell.msix
REM If ErrorLevel 1 goto End If ErrorLevel 1 goto End
REM %signBinarySha256% ..\binarm64\NppShell.arm64.dll %signBinarySha256% ..\binarm64\NppShell.arm64.dll
REM If ErrorLevel 1 goto End If ErrorLevel 1 goto End
%signBinary% ..\bin\plugins\Config\nppPluginList.dll %signBinary% ..\bin\plugins\Config\nppPluginList.dll
If ErrorLevel 1 goto End If ErrorLevel 1 goto End

View File

@ -1053,7 +1053,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="37A8ED" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="37A8ED" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="37A8ED" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="37A8ED" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="E5C138" bgColor="4C4A41" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="E5C138" bgColor="4C4A41" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="4C4A41" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="4C4A41" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="4C4A41" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="4C4A41" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1094,6 +1094,6 @@ Credits:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="BDAE9D" bgColor="2A211C" /> <WidgetStyle name="Document map" styleID="0" fgColor="BDAE9D" bgColor="2A211C" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="BDAE9D" bgColor="2A211C" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="BDAE9D" bgColor="2A211C" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1043,7 +1043,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1084,6 +1084,6 @@ Credits:
<WidgetStyle name="URL hovered" styleID="0" fgColor="BDAE9D" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="BDAE9D" />
<WidgetStyle name="Document map" styleID="0" fgColor="F8F8F8" bgColor="0C1021" /> <WidgetStyle name="Document map" styleID="0" fgColor="F8F8F8" bgColor="0C1021" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="F8F8F8" bgColor="0C1021" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="F8F8F8" bgColor="0C1021" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1043,7 +1043,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1084,6 +1084,6 @@ Credits:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="C3BE98" bgColor="1A0F0B" /> <WidgetStyle name="Document map" styleID="0" fgColor="C3BE98" bgColor="1A0F0B" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="C3BE98" bgColor="1A0F0B" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="C3BE98" bgColor="1A0F0B" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1162,7 +1162,7 @@ Installation : Copy this file to "%APPDATA%\Notepad++\themes" and in a portable
<WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="8F8F8F" bgColor="363636" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="8F8F8F" bgColor="363636" fontName="" fontStyle="0" fontSize="9" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="363636" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="363636" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="363636" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="363636" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1203,6 +1203,6 @@ Installation : Copy this file to "%APPDATA%\Notepad++\themes" and in a portable
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="C7C7C7" bgColor="2E2E2E" /> <WidgetStyle name="Document map" styleID="0" fgColor="C7C7C7" bgColor="2E2E2E" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="C7C7C7" bgColor="2E2E2E" fontName="Source Code Pro" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="C7C7C7" bgColor="2E2E2E" fontName="Source Code Pro" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1822,6 +1822,6 @@ License: GPL2
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFFFFF" /> <WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFFFFF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Non-printing characters custom color" styleID="0" fgColor="5F5F5F" /> <WidgetStyle name="Non-printing characters custom color" styleID="0" fgColor="5F5F5F" />
<WidgetStyle name="Global override" styleID="0" fgColor="DCDCCC" bgColor="3F3F3F" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="DCDCCC" bgColor="3F3F3F" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1038,7 +1038,7 @@ https://notepad-plus-plus.org/donate/
</LexerStyles> </LexerStyles>
<GlobalStyles> <GlobalStyles>
<!-- Attention : Don't modify the name of styleID="0" --> <!-- Attention : Don't modify the name of styleID="0" -->
<WidgetStyle name="Default Style" styleID="32" fgColor="FFFFFF" bgColor="000000" fontName="Courier New" fontStyle="0" fontSize="10" /> <WidgetStyle name="Default Style" styleID="32" fgColor="FFFFFF" bgColor="000000" fontName="Courier New" fontStyle="0" fontSize="9" />
<WidgetStyle name="Indent guideline style" styleID="37" fgColor="C0C0C0" bgColor="000000" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Indent guideline style" styleID="37" fgColor="C0C0C0" bgColor="000000" fontName="" fontStyle="0" fontSize="" />
<WidgetStyle name="Brace highlight style" styleID="34" fgColor="00FF00" bgColor="000000" fontName="" fontStyle="1" fontSize="" /> <WidgetStyle name="Brace highlight style" styleID="34" fgColor="00FF00" bgColor="000000" fontName="" fontStyle="1" fontSize="" />
<WidgetStyle name="Bad brace colour" styleID="35" fgColor="FF0000" bgColor="000000" fontName="" fontStyle="1" fontSize="" /> <WidgetStyle name="Bad brace colour" styleID="35" fgColor="FF0000" bgColor="000000" fontName="" fontStyle="1" fontSize="" />
@ -1091,6 +1091,6 @@ https://notepad-plus-plus.org/donate/
<WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" /> <WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Non-printing characters custom color" styleID="0" fgColor="FF8080" /> <WidgetStyle name="Non-printing characters custom color" styleID="0" fgColor="FF8080" />
<WidgetStyle name="Global override" styleID="0" fgColor="FFFFFF" bgColor="000000" fontName="Courier New" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="FFFFFF" bgColor="000000" fontName="Courier New" fontStyle="0" fontSize="9" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1062,6 +1062,6 @@ so your enhanced file can be included in Notepad++ future release.
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFB0FF" /> <WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFB0FF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FFB0FF" fontName="Courier New" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FFB0FF" fontName="Courier New" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1219,6 +1219,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="B7975D" bgColor="2B0F01" /> <WidgetStyle name="Document map" styleID="0" fgColor="B7975D" bgColor="2B0F01" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="B7975D" bgColor="2B0F01" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="B7975D" bgColor="2B0F01" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1048,7 +1048,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1089,6 +1089,6 @@ Credits:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="FFFFFF" bgColor="222C28" /> <WidgetStyle name="Document map" styleID="0" fgColor="FFFFFF" bgColor="222C28" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="FFFFFF" bgColor="222C28" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="FFFFFF" bgColor="222C28" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1064,7 +1064,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="F8F8F0" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="F8F8F0" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="F8F8F0" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="F8F8F0" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1105,6 +1105,6 @@ Credits:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="F8F8F2" bgColor="272822" /> <WidgetStyle name="Document map" styleID="0" fgColor="F8F8F2" bgColor="272822" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="F8F8F2" bgColor="272822" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="F8F8F2" bgColor="272822" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1219,6 +1219,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="F2C476" bgColor="58693D" /> <WidgetStyle name="Document map" styleID="0" fgColor="F2C476" bgColor="58693D" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="F2C476" bgColor="58693D" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="F2C476" bgColor="58693D" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1216,6 +1216,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="BA9C80" /> <WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="BA9C80" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="000000" bgColor="BA9C80" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="000000" bgColor="BA9C80" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1121,6 +1121,6 @@ Notepad++ Custom Style
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="E0E2E4" bgColor="293134" /> <WidgetStyle name="Document map" styleID="0" fgColor="E0E2E4" bgColor="293134" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="E0E2E4" bgColor="293134" fontName="Courier New" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="E0E2E4" bgColor="293134" fontName="Courier New" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1060,7 +1060,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="8BA7A7" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="8BA7A7" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="8BA7A7" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="8BA7A7" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1101,6 +1101,6 @@ Credits:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="F8F8F8" bgColor="0B161D" /> <WidgetStyle name="Document map" styleID="0" fgColor="F8F8F8" bgColor="0B161D" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="F8F8F8" bgColor="0B161D" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="F8F8F8" bgColor="0B161D" fontName="DejaVu Sans Mono" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -899,7 +899,7 @@ http://sourceforge.net/donate/index.php?group_id=95717
<WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="FFFFFF" bgColor="1F4661" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="FFFFFF" bgColor="1F4661" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="1F4661" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="1F4661" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="1F4661" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="1F4661" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -940,6 +940,6 @@ http://sourceforge.net/donate/index.php?group_id=95717
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="FFFFFF" bgColor="112435" /> <WidgetStyle name="Document map" styleID="0" fgColor="FFFFFF" bgColor="112435" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FF8000" fontName="Courier New" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FF8000" fontName="Courier New" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1227,6 +1227,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="808040" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="808040" />
<WidgetStyle name="Document map" styleID="0" fgColor="657B83" bgColor="FDF6E3" /> <WidgetStyle name="Document map" styleID="0" fgColor="657B83" bgColor="FDF6E3" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="657B83" bgColor="FDF6E3" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="657B83" bgColor="FDF6E3" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1619,6 +1619,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="839496" bgColor="002B36" /> <WidgetStyle name="Document map" styleID="0" fgColor="839496" bgColor="002B36" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="839496" bgColor="002B36" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="839496" bgColor="002B36" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1049,7 +1049,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" /> <WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" /> <WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" />
<WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" /> <WidgetStyle name="Edge colour" styleID="0" fgColor="EEEEEC" />
<WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Line number margin" styleID="33" fgColor="EEEEEC" bgColor="2E3436" fontName="" fontStyle="0" fontSize="8" />
<WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Bookmark margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" /> <WidgetStyle name="Change History margin" styleID="0" bgColor="2E3436" />
<WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" /> <WidgetStyle name="Change History modified" styleID="0" fgColor="FF8000" bgColor="FF8000" />
@ -1090,6 +1090,6 @@ Credits:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="F8F8F8" bgColor="141414" /> <WidgetStyle name="Document map" styleID="0" fgColor="F8F8F8" bgColor="141414" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="F8F8F8" bgColor="141414" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="F8F8F8" bgColor="141414" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1060,6 +1060,6 @@ http://sourceforge.net/donate/index.php?group_id=95717
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="FFFFFF" bgColor="000000" /> <WidgetStyle name="Document map" styleID="0" fgColor="FFFFFF" bgColor="000000" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FF8000" fontName="Courier New" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FF8000" fontName="Courier New" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1789,6 +1789,6 @@ License: GPL2
<WidgetStyle name="URL hovered" styleID="0" fgColor="A3DCA3" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="A3DCA3" />
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFFFFF" /> <WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFFFFF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="DCDCCC" bgColor="3F3F3F" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="DCDCCC" bgColor="3F3F3F" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -1216,6 +1216,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="808040" /> <WidgetStyle name="URL hovered" styleID="0" fgColor="808040" />
<WidgetStyle name="Document map" styleID="0" fgColor="5F5F00" bgColor="D7D7AF" /> <WidgetStyle name="Document map" styleID="0" fgColor="5F5F00" bgColor="D7D7AF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<WidgetStyle name="Global override" styleID="0" fgColor="5F5F00" bgColor="D7D7AF" fontName="Consolas" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="5F5F00" bgColor="D7D7AF" fontName="Consolas" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -955,29 +955,6 @@ bool str2Clipboard(const wstring &str2cpy, HWND hwnd)
return true; return true;
} }
std::wstring strFromClipboard()
{
std::wstring clipboardText;
if (::OpenClipboard(NULL))
{
if (::IsClipboardFormatAvailable(CF_UNICODETEXT))
{
HANDLE hClipboardData = ::GetClipboardData(CF_UNICODETEXT);
if (hClipboardData)
{
wchar_t* pWc = static_cast<wchar_t*>(::GlobalLock(hClipboardData));
if (pWc)
{
clipboardText = pWc;
::GlobalUnlock(hClipboardData);
}
}
}
::CloseClipboard();
}
return clipboardText;
}
bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd) bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd)
{ {
const wstring crlf = L"\r\n"; const wstring crlf = L"\r\n";
@ -1560,25 +1537,7 @@ bool toggleReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath, bool& isC
} }
else else
{ {
if (::GetLastError() == ERROR_ACCESS_DENIED) // probably the ERROR_ACCESS_DENIED (5) (TODO: UAC-prompt candidate)
{
// try to set elevated
// (notepad++.exe #UAC-SETFILEATTRIBUTES# attrib_flags_number_str dest_file_path)
wstring strCmdLineParams = NPP_UAC_SETFILEATTRIBUTES_SIGN;
strCmdLineParams += L" \"" + to_wstring(dwFileAttribs) + L"\" \"";
strCmdLineParams += fileFullPath;
strCmdLineParams += L"\"";
DWORD dwNppUacOpError = invokeNppUacOp(strCmdLineParams);
if (dwNppUacOpError == NO_ERROR)
{
isChangedToReadOnly = (dwFileAttribs & FILE_ATTRIBUTE_READONLY) != 0;
return true;
}
else
{
::SetLastError(dwNppUacOpError); // set that as our current thread one for a possible reporting later
}
}
return false; return false;
} }
} }
@ -2195,40 +2154,3 @@ void ControlInfoTip::hide()
} }
#pragma warning(default:4996) #pragma warning(default:4996)
DWORD invokeNppUacOp(std::wstring& strCmdLineParams)
{
if ((strCmdLineParams.length() == 0) || (strCmdLineParams.length() > (USHRT_MAX / sizeof(WCHAR))))
{
// no cmdline or it exceeds the current max WinOS 32767 WCHARs
return ERROR_INVALID_PARAMETER;
}
wchar_t wszNppFullPath[MAX_PATH]{};
::SetLastError(NO_ERROR);
if (!::GetModuleFileName(NULL, wszNppFullPath, MAX_PATH) || (::GetLastError() == ERROR_INSUFFICIENT_BUFFER))
{
return ::GetLastError();
}
SHELLEXECUTEINFOW sei{};
sei.cbSize = sizeof(SHELLEXECUTEINFOW);
sei.lpVerb = L"runas"; // UAC prompt
sei.nShow = SW_SHOWNORMAL;
sei.fMask = SEE_MASK_NOCLOSEPROCESS; // sei.hProcess member receives the launched process handle
sei.lpFile = wszNppFullPath;
sei.lpParameters = strCmdLineParams.c_str();
if (!::ShellExecuteExW(&sei))
return ::GetLastError();
// wait for the elevated Notepad++ process to finish
DWORD dwError = NO_ERROR;
if (sei.hProcess) // beware - do not check here for the INVALID_HANDLE_VALUE (valid GetCurrentProcess() pseudohandle)
{
::WaitForSingleObject(sei.hProcess, INFINITE);
::GetExitCodeProcess(sei.hProcess, &dwError);
::CloseHandle(sei.hProcess);
}
return dwError;
}

View File

@ -169,7 +169,6 @@ std::wstring stringTakeWhileAdmissable(const std::wstring& input, const std::wst
double stodLocale(const std::wstring& str, _locale_t loc, size_t* idx = NULL); double stodLocale(const std::wstring& str, _locale_t loc, size_t* idx = NULL);
bool str2Clipboard(const std::wstring &str2cpy, HWND hwnd); bool str2Clipboard(const std::wstring &str2cpy, HWND hwnd);
std::wstring strFromClipboard();
class Buffer; class Buffer;
bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd); bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd);
@ -332,10 +331,3 @@ private:
ControlInfoTip(const ControlInfoTip&) = delete; ControlInfoTip(const ControlInfoTip&) = delete;
ControlInfoTip& operator=(const ControlInfoTip&) = delete; ControlInfoTip& operator=(const ControlInfoTip&) = delete;
}; };
#define NPP_UAC_SAVE_SIGN L"#UAC-SAVE#"
#define NPP_UAC_SETFILEATTRIBUTES_SIGN L"#UAC-SETFILEATTRIBUTES#"
#define NPP_UAC_MOVEFILE_SIGN L"#UAC-MOVEFILE#"
#define NPP_UAC_CREATEEMPTYFILE_SIGN L"#UAC-CREATEEMPTYFILE#"
DWORD invokeNppUacOp(std::wstring& strCmdLineParams);

View File

@ -54,10 +54,7 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname)
{ {
bool isFromNetwork = PathIsNetworkPath(fname); bool isFromNetwork = PathIsNetworkPath(fname);
if (isFromNetwork && isTimeoutReached) // The file doesn't exist, and the file is a network file, plus the network problem has been detected due to timeout if (isFromNetwork && isTimeoutReached) // The file doesn't exist, and the file is a network file, plus the network problem has been detected due to timeout
{ return; // In this case, we don't call createFile to prevent hanging
_dwErrorCode = ERROR_FILE_NOT_FOUND; // store
return; // In this case, we don't call createFile to prevent hanging
}
} }
_hFile = ::CreateFileW(fname, _accessParam, _shareParam, NULL, dispParam, _attribParam, NULL); _hFile = ::CreateFileW(fname, _accessParam, _shareParam, NULL, dispParam, _attribParam, NULL);
@ -71,9 +68,6 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname)
_hFile = ::CreateFileW(fname, _accessParam, _shareParam, NULL, dispParam, _attribParam, NULL); _hFile = ::CreateFileW(fname, _accessParam, _shareParam, NULL, dispParam, _attribParam, NULL);
} }
if (_hFile == INVALID_HANDLE_VALUE)
_dwErrorCode = ::GetLastError(); // store
if (fileExists && (dispParam == CREATE_ALWAYS) && (_hFile != INVALID_HANDLE_VALUE)) if (fileExists && (dispParam == CREATE_ALWAYS) && (_hFile != INVALID_HANDLE_VALUE))
{ {
// restore back the original creation date & attributes // restore back the original creation date & attributes
@ -97,7 +91,7 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname)
else else
{ {
msg += " failed to open, CreateFileW ErrorCode: "; msg += " failed to open, CreateFileW ErrorCode: ";
msg += std::to_string(_dwErrorCode); msg += std::to_string(::GetLastError());
} }
writeLog(nppIssueLog.c_str(), msg.c_str()); writeLog(nppIssueLog.c_str(), msg.c_str());
} }
@ -106,13 +100,11 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname)
void Win32_IO_File::close() void Win32_IO_File::close()
{ {
_dwErrorCode = NO_ERROR; // reset
if (isOpened()) if (isOpened())
{ {
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
DWORD flushError = NO_ERROR; DWORD flushError = NOERROR;
if (_written) if (_written)
{ {
if (!::FlushFileBuffers(_hFile)) if (!::FlushFileBuffers(_hFile))
@ -167,14 +159,7 @@ Please try using another storage and also check if your saved data is not corrup
} }
} }
} }
::CloseHandle(_hFile);
_dwErrorCode = flushError; // store possible flushing error 1st
if (!::CloseHandle(_hFile))
{
if (!flushError)
_dwErrorCode = ::GetLastError(); // store
}
_hFile = INVALID_HANDLE_VALUE; _hFile = INVALID_HANDLE_VALUE;
@ -209,8 +194,6 @@ Please try using another storage and also check if your saved data is not corrup
bool Win32_IO_File::write(const void *wbuf, size_t buf_size) bool Win32_IO_File::write(const void *wbuf, size_t buf_size)
{ {
_dwErrorCode = NO_ERROR; // reset
if (!isOpened() || (wbuf == nullptr)) if (!isOpened() || (wbuf == nullptr))
return false; return false;
@ -220,7 +203,6 @@ bool Win32_IO_File::write(const void *wbuf, size_t buf_size)
size_t bytes_left_to_write = buf_size; size_t bytes_left_to_write = buf_size;
BOOL success = FALSE; BOOL success = FALSE;
DWORD writeError = NO_ERROR; // use also a local var here to be 100% thread-safe
do do
{ {
@ -237,10 +219,6 @@ bool Win32_IO_File::write(const void *wbuf, size_t buf_size)
bytes_left_to_write -= static_cast<size_t>(bytes_written); bytes_left_to_write -= static_cast<size_t>(bytes_written);
total_bytes_written += static_cast<size_t>(bytes_written); total_bytes_written += static_cast<size_t>(bytes_written);
} }
else
{
writeError = ::GetLastError();
}
} while (success && bytes_left_to_write); } while (success && bytes_left_to_write);
NppParameters& nppParam = NppParameters::getInstance(); NppParameters& nppParam = NppParameters::getInstance();
@ -256,11 +234,11 @@ bool Win32_IO_File::write(const void *wbuf, size_t buf_size)
std::string msg = _path; std::string msg = _path;
msg += " written failed: "; msg += " written failed: ";
std::wstring lastErrorMsg = GetLastErrorAsString(writeError); std::wstring lastErrorMsg = GetLastErrorAsString(::GetLastError());
msg += wstring2string(lastErrorMsg, CP_UTF8); msg += wstring2string(lastErrorMsg, CP_UTF8);
writeLog(nppIssueLog.c_str(), msg.c_str()); writeLog(nppIssueLog.c_str(), msg.c_str());
} }
_dwErrorCode = writeError; // store
return false; return false;
} }
else else

View File

@ -48,10 +48,6 @@ public:
return write(str.c_str(), str.length()); return write(str.c_str(), str.length());
}; };
DWORD getLastErrorCode() {
return _dwErrorCode;
};
private: private:
HANDLE _hFile {INVALID_HANDLE_VALUE}; HANDLE _hFile {INVALID_HANDLE_VALUE};
bool _written {false}; bool _written {false};
@ -60,6 +56,4 @@ private:
const DWORD _accessParam { GENERIC_READ | GENERIC_WRITE }; const DWORD _accessParam { GENERIC_READ | GENERIC_WRITE };
const DWORD _shareParam { FILE_SHARE_READ | FILE_SHARE_WRITE }; const DWORD _shareParam { FILE_SHARE_READ | FILE_SHARE_WRITE };
const DWORD _attribParam { FILE_ATTRIBUTE_NORMAL }; const DWORD _attribParam { FILE_ATTRIBUTE_NORMAL };
DWORD _dwErrorCode{ NO_ERROR };
}; };

View File

@ -1025,20 +1025,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
// Return toolbar icon set choice as an integer value. Here are 5 possible values: // Return toolbar icon set choice as an integer value. Here are 5 possible values:
// 0 (Fluent UI: small), 1 (Fluent UI: large), 2 (Filled Fluent UI: small), 3 (Filled Fluent UI: large) and 4 (Standard icons: small). // 0 (Fluent UI: small), 1 (Fluent UI: large), 2 (Filled Fluent UI: small), 3 (Filled Fluent UI: large) and 4 (Standard icons: small).
#define NPPM_GETNPPSETTINGSDIRPATH (NPPMSG + 119) // For RUNCOMMAND_USER
// int NPPM_GETNPPSETTINGSDIRPATH(size_t strLen, wchar_t *settingsDirPath)
// Get path for the active Notepad++ settings: it will use -settingsDir path if that's defined; if not, it will use Cloud directory if that's defined;
// if not, it will use the AppData settings directory, or finally the installation path. This allows plugins to have one interface to find out
// where the active Notepad++ settings are stored, whichever location they are currently set to.
// wParam[in]: strLen - size of allocated buffer "settingsDirPath"
// lParam[out]: settingsDirPath - Users should call it with settingsDirPath be NULL to get the required number of wchar_t (not including the terminating nul character),
// allocate settingsDirPath buffer with the return value + 1, then call it again to get the path.
// Returns the number of wchar_t copied/to copy. If the return value is 0, then the "strLen" is not enough to copy the path, or the settings path could not be determined.
//
// Note: This message is for the active Notepad++ configuration location. If you are looking for the settings directory for plugins (...\Plugins\Config\),
// use NPPM_GETPLUGINSCONFIGDIR instead.
// For RUNCOMMAND_USER
#define VAR_NOT_RECOGNIZED 0 #define VAR_NOT_RECOGNIZED 0
#define FULL_CURRENT_PATH 1 #define FULL_CURRENT_PATH 1
#define CURRENT_DIRECTORY 2 #define CURRENT_DIRECTORY 2

View File

@ -3218,23 +3218,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return settingsOnCloudPath.length(); return settingsOnCloudPath.length();
} }
case NPPM_GETNPPSETTINGSDIRPATH:
{
// get the path (-settingsDir, Cloud directory, AppData or NppDir selection handled by _userPath, returned by .getUserPath())
wstring settingsDirPath = nppParam.getUserPath();
// if the LPARAM is a big enough non-null pointer, populate that memory with the path string
if (lParam != 0)
{
if (settingsDirPath.length() >= static_cast<size_t>(wParam))
return 0;
lstrcpy(reinterpret_cast<wchar_t*>(lParam), settingsDirPath.c_str());
}
// the message returns the string length
return settingsDirPath.length();
}
case NPPM_SETLINENUMBERWIDTHMODE: case NPPM_SETLINENUMBERWIDTHMODE:
{ {
if (lParam != LINENUMWIDTH_DYNAMIC && lParam != LINENUMWIDTH_CONSTANT) if (lParam != LINENUMWIDTH_DYNAMIC && lParam != LINENUMWIDTH_CONSTANT)

View File

@ -683,11 +683,8 @@ bool Notepad_plus::doSave(BufferID id, const wchar_t * filename, bool isCopy)
} }
else if (res == SavingStatus::SaveWritingFailed) else if (res == SavingStatus::SaveWritingFailed)
{ {
if (!(NppParameters::getInstance()).isEndSessionCritical()) // can we report to the user? wstring errorMessage = GetLastErrorAsString(GetLastError());
{ ::MessageBox(_pPublicInterface->getHSelf(), errorMessage.c_str(), L"Save failed", MB_OK | MB_ICONWARNING);
wstring errorMessage = GetLastErrorAsString(::GetLastError());
::MessageBox(_pPublicInterface->getHSelf(), errorMessage.c_str(), L"Save failed", MB_OK | MB_ICONWARNING);
}
} }
else if (res == SavingStatus::SaveOpenFailed) else if (res == SavingStatus::SaveOpenFailed)
{ {

View File

@ -2649,15 +2649,13 @@ void NppParameters::feedColumnEditorParameters(TiXmlNode *node)
if (strVal) if (strVal)
{ {
if (lstrcmp(strVal, L"hex") == 0) if (lstrcmp(strVal, L"hex") == 0)
_columnEditParam._formatChoice = BASE_16; _columnEditParam._formatChoice = 1;
else if (lstrcmp(strVal, L"hexuc") == 0)
_columnEditParam._formatChoice = BASE_16_UPPERCASE;
else if (lstrcmp(strVal, L"oct") == 0) else if (lstrcmp(strVal, L"oct") == 0)
_columnEditParam._formatChoice = BASE_08; _columnEditParam._formatChoice = 2;
else if (lstrcmp(strVal, L"bin") == 0) else if (lstrcmp(strVal, L"bin") == 0)
_columnEditParam._formatChoice = BASE_02; _columnEditParam._formatChoice = 3;
else // "dec" else // "dec"
_columnEditParam._formatChoice = BASE_10; _columnEditParam._formatChoice = 0;
} }
strVal = (childNode->ToElement())->Attribute(L"leadingChoice"); strVal = (childNode->ToElement())->Attribute(L"leadingChoice");
@ -4372,13 +4370,11 @@ bool NppParameters::writeColumnEditorSettings() const
(numberNode.ToElement())->SetAttribute(L"increase", _columnEditParam._increaseNum); (numberNode.ToElement())->SetAttribute(L"increase", _columnEditParam._increaseNum);
(numberNode.ToElement())->SetAttribute(L"repeat", _columnEditParam._repeatNum); (numberNode.ToElement())->SetAttribute(L"repeat", _columnEditParam._repeatNum);
wstring format = L"dec"; wstring format = L"dec";
if (_columnEditParam._formatChoice == BASE_16) if (_columnEditParam._formatChoice == 1)
format = L"hex"; format = L"hex";
else if (_columnEditParam._formatChoice == BASE_16_UPPERCASE) else if (_columnEditParam._formatChoice == 2)
format = L"hexuc";
else if (_columnEditParam._formatChoice == BASE_08)
format = L"oct"; format = L"oct";
else if (_columnEditParam._formatChoice == BASE_02) else if (_columnEditParam._formatChoice == 3)
format = L"bin"; format = L"bin";
(numberNode.ToElement())->SetAttribute(L"formatChoice", format); (numberNode.ToElement())->SetAttribute(L"formatChoice", format);
wstring leading = L"none"; wstring leading = L"none";

View File

@ -1320,7 +1320,7 @@ struct ColumnEditorParam final
int _initialNum = -1; int _initialNum = -1;
int _increaseNum = -1; int _increaseNum = -1;
int _repeatNum = -1; int _repeatNum = -1;
int _formatChoice = 0; // 0:Dec 1:Hex 2:Oct 3:Bin 4:HexUpperCase int _formatChoice = 0; // 0:Dec 1:Hex 2:Oct 3:Bin
leadingChoice _leadingChoice = noneLeading; leadingChoice _leadingChoice = noneLeading;
}; };

View File

@ -65,15 +65,6 @@ namespace // anonymous
return defvalue; // fallback unknown return defvalue; // fallback unknown
} }
// local helper to get the current system time in milliseconds since Unix epoch (January 1, 1970)
ULONGLONG GetUnixSysTimeInMilliseconds()
{
FILETIME ft;
::GetSystemTimeAsFileTime(&ft); // 100-nanosecond intervals since January 1, 1601 (UTC)
ULONGLONG ullTime = (((ULONGLONG)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
const ULONGLONG EPOCH_DIFF = 116444736000000000ULL; // difference between Jan 1, 1601 and Jan 1, 1970 in 100-ns intervals
return (ullTime - EPOCH_DIFF) / 10000; // subtract the diff and convert to milliseconds
}
} // anonymous namespace } // anonymous namespace
using namespace std; using namespace std;
@ -1079,23 +1070,21 @@ bool FileManager::reloadBufferDeferred(BufferID id)
bool FileManager::deleteFile(BufferID id) bool FileManager::deleteFile(BufferID id)
{ {
if (id == BUFFER_INVALID)
return false;
const Buffer* buf = getBufferByID(id); const Buffer* buf = getBufferByID(id);
wstring fileNamePath = buf->getFullPathName(); wstring fileNamePath = buf->getFullPathName();
if (!doesFileExist(fileNamePath.c_str()))
return false;
// Make sure to form a string with double '\0' terminator. // Make sure to form a string with double '\0' terminator.
fileNamePath.append(1, '\0'); fileNamePath.append(1, '\0');
if (!doesFileExist(fileNamePath.c_str()))
return false;
SHFILEOPSTRUCT fileOpStruct = {}; SHFILEOPSTRUCT fileOpStruct = {};
fileOpStruct.hwnd = NULL; fileOpStruct.hwnd = NULL;
fileOpStruct.pFrom = fileNamePath.c_str(); fileOpStruct.pFrom = fileNamePath.c_str();
fileOpStruct.pTo = NULL; fileOpStruct.pTo = NULL;
fileOpStruct.wFunc = FO_DELETE; fileOpStruct.wFunc = FO_DELETE;
fileOpStruct.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION; // FOF_NOCONFIRMATION - prevent possible redundant shell-dlg (Notepad++ uses its own delete-confirmation dlg) fileOpStruct.fFlags = FOF_ALLOWUNDO;
fileOpStruct.fAnyOperationsAborted = false; fileOpStruct.fAnyOperationsAborted = false;
fileOpStruct.hNameMappings = NULL; fileOpStruct.hNameMappings = NULL;
fileOpStruct.lpszProgressTitle = NULL; fileOpStruct.lpszProgressTitle = NULL;
@ -1104,30 +1093,12 @@ bool FileManager::deleteFile(BufferID id)
} }
bool FileManager::moveFile(BufferID id, const wchar_t* newFileName) bool FileManager::moveFile(BufferID id, const wchar_t * newFileName)
{ {
if (id == BUFFER_INVALID)
return false;
Buffer* buf = getBufferByID(id); Buffer* buf = getBufferByID(id);
const wchar_t* fileNamePath = buf->getFullPathName(); const wchar_t *fileNamePath = buf->getFullPathName();
if (!::MoveFileExW(fileNamePath, newFileName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH)) if (::MoveFileEx(fileNamePath, newFileName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH) == 0)
{ return false;
if (::GetLastError() != ERROR_ACCESS_DENIED)
return false;
// ERROR_ACCESS_DENIED, try to move elevated
// (notepad++.exe #UAC-MOVEFILE# original_file_path new_file_path)
wstring strCmdLineParams = NPP_UAC_MOVEFILE_SIGN;
strCmdLineParams += L" \"";
strCmdLineParams += fileNamePath;
strCmdLineParams += L"\" \"";
strCmdLineParams += newFileName;
strCmdLineParams += L"\"";
DWORD dwNppUacOpError = invokeNppUacOp(strCmdLineParams);
if (dwNppUacOpError != NO_ERROR)
return false;
}
buf->setFileName(newFileName); buf->setFileName(newFileName);
return true; return true;
@ -1352,7 +1323,7 @@ SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool
Buffer* buffer = getBufferByID(id); Buffer* buffer = getBufferByID(id);
bool isHiddenOrSys = false; bool isHiddenOrSys = false;
wchar_t fullpath[MAX_PATH]{}; wchar_t fullpath[MAX_PATH] = { 0 };
if (isWin32NamespacePrefixedFileName(filename)) if (isWin32NamespacePrefixedFileName(filename))
{ {
// use directly the raw file name, skip the GetFullPathName WINAPI // use directly the raw file name, skip the GetFullPathName WINAPI
@ -1367,7 +1338,7 @@ SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool
} }
} }
wchar_t dirDest[MAX_PATH]{}; wchar_t dirDest[MAX_PATH];
wcscpy_s(dirDest, MAX_PATH, fullpath); wcscpy_s(dirDest, MAX_PATH, fullpath);
::PathRemoveFileSpecW(dirDest); ::PathRemoveFileSpecW(dirDest);
@ -1408,137 +1379,105 @@ SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool
int encoding = buffer->getEncoding(); int encoding = buffer->getEncoding();
wstring strTempFile = L""; if (UnicodeConvertor.openFile(fullpath))
if (!UnicodeConvertor.openFile(fullpath))
{ {
if (NppParameters::getInstance().isEndSessionCritical()) _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document
return SavingStatus::SaveOpenFailed; // cannot continue to the UAC-prompt at the Windows logoff/reboot/shutdown time
if (UnicodeConvertor.getLastFileErrorState() != ERROR_ACCESS_DENIED) size_t lengthDoc = _pscratchTilla->getCurrentDocLen();
return SavingStatus::SaveOpenFailed; // cannot be solved by the UAC-prompt char* buf = (char*)_pscratchTilla->execute(SCI_GETCHARACTERPOINTER); //to get characters directly from Scintilla buffer
bool isWrittenSuccessful = false;
// ERROR_ACCESS_DENIED, swap to temporary file copy for the UAC elevation way if (encoding == -1) //no special encoding; can be handled directly by Utf8_16_Write
wchar_t wszBuf[MAX_PATH + 1]{};
if (::GetTempPath(MAX_PATH, wszBuf) == 0)
return SavingStatus::SaveOpenFailed; // cannot continue
strTempFile = wszBuf;
strTempFile += L"npp-" + std::to_wstring(GetUnixSysTimeInMilliseconds()) + L".tmp"; // make unique temporary filename
if (!UnicodeConvertor.openFile(strTempFile.c_str()))
return SavingStatus::SaveOpenFailed; // cannot continue, weird
}
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document
size_t lengthDoc = _pscratchTilla->getCurrentDocLen();
char* buf = (char*)_pscratchTilla->execute(SCI_GETCHARACTERPOINTER); //to get characters directly from Scintilla buffer
bool isWrittenSuccessful = false;
if (encoding == -1) //no special encoding; can be handled directly by Utf8_16_Write
{
isWrittenSuccessful = UnicodeConvertor.writeFile(buf, lengthDoc);
if (lengthDoc == 0)
isWrittenSuccessful = true;
}
else
{
if (lengthDoc == 0)
{ {
isWrittenSuccessful = UnicodeConvertor.writeFile(buf, 0); isWrittenSuccessful = UnicodeConvertor.writeFile(buf, lengthDoc);
if (lengthDoc == 0)
isWrittenSuccessful = true;
} }
else else
{ {
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); if (lengthDoc == 0)
size_t grabSize = 0;
for (size_t i = 0; i < lengthDoc; i += grabSize)
{ {
grabSize = lengthDoc - i; isWrittenSuccessful = UnicodeConvertor.writeFile(buf, 0);
if (grabSize > blockSize) }
grabSize = blockSize; else
{
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
size_t grabSize = 0;
for (size_t i = 0; i < lengthDoc; i += grabSize)
{
grabSize = lengthDoc - i;
if (grabSize > blockSize)
grabSize = blockSize;
int newDataLen = 0; int newDataLen = 0;
int incompleteMultibyteChar = 0; int incompleteMultibyteChar = 0;
const char* newData = wmc.encode(SC_CP_UTF8, encoding, buf + i, static_cast<int>(grabSize), &newDataLen, &incompleteMultibyteChar); const char* newData = wmc.encode(SC_CP_UTF8, encoding, buf + i, static_cast<int>(grabSize), &newDataLen, &incompleteMultibyteChar);
grabSize -= incompleteMultibyteChar; grabSize -= incompleteMultibyteChar;
isWrittenSuccessful = UnicodeConvertor.writeFile(newData, newDataLen); isWrittenSuccessful = UnicodeConvertor.writeFile(newData, newDataLen);
}
} }
} }
}
UnicodeConvertor.closeFile(); UnicodeConvertor.closeFile();
if (isHiddenOrSys && strTempFile.empty()) // Error, we didn't write the entire document to disk.
::SetFileAttributes(fullpath, attributes.dwFileAttributes); if (!isWrittenSuccessful)
// Error, we didn't write the entire document to disk.
if (!isWrittenSuccessful)
{
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
if (!strTempFile.empty())
::DeleteFileW(strTempFile.c_str());
return SavingStatus::SaveWritingFailed;
}
if (!strTempFile.empty())
{
// elevated saving/overwriting of the original file by the help of the tempfile
// (notepad++.exe #UAC-SAVE# temp_file_path dest_file_path)
wstring strCmdLineParams = NPP_UAC_SAVE_SIGN;
strCmdLineParams += L" \"" + strTempFile + L"\" \"";
strCmdLineParams += fullpath;
strCmdLineParams += L"\"";
DWORD dwNppUacOpError = invokeNppUacOp(strCmdLineParams);
if (dwNppUacOpError != NO_ERROR)
{ {
::DeleteFileW(strTempFile.c_str()); // ensure no failed op remnant _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
::SetLastError(dwNppUacOpError); // set that as our current thread one for reporting later
return SavingStatus::SaveWritingFailed; return SavingStatus::SaveWritingFailed;
} }
}
if (isCopy) // "Save a Copy As..." command if (isHiddenOrSys)
{ ::SetFileAttributes(fullpath, attributes.dwFileAttributes);
unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
_pscratchTilla->execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
_pscratchTilla->execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);
return SavingStatus::SaveOK; //all done - we don't change the current buffer's path to "fullpath", since it's "Save a Copy As..." action.
}
buffer->setFileName(fullpath); if (isCopy) // "Save a Copy As..." command
// if not a large file and language is normal text (not defined)
// we may try determine its language from its content
if (!buffer->isLargeFile() && buffer->_lang == L_TEXT)
{
LangType detectedLang = detectLanguageFromTextBeginning((unsigned char*)buf, lengthDoc);
// if a language is detected from the content
if (detectedLang != L_TEXT)
{ {
buffer->_lang = detectedLang; unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
buffer->doNotify(BufferChangeFilename | BufferChangeTimestamp | BufferChangeLanguage); _pscratchTilla->execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
_pscratchTilla->execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);
return SavingStatus::SaveOK; //all done - we don't change the current buffer's path to "fullpath", since it's "Save a Copy As..." action.
} }
buffer->setFileName(fullpath);
// if not a large file and language is normal text (not defined)
// we may try determine its language from its content
if (!buffer->isLargeFile() && buffer->_lang == L_TEXT)
{
LangType detectedLang = detectLanguageFromTextBeginning((unsigned char*)buf, lengthDoc);
// if a language is detected from the content
if (detectedLang != L_TEXT)
{
buffer->_lang = detectedLang;
buffer->doNotify(BufferChangeFilename | BufferChangeTimestamp | BufferChangeLanguage);
}
}
buffer->setDirty(false);
buffer->setUnsync(false);
buffer->setSavePointDirty(false);
buffer->setStatus(DOC_REGULAR);
buffer->checkFileState();
_pscratchTilla->execute(SCI_SETSAVEPOINT);
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
wstring backupFilePath = buffer->getBackupFileName();
if (!backupFilePath.empty())
{
// delete backup file
buffer->setBackupFileName(wstring());
::DeleteFile(backupFilePath.c_str());
}
return SavingStatus::SaveOK;
} }
buffer->setDirty(false); else
buffer->setUnsync(false);
buffer->setSavePointDirty(false);
buffer->setStatus(DOC_REGULAR);
buffer->checkFileState();
_pscratchTilla->execute(SCI_SETSAVEPOINT);
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
wstring backupFilePath = buffer->getBackupFileName();
if (!backupFilePath.empty())
{ {
// delete backup file return SavingStatus::SaveOpenFailed;
buffer->setBackupFileName(wstring());
::DeleteFile(backupFilePath.c_str());
} }
return SavingStatus::SaveOK;
} }
size_t FileManager::nextUntitledNewNumber() const size_t FileManager::nextUntitledNewNumber() const
@ -2081,26 +2020,10 @@ BufferID FileManager::getBufferFromDocument(Document doc)
} }
bool FileManager::createEmptyFile(const wchar_t* path) bool FileManager::createEmptyFile(const wchar_t * path)
{ {
Win32_IO_File file(path); Win32_IO_File file(path);
if (!file.isOpened()) return file.isOpened();
{
if (file.getLastErrorCode() != ERROR_ACCESS_DENIED)
return false;
// ERROR_ACCESS_DENIED, try the same but elevated
// (notepad++.exe #UAC-CREATEEMPTYFILE# new_empty_file_path)
wstring strCmdLineParams = NPP_UAC_CREATEEMPTYFILE_SIGN;
strCmdLineParams += L" \"";
strCmdLineParams += path;
strCmdLineParams += L"\"";
DWORD dwNppUacOpError = invokeNppUacOp(strCmdLineParams);
if (dwNppUacOpError != NO_ERROR)
return false;
}
return true;
} }

View File

@ -53,7 +53,7 @@ wstring getTextFromCombo(HWND hCombo)
auto str = std::make_unique<wchar_t[]>(strSize); auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0'); std::fill_n(str.get(), strSize, L'\0');
::SendMessage(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH, reinterpret_cast<LPARAM>(str.get())); ::SendMessage(hCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, reinterpret_cast<LPARAM>(str.get()));
return wstring(str.get()); return wstring(str.get());
} }
@ -63,7 +63,7 @@ void delLeftWordInEdit(HWND hEdit)
auto str = std::make_unique<wchar_t[]>(strSize); auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0'); std::fill_n(str.get(), strSize, L'\0');
::SendMessage(hEdit, WM_GETTEXT, FINDREPLACE_MAXLENGTH, reinterpret_cast<LPARAM>(str.get())); ::SendMessage(hEdit, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, reinterpret_cast<LPARAM>(str.get()));
WORD cursor = 0; WORD cursor = 0;
::SendMessage(hEdit, EM_GETSEL, (WPARAM)&cursor, 0); ::SendMessage(hEdit, EM_GETSEL, (WPARAM)&cursor, 0);
WORD wordstart = cursor; WORD wordstart = cursor;
@ -248,20 +248,6 @@ void Searching::displaySectionCentered(size_t posStart, size_t posEnd, Scintilla
// Adjust so that we see the entire match; primarily horizontally // Adjust so that we see the entire match; primarily horizontally
pEditView->execute(SCI_SCROLLRANGE, posStart, posEnd); pEditView->execute(SCI_SCROLLRANGE, posStart, posEnd);
// make sure won't start/end the selection in the middle of a multibyte character,
// or in between a CR/LF pair for Windows files
// (needed for stale search-results where user has made doc edits after the search)
if (posStart > 0)
{
posStart = pEditView->execute(SCI_POSITIONBEFORE, posStart);
posStart = pEditView->execute(SCI_POSITIONAFTER, posStart);
}
if (posEnd > 0)
{
posEnd = pEditView->execute(SCI_POSITIONBEFORE, posEnd);
posEnd = pEditView->execute(SCI_POSITIONAFTER, posEnd);
}
// Move cursor to end of result and select result // Move cursor to end of result and select result
pEditView->execute(SCI_GOTOPOS, posEnd); pEditView->execute(SCI_GOTOPOS, posEnd);
pEditView->execute(SCI_SETANCHOR, posStart); pEditView->execute(SCI_SETANCHOR, posStart);
@ -4919,7 +4905,7 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM
else if ((message == WM_KEYDOWN) && (wParam == VK_DOWN) && (::SendMessage(hwndCombo, CB_GETCURSEL, 0, 0) == CB_ERR)) else if ((message == WM_KEYDOWN) && (wParam == VK_DOWN) && (::SendMessage(hwndCombo, CB_GETCURSEL, 0, 0) == CB_ERR))
{ {
// down key on unselected combobox item -> store current edit text as draft // down key on unselected combobox item -> store current edit text as draft
::SendMessage(hwndCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH, reinterpret_cast<LPARAM>(draftString.get())); ::SendMessage(hwndCombo, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, reinterpret_cast<LPARAM>(draftString.get()));
} }
else if ((message == WM_KEYDOWN) && (wParam == VK_UP) && (::SendMessage(hwndCombo, CB_GETCURSEL, 0, 0) == CB_ERR)) else if ((message == WM_KEYDOWN) && (wParam == VK_UP) && (::SendMessage(hwndCombo, CB_GETCURSEL, 0, 0) == CB_ERR))
{ {
@ -4931,54 +4917,11 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM
{ {
// up key on top selected combobox item -> restore draft to edit text // up key on top selected combobox item -> restore draft to edit text
::SendMessage(hwndCombo, CB_SETCURSEL, WPARAM(-1), 0); ::SendMessage(hwndCombo, CB_SETCURSEL, WPARAM(-1), 0);
::SendMessage(hwndCombo, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(draftString.get())); ::SendMessage(hwndCombo, WM_SETTEXT, FINDREPLACE_MAXLENGTH - 1, reinterpret_cast<LPARAM>(draftString.get()));
::SendMessage(hwndCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); ::SendMessage(hwndCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1));
return 0; return 0;
} }
else if (message == WM_PASTE)
{
// needed to allow CR (i.e., multiline) into combobox text;
// (the default functionality terminates the paste at the first CR character)
HWND hParent = ::GetParent(hwndCombo);
HWND hFindWhatCombo = ::GetDlgItem(hParent, IDFINDWHAT);
HWND hReplaceWithCombo = ::GetDlgItem(hParent, IDREPLACEWITH);
if ((hwndCombo == hFindWhatCombo) || (hwndCombo == hReplaceWithCombo))
{
CLIPFORMAT cfColumnSelect = static_cast<CLIPFORMAT>(::RegisterClipboardFormat(L"MSDEVColumnSelect"));
if (!::IsClipboardFormatAvailable(cfColumnSelect))
{
wstring clipboardText = strFromClipboard();
if (!clipboardText.empty())
{
wstring origText = getTextFromCombo(hwndCombo);
DWORD selStartIndex = 0;
DWORD selEndIndex = 0;
// In case there are selected text in combo box field
::SendMessage(hwndCombo, CB_GETEDITSEL, (WPARAM)&selStartIndex, (LPARAM)&selEndIndex);
wstring changedText = origText.substr(0, selStartIndex) + clipboardText + origText.substr(selEndIndex);
if (changedText.length() > FINDREPLACE_MAXLENGTH - 1)
{
changedText = changedText.substr(0, FINDREPLACE_MAXLENGTH - 1);
}
if (changedText != origText)
{
::SendMessage(hwndCombo, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(changedText.c_str()));
::SendMessage(hParent, WM_COMMAND,
MAKELPARAM(hwndCombo == hFindWhatCombo ? IDFINDWHAT : IDREPLACEWITH, CBN_EDITUPDATE),
reinterpret_cast<LPARAM>(hwndCombo));
}
}
}
return 0;
}
}
return CallWindowProc(originalComboEditProc, hwnd, message, wParam, lParam); return CallWindowProc(originalComboEditProc, hwnd, message, wParam, lParam);
} }

View File

@ -3919,19 +3919,15 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, size_t initial, siz
//Defined in ScintillaEditView.h : //Defined in ScintillaEditView.h :
//const UCHAR MASK_FORMAT = 0x03; //const UCHAR MASK_FORMAT = 0x03;
bool useUppercase = false; UCHAR f = format & MASK_FORMAT;
int base = 10; int base = 10;
if (format == BASE_16) if (f == BASE_16)
base = 16; base = 16;
else if (format == BASE_08) else if (f == BASE_08)
base = 8; base = 8;
else if (format == BASE_02) else if (f == BASE_02)
base = 2; base = 2;
else if (format == BASE_16_UPPERCASE)
{
base = 16;
useUppercase = true;
}
const int stringSize = 512; const int stringSize = 512;
char str[stringSize]; char str[stringSize];
@ -3970,7 +3966,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, size_t initial, siz
cmi[i]._selLpos += totalDiff; cmi[i]._selLpos += totalDiff;
cmi[i]._selRpos += totalDiff; cmi[i]._selRpos += totalDiff;
variedFormatNumber2String<char>(str, stringSize, numbers.at(i), base, useUppercase, kib, lead); variedFormatNumber2String<char>(str, stringSize, numbers.at(i), base, kib, lead);
const bool hasVirtualSpc = cmi[i]._nbVirtualAnchorSpc > 0; const bool hasVirtualSpc = cmi[i]._nbVirtualAnchorSpc > 0;
if (hasVirtualSpc) // if virtual space is present, then insert space if (hasVirtualSpc) // if virtual space is present, then insert space

View File

@ -109,7 +109,12 @@ enum TextCase : UCHAR
RANDOMCASE RANDOMCASE
}; };
enum : UCHAR { BASE_10 = 0, BASE_16 = 1, BASE_08 = 2, BASE_02 = 3, BASE_16_UPPERCASE = 4 }; const UCHAR MASK_FORMAT = 0x03;
const UCHAR BASE_10 = 0x00; // Dec
const UCHAR BASE_16 = 0x01; // Hex
const UCHAR BASE_08 = 0x02; // Oct
const UCHAR BASE_02 = 0x03; // Bin
const int MARK_BOOKMARK = 20; const int MARK_BOOKMARK = 20;
const int MARK_HIDELINESBEGIN = 19; const int MARK_HIDELINESBEGIN = 19;
@ -247,7 +252,7 @@ const std::vector<std::vector<const char*>> g_nonPrintingChars =
size_t getNbDigits(size_t aNum, size_t base); size_t getNbDigits(size_t aNum, size_t base);
template<typename T> template<typename T>
T* variedFormatNumber2String(T* str, size_t strLen, size_t number, size_t base, bool useUpper, size_t nbDigits, ColumnEditorParam::leadingChoice lead) T* variedFormatNumber2String(T* str, size_t strLen, size_t number, size_t base, size_t nbDigits, ColumnEditorParam::leadingChoice lead)
{ {
if (nbDigits == 0 || nbDigits >= strLen) return NULL; if (nbDigits == 0 || nbDigits >= strLen) return NULL;
@ -288,8 +293,6 @@ T* variedFormatNumber2String(T* str, size_t strLen, size_t number, size_t base,
else if (base == 16) else if (base == 16)
{ {
std::stringstream stream; std::stringstream stream;
if (useUpper)
stream << std::uppercase;
stream << std::hex << number; stream << std::hex << number;
numberStr = stream.str(); numberStr = stream.str();
} }

View File

@ -42,23 +42,21 @@ void ColumnEditorDlg::display(bool toShow) const
intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
static HBRUSH hRedBrush = nullptr;
static int whichFlashRed = 0;
constexpr COLORREF rgbRed = RGB(255, 0, 0);
static HWND hCurrentBalloonTip = nullptr;
switch (message) switch (message)
{ {
case WM_INITDIALOG : case WM_INITDIALOG :
{ {
hRedBrush = CreateSolidBrush(rgbRed); // Create red brush once
ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam; ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam;
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
::SetDlgItemText(_hSelf, IDC_COL_TEXT_EDIT, colEditParam._insertedTextContent.c_str()); ::SetDlgItemText(_hSelf, IDC_COL_TEXT_EDIT, colEditParam._insertedTextContent.c_str());
setNumericFields(colEditParam); if (colEditParam._initialNum != -1)
::SetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, colEditParam._initialNum, FALSE);
if (colEditParam._increaseNum != -1)
::SetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, colEditParam._increaseNum, FALSE);
if (colEditParam._repeatNum != -1)
::SetDlgItemInt(_hSelf, IDC_COL_REPEATNUM_EDIT, colEditParam._repeatNum, FALSE);
::SendDlgItemMessage(_hSelf, IDC_COL_LEADING_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"None")); ::SendDlgItemMessage(_hSelf, IDC_COL_LEADING_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"None"));
::SendDlgItemMessage(_hSelf, IDC_COL_LEADING_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Zeros")); ::SendDlgItemMessage(_hSelf, IDC_COL_LEADING_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"Zeros"));
@ -74,22 +72,15 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SendMessage(::GetDlgItem(_hSelf, IDC_COL_LEADING_COMBO), CB_SETCURSEL, curSel, 0); ::SendMessage(::GetDlgItem(_hSelf, IDC_COL_LEADING_COMBO), CB_SETCURSEL, curSel, 0);
int format = IDC_COL_DEC_RADIO; int format = IDC_COL_DEC_RADIO;
if ((colEditParam._formatChoice == BASE_16) || (colEditParam._formatChoice == BASE_16_UPPERCASE)) // either BASE_16 or BASE_16_UC if (colEditParam._formatChoice == 1)
format = IDC_COL_HEX_RADIO; format = IDC_COL_HEX_RADIO;
else if (colEditParam._formatChoice == BASE_08) else if (colEditParam._formatChoice == 2)
format = IDC_COL_OCT_RADIO; format = IDC_COL_OCT_RADIO;
else if (colEditParam._formatChoice == BASE_02) else if (colEditParam._formatChoice == 3)
format = IDC_COL_BIN_RADIO; format = IDC_COL_BIN_RADIO;
::SendDlgItemMessage(_hSelf, format, BM_SETCHECK, TRUE, 0); ::SendDlgItemMessage(_hSelf, format, BM_SETCHECK, TRUE, 0);
// populate the Hex-Case dropdown and activate correct case
::SendDlgItemMessage(_hSelf, IDC_COL_HEXUC_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"a-f"));
::SendDlgItemMessage(_hSelf, IDC_COL_HEXUC_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(L"A-F"));
UCHAR uc = (colEditParam._formatChoice == BASE_16_UPPERCASE) ? 1 : 0;
::SendDlgItemMessage(_hSelf, IDC_COL_HEXUC_COMBO, CB_SETCURSEL, uc, 0); // activate correct case
EnableWindow(GetDlgItem(_hSelf, IDC_COL_HEXUC_COMBO), format == IDC_COL_HEX_RADIO); // enable combobox only if hex is chosen
switchTo(colEditParam._mainChoice); switchTo(colEditParam._mainChoice);
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE); goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
@ -98,12 +89,6 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
case WM_CTLCOLOREDIT: case WM_CTLCOLOREDIT:
{ {
int id = GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
if (id == whichFlashRed)
{
SetBkColor((HDC)wParam, rgbRed);
return (LRESULT)hRedBrush;
}
return NppDarkMode::onCtlColorCtrl(reinterpret_cast<HDC>(wParam)); return NppDarkMode::onCtlColorCtrl(reinterpret_cast<HDC>(wParam));
} }
@ -167,35 +152,25 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{ {
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDCANCEL: // in case of ESC keystroke case IDCANCEL : // Close
{ display(false);
if (hCurrentBalloonTip && IsWindowVisible(hCurrentBalloonTip)) // if current baloon tip shown, just hide it
{
ShowWindow(hCurrentBalloonTip, SW_HIDE);
}
else // if current baloon tip doesn't show, we hide Column Editor dialog
{
display(false);
}
return TRUE; return TRUE;
}
case IDOK: case IDOK :
{ {
(*_ppEditView)->execute(SCI_BEGINUNDOACTION); (*_ppEditView)->execute(SCI_BEGINUNDOACTION);
constexpr int stringSize = 1024; constexpr int stringSize = 1024;
wchar_t str[stringSize]{}; wchar_t str[stringSize]{};
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0)); bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
if (isTextMode) if (isTextMode)
{ {
::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, stringSize, reinterpret_cast<LPARAM>(str)); ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, stringSize, reinterpret_cast<LPARAM>(str));
display(false); display(false);
if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1) if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1)
{ {
ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo(); ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo();
@ -213,9 +188,9 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
auto endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos); auto endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);
constexpr int lineAllocatedLen = 1024; constexpr int lineAllocatedLen = 1024;
wchar_t* line = new wchar_t[lineAllocatedLen]; wchar_t *line = new wchar_t[lineAllocatedLen];
for (size_t i = cursorLine; i <= static_cast<size_t>(endLine); ++i) for (size_t i = cursorLine ; i <= static_cast<size_t>(endLine); ++i)
{ {
auto lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i); auto lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
auto lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i); auto lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
@ -225,7 +200,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
if (lineLen > lineAllocatedLen) if (lineLen > lineAllocatedLen)
{ {
delete[] line; delete [] line;
line = new wchar_t[lineLen]; line = new wchar_t[lineLen];
} }
(*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd); (*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd);
@ -243,43 +218,19 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
auto posRelative2Start = posAbs2Start - lineBegin; auto posRelative2Start = posAbs2Start - lineBegin;
if (posRelative2Start > static_cast<long long>(s2r.length())) if (posRelative2Start > static_cast<long long>(s2r.length()))
posRelative2Start = s2r.length(); posRelative2Start = s2r.length();
s2r.insert(posRelative2Start, str); s2r.insert(posRelative2Start, str);
} }
(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd); (*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd);
} }
delete[] line; delete [] line;
} }
} }
else else
{ {
ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam; size_t initialNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, NULL, TRUE);
size_t increaseNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, NULL, TRUE);
::GetDlgItemText(_hSelf, IDC_COL_INITNUM_EDIT, str, stringSize); size_t repeat = ::GetDlgItemInt(_hSelf, IDC_COL_REPEATNUM_EDIT, NULL, TRUE);
int initialNumber = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize);
if (initialNumber == -1)
{
whichFlashRed = sendValidationErrorMessage(IDC_COL_INITNUM_EDIT, colEditParam._formatChoice, str);
return TRUE;
}
::GetDlgItemText(_hSelf, IDC_COL_INCREASENUM_EDIT, str, stringSize);
int increaseNumber = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize);
if (increaseNumber == -1)
{
whichFlashRed = sendValidationErrorMessage(IDC_COL_INCREASENUM_EDIT, colEditParam._formatChoice, str);
return TRUE;
}
::GetDlgItemText(_hSelf, IDC_COL_REPEATNUM_EDIT, str, stringSize);
int repeat = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize);
if (repeat == -1)
{
whichFlashRed = sendValidationErrorMessage(IDC_COL_REPEATNUM_EDIT, colEditParam._formatChoice, str);
return TRUE;
}
if (repeat == 0) if (repeat == 0)
{ {
repeat = 1; // Without this we might get an infinite loop while calculating the set "numbers" below. repeat = 1; // Without this we might get an infinite loop while calculating the set "numbers" below.
@ -317,7 +268,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
const size_t kiMaxSize = 1 + (size_t)endLine - (size_t)cursorLine; const size_t kiMaxSize = 1 + (size_t)endLine - (size_t)cursorLine;
while (numbers.size() < kiMaxSize) while (numbers.size() < kiMaxSize)
{ {
for (int i = 0; i < repeat; i++) for (size_t i = 0; i < repeat; i++)
{ {
numbers.push_back(curNumber); numbers.push_back(curNumber);
@ -328,21 +279,17 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
} }
constexpr int lineAllocatedLen = 1024; constexpr int lineAllocatedLen = 1024;
wchar_t* line = new wchar_t[lineAllocatedLen]; wchar_t *line = new wchar_t[lineAllocatedLen];
UCHAR f = format & MASK_FORMAT;
size_t base = 10; size_t base = 10;
bool useUppercase = false; if (f == BASE_16)
if (format == BASE_16)
base = 16; base = 16;
else if (format == BASE_08) else if (f == BASE_08)
base = 8; base = 8;
else if (format == BASE_02) else if (f == BASE_02)
base = 2; base = 2;
else if (format == BASE_16_UPPERCASE)
{
base = 16;
useUppercase = true;
}
size_t endNumber = *numbers.rbegin(); size_t endNumber = *numbers.rbegin();
size_t nbEnd = getNbDigits(endNumber, base); size_t nbEnd = getNbDigits(endNumber, base);
@ -350,7 +297,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
size_t nb = std::max<size_t>(nbInit, nbEnd); size_t nb = std::max<size_t>(nbInit, nbEnd);
for (size_t i = cursorLine; i <= size_t(endLine); ++i) for (size_t i = cursorLine ; i <= size_t(endLine) ; ++i)
{ {
auto lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i); auto lineBegin = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, i);
auto lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i); auto lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
@ -360,7 +307,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
if (lineLen > lineAllocatedLen) if (lineLen > lineAllocatedLen)
{ {
delete[] line; delete [] line;
line = new wchar_t[lineLen]; line = new wchar_t[lineLen];
} }
(*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd); (*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd);
@ -370,7 +317,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
// //
// Calcule wstring // Calcule wstring
// //
variedFormatNumber2String<wchar_t>(str, stringSize, numbers.at(i - cursorLine), base, useUppercase, nb, getLeading()); variedFormatNumber2String<wchar_t>(str, stringSize, numbers.at(i - cursorLine), base, nb, getLeading());
if (lineEndCol < cursorCol) if (lineEndCol < cursorCol)
{ {
@ -384,21 +331,21 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
auto posRelative2Start = posAbs2Start - lineBegin; auto posRelative2Start = posAbs2Start - lineBegin;
if (posRelative2Start > static_cast<long long>(s2r.length())) if (posRelative2Start > static_cast<long long>(s2r.length()))
posRelative2Start = s2r.length(); posRelative2Start = s2r.length();
s2r.insert(posRelative2Start, str); s2r.insert(posRelative2Start, str);
} }
(*_ppEditView)->replaceTarget(s2r.c_str(), int(lineBegin), int(lineEnd)); (*_ppEditView)->replaceTarget(s2r.c_str(), int(lineBegin), int(lineEnd));
} }
delete[] line; delete [] line;
} }
} }
(*_ppEditView)->execute(SCI_ENDUNDOACTION); (*_ppEditView)->execute(SCI_ENDUNDOACTION);
(*_ppEditView)->grabFocus(); (*_ppEditView)->grabFocus();
return TRUE; return TRUE;
} }
case IDC_COL_TEXT_RADIO: case IDC_COL_TEXT_RADIO :
case IDC_COL_NUM_RADIO: case IDC_COL_NUM_RADIO :
{ {
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam; ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
colEditParam._mainChoice = (wParam == IDC_COL_TEXT_RADIO) ? activeText : activeNumeric; colEditParam._mainChoice = (wParam == IDC_COL_TEXT_RADIO) ? activeText : activeNumeric;
@ -412,16 +359,13 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
case IDC_COL_BIN_RADIO: case IDC_COL_BIN_RADIO:
{ {
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam; ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
colEditParam._formatChoice = BASE_10; // dec colEditParam._formatChoice = 0; // dec
if (LOWORD(wParam) == IDC_COL_HEX_RADIO) if (wParam == IDC_COL_HEX_RADIO)
colEditParam._formatChoice = getHexCase(); // will pick appropriate UC or LC version of hex colEditParam._formatChoice = 1;
else if (LOWORD(wParam) == IDC_COL_OCT_RADIO) else if (wParam == IDC_COL_OCT_RADIO)
colEditParam._formatChoice = BASE_08; colEditParam._formatChoice = 2;
else if (LOWORD(wParam) == IDC_COL_BIN_RADIO) else if (wParam == IDC_COL_BIN_RADIO)
colEditParam._formatChoice = BASE_02; colEditParam._formatChoice = 3;
setNumericFields(colEditParam); // reformat the field text to be based on the new radix
EnableWindow(GetDlgItem(_hSelf, IDC_COL_HEXUC_COMBO), LOWORD(wParam) == IDC_COL_HEX_RADIO); // enable combobox only if hex is chosen
return TRUE; return TRUE;
} }
@ -455,14 +399,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE; return TRUE;
} }
int num = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize); int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
if (num == -1)
{
num = colEditParam._initialNum;
setNumericFields(colEditParam); // reformat the strings to eliminate error
whichFlashRed = sendValidationErrorMessage(LOWORD(wParam), colEditParam._formatChoice, str);
}
colEditParam._initialNum = num; colEditParam._initialNum = num;
return TRUE; return TRUE;
} }
@ -476,14 +413,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE; return TRUE;
} }
int num = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize); int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
if (num == -1)
{
num = colEditParam._increaseNum;
setNumericFields(colEditParam); // reformat the strings to eliminate error
whichFlashRed = sendValidationErrorMessage(LOWORD(wParam), colEditParam._formatChoice, str);
}
colEditParam._increaseNum = num; colEditParam._increaseNum = num;
return TRUE; return TRUE;
} }
@ -497,14 +427,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE; return TRUE;
} }
int num = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize); int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
if (num == -1)
{
num = colEditParam._repeatNum;
setNumericFields(colEditParam); // reformat the strings to eliminate error
whichFlashRed = sendValidationErrorMessage(LOWORD(wParam), colEditParam._formatChoice, str);
}
colEditParam._repeatNum = num; colEditParam._repeatNum = num;
return TRUE; return TRUE;
} }
@ -520,15 +443,6 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
colEditParam._leadingChoice = getLeading(); colEditParam._leadingChoice = getLeading();
return TRUE; return TRUE;
} }
else if(LOWORD(wParam) == IDC_COL_HEXUC_COMBO)
{
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
if ((colEditParam._formatChoice & BASE_16) == BASE_16 )
colEditParam._formatChoice = getHexCase();
setNumericFields(colEditParam); // want the GUI fields to update case when combobox changes
return TRUE;
}
} }
break; break;
} }
@ -538,51 +452,6 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
break; break;
} }
case WM_TIMER:
{
static int idRedraw = 0;
if (wParam == IDT_COL_FLASH_TIMER)
{
KillTimer(_hSelf, IDT_COL_FLASH_TIMER);
idRedraw = whichFlashRed; // keep the ID for the one whose flash is ending...
whichFlashRed = 0; // must be 0 before the redraw, otherwise it will maintain color
redrawDlgItem(idRedraw, true); // redraw the just the one that was flashed
// Remember the latest/current baloon tip handle
hCurrentBalloonTip = [](HWND hEditControl) -> HWND {
HWND hTooltip = FindWindowEx(NULL, NULL, L"tooltips_class32", NULL);
while (hTooltip)
{
HWND hParent = GetParent(hTooltip);
if (hParent == hEditControl || hParent == GetParent(hEditControl))
{
return hTooltip;
}
hTooltip = FindWindowEx(NULL, hTooltip, L"tooltips_class32", NULL);
}
return NULL;
}(GetDlgItem(_hSelf, idRedraw));
}
if (wParam == IDC_COL_BALLONTIP_TIMER)
{
KillTimer(_hSelf, IDC_COL_BALLONTIP_TIMER);
SendMessage(GetDlgItem(_hSelf, idRedraw), EM_HIDEBALLOONTIP, 0, 0);
}
break;
}
case WM_DESTROY:
{
DeleteObject(hRedBrush);
break;
}
default : default :
return FALSE; return FALSE;
} }
@ -623,23 +492,16 @@ void ColumnEditorDlg::switchTo(bool toText)
UCHAR ColumnEditorDlg::getFormat() UCHAR ColumnEditorDlg::getFormat()
{ {
UCHAR f = BASE_10; // Dec by default UCHAR f = 0; // Dec by default
if (isCheckedOrNot(IDC_COL_HEX_RADIO)) if (isCheckedOrNot(IDC_COL_HEX_RADIO))
f = getHexCase(); // will give BASE_16 or BASE_16_UC, depending on case selector f = 1;
else if (isCheckedOrNot(IDC_COL_OCT_RADIO)) else if (isCheckedOrNot(IDC_COL_OCT_RADIO))
f = BASE_08; f = 2;
else if (isCheckedOrNot(IDC_COL_BIN_RADIO)) else if (isCheckedOrNot(IDC_COL_BIN_RADIO))
f = BASE_02; f = 3;
return f; return f;
} }
UCHAR ColumnEditorDlg::getHexCase(void)
{
int curSel = static_cast<int>(::SendDlgItemMessage(_hSelf, IDC_COL_HEXUC_COMBO, CB_GETCURSEL, 0, 0));
return (curSel == 1) ? BASE_16_UPPERCASE : BASE_16;
}
ColumnEditorParam::leadingChoice ColumnEditorDlg::getLeading() ColumnEditorParam::leadingChoice ColumnEditorDlg::getLeading()
{ {
ColumnEditorParam::leadingChoice leading = ColumnEditorParam::noneLeading; ColumnEditorParam::leadingChoice leading = ColumnEditorParam::noneLeading;
@ -665,147 +527,3 @@ ColumnEditorParam::leadingChoice ColumnEditorDlg::getLeading()
} }
return leading; return leading;
} }
void ColumnEditorDlg::setNumericFields(const ColumnEditorParam& colEditParam)
{
if (colEditParam._formatChoice == BASE_10)
{
if (colEditParam._initialNum != -1)
::SetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, colEditParam._initialNum, FALSE);
else
::SetDlgItemText(_hSelf, IDC_COL_INITNUM_EDIT, L"");
if (colEditParam._increaseNum != -1)
::SetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, colEditParam._increaseNum, FALSE);
else
::SetDlgItemText(_hSelf, IDC_COL_INCREASENUM_EDIT, L"");
if (colEditParam._repeatNum != -1)
::SetDlgItemInt(_hSelf, IDC_COL_REPEATNUM_EDIT, colEditParam._repeatNum, FALSE);
else
::SetDlgItemText(_hSelf, IDC_COL_REPEATNUM_EDIT, L"");
}
else
{
size_t base = 10;
switch (colEditParam._formatChoice)
{
case BASE_16: // hex
case BASE_16_UPPERCASE: // or hex w/ uppercase A-F
base = 16;
break;
case BASE_08: // oct
base = 8;
break;
case BASE_02: // bin
base = 2;
break;
default:
base = 10;
break;
}
bool useUpper = (colEditParam._formatChoice == BASE_16_UPPERCASE);
constexpr int stringSize = 1024;
wchar_t str[stringSize]{};
if (colEditParam._initialNum != -1)
{
variedFormatNumber2String<wchar_t>(str, stringSize, colEditParam._initialNum, base, useUpper, getNbDigits(colEditParam._initialNum, base), getLeading());
::SetDlgItemText(_hSelf, IDC_COL_INITNUM_EDIT, str);
}
else
::SetDlgItemText(_hSelf, IDC_COL_INITNUM_EDIT, L"");
if (colEditParam._increaseNum != -1)
{
variedFormatNumber2String<wchar_t>(str, stringSize, colEditParam._increaseNum, base, useUpper, getNbDigits(colEditParam._increaseNum, base), getLeading());
::SetDlgItemText(_hSelf, IDC_COL_INCREASENUM_EDIT, str);
}
else
::SetDlgItemText(_hSelf, IDC_COL_INCREASENUM_EDIT, L"");
if (colEditParam._repeatNum != -1)
{
variedFormatNumber2String<wchar_t>(str, stringSize, colEditParam._repeatNum, base, useUpper, getNbDigits(colEditParam._repeatNum, base), getLeading());
::SetDlgItemText(_hSelf, IDC_COL_REPEATNUM_EDIT, str);
}
else
::SetDlgItemText(_hSelf, IDC_COL_REPEATNUM_EDIT, L"");
}
return;
}
// Convert the string to an integer, depending on base
int ColumnEditorDlg::getNumericFieldValueFromText(int formatChoice, wchar_t str[], size_t /*stringSize*/)
{
int num = 0;
int base = 0;
switch (formatChoice)
{
case BASE_16:
case BASE_16_UPPERCASE:
base = 16;
break;
case BASE_08:
base = 8;
break;
case BASE_02:
base = 2;
break;
default:
base = 10;
break;
}
// convert string in base to int value; on error, return -1
wchar_t* pEnd = nullptr;
num = static_cast<int>(std::wcstol(str, &pEnd, base));
if (pEnd == nullptr || *pEnd != L'\0')
{
return -1;
}
return num;
}
int ColumnEditorDlg::sendValidationErrorMessage(int whichFlashRed, int formatChoice, wchar_t str[])
{
wchar_t wcMsg[1024];
const wchar_t *wcRadixNote;
EDITBALLOONTIP ebt;
ebt.cbStruct = sizeof(EDITBALLOONTIP);
ebt.pszTitle = L"Invalid Numeric Entry";
switch (formatChoice)
{
case BASE_16:
case BASE_16_UPPERCASE:
wcRadixNote = L"Hex numbers use 0-9, A-F!";
break;
case BASE_08:
wcRadixNote = L"Oct numbers only use 0-7!";
break;
case BASE_02:
wcRadixNote = L"Bin numbers only use 0-1!";
break;
default:
wcRadixNote = L"Decimal numbers only use 0-9!";
break;
}
if (str[0])
{
swprintf_s(wcMsg, L"Entered string \"%s\":\r\n%s", str, wcRadixNote);
ebt.pszText = wcMsg;
}
ebt.ttiIcon = TTI_ERROR_LARGE; // tooltip icon
SendMessage(GetDlgItem(_hSelf, whichFlashRed), EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt);
SetTimer(_hSelf, IDT_COL_FLASH_TIMER, 250, NULL);
SetTimer(_hSelf, IDC_COL_BALLONTIP_TIMER, 3500, NULL);
redrawDlgItem(whichFlashRed);
return whichFlashRed;
}

View File

@ -45,14 +45,10 @@ public :
void switchTo(bool toText); void switchTo(bool toText);
UCHAR getFormat(); UCHAR getFormat();
ColumnEditorParam::leadingChoice getLeading(); ColumnEditorParam::leadingChoice getLeading();
UCHAR getHexCase(void);
protected : protected :
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private : private :
ScintillaEditView **_ppEditView = nullptr; ScintillaEditView **_ppEditView = nullptr;
void setNumericFields(const ColumnEditorParam& colEditParam);
int getNumericFieldValueFromText(int formatChoice, wchar_t str[], size_t stringSize);
int sendValidationErrorMessage(int whichFlashRed, int formatChoice, wchar_t str[]);
}; };

View File

@ -25,28 +25,27 @@ EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Column / Multi-Selection Editor" CAPTION "Column / Multi-Selection Editor"
FONT 8, L"MS Shell Dlg", 0, 0, 0x0 FONT 8, L"MS Shell Dlg", 0, 0, 0x0
BEGIN BEGIN
CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,6,124,10 CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,6,124,10
CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,68,204,10 CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,68,204,10
GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,8,14,124,46 GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,8,14,124,46
EDITTEXT IDC_COL_TEXT_EDIT,20,32,97,12,ES_AUTOHSCROLL EDITTEXT IDC_COL_TEXT_EDIT,20,32,97,12,ES_AUTOHSCROLL
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,16,86,188,44,BS_CENTER
CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,27,99,50,10
CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,99,50,10
CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,114,50,10
CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,110,114,50,10
COMBOBOX IDC_COL_HEXUC_COMBO,150,97,40,10,CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "",IDC_COL_NUM_GRP_STATIC,8,77,204,130 GROUPBOX "",IDC_COL_NUM_GRP_STATIC,8,77,204,130
RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,140,76,8 RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,89,76,8
EDITTEXT IDC_COL_INITNUM_EDIT,90,138,38,12 EDITTEXT IDC_COL_INITNUM_EDIT,90,87,38,12,ES_NUMBER
RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,157,75,8 RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,106,75,8
EDITTEXT IDC_COL_INCREASENUM_EDIT,90,155,38,12 EDITTEXT IDC_COL_INCREASENUM_EDIT,90,104,38,12,ES_NUMBER
RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,174,75,8 RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,123,75,8
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,172,38,12 EDITTEXT IDC_COL_REPEATNUM_EDIT,90,121,38,12,ES_NUMBER
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,191,75,8 RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,140,75,8
COMBOBOX IDC_COL_LEADING_COMBO,90,189,100,30,CBS_DROPDOWNLIST | WS_TABSTOP COMBOBOX IDC_COL_LEADING_COMBO,90,138,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,16,155,188,44,BS_CENTER
CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,168,70,10
CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,122,168,70,10
CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,183,70,10
CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,122,183,70,10
DEFPUSHBUTTON "OK",IDOK,142,18,70,14 DEFPUSHBUTTON "OK",IDOK,142,18,70,14
PUSHBUTTON "Cancel",IDCANCEL,142,36,70,14 PUSHBUTTON "Cancel",IDCANCEL,142,36,70,14

View File

@ -37,7 +37,4 @@
#define IDC_COL_REPEATNUM_EDIT (IDD_COLUMNEDIT + 17) #define IDC_COL_REPEATNUM_EDIT (IDD_COLUMNEDIT + 17)
#define IDC_COL_LEADING_STATIC (IDD_COLUMNEDIT + 18) #define IDC_COL_LEADING_STATIC (IDD_COLUMNEDIT + 18)
#define IDC_COL_LEADING_COMBO (IDD_COLUMNEDIT + 19) #define IDC_COL_LEADING_COMBO (IDD_COLUMNEDIT + 19)
#define IDC_COL_HEXUC_COMBO (IDD_COLUMNEDIT + 20)
#define IDT_COL_FLASH_TIMER (IDD_COLUMNEDIT + 21)
#define IDC_COL_BALLONTIP_TIMER (IDD_COLUMNEDIT + 22)
#endif// COLUMNEDITOR_RC_H #endif// COLUMNEDITOR_RC_H

View File

@ -292,7 +292,6 @@ Utf8_16_Write::Utf8_16_Write()
m_pNewBuf = NULL; m_pNewBuf = NULL;
m_bFirstWrite = true; m_bFirstWrite = true;
m_nBufSize = 0; m_nBufSize = 0;
m_dwLastFileError = NO_ERROR;
} }
Utf8_16_Write::~Utf8_16_Write() Utf8_16_Write::~Utf8_16_Write()
@ -302,14 +301,11 @@ Utf8_16_Write::~Utf8_16_Write()
bool Utf8_16_Write::openFile(const wchar_t *name) bool Utf8_16_Write::openFile(const wchar_t *name)
{ {
m_dwLastFileError = NO_ERROR;
m_pFile = std::make_unique<Win32_IO_File>(name); m_pFile = std::make_unique<Win32_IO_File>(name);
if (!m_pFile) if (!m_pFile)
return false; return false;
m_dwLastFileError = m_pFile->getLastErrorCode();
if (!m_pFile->isOpened()) if (!m_pFile->isOpened())
{ {
m_pFile = nullptr; m_pFile = nullptr;
@ -323,85 +319,78 @@ bool Utf8_16_Write::openFile(const wchar_t *name)
bool Utf8_16_Write::writeFile(const void* p, size_t _size) bool Utf8_16_Write::writeFile(const void* p, size_t _size)
{ {
m_dwLastFileError = NO_ERROR; // no file open
// no file open
if (!m_pFile) if (!m_pFile)
{
return false; return false;
}
if (m_bFirstWrite) if (m_bFirstWrite)
{ {
switch (m_eEncoding) switch (m_eEncoding)
{ {
case uniUTF8: case uniUTF8:
{ {
if (!m_pFile->write(k_Boms[m_eEncoding], 3)) if (!m_pFile->write(k_Boms[m_eEncoding], 3))
{
m_dwLastFileError = m_pFile->getLastErrorCode();
return false; return false;
} }
}
break; break;
case uni16BE: case uni16BE:
case uni16LE: case uni16LE:
{ {
if (!m_pFile->write(k_Boms[m_eEncoding], 2)) if (!m_pFile->write(k_Boms[m_eEncoding], 2))
{
m_dwLastFileError = m_pFile->getLastErrorCode();
return false; return false;
}
} }
break; break;
default: default:
{ {
// nothing to do // nothing to do
} }
break; break;
} }
m_bFirstWrite = false; m_bFirstWrite = false;
} }
bool isOK = false; bool isOK = false;
switch (m_eEncoding) switch (m_eEncoding)
{ {
case uni7Bit: case uni7Bit:
case uni8Bit: case uni8Bit:
case uniCookie: case uniCookie:
case uniUTF8: case uniUTF8:
{ {
// Normal write // Normal write
if (m_pFile->write(p, _size)) if (m_pFile->write(p, _size))
isOK = true; isOK = true;
m_dwLastFileError = m_pFile->getLastErrorCode();
} }
break; break;
case uni16BE_NoBOM: case uni16BE_NoBOM:
case uni16LE_NoBOM: case uni16LE_NoBOM:
case uni16BE: case uni16BE:
case uni16LE: case uni16LE:
{ {
static const unsigned int bufSize = 64 * 1024; static const unsigned int bufSize = 64*1024;
utf16* buf = new utf16[bufSize]; utf16* buf = new utf16[bufSize];
Utf8_Iter iter8; Utf8_Iter iter8;
iter8.set(static_cast<const ubyte*>(p), _size, m_eEncoding); iter8.set(static_cast<const ubyte*>(p), _size, m_eEncoding);
unsigned int bufIndex = 0; unsigned int bufIndex = 0;
while (iter8) while (iter8)
{ {
++iter8; ++iter8;
while ((bufIndex < bufSize) && iter8.canGet()) while ((bufIndex < bufSize) && iter8.canGet())
iter8.get(&buf[bufIndex++]); iter8.get(&buf [bufIndex++]);
if (bufIndex == bufSize || !iter8) if (bufIndex == bufSize || !iter8)
{ {
if (!m_pFile->write(buf, bufIndex * sizeof(utf16))) if (!m_pFile->write(buf, bufIndex * sizeof(utf16)))
{ {
m_dwLastFileError = m_pFile->getLastErrorCode();
delete[] buf; delete[] buf;
return 0; return 0;
} }
@ -410,14 +399,15 @@ bool Utf8_16_Write::writeFile(const void* p, size_t _size)
} }
isOK = true; isOK = true;
delete[] buf; delete[] buf;
}
}
break; break;
default: default:
break; break;
} }
return isOK; return isOK;
} }
@ -516,15 +506,7 @@ void Utf8_16_Write::closeFile()
} }
if (m_pFile) if (m_pFile)
{
m_pFile->close(); // explicit closing for getting the possible flushing/closing error code
m_dwLastFileError = m_pFile->getLastErrorCode();
m_pFile = nullptr; m_pFile = nullptr;
}
else
{
m_dwLastFileError = NO_ERROR;
}
} }

View File

@ -148,14 +148,11 @@ public:
size_t convert(char* p, size_t _size); size_t convert(char* p, size_t _size);
char* getNewBuf() { return reinterpret_cast<char*>(m_pNewBuf); } char* getNewBuf() { return reinterpret_cast<char*>(m_pNewBuf); }
DWORD getLastFileErrorState() { return m_dwLastFileError; }
protected: protected:
UniMode m_eEncoding; UniMode m_eEncoding;
std::unique_ptr<Win32_IO_File> m_pFile; std::unique_ptr<Win32_IO_File> m_pFile;
ubyte* m_pNewBuf; ubyte* m_pNewBuf;
size_t m_nBufSize; size_t m_nBufSize;
bool m_bFirstWrite; bool m_bFirstWrite;
DWORD m_dwLastFileError;
}; };

View File

@ -1077,7 +1077,7 @@ wstring CustomFileDialog::doSaveDlg()
CurrentDirBackup backup; CurrentDirBackup backup;
_impl->addFlags(FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM | FOS_NOTESTFILECREATE); _impl->addFlags(FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM);
bool bOk = _impl->show(); bool bOk = _impl->show();
return bOk ? _impl->getResultFilename() : L""; return bOk ? _impl->getResultFilename() : L"";
} }

View File

@ -19,14 +19,14 @@
//************ Notepad++ version ************************** //************ Notepad++ version **************************
#define NOTEPAD_PLUS_VERSION L"Notepad++ v8.8.5" #define NOTEPAD_PLUS_VERSION L"Notepad++ v8.8.4"
// should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71
// ex : #define VERSION_VALUE L"5.63\0" // ex : #define VERSION_VALUE L"5.63\0"
#define VERSION_INTERNAL_VALUE L"8.85\0" #define VERSION_INTERNAL_VALUE L"8.84\0"
#define VERSION_PRODUCT_VALUE L"8.8.5\0" #define VERSION_PRODUCT_VALUE L"8.8.4\0"
#define VERSION_DIGITALVALUE 8, 8, 5, 0 #define VERSION_DIGITALVALUE 8, 8, 4, 0
//********************************************************** //**********************************************************

View File

@ -1774,7 +1774,7 @@
<!-- Attention : Don't modify the name of styleID="0" --> <!-- Attention : Don't modify the name of styleID="0" -->
<WidgetStyle name="Default Style" styleID="32" fgColor="000000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="10" /> <WidgetStyle name="Default Style" styleID="32" fgColor="000000" bgColor="FFFFFF" fontName="Courier New" fontStyle="0" fontSize="10" />
<WidgetStyle name="Indent guideline style" styleID="37" fgColor="C0C0C0" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Indent guideline style" styleID="37" fgColor="C0C0C0" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WidgetStyle name="Brace highlight style" styleID="34" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" /> <WidgetStyle name="Brace highlight style" styleID="34" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="10" />
<WidgetStyle name="Bad brace colour" styleID="35" fgColor="800000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" /> <WidgetStyle name="Bad brace colour" styleID="35" fgColor="800000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
<WidgetStyle name="Current line background colour" styleID="0" bgColor="E8E8FF" /> <WidgetStyle name="Current line background colour" styleID="0" bgColor="E8E8FF" />
<!-- In below rule 'fgColor' attribute for 'Selected text colour' can be unlocked with a enableSelectFgColor.xml file --> <!-- In below rule 'fgColor' attribute for 'Selected text colour' can be unlocked with a enableSelectFgColor.xml file -->
@ -1825,6 +1825,6 @@
<WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" /> <WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="DADADA" /> <WidgetStyle name="EOL custom color" styleID="0" fgColor="DADADA" />
<WidgetStyle name="Non-printing characters custom color" styleID="0" fgColor="FFB56A" /> <WidgetStyle name="Non-printing characters custom color" styleID="0" fgColor="FFB56A" />
<WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FF8000" fontName="Courier New" fontStyle="0" fontSize="" /> <WidgetStyle name="Global override" styleID="0" fgColor="FFFF80" bgColor="FF8000" fontName="Courier New" fontStyle="0" fontSize="10" />
</GlobalStyles> </GlobalStyles>
</NotepadPlus> </NotepadPlus>

View File

@ -408,101 +408,6 @@ bool launchUpdater(const std::wstring& updaterFullPath, const std::wstring& upda
return true; return true;
} }
DWORD nppUacSave(const wchar_t* wszTempFilePath, const wchar_t* wszProtectedFilePath2Save)
{
if ((lstrlenW(wszTempFilePath) == 0) || (lstrlenW(wszProtectedFilePath2Save) == 0)) // safe check (lstrlen returns 0 for possible nullptr)
return ERROR_INVALID_PARAMETER;
if (!doesFileExist(wszTempFilePath))
return ERROR_FILE_NOT_FOUND;
DWORD dwRetCode = ERROR_SUCCESS;
bool isOutputReadOnly = false;
bool isOutputHidden = false;
bool isOutputSystem = false;
WIN32_FILE_ATTRIBUTE_DATA attributes{};
attributes.dwFileAttributes = INVALID_FILE_ATTRIBUTES;
if (getFileAttributesExWithTimeout(wszProtectedFilePath2Save, &attributes))
{
if (attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES && !(attributes.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
isOutputReadOnly = (attributes.dwFileAttributes & FILE_ATTRIBUTE_READONLY) != 0;
isOutputHidden = (attributes.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0;
isOutputSystem = (attributes.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) != 0;
if (isOutputReadOnly) attributes.dwFileAttributes &= ~FILE_ATTRIBUTE_READONLY;
if (isOutputHidden) attributes.dwFileAttributes &= ~FILE_ATTRIBUTE_HIDDEN;
if (isOutputSystem) attributes.dwFileAttributes &= ~FILE_ATTRIBUTE_SYSTEM;
if (isOutputReadOnly || isOutputHidden || isOutputSystem)
::SetFileAttributes(wszProtectedFilePath2Save, attributes.dwFileAttributes); // temporarily remove the problematic ones
}
}
// cannot use simple MoveFile here as it retains the tempfile permissions when on the same volume...
if (!::CopyFileW(wszTempFilePath, wszProtectedFilePath2Save, FALSE))
{
// fails if the destination file exists and has the R/O and/or Hidden attribute set
dwRetCode = ::GetLastError();
}
else
{
// ok, now dispose of the tempfile used
::DeleteFileW(wszTempFilePath);
}
// set back the possible original file attributes
if (isOutputReadOnly || isOutputHidden || isOutputSystem)
{
if (isOutputReadOnly) attributes.dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
if (isOutputHidden) attributes.dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
if (isOutputSystem) attributes.dwFileAttributes |= FILE_ATTRIBUTE_SYSTEM;
::SetFileAttributes(wszProtectedFilePath2Save, attributes.dwFileAttributes);
}
return dwRetCode;
}
DWORD nppUacSetFileAttributes(const DWORD dwFileAttribs, const wchar_t* wszFilePath)
{
if (lstrlenW(wszFilePath) == 0) // safe check (lstrlen returns 0 for possible nullptr)
return ERROR_INVALID_PARAMETER;
if (!doesFileExist(wszFilePath))
return ERROR_FILE_NOT_FOUND;
if (dwFileAttribs == INVALID_FILE_ATTRIBUTES || (dwFileAttribs & FILE_ATTRIBUTE_DIRECTORY))
return ERROR_INVALID_PARAMETER;
if (!::SetFileAttributes(wszFilePath, dwFileAttribs))
return ::GetLastError();
return ERROR_SUCCESS;
}
DWORD nppUacMoveFile(const wchar_t* wszOriginalFilePath, const wchar_t* wszNewFilePath)
{
if ((lstrlenW(wszOriginalFilePath) == 0) || (lstrlenW(wszNewFilePath) == 0)) // safe check (lstrlen returns 0 for possible nullptr)
return ERROR_INVALID_PARAMETER;
if (!doesFileExist(wszOriginalFilePath))
return ERROR_FILE_NOT_FOUND;
if (!::MoveFileEx(wszOriginalFilePath, wszNewFilePath, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH))
return ::GetLastError();
else
return ERROR_SUCCESS;
}
DWORD nppUacCreateEmptyFile(const wchar_t* wszNewEmptyFilePath)
{
if (lstrlenW(wszNewEmptyFilePath) == 0) // safe check (lstrlen returns 0 for possible nullptr)
return ERROR_INVALID_PARAMETER;
if (doesFileExist(wszNewEmptyFilePath))
return ERROR_FILE_EXISTS;
Win32_IO_File file(wszNewEmptyFilePath);
if (!file.isOpened())
return file.getLastErrorCode();
return ERROR_SUCCESS;
}
} // namespace } // namespace
@ -512,45 +417,6 @@ std::chrono::steady_clock::time_point g_nppStartTimePoint{};
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ PWSTR pCmdLine, _In_ int /*nShowCmd*/) int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ PWSTR pCmdLine, _In_ int /*nShowCmd*/)
{ {
g_nppStartTimePoint = std::chrono::steady_clock::now(); g_nppStartTimePoint = std::chrono::steady_clock::now();
// Notepad++ UAC OPS /////////////////////////////////////////////////////////////////////////////////////////////
if ((lstrlenW(pCmdLine) > 0) && (__argc >= 2)) // safe (if pCmdLine is NULL, lstrlen returns 0)
{
const wchar_t* wszNppUacOpSign = __wargv[1];
if (lstrlenW(wszNppUacOpSign) > lstrlenW(L"#UAC-#"))
{
if ((__argc == 4) && (wcscmp(wszNppUacOpSign, NPP_UAC_SAVE_SIGN) == 0))
{
// __wargv[x]: 2 ... tempFilePath, 3 ... protectedFilePath2Save
return static_cast<int>(nppUacSave(__wargv[2], __wargv[3]));
}
if ((__argc == 4) && (wcscmp(wszNppUacOpSign, NPP_UAC_SETFILEATTRIBUTES_SIGN) == 0))
{
// __wargv[x]: 2 ... dwFileAttributes (string), 3 ... filePath
try
{
return static_cast<int>(nppUacSetFileAttributes(static_cast<DWORD>(std::stoul(std::wstring(__wargv[2]))), __wargv[3]));
}
catch ([[maybe_unused]] const std::exception& e)
{
return static_cast<int>(ERROR_INVALID_PARAMETER); // conversion error (check e.what() for details)
}
}
if ((__argc == 4) && (wcscmp(wszNppUacOpSign, NPP_UAC_MOVEFILE_SIGN) == 0))
{
// __wargv[x]: 2 ... originalFilePath, 3 ... newFilePath
return static_cast<int>(nppUacMoveFile(__wargv[2], __wargv[3]));
}
if ((__argc == 3) && (wcscmp(wszNppUacOpSign, NPP_UAC_CREATEEMPTYFILE_SIGN) == 0))
{
// __wargv[x]: 2 ... newEmptyFilePath
return static_cast<int>(nppUacCreateEmptyFile(__wargv[2]));
}
}
} // Notepad++ UAC OPS////////////////////////////////////////////////////////////////////////////////////////////
bool TheFirstOne = true; bool TheFirstOne = true;
::SetLastError(NO_ERROR); ::SetLastError(NO_ERROR);