Compare commits

..

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

56 changed files with 482 additions and 1306 deletions

View File

@ -1214,7 +1214,6 @@ Translation note:
<Item id="6909" name="Select Word Under Caret when Nothing Selected"/>
<Item id="6910" name="Minimum Size for Auto-Checking &quot;In selection&quot;:"/>
<Item id="6913" name="Fill Find in Files Directory Field Based On Active Document"/>
<Item id="6916" name=": Max Characters to Auto-Fill Find Field from Selection"/>
</Searching>
<RecentFilesHistory title="Recent Files History">
@ -1866,8 +1865,7 @@ Click on &quot;?&quot; button on right to open website with User Manual."/>
<!-- Don't translate "(&quot;Non-printing characters custom color&quot;)" -->
<npcCustomColor-tip value="Go to Style Configurator to change the default custom color for selected whitespace and non-printing characters (&quot;Non-printing characters custom color&quot;)."/>
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
<searchingInSelThresh-tip value="Minimum number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is $INT_REPLACE$. Set the value to 0 to disable auto-checking."/>
<searchingFillFindWhat-tip value="Maximum number of selected characters in edit zone to fill automatically the &quot;Find what&quot; field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of &quot;Find what&quot; field, limited by the system."/>
<searchingInSelThresh-tip value="Number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is 1024. Set the value to 0 to disable auto-checking."/>
<verticalEdge-tip value="Add your column marker by indicating its position with a decimal number. You can define several column markers by using white space to separate the different numbers."/>
<fileSaveAsCopySaveButton-tip value="Hold Shift while pressing Save to open the copy after saving."/>
<autoIndentBasic-tip value="Ensure that the indentation of the current line (i.e. the new line created by pressing the ENTER key) matches the indentation of the previous line."/>
@ -1891,9 +1889,8 @@ If you select advanced mode but do not edit files in the aforementioned language
<statusbar-Sel value="Sel: "/>
<statusbar-Sel-number value="Sel"/>
<toolbar-accent-tip value="This option makes your toolbar icons follow Windows system accent color. Accent color is the highlight color used in buttons, borders, and Start menu tiles in Windows. To change it, go to Settings &gt; Personalization &gt; Colors, then select your preferred accent color."/>
<len-limit-exceeded-tip value="Length limit exceeded: Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
<max-len-on-search-tip value="Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
<max-len-on-save-tip value="The length of your input is very long and may not be saved for your next session."/>
<max-len-on-search-tip value="Only $INT_REPLACE$ characters are allowed for the find/replace text length - your input could be truncated, and it won't be saved for the next session."/>
<max-len-on-save-tip value="This search input (> $INT_REPLACE$ characters) won't be saved for the next session."/>
<goto-setting-tip value="Find your setting here"/>
</MiscStrings>
</Native-Langue>

View File

@ -1214,7 +1214,6 @@ Translation note:
<Item id="6909" name="Select Word Under Caret when Nothing Selected"/>
<Item id="6910" name="Minimum Size for Auto-Checking &quot;In selection&quot;:"/>
<Item id="6913" name="Fill Find in Files Directory Field Based On Active Document"/>
<Item id="6916" name=": Max Characters to Auto-Fill Find Field from Selection"/>
</Searching>
<RecentFilesHistory title="Recent Files History">
@ -1866,8 +1865,7 @@ Click on &quot;?&quot; button on right to open website with User Manual."/>
<!-- Don't translate "(&quot;Non-printing characters custom color&quot;)" -->
<npcCustomColor-tip value="Go to Style Configurator to change the default custom color for selected whitespace and non-printing characters (&quot;Non-printing characters custom color&quot;)."/>
<npcIncludeCcUniEol-tip value="Apply non-printing characters appearance settings to C0, C1 control and Unicode EOL (next line, line separator and paragraph separator) characters."/>
<searchingInSelThresh-tip value="Minimum number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is $INT_REPLACE$. Set the value to 0 to disable auto-checking."/>
<searchingFillFindWhat-tip value="Maximum number of selected characters in edit zone to fill automatically the &quot;Find what&quot; field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of &quot;Find what&quot; field, limited by the system."/>
<searchingInSelThresh-tip value="Number of selected characters in edit zone to automatically check the &quot;In selection&quot; checkbox when the Find dialog is activated. The maximum value is 1024. Set the value to 0 to disable auto-checking."/>
<verticalEdge-tip value="Add your column marker by indicating its position with a decimal number. You can define several column markers by using white space to separate the different numbers."/>
<fileSaveAsCopySaveButton-tip value="Hold Shift while pressing Save to open the copy after saving."/>
<autoIndentBasic-tip value="Ensure that the indentation of the current line (i.e. the new line created by pressing the ENTER key) matches the indentation of the previous line."/>
@ -1891,9 +1889,8 @@ If you select advanced mode but do not edit files in the aforementioned language
<statusbar-Sel value="Sel: "/>
<statusbar-Sel-number value="Sel"/>
<toolbar-accent-tip value="This option makes your toolbar icons follow Windows system accent color. Accent color is the highlight color used in buttons, borders, and Start menu tiles in Windows. To change it, go to Settings &gt; Personalization &gt; Colors, then select your preferred accent color."/>
<len-limit-exceeded-tip value="Length limit exceeded: Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
<max-len-on-search-tip value="Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session."/>
<max-len-on-save-tip value="The length of your input is very long and may not be saved for your next session."/>
<max-len-on-search-tip value="Only $INT_REPLACE$ characters are allowed for the find/replace text length - your input could be truncated, and it won't be saved for the next session."/>
<max-len-on-save-tip value="This search input (> $INT_REPLACE$ characters) won't be saved for the next session."/>
<goto-setting-tip value="Find your setting here"/>
</MiscStrings>
</Native-Langue>

View File

@ -1211,8 +1211,7 @@ Translation note:
<Item id="6908" name="Remplir le champ de recherche avec le texte sélectionné"/>
<Item id="6909" name="Sélectionner le mot sous le curseur si rien nest sélectionné"/>
<Item id="6910" name="Taille minimale pour lauto-coche de « Dans la sélection » :"/>
<Item id="6913" name="Remplir le champ de &quot;Dossier&quot; de &quot;Recherche dans les fichiers&quot; avec chemin du fichier actif"/>
<Item id="6916" name=" : Nombre max. de caractères sélectionnés à copier dans le champ de recherche"/>
<Item id="6913" name="Remplir le champ Répertoire de la Recherche dans les fichiers en se basant sur la document actif"/>
</Searching>
<RecentFilesHistory title="Fichiers récents">
@ -1861,8 +1860,7 @@ Cliquez sur le bouton « ? » à droite pour ouvrir le site web du manuel utilis
<!-- Don't translate "(&quot;Non-printing characters custom color&quot;)" -->
<npcCustomColor-tip value="Aller dans le Configurateur de style pour changer la couleur personnalisée par défaut pour la sélection des caractères blancs et des caractères non-imprimables (« Couleur personnalisée des caractères non-imprimables »)."/>
<npcIncludeCcUniEol-tip value="Applique les paramètres dapparence des caractères non-imprimables aux contrôles C0, C1 et aux caractères Unicode EOL (ligne suivante, séparateur de ligne et séparateur de paragraphe)."/>
<searchingInSelThresh-tip value="Nombre minimal de caractères sélectionnés dans la zone dédition pour cocher automatiquement la case « Dans sélection » quand la fenêtre de recherche est activée. La valeur maximale est $INT_REPLACE$. Mettre la valeur à 0 pour désactiver lauto-coche."/>
<searchingFillFindWhat-tip value="Nombre maximal de caractères sélectionnés dans la zone de texte à utiliser pour remplir automatiquement le champ « Rechercher » lors de l'activation de la combinaison Ctrl+F. La valeur maximale est $INT_REPLACE$, soit la taille maximale du champ « Rechercher », limitée par le système."/>
<searchingInSelThresh-tip value="Nombre de caractères sélectionnés dans la zone dédition pour cocher automatiquement la case « Dans sélection » quand la fenêtre de recherche est activée. La valeur maximale est 1024. Mettre la valeur à 0 pour désactiver lauto-coche."/>
<verticalEdge-tip value="Ajoutez votre marqueur de colonne en indiquant sa position avec un nombre entier. Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour séparer les différents nombres."/>
<fileSaveAsCopySaveButton-tip value="Maintenez Shift en appuyant sur Enregistrer pour ouvrir une copie après enregistrement."/>
<autoIndentBasic-tip value="Assurez-vous que la ligne courante (c'est-à-dire la nouvelle ligne saisie en appuyant sur ENTRÉE) a la même indentation que la ligne précédente."/>
@ -1886,9 +1884,8 @@ Si vous sélectionnez le mode avancé sans modifier les fichiers des langues men
<statusbar-Sel value="Sel : "/>
<statusbar-Sel-number value="Sel"/>
<toolbar-accent-tip value="Cette option permet aux icônes de votre barre d'outils d'adopter la couleur d'accentuation du système Windows. La couleur d'accentuation est la couleur de surbrillance utilisée pour les boutons, les bordures et les tuiles du menu Démarrer sous Windows. Pour la modifier, accédez à Paramètres &gt; Personnalisation &gt; Couleurs, puis sélectionnez votre couleur d'accentuation préférée."/>
<len-limit-exceeded-tip value="Limite de longueur dépassée : Votre saisie peut dépasser la limite autorisée et avoir été tronquée, et elle ne sera pas enregistrée pour la prochaine session."/>
<max-len-on-search-tip value="Votre saisie peut dépasser la limite autorisée et avoir été tronquée, et elle ne sera pas enregistrée pour la prochaine session."/>
<max-len-on-save-tip value="La longueur de votre saisie est très longue et il se peut qu'elle ne soit pas enregistrée pour votre prochaine session."/>
<max-len-on-search-tip value="Seuls $INT_REPLACE$ caractères sont autorisés pour la longueur du texte de recherche/remplacement - votre saisie pourrait être tronquée et ne serait pas enregistrée pour la session suivante."/>
<max-len-on-save-tip value="Cette entrée de recherche (> $INT_REPLACE$ caractères) ne sera pas enregistrée pour la prochaine session."/>
<goto-setting-tip value="Réglage du paramètre ici"/>
</MiscStrings>
</Native-Langue>

View File

@ -1167,8 +1167,6 @@
<Item id="6908" name="用選取詞填充尋找與取代對話方塊中的尋找內容"/>
<Item id="6909" name="在沒有任何選取時,選取游標下的字串"/>
<Item id="6910" name="啟動自動勾選核取方塊「僅尋找選取範圍」的最小值:"/>
<Item id="6913" name="根據目前啟用文件的路徑自動填入「在多個檔案中尋找」的「資料夾」欄"/>
<Item id="6916" name=":從選定內容中自動填入查找欄位的最大字元數"/>
</Searching>
<RecentFilesHistory title="最近使用的檔案">
@ -1688,8 +1686,7 @@
1. 修改這些選項需要重新開啟已開啟的大型文件以達到預期的效果。
2. 如果「停用自動換行」被啟動,在開啟一個大型文件時,「自動換行」將對所有文件停用。 你可以通過選單「檢視-&gt;自動換行」重新啟動這個功能。"/>
<searchingInSelThresh-tip value="在尋找與取代對話方塊啟動時,為啟動自動勾選核取方塊「僅尋找選取範圍」在編輯區中選取的最小字符數量。 最大值為 $INT_REPLACE$。 將值設置為 0 將停止自動勾選功能。"/>
<searchingFillFindWhat-tip value="在尋找與取代對話方塊啟動時,為啟動自動填入「尋找內容」欄位,以編輯區域中選定字元的最大值(最多 $INT_REPLACE 個字元)。此值是「尋找內容」欄位的最大長度,由系統限制。"/>
<searchingInSelThresh-tip value="在尋找與取代對話方塊啟動時,為啟動自動勾選核取方塊「僅尋找選取範圍」在編輯區中選取的字符數量。 最大值為 1024。 將值設置為 0 將停止自動勾選功能。"/>
<verticalEdge-tip value="如欲添加列標記可以在下面以數字指示其列位置。使用空格分隔不同數字來定義多個列標記。"/>
<autoIndentBasic-tip value="確保目前行(即按 ENTER 鍵所打的新行)的縮排與上一行的縮排相同。"/>
<autoIndentAdvanced-tip value="啟用為「類 C Python C
@ -1711,9 +1708,8 @@ C、C++、Java、C#、Objective-C、PHP、JavaScript、JSP、CSS、Perl、Rust
<statusbar-Sel value="選取:"/>
<statusbar-Sel-number value="選取"/>
<toolbar-accent-tip value="此選項可讓您的工具列圖示遵循 Windows 系統強調色。強調色是 Windows 中的按鈕、邊框和開始功能表圖塊所使用的反白顯示顏色。要更改它,請轉到「設定」&gt;「個性化」&gt;「顏色」,然後選擇您喜歡的強調色。"/>
<len-limit-exceeded-tip value="已超出長度限制:輸入內容可能超出允許的限制並已被截斷,此輸入也將不會保存以供下次 Notepad++ 啟動時使用。"/>
<max-len-on-search-tip value="輸入內容可能超出允許的限制並已被截斷,此輸入也將不會保存以供下次 Notepad++ 啟動時使用。"/>
<max-len-on-save-tip value="輸入內容過長,可能無法保存以供下次 Notepad++ 啟動時使用。"/>
<max-len-on-search-tip value="尋找/取代文字長度僅允許 $INT_REPLACE$ 個字元 - 您的輸入可能會被截斷,此搜尋輸入也將不會保存以供下次 Notepad++ 啟動時使用。"/>
<max-len-on-save-tip value="此搜尋輸入( > $INT_REPLACE$ 個字元)將不會保存以供下次 Notepad++ 啟動時使用。"/>
<goto-setting-tip value="相關的偏好設定在此"/>
</MiscStrings>
</Native-Langue>

View File

@ -1053,7 +1053,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="37A8ED" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="37A8ED" />
<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="Change History margin" styleID="0" bgColor="4C4A41" />
<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="Document map" styleID="0" fgColor="BDAE9D" bgColor="2A211C" />
<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>
</NotepadPlus>

View File

@ -1043,7 +1043,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" />
<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="Change History margin" styleID="0" bgColor="2E3436" />
<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="Document map" styleID="0" fgColor="F8F8F8" bgColor="0C1021" />
<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>
</NotepadPlus>

View File

@ -1043,7 +1043,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" />
<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="Change History margin" styleID="0" bgColor="2E3436" />
<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="Document map" styleID="0" fgColor="C3BE98" bgColor="1A0F0B" />
<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>
</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="Multi-edit carets color" styleID="0" fgColor="A7A7A7" />
<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="Change History margin" styleID="0" bgColor="363636" />
<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="Document map" styleID="0" fgColor="C7C7C7" bgColor="2E2E2E" />
<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>
</NotepadPlus>

View File

@ -1822,6 +1822,6 @@ License: GPL2
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFFFFF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<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>
</NotepadPlus>

View File

@ -1038,7 +1038,7 @@ https://notepad-plus-plus.org/donate/
</LexerStyles>
<GlobalStyles>
<!-- 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="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="" />
@ -1091,6 +1091,6 @@ https://notepad-plus-plus.org/donate/
<WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="808080" />
<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>
</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="Document map" styleID="0" fgColor="000000" bgColor="FFB0FF" />
<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>
</NotepadPlus>

View File

@ -1219,6 +1219,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="B7975D" bgColor="2B0F01" />
<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>
</NotepadPlus>

View File

@ -1048,7 +1048,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="FFFFFF" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="FFFFFF" />
<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="Change History margin" styleID="0" bgColor="2E3436" />
<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="Document map" styleID="0" fgColor="FFFFFF" bgColor="222C28" />
<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>
</NotepadPlus>

View File

@ -1064,7 +1064,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="F8F8F0" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="F8F8F0" />
<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="Change History margin" styleID="0" bgColor="2E3436" />
<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="Document map" styleID="0" fgColor="F8F8F2" bgColor="272822" />
<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>
</NotepadPlus>

View File

@ -1219,6 +1219,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="F2C476" bgColor="58693D" />
<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>
</NotepadPlus>

View File

@ -1216,6 +1216,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="BA9C80" />
<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>
</NotepadPlus>

View File

@ -1121,6 +1121,6 @@ Notepad++ Custom Style
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="E0E2E4" bgColor="293134" />
<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>
</NotepadPlus>

View File

@ -1060,7 +1060,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="8BA7A7" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="8BA7A7" />
<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="Change History margin" styleID="0" bgColor="2E3436" />
<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="Document map" styleID="0" fgColor="F8F8F8" bgColor="0B161D" />
<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>
</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="Multi-edit carets color" 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="Change History margin" styleID="0" bgColor="1F4661" />
<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="Document map" styleID="0" fgColor="FFFFFF" bgColor="112435" />
<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>
</NotepadPlus>

View File

@ -1227,6 +1227,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="808040" />
<WidgetStyle name="Document map" styleID="0" fgColor="657B83" bgColor="FDF6E3" />
<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>
</NotepadPlus>

View File

@ -1619,6 +1619,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="FFFFFF" />
<WidgetStyle name="Document map" styleID="0" fgColor="839496" bgColor="002B36" />
<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>
</NotepadPlus>

View File

@ -1049,7 +1049,7 @@ Credits:
<WidgetStyle name="Caret colour" styleID="2069" fgColor="A7A7A7" />
<WidgetStyle name="Multi-edit carets color" styleID="0" fgColor="A7A7A7" />
<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="Change History margin" styleID="0" bgColor="2E3436" />
<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="Document map" styleID="0" fgColor="F8F8F8" bgColor="141414" />
<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>
</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="Document map" styleID="0" fgColor="FFFFFF" bgColor="000000" />
<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>
</NotepadPlus>

View File

@ -1789,6 +1789,6 @@ License: GPL2
<WidgetStyle name="URL hovered" styleID="0" fgColor="A3DCA3" />
<WidgetStyle name="Document map" styleID="0" fgColor="000000" bgColor="FFFFFF" />
<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>
</NotepadPlus>

View File

@ -1216,6 +1216,6 @@ Installation:
<WidgetStyle name="URL hovered" styleID="0" fgColor="808040" />
<WidgetStyle name="Document map" styleID="0" fgColor="5F5F00" bgColor="D7D7AF" />
<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>
</NotepadPlus>

View File

@ -955,29 +955,6 @@ bool str2Clipboard(const wstring &str2cpy, HWND hwnd)
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)
{
const wstring crlf = L"\r\n";
@ -1560,25 +1537,7 @@ bool toggleReadOnlyFlagFromFileAttributes(const wchar_t* fileFullPath, bool& isC
}
else
{
if (::GetLastError() == ERROR_ACCESS_DENIED)
{
// 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
}
}
// probably the ERROR_ACCESS_DENIED (5) (TODO: UAC-prompt candidate)
return false;
}
}
@ -2136,7 +2095,7 @@ bool isCoreWindows()
return isCoreWindows;
}
bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond /* = 0 */, int maxWidth /* = 200 */)
bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond /* = 0 */)
{
_hWndInfoTip = CreateWindowEx(isRTL ? WS_EX_LAYOUTRTL : 0, TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,
@ -2161,7 +2120,7 @@ bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attache
return false;
}
SendMessage(_hWndInfoTip, TTM_SETMAXTIPWIDTH, 0, maxWidth);
SendMessage(_hWndInfoTip, TTM_SETMAXTIPWIDTH, 0, 200);
SendMessage(_hWndInfoTip, TTM_ACTIVATE, TRUE, 0);
if (remainTimeMillisecond)
@ -2170,22 +2129,14 @@ bool ControlInfoTip::init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attache
return true;
}
void ControlInfoTip::show(showPosition pos) const
void ControlInfoTip::show() const
{
if (!isValid()) return;
RECT rcComboBox;
GetWindowRect(reinterpret_cast<HWND>(_toolInfo.uId), &rcComboBox);
int xPos = 0;
if (pos == beginning)
xPos = rcComboBox.left + 15;
else if (pos == middle)
xPos = rcComboBox.left + (rcComboBox.right - rcComboBox.left) / 2;
else // (pos == end)
xPos = rcComboBox.left + (rcComboBox.right - rcComboBox.left) - 15;
int xPos = rcComboBox.left + (rcComboBox.right - rcComboBox.left) / 2;
int yPos = rcComboBox.top + 25;
SendMessage(_hWndInfoTip, TTM_TRACKPOSITION, 0, MAKELPARAM(xPos, yPos));
@ -2203,40 +2154,3 @@ void ControlInfoTip::hide()
}
#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);
bool str2Clipboard(const std::wstring &str2cpy, HWND hwnd);
std::wstring strFromClipboard();
class Buffer;
bool buf2Clipboard(const std::vector<Buffer*>& buffers, bool isFullPath, HWND hwnd);
@ -311,7 +310,7 @@ public:
hide();
}
};
bool init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const std::wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond = 0, int maxWidth = 200); // remainTimeMillisecond = 0: no timeout
bool init(HINSTANCE hInst, HWND ctrl2attached, HWND ctrl2attachedParent, const std::wstring& tipStr, bool isRTL, unsigned int remainTimeMillisecond = 0); // remainTimeMillisecond = 0: no timeout
bool isValid() const {
return _hWndInfoTip != nullptr;
@ -321,8 +320,7 @@ public:
return _hWndInfoTip;
};
enum showPosition {beginning, middle, end};
void show(showPosition pos = middle) const;
void show() const;
void hide();
@ -333,10 +331,3 @@ private:
ControlInfoTip(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);
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
{
_dwErrorCode = ERROR_FILE_NOT_FOUND; // store
return; // In this case, we don't call createFile to prevent hanging
}
return; // In this case, we don't call createFile to prevent hanging
}
_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);
}
if (_hFile == INVALID_HANDLE_VALUE)
_dwErrorCode = ::GetLastError(); // store
if (fileExists && (dispParam == CREATE_ALWAYS) && (_hFile != INVALID_HANDLE_VALUE))
{
// restore back the original creation date & attributes
@ -97,7 +91,7 @@ Win32_IO_File::Win32_IO_File(const wchar_t *fname)
else
{
msg += " failed to open, CreateFileW ErrorCode: ";
msg += std::to_string(_dwErrorCode);
msg += std::to_string(::GetLastError());
}
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()
{
_dwErrorCode = NO_ERROR; // reset
if (isOpened())
{
NppParameters& nppParam = NppParameters::getInstance();
DWORD flushError = NO_ERROR;
DWORD flushError = NOERROR;
if (_written)
{
if (!::FlushFileBuffers(_hFile))
@ -167,14 +159,7 @@ Please try using another storage and also check if your saved data is not corrup
}
}
}
_dwErrorCode = flushError; // store possible flushing error 1st
if (!::CloseHandle(_hFile))
{
if (!flushError)
_dwErrorCode = ::GetLastError(); // store
}
::CloseHandle(_hFile);
_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)
{
_dwErrorCode = NO_ERROR; // reset
if (!isOpened() || (wbuf == nullptr))
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;
BOOL success = FALSE;
DWORD writeError = NO_ERROR; // use also a local var here to be 100% thread-safe
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);
total_bytes_written += static_cast<size_t>(bytes_written);
}
else
{
writeError = ::GetLastError();
}
} while (success && bytes_left_to_write);
NppParameters& nppParam = NppParameters::getInstance();
@ -256,11 +234,11 @@ bool Win32_IO_File::write(const void *wbuf, size_t buf_size)
std::string msg = _path;
msg += " written failed: ";
std::wstring lastErrorMsg = GetLastErrorAsString(writeError);
std::wstring lastErrorMsg = GetLastErrorAsString(::GetLastError());
msg += wstring2string(lastErrorMsg, CP_UTF8);
writeLog(nppIssueLog.c_str(), msg.c_str());
}
_dwErrorCode = writeError; // store
return false;
}
else

View File

@ -48,10 +48,6 @@ public:
return write(str.c_str(), str.length());
};
DWORD getLastErrorCode() {
return _dwErrorCode;
};
private:
HANDLE _hFile {INVALID_HANDLE_VALUE};
bool _written {false};
@ -60,6 +56,4 @@ private:
const DWORD _accessParam { GENERIC_READ | GENERIC_WRITE };
const DWORD _shareParam { FILE_SHARE_READ | FILE_SHARE_WRITE };
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:
// 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)
// 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
// For RUNCOMMAND_USER
#define VAR_NOT_RECOGNIZED 0
#define FULL_CURRENT_PATH 1
#define CURRENT_DIRECTORY 2

View File

@ -503,11 +503,20 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_LAUNCHFINDINFILESDLG:
{
// Find in files function code should be here due to the number of parameters (2) cannot be passed via WM_COMMAND
constexpr int strSize = FINDREPLACE_MAXLENGTH;
bool isFirstTime = !_findReplaceDlg.isCreated();
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
_findReplaceDlg.setSearchTextWithSettings();
const NppGUI& nppGui = nppParam.getNppGUI();
if (nppGui._fillFindFieldWithSelected)
{
auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0');
_pEditView->getGenericSelectedText(str.get(), strSize, nppGui._fillFindFieldSelectCaret);
_findReplaceDlg.setSearchText(str.get());
}
if (isFirstTime)
_nativeLangSpeaker.changeFindReplaceDlgLang(_findReplaceDlg);
@ -519,14 +528,17 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_FINDINPROJECTS:
{
constexpr int strSize = FINDREPLACE_MAXLENGTH;
auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0');
bool isFirstTime = not _findReplaceDlg.isCreated();
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
_findReplaceDlg.setSearchTextWithSettings();
_pEditView->getGenericSelectedText(str.get(), strSize);
_findReplaceDlg.setSearchText(str.get());
if (isFirstTime)
_nativeLangSpeaker.changeDlgLang(_findReplaceDlg.getHSelf(), "Find");
_findReplaceDlg.launchFindInProjectsDlg();
_findReplaceDlg.setProjectCheckmarks(NULL, (int) wParam);
return TRUE;
@ -534,13 +546,18 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
case NPPM_INTERNAL_FINDINFINDERDLG:
{
constexpr int strSize = FINDREPLACE_MAXLENGTH;
auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0');
Finder *launcher = reinterpret_cast<Finder *>(wParam);
bool isFirstTime = !_findInFinderDlg.isCreated();
_findInFinderDlg.doDialog(launcher, _nativeLangSpeaker.isRTL());
_findReplaceDlg.setSearchTextWithSettings();
_pEditView->getGenericSelectedText(str.get(), strSize);
_findReplaceDlg.setSearchText(str.get());
setFindReplaceFolderFilter(NULL, NULL);
if (isFirstTime)
@ -1011,15 +1028,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
wchar_t *pTchar = reinterpret_cast<wchar_t *>(lParam);
if (message == NPPM_GETCURRENTWORD)
{
auto txtW = _pEditView->getSelectedTextToWChar();
if (txtW)
wcscpy_s(str.get(), strSize, txtW);
}
_pEditView->getGenericSelectedText(str.get(), strSize);
else if (message == NPPM_GETCURRENTLINESTR)
{
_pEditView->getLine(_pEditView->getCurrentLineNumber(), str.get(), strSize);
}
// For the compatibility reason, if wParam is 0, then we assume the size of wstring buffer (lParam) is large enough.
// otherwise we check if the wstring buffer size is enough for the wstring to copy.
@ -1049,10 +1060,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
int hasSlash = 0;
auto txtW = _pEditView->getSelectedTextToWChar(); // this is either the selected text, or the word under the cursor if there is no selection
if (txtW)
wcscpy_s(str.get(), strSize, txtW);
_pEditView->getGenericSelectedText(str.get(), strSize); // this is either the selected text, or the word under the cursor if there is no selection
hasSlash = FALSE;
for (int i = 0; str[i] != 0; i++)
if (CharacterIs(str[i], L"\\/"))
@ -3210,23 +3218,6 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
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:
{
if (lParam != LINENUMWIDTH_DYNAMIC && lParam != LINENUMWIDTH_CONSTANT)

View File

@ -439,7 +439,7 @@ void Notepad_plus::command(int id)
auto pBinText = std::make_unique<char[]>(strSize);
std::fill_n(pBinText.get(), strSize, '\0');
_pEditView->getSelectedTextToMultiChar(pBinText.get(), textLen + 1);
_pEditView->getSelectedText(pBinText.get(), textLen + 1);
// Open the clipboard and empty it.
if (!::OpenClipboard(NULL))
@ -1356,6 +1356,16 @@ void Notepad_plus::command(int id)
case IDM_SEARCH_REPLACE :
case IDM_SEARCH_MARK :
{
const int strSize = FINDREPLACE_MAXLENGTH;
auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0');
const NppGUI& nppGui = (NppParameters::getInstance()).getNppGUI();
if (nppGui._fillFindFieldWithSelected)
{
_pEditView->getGenericSelectedText(str.get(), strSize, nppGui._fillFindFieldSelectCaret);
}
bool isFirstTime = !_findReplaceDlg.isCreated();
DIALOG_TYPE dlgID = FIND_DLG;
@ -1365,7 +1375,13 @@ void Notepad_plus::command(int id)
dlgID = MARK_DLG;
_findReplaceDlg.doDialog(dlgID, _nativeLangSpeaker.isRTL());
_findReplaceDlg.setSearchTextWithSettings();
if (nppGui._fillFindFieldWithSelected)
{
if (lstrlen(str.get()) <= FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT)
{
_findReplaceDlg.setSearchText(str.get());
}
}
setFindReplaceFolderFilter(NULL, NULL);
@ -1382,6 +1398,10 @@ void Notepad_plus::command(int id)
case IDM_SEARCH_FINDINCREMENT :
{
const int strSize = FINDREPLACE_MAXLENGTH;
auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0');
static bool isFirstTime = true;
if (isFirstTime)
{
@ -1389,9 +1409,9 @@ void Notepad_plus::command(int id)
isFirstTime = false;
}
auto str = _pEditView->getSelectedTextToWChar(false);
if (str) // the selected text is not empty, then use it
_incrementFindDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
_pEditView->getGenericSelectedText(str.get(), strSize, false);
if (0 != str[0]) // the selected text is not empty, then use it
_incrementFindDlg.setSearchText(str.get(), _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit);
_incrementFindDlg.display();
}
@ -1439,11 +1459,13 @@ void Notepad_plus::command(int id)
if (isFirstTime)
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL(), false);
const wchar_t* str = _findReplaceDlg.setSearchTextWithSettings();
if (!str) return;
_findReplaceDlg._env->_str2Search = str;
const int strSize = FINDREPLACE_MAXLENGTH;
auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0');
_pEditView->getGenericSelectedText(str.get(), strSize);
_findReplaceDlg.setSearchText(str.get());
_findReplaceDlg._env->_str2Search = str.get();
setFindReplaceFolderFilter(NULL, NULL);
if (isFirstTime)
_nativeLangSpeaker.changeFindReplaceDlgLang(_findReplaceDlg);
@ -1453,7 +1475,7 @@ void Notepad_plus::command(int id)
op._whichDirection = (id == IDM_SEARCH_SETANDFINDNEXT?DIR_DOWN:DIR_UP);
FindStatus status = FSNoMessage;
_findReplaceDlg.processFindNext(str, &op, &status);
_findReplaceDlg.processFindNext(str.get(), &op, &status);
if (status == FSEndReached)
{
wstring msg = _nativeLangSpeaker.getLocalizedStrFromID("find-status-end-reached", FIND_STATUS_END_REACHED_TEXT);
@ -1492,8 +1514,10 @@ void Notepad_plus::command(int id)
case IDM_SEARCH_VOLATILE_FINDNEXT :
case IDM_SEARCH_VOLATILE_FINDPREV :
{
auto str = _pEditView->getSelectedTextToWChar();
if (!str) return;
const int strSize = FINDREPLACE_MAXLENGTH;
auto str = std::make_unique<wchar_t[]>(strSize);
std::fill_n(str.get(), strSize, L'\0');
_pEditView->getGenericSelectedText(str.get(), strSize);
FindOption op;
op._isMatchCase = false;
@ -1503,7 +1527,7 @@ void Notepad_plus::command(int id)
op._whichDirection = (id == IDM_SEARCH_VOLATILE_FINDNEXT ? DIR_DOWN : DIR_UP);
FindStatus status = FSNoMessage;
_findReplaceDlg.processFindNext(str, &op, &status);
_findReplaceDlg.processFindNext(str.get(), &op, &status);
if (status == FSEndReached)
{
wstring msg = _nativeLangSpeaker.getLocalizedStrFromID("find-status-end-reached", FIND_STATUS_END_REACHED_TEXT);
@ -1535,11 +1559,26 @@ void Notepad_plus::command(int id)
else // (id == IDM_SEARCH_MARKALLEXT5)
styleID = SCE_UNIVERSAL_FOUND_STYLE_EXT5;
auto selectedText = _pEditView->getSelectedTextToWChar(true);
const int strSize = FINDREPLACE_MAXLENGTH;
auto selectedText = std::make_unique<wchar_t[]>(strSize);
std::fill_n(selectedText.get(), strSize, L'\0');
if (selectedText)
auto wordOnCaret = std::make_unique<wchar_t[]>(strSize);
std::fill_n(wordOnCaret.get(), strSize, L'\0');
_pEditView->getGenericSelectedText(selectedText.get(), strSize, false);
_pEditView->getGenericWordOnCaretPos(wordOnCaret.get(), strSize);
if (selectedText[0] == '\0')
{
_findReplaceDlg.markAll(selectedText, styleID);
if (lstrlen(wordOnCaret.get()) > 0)
{
_findReplaceDlg.markAll(wordOnCaret.get(), styleID);
}
}
else
{
_findReplaceDlg.markAll(selectedText.get(), styleID);
}
}
break;
@ -3466,16 +3505,20 @@ void Notepad_plus::command(int id)
case IDM_ABOUT:
{
bool doAboutDlg = false;
const int maxSelLen = 64;
auto textLen = _pEditView->execute(SCI_GETSELTEXT, 0, 0);
if (textLen <= 0)
doAboutDlg = true;
if (textLen > maxSelLen)
doAboutDlg = true;
if (!doAboutDlg)
{
int iQuote = -1;
auto authorW = _pEditView->getSelectedTextToWChar();
if (authorW)
iQuote = getQuoteIndexFrom(authorW);
char author[maxSelLen+1] = "";
_pEditView->getSelectedText(author, maxSelLen + 1);
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
const wchar_t * authorW = wmc.char2wchar(author, _nativeLangSpeaker.getLangEncoding());
int iQuote = getQuoteIndexFrom(authorW);
if (iQuote == -1)
{

View File

@ -683,11 +683,8 @@ bool Notepad_plus::doSave(BufferID id, const wchar_t * filename, bool isCopy)
}
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)
{

View File

@ -420,9 +420,9 @@ BOOL Notepad_plus::notify(SCNotification *notification)
{
if (nppGui._smartHiliteOnAnotherView)
{
auto selectedText = _pEditView->getSelectedTextToWChar(false);
if (selectedText)
_smartHighlighter.highlightViewWithWord(notifyView, selectedText);
wchar_t selectedText[1024];
_pEditView->getGenericSelectedText(selectedText, sizeof(selectedText) / sizeof(wchar_t), false);
_smartHighlighter.highlightViewWithWord(notifyView, selectedText);
}
break;
}

View File

@ -2649,15 +2649,13 @@ void NppParameters::feedColumnEditorParameters(TiXmlNode *node)
if (strVal)
{
if (lstrcmp(strVal, L"hex") == 0)
_columnEditParam._formatChoice = BASE_16;
else if (lstrcmp(strVal, L"hexuc") == 0)
_columnEditParam._formatChoice = BASE_16_UPPERCASE;
_columnEditParam._formatChoice = 1;
else if (lstrcmp(strVal, L"oct") == 0)
_columnEditParam._formatChoice = BASE_08;
_columnEditParam._formatChoice = 2;
else if (lstrcmp(strVal, L"bin") == 0)
_columnEditParam._formatChoice = BASE_02;
_columnEditParam._formatChoice = 3;
else // "dec"
_columnEditParam._formatChoice = BASE_10;
_columnEditParam._formatChoice = 0;
}
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"repeat", _columnEditParam._repeatNum);
wstring format = L"dec";
if (_columnEditParam._formatChoice == BASE_16)
if (_columnEditParam._formatChoice == 1)
format = L"hex";
else if (_columnEditParam._formatChoice == BASE_16_UPPERCASE)
format = L"hexuc";
else if (_columnEditParam._formatChoice == BASE_08)
else if (_columnEditParam._formatChoice == 2)
format = L"oct";
else if (_columnEditParam._formatChoice == BASE_02)
else if (_columnEditParam._formatChoice == 3)
format = L"bin";
(numberNode.ToElement())->SetAttribute(L"formatChoice", format);
wstring leading = L"none";
@ -6185,17 +6181,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
_nppGUI._inSelectionAutocheckThreshold = FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT;
}
int fillFindWhatThresh;
if (element->Attribute(L"fillFindWhatThreshold", &fillFindWhatThresh) &&
(fillFindWhatThresh >= 1 && fillFindWhatThresh <= FINDREPLACE_MAXLENGTH - 1))
{
_nppGUI._fillFindWhatThreshold = fillFindWhatThresh;
}
else
{
_nppGUI._fillFindWhatThreshold = FILL_FINDWHAT_THRESHOLD_DEFAULT;
}
const wchar_t* optFillDirFieldFromActiveDoc = element->Attribute(L"fillDirFieldFromActiveDoc");
if (optFillDirFieldFromActiveDoc)
{
@ -7838,7 +7823,6 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(L"confirmReplaceInAllOpenDocs", _nppGUI._confirmReplaceInAllOpenDocs ? L"yes" : L"no");
GUIConfigElement->SetAttribute(L"replaceStopsWithoutFindingNext", _nppGUI._replaceStopsWithoutFindingNext ? L"yes" : L"no");
GUIConfigElement->SetAttribute(L"inSelectionAutocheckThreshold", _nppGUI._inSelectionAutocheckThreshold);
GUIConfigElement->SetAttribute(L"fillFindWhatThreshold", _nppGUI._fillFindWhatThreshold);
GUIConfigElement->SetAttribute(L"fillDirFieldFromActiveDoc", _nppGUI._fillDirFieldFromActiveDoc ? L"yes" : L"no");
}

View File

@ -164,10 +164,7 @@ const int COPYDATA_FULL_CMDLINE = 3;
#define NPP_STYLING_FILESIZE_LIMIT_DEFAULT (200 * 1024 * 1024) // 200MB+ file won't be styled
#define FINDREPLACE_MAXLENGTH 16384 // the maximum length of the string (decrease 1 for '\0') to search in the editor
const int FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT = 1024;
const int FILL_FINDWHAT_THRESHOLD_DEFAULT = 1024;
const wchar_t fontSizeStrs[][3] = {L"", L"5", L"6", L"7", L"8", L"9", L"10", L"11", L"12", L"14", L"16", L"18", L"20", L"22", L"24", L"26", L"28"};
@ -909,7 +906,6 @@ struct NppGUI final
bool _confirmReplaceInAllOpenDocs = true;
bool _replaceStopsWithoutFindingNext = false;
int _inSelectionAutocheckThreshold = FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT;
int _fillFindWhatThreshold = FILL_FINDWHAT_THRESHOLD_DEFAULT;
bool _fillDirFieldFromActiveDoc = false;
bool _muteSounds = false;
bool _enableFoldCmdToggable = false;
@ -1324,7 +1320,7 @@ struct ColumnEditorParam final
int _initialNum = -1;
int _increaseNum = -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;
};

View File

@ -65,15 +65,6 @@ namespace // anonymous
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
using namespace std;
@ -1079,23 +1070,21 @@ bool FileManager::reloadBufferDeferred(BufferID id)
bool FileManager::deleteFile(BufferID id)
{
if (id == BUFFER_INVALID)
return false;
const Buffer* buf = getBufferByID(id);
wstring fileNamePath = buf->getFullPathName();
if (!doesFileExist(fileNamePath.c_str()))
return false;
// Make sure to form a string with double '\0' terminator.
fileNamePath.append(1, '\0');
if (!doesFileExist(fileNamePath.c_str()))
return false;
SHFILEOPSTRUCT fileOpStruct = {};
fileOpStruct.hwnd = NULL;
fileOpStruct.pFrom = fileNamePath.c_str();
fileOpStruct.pTo = NULL;
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.hNameMappings = 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);
const wchar_t* fileNamePath = buf->getFullPathName();
if (!::MoveFileExW(fileNamePath, newFileName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH))
{
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;
}
const wchar_t *fileNamePath = buf->getFullPathName();
if (::MoveFileEx(fileNamePath, newFileName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH) == 0)
return false;
buf->setFileName(newFileName);
return true;
@ -1352,7 +1323,7 @@ SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool
Buffer* buffer = getBufferByID(id);
bool isHiddenOrSys = false;
wchar_t fullpath[MAX_PATH]{};
wchar_t fullpath[MAX_PATH] = { 0 };
if (isWin32NamespacePrefixedFileName(filename))
{
// 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);
::PathRemoveFileSpecW(dirDest);
@ -1408,137 +1379,105 @@ SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool
int encoding = buffer->getEncoding();
wstring strTempFile = L"";
if (!UnicodeConvertor.openFile(fullpath))
if (UnicodeConvertor.openFile(fullpath))
{
if (NppParameters::getInstance().isEndSessionCritical())
return SavingStatus::SaveOpenFailed; // cannot continue to the UAC-prompt at the Windows logoff/reboot/shutdown time
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document
if (UnicodeConvertor.getLastFileErrorState() != ERROR_ACCESS_DENIED)
return SavingStatus::SaveOpenFailed; // cannot be solved by the UAC-prompt
size_t lengthDoc = _pscratchTilla->getCurrentDocLen();
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
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)
if (encoding == -1) //no special encoding; can be handled directly by Utf8_16_Write
{
isWrittenSuccessful = UnicodeConvertor.writeFile(buf, 0);
isWrittenSuccessful = UnicodeConvertor.writeFile(buf, lengthDoc);
if (lengthDoc == 0)
isWrittenSuccessful = true;
}
else
{
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
size_t grabSize = 0;
for (size_t i = 0; i < lengthDoc; i += grabSize)
if (lengthDoc == 0)
{
grabSize = lengthDoc - i;
if (grabSize > blockSize)
grabSize = blockSize;
isWrittenSuccessful = UnicodeConvertor.writeFile(buf, 0);
}
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 incompleteMultibyteChar = 0;
const char* newData = wmc.encode(SC_CP_UTF8, encoding, buf + i, static_cast<int>(grabSize), &newDataLen, &incompleteMultibyteChar);
grabSize -= incompleteMultibyteChar;
isWrittenSuccessful = UnicodeConvertor.writeFile(newData, newDataLen);
int newDataLen = 0;
int incompleteMultibyteChar = 0;
const char* newData = wmc.encode(SC_CP_UTF8, encoding, buf + i, static_cast<int>(grabSize), &newDataLen, &incompleteMultibyteChar);
grabSize -= incompleteMultibyteChar;
isWrittenSuccessful = UnicodeConvertor.writeFile(newData, newDataLen);
}
}
}
}
UnicodeConvertor.closeFile();
UnicodeConvertor.closeFile();
if (isHiddenOrSys && strTempFile.empty())
::SetFileAttributes(fullpath, attributes.dwFileAttributes);
// 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)
// Error, we didn't write the entire document to disk.
if (!isWrittenSuccessful)
{
::DeleteFileW(strTempFile.c_str()); // ensure no failed op remnant
::SetLastError(dwNppUacOpError); // set that as our current thread one for reporting later
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
return SavingStatus::SaveWritingFailed;
}
}
if (isCopy) // "Save a Copy As..." command
{
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.
}
if (isHiddenOrSys)
::SetFileAttributes(fullpath, attributes.dwFileAttributes);
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)
if (isCopy) // "Save a Copy As..." command
{
buffer->_lang = detectedLang;
buffer->doNotify(BufferChangeFilename | BufferChangeTimestamp | BufferChangeLanguage);
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 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);
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())
else
{
// delete backup file
buffer->setBackupFileName(wstring());
::DeleteFile(backupFilePath.c_str());
return SavingStatus::SaveOpenFailed;
}
return SavingStatus::SaveOK;
}
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);
if (!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;
return file.isOpened();
}

View File

@ -53,7 +53,7 @@ wstring getTextFromCombo(HWND hCombo)
auto str = std::make_unique<wchar_t[]>(strSize);
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());
}
@ -63,7 +63,7 @@ void delLeftWordInEdit(HWND hEdit)
auto str = std::make_unique<wchar_t[]>(strSize);
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;
::SendMessage(hEdit, EM_GETSEL, (WPARAM)&cursor, 0);
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
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
pEditView->execute(SCI_GOTOPOS, posEnd);
pEditView->execute(SCI_SETANCHOR, posStart);
@ -1579,8 +1565,8 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH);
::SendMessage(hFindCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH * 2 - 1, 0);
::SendMessage(hReplaceCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH * 2 - 1, 0);
::SendMessage(hFindCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH - 1, 0);
::SendMessage(hReplaceCombo, CB_LIMITTEXT, FINDREPLACE_MAXLENGTH - 1, 0);
HWND hFiltersCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO);
HWND hDirCombo = ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO);
@ -1971,24 +1957,21 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
{
if (HIWORD(wParam) == CBN_EDITUPDATE)
{
HWND hComboBox = ::GetDlgItem(_hSelf, LOWORD(wParam));
HWND hEdit = GetWindow(hComboBox, GW_CHILD);
if (!hEdit)
return FALSE;
HWND hComboBox = ::GetDlgItem(_hSelf, LOWORD(wParam));
LRESULT length = ::GetWindowTextLength(hComboBox);
static int maxLength = (int)SendMessage(hEdit, EM_GETLIMITTEXT, 0, 0);
LRESULT length = ::GetWindowTextLength(hEdit);
if (length >= maxLength) // should be (FINDREPLACE_MAXLENGTH * 2 - 1)
if (length >= FINDREPLACE_MAXLENGTH - 1)
{
if (!_maxLenOnSearchTip.isValid()) // Create the tooltip and add the tool ONLY ONCE
{
NativeLangSpeaker* pNativeSpeaker = nppParamInst.getNativeLangSpeaker();
wstring tip = pNativeSpeaker->getLocalizedStrFromID("len-limit-exceeded-tip", L"Length limit exceeded: Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session.");
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-search-tip", L"Only $INT_REPLACE$ characters are allowed for the find/replace text length - your input could be truncated, and it won't be saved for the next session.");
tip = stringReplace(tip, L"$INT_REPLACE$", std::to_wstring(FINDREPLACE_MAXLENGTH - 1));
static wstring maxLenOnSearchTip = tip;
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSearchTip.c_str(), _isRTL, 0, 170);
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSearchTip.c_str(), _isRTL);
if (!isSuccessful)
{
@ -1997,39 +1980,19 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
}
_maxLenOnSearchTip.show(ControlInfoTip::showPosition::beginning);
}
else if (length > FINDREPLACE_MAXLENGTH - 1)
{
if (!_maxLenOnSearchTip.isValid()) // Create the tooltip and add the tool ONLY ONCE
{
NativeLangSpeaker* pNativeSpeaker = nppParamInst.getNativeLangSpeaker();
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-search-tip", L"Your input may exceed the limit allowed and could have been truncated, and it won't be saved for the next session.");
static wstring maxLenOnSearchTip = tip;
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSearchTip.c_str(), _isRTL, 0, 170);
if (!isSuccessful)
{
return FALSE;
}
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
}
_maxLenOnSearchTip.show(ControlInfoTip::showPosition::beginning);
_maxLenOnSearchTip.show();
}
else if (length >= FINDREPLACE_MAXLENGTH2SAVE - 1) // FINDREPLACE_MAXLENGTH2SAVE < length < FINDREPLACE_MAXLENGTH
{
if (!_maxLenOnSearchTip.isValid()) // Create the tooltip and add the tool ONLY ONCE
{
NativeLangSpeaker* pNativeSpeaker = nppParamInst.getNativeLangSpeaker();
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-save-tip", L"The length of your input is very long and may not be saved for your next session.");
wstring tip = pNativeSpeaker->getLocalizedStrFromID("max-len-on-save-tip", L"This search input (> $INT_REPLACE$ characters) won't be saved for the next session");
tip = stringReplace(tip, L"$INT_REPLACE$", std::to_wstring(FINDREPLACE_MAXLENGTH2SAVE - 1));
static wstring maxLenOnSaveTip = tip;
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSaveTip.c_str(), _isRTL, 0, 170);
bool isSuccessful = _maxLenOnSearchTip.init(_hInst, hComboBox, _hSelf, maxLenOnSaveTip.c_str(), _isRTL);
if (!isSuccessful)
{
@ -2038,7 +2001,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
NppDarkMode::setDarkTooltips(_maxLenOnSearchTip.getTipHandle(), NppDarkMode::ToolTipsType::tooltip);
}
_maxLenOnSearchTip.show(ControlInfoTip::showPosition::beginning);
_maxLenOnSearchTip.show();
}
else
{
@ -4067,18 +4030,14 @@ int FindReplaceDlg::regexBackwardMsgBox()
return msgboxID;
}
void FindReplaceDlg::setSearchText(const wchar_t * txt2find)
void FindReplaceDlg::setSearchText(wchar_t * txt2find)
{
HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
if (txt2find && txt2find[0])
{
// We got a valid search string
HWND hEdit = GetWindow(hCombo, GW_CHILD);
if (hEdit)
{
::SendMessage(hEdit, EM_SETSEL, 0, static_cast<WPARAM>(-1)); // Select all text
::SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)txt2find);
}
::SendMessage(hCombo, CB_SETCURSEL, static_cast<WPARAM>(-1), 0); // remove selection - to allow using down arrow to get to last searched word
::SetDlgItemText(_hSelf, IDFINDWHAT, txt2find);
}
::SendMessage(hCombo, CB_SETEDITSEL, 0, MAKELPARAM(0, -1)); // select all text - fast edit
}
@ -4946,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))
{
// 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))
{
@ -4958,38 +4917,11 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM
{
// up key on top selected combobox item -> restore draft to edit text
::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));
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())
{
HWND hEdit = GetWindow(hwndCombo, GW_CHILD);
if (hEdit)
{
::SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)clipboardText.c_str());
}
}
}
return 0;
}
}
return CallWindowProc(originalComboEditProc, hwnd, message, wParam, lParam);
}
@ -5380,7 +5312,7 @@ bool FindReplaceDlg::replaceInProjectsConfirmCheck()
return confirmed;
}
bool FindReplaceDlg::replaceInOpenDocsConfirmCheck()
bool FindReplaceDlg::replaceInOpenDocsConfirmCheck(void)
{
bool confirmed = false;
@ -5398,26 +5330,6 @@ bool FindReplaceDlg::replaceInOpenDocsConfirmCheck()
return confirmed;
}
// return NULL if nothing to set in find field.
// Otherwise return string pointer (wchar_t *) in which the selected text was copied.
// Note that the string pointer don't need to and should not be deallocated.
const wchar_t* FindReplaceDlg::setSearchTextWithSettings()
{
const NppGUI& nppGui = NppParameters::getInstance().getNppGUI();
if (nppGui._fillFindFieldWithSelected)
{
Sci_Position selStrCharNum = 0;
const wchar_t* selStr = (*_ppEditView)->getSelectedTextToWChar(nppGui._fillFindFieldSelectCaret, &selStrCharNum);
if (selStr && selStrCharNum <= nppGui._fillFindWhatThreshold)
{
setSearchText(selStr);
return selStr;
}
}
return nullptr;
}
wstring Finder::getHitsString(int count) const
{
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
@ -6327,11 +6239,12 @@ void FindIncrementDlg::markSelectedTextInc(bool enable, FindOption *opt)
if (range.cpMin == range.cpMax)
return;
auto text2Find = (*(_pFRDlg->_ppEditView))->getSelectedTextToWChar(false); //do not expand selection (false)
if (!text2Find)
return;
const int strSize = FINDREPLACE_MAXLENGTH;
auto text2Find = std::make_unique<wchar_t[]>(strSize);
std::fill_n(text2Find.get(), strSize, L'\0');
opt->_str2Search = text2Find;
(*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find.get(), FINDREPLACE_MAXLENGTH, false); //do not expand selection (false)
opt->_str2Search = text2Find.get();
_pFRDlg->markAllInc(opt);
}

View File

@ -29,6 +29,7 @@
#define FIND_INVALID_REGULAR_EXPRESSION -2
#define FINDREPLACE_MAXLENGTH 16384 // the maximum length of the string (decrease 1 for '\0') to search in the editor
#define FINDREPLACE_MAXLENGTH2SAVE 2048 // the maximum length of the string (decrease 1 for '\0') to save in the config.xml file
#define FINDTEMPSTRING_MAXSIZE 1024*1024
@ -287,7 +288,7 @@ public :
void replaceAllInOpenedDocs();
void findAllIn(InWhat op);
void setSearchText(const wchar_t * txt2find);
void setSearchText(wchar_t * txt2find);
void gotoNextFoundResult(int direction = 0) const {
if (_pFinder) _pFinder->gotoNextFoundResult(direction);
@ -336,13 +337,14 @@ public :
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
}
void beginNewFilesSearch() {
void beginNewFilesSearch()
{
_pFinder->beginNewFilesSearch();
_pFinder->addSearchLine(getText2search().c_str());
}
void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection) {
void finishFilesSearch(int count, int searchedCount, bool searchedEntireNotSelection)
{
_pFinder->finishFilesSearch(count, searchedCount, searchedEntireNotSelection, _env);
}
@ -420,7 +422,6 @@ public :
DIALOG_TYPE getCurrentStatus() {return _currentStatus;};
Finder* getFinderFrom(HWND hwnd);
int regexBackwardMsgBox();
const wchar_t* setSearchTextWithSettings();
protected :
void resizeDialogElements();
@ -526,7 +527,7 @@ private:
void drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
bool replaceInFilesConfirmCheck(const std::wstring& directory, const std::wstring& fileTypes);
bool replaceInProjectsConfirmCheck();
bool replaceInOpenDocsConfirmCheck();
bool replaceInOpenDocsConfirmCheck(void);
ContextMenu _swapPopupMenu;
enum SwapButtonStatus {swap, down, up} _swapButtonStatus = swap;

View File

@ -2793,61 +2793,48 @@ char * ScintillaEditView::getWordOnCaretPos(char * txt, size_t size)
return getWordFromRange(txt, size, range.first, range.second);
}
wchar_t * ScintillaEditView::getGenericWordOnCaretPos(wchar_t * txt, int size)
{
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
size_t cp = execute(SCI_GETCODEPAGE);
char *txtA = new char[size + 1];
getWordOnCaretPos(txtA, size);
char * ScintillaEditView::getSelectedTextToMultiChar(char * txt, size_t size, bool expand)
const wchar_t * txtW = wmc.char2wchar(txtA, cp);
wcscpy_s(txt, size, txtW);
delete [] txtA;
return txt;
}
char * ScintillaEditView::getSelectedText(char * txt, size_t size, bool expand)
{
if (!size)
return NULL;
Sci_CharacterRangeFull range = getSelection();
if (range.cpMax == range.cpMin && expand)
{
expandWordSelection();
range = getSelection();
}
if (!(static_cast<Sci_Position>(size) > (range.cpMax - range.cpMin))) //there must be atleast 1 byte left for zero terminator
{
range.cpMax = range.cpMin + size -1; //keep room for zero terminator
}
//getText(txt, range.cpMin, range.cpMax);
return getWordFromRange(txt, size, range.cpMin, range.cpMax);
}
// get the selected text & selected text character number (not the multi-chars lenghth for the allocation, if selCharNumber is not nul).
// This function returns the pointer of wide char string (wchar_t *) that we don't need to and should not deallocate.
const wchar_t * ScintillaEditView::getSelectedTextToWChar(bool expand, Sci_Position* selCharNumber)
wchar_t * ScintillaEditView::getGenericSelectedText(wchar_t * txt, int size, bool expand)
{
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
size_t cp = execute(SCI_GETCODEPAGE);
char *txtA = nullptr;
Sci_CharacterRangeFull range = getSelection();
if (range.cpMax == range.cpMin && expand)
{
expandWordSelection();
range = getSelection();
}
auto selNum = execute(SCI_COUNTCHARACTERS, range.cpMin, range.cpMax);
// return the selected string's character number
if (selCharNumber)
*selCharNumber = selNum;
if (selNum == 0)
return nullptr;
// then get the selected string's total bytes (without counting the last NULL char)
auto neededByte = execute(SCI_GETSELTEXT, 0, NULL);
txtA = new char[neededByte + 1];
execute(SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(txtA));
char *txtA = new char[size + 1];
getSelectedText(txtA, size, expand);
const wchar_t * txtW = wmc.char2wchar(txtA, cp);
wcscpy_s(txt, size, txtW);
delete [] txtA;
return txtW;
return txt;
}
intptr_t ScintillaEditView::searchInTarget(const wchar_t * text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const
@ -3932,19 +3919,15 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, size_t initial, siz
//Defined in ScintillaEditView.h :
//const UCHAR MASK_FORMAT = 0x03;
bool useUppercase = false;
UCHAR f = format & MASK_FORMAT;
int base = 10;
if (format == BASE_16)
if (f == BASE_16)
base = 16;
else if (format == BASE_08)
else if (f == BASE_08)
base = 8;
else if (format == BASE_02)
else if (f == BASE_02)
base = 2;
else if (format == BASE_16_UPPERCASE)
{
base = 16;
useUppercase = true;
}
const int stringSize = 512;
char str[stringSize];
@ -3983,7 +3966,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfos & cmi, size_t initial, siz
cmi[i]._selLpos += 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;
if (hasVirtualSpc) // if virtual space is present, then insert space

View File

@ -109,7 +109,12 @@ enum TextCase : UCHAR
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_HIDELINESBEGIN = 19;
@ -247,7 +252,7 @@ const std::vector<std::vector<const char*>> g_nonPrintingChars =
size_t getNbDigits(size_t aNum, size_t base);
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;
@ -288,8 +293,6 @@ T* variedFormatNumber2String(T* str, size_t strLen, size_t number, size_t base,
else if (base == 16)
{
std::stringstream stream;
if (useUpper)
stream << std::uppercase;
stream << std::hex << number;
numberStr = stream.str();
}
@ -464,10 +467,10 @@ public:
void getVisibleStartAndEndPosition(intptr_t* startPos, intptr_t* endPos);
char * getWordFromRange(char * txt, size_t size, size_t pos1, size_t pos2);
char * getSelectedTextToMultiChar(char * txt, size_t size, bool expand = true);
const wchar_t* getSelectedTextToWChar(bool expand = true, Sci_Position* selCharNumber = nullptr);
char * getSelectedText(char * txt, size_t size, bool expand = true);
char * getWordOnCaretPos(char * txt, size_t size);
wchar_t * getGenericWordOnCaretPos(wchar_t * txt, int size);
wchar_t * getGenericSelectedText(wchar_t * txt, int size, bool expand = true);
intptr_t searchInTarget(const wchar_t * Text2Find, size_t lenOfText2Find, size_t fromPos, size_t toPos) const;
void appendGenericText(const wchar_t * text2Append) const;
void addGenericText(const wchar_t * text2Append) const;

View File

@ -151,7 +151,12 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
return;
}
const wchar_t * text2FindW = pHighlightView->getSelectedTextToWChar(false); //do not expand selection (false)
char * text2Find = new char[textlen + 1];
pHighlightView->getSelectedText(text2Find, textlen + 1, false); //do not expand selection (false)
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
UINT cp = static_cast<UINT>(pHighlightView->execute(SCI_GETCODEPAGE));
const wchar_t * text2FindW = wmc.char2wchar(text2Find, cp);
highlightViewWithWord(pHighlightView, text2FindW);
@ -166,4 +171,6 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView, Scintil
// Hightlight the unfocused view even if it's a clone, as it might be in a different area of the document
highlightViewWithWord(unfocusView, text2FindW);
}
delete[] text2Find;
}

View File

@ -42,23 +42,21 @@ void ColumnEditorDlg::display(bool toShow) const
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)
{
case WM_INITDIALOG :
{
hRedBrush = CreateSolidBrush(rgbRed); // Create red brush once
ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam;
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
::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"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);
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;
else if (colEditParam._formatChoice == BASE_08)
else if (colEditParam._formatChoice == 2)
format = IDC_COL_OCT_RADIO;
else if (colEditParam._formatChoice == BASE_02)
else if (colEditParam._formatChoice == 3)
format = IDC_COL_BIN_RADIO;
::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);
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
@ -98,12 +89,6 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
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));
}
@ -167,35 +152,25 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
switch (LOWORD(wParam))
{
case IDCANCEL: // in case of ESC keystroke
{
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);
}
case IDCANCEL : // Close
display(false);
return TRUE;
}
case IDOK:
{
case IDOK :
{
(*_ppEditView)->execute(SCI_BEGINUNDOACTION);
constexpr int stringSize = 1024;
wchar_t str[stringSize]{};
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
if (isTextMode)
{
::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_EDIT, WM_GETTEXT, stringSize, reinterpret_cast<LPARAM>(str));
display(false);
if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1)
{
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);
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 lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
@ -225,7 +200,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
if (lineLen > lineAllocatedLen)
{
delete[] line;
delete [] line;
line = new wchar_t[lineLen];
}
(*_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;
if (posRelative2Start > static_cast<long long>(s2r.length()))
posRelative2Start = s2r.length();
s2r.insert(posRelative2Start, str);
}
(*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd);
}
delete[] line;
delete [] line;
}
}
else
{
ColumnEditorParam colEditParam = NppParameters::getInstance()._columnEditParam;
::GetDlgItemText(_hSelf, IDC_COL_INITNUM_EDIT, str, stringSize);
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;
}
size_t initialNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, NULL, TRUE);
size_t increaseNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, NULL, TRUE);
size_t repeat = ::GetDlgItemInt(_hSelf, IDC_COL_REPEATNUM_EDIT, NULL, TRUE);
if (repeat == 0)
{
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;
while (numbers.size() < kiMaxSize)
{
for (int i = 0; i < repeat; i++)
for (size_t i = 0; i < repeat; i++)
{
numbers.push_back(curNumber);
@ -328,21 +279,17 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
}
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;
bool useUppercase = false;
if (format == BASE_16)
if (f == BASE_16)
base = 16;
else if (format == BASE_08)
else if (f == BASE_08)
base = 8;
else if (format == BASE_02)
else if (f == BASE_02)
base = 2;
else if (format == BASE_16_UPPERCASE)
{
base = 16;
useUppercase = true;
}
size_t endNumber = *numbers.rbegin();
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);
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 lineEnd = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, i);
@ -360,7 +307,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
if (lineLen > lineAllocatedLen)
{
delete[] line;
delete [] line;
line = new wchar_t[lineLen];
}
(*_ppEditView)->getGenericText(line, lineLen, lineBegin, lineEnd);
@ -370,7 +317,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
//
// 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)
{
@ -384,21 +331,21 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
auto posRelative2Start = posAbs2Start - lineBegin;
if (posRelative2Start > static_cast<long long>(s2r.length()))
posRelative2Start = s2r.length();
s2r.insert(posRelative2Start, str);
}
(*_ppEditView)->replaceTarget(s2r.c_str(), int(lineBegin), int(lineEnd));
}
delete[] line;
delete [] line;
}
}
(*_ppEditView)->execute(SCI_ENDUNDOACTION);
(*_ppEditView)->grabFocus();
return TRUE;
}
case IDC_COL_TEXT_RADIO:
case IDC_COL_NUM_RADIO:
(*_ppEditView)->grabFocus();
return TRUE;
}
case IDC_COL_TEXT_RADIO :
case IDC_COL_NUM_RADIO :
{
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
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:
{
ColumnEditorParam& colEditParam = NppParameters::getInstance()._columnEditParam;
colEditParam._formatChoice = BASE_10; // dec
if (LOWORD(wParam) == IDC_COL_HEX_RADIO)
colEditParam._formatChoice = getHexCase(); // will pick appropriate UC or LC version of hex
else if (LOWORD(wParam) == IDC_COL_OCT_RADIO)
colEditParam._formatChoice = BASE_08;
else if (LOWORD(wParam) == IDC_COL_BIN_RADIO)
colEditParam._formatChoice = BASE_02;
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
colEditParam._formatChoice = 0; // dec
if (wParam == IDC_COL_HEX_RADIO)
colEditParam._formatChoice = 1;
else if (wParam == IDC_COL_OCT_RADIO)
colEditParam._formatChoice = 2;
else if (wParam == IDC_COL_BIN_RADIO)
colEditParam._formatChoice = 3;
return TRUE;
}
@ -455,14 +399,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE;
}
int num = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize);
if (num == -1)
{
num = colEditParam._initialNum;
setNumericFields(colEditParam); // reformat the strings to eliminate error
whichFlashRed = sendValidationErrorMessage(LOWORD(wParam), colEditParam._formatChoice, str);
}
int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
colEditParam._initialNum = num;
return TRUE;
}
@ -476,14 +413,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE;
}
int num = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize);
if (num == -1)
{
num = colEditParam._increaseNum;
setNumericFields(colEditParam); // reformat the strings to eliminate error
whichFlashRed = sendValidationErrorMessage(LOWORD(wParam), colEditParam._formatChoice, str);
}
int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
colEditParam._increaseNum = num;
return TRUE;
}
@ -497,14 +427,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE;
}
int num = getNumericFieldValueFromText(colEditParam._formatChoice, str, stringSize);
if (num == -1)
{
num = colEditParam._repeatNum;
setNumericFields(colEditParam); // reformat the strings to eliminate error
whichFlashRed = sendValidationErrorMessage(LOWORD(wParam), colEditParam._formatChoice, str);
}
int num = ::GetDlgItemInt(_hSelf, LOWORD(wParam), NULL, TRUE);
colEditParam._repeatNum = num;
return TRUE;
}
@ -520,15 +443,6 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
colEditParam._leadingChoice = getLeading();
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;
}
@ -538,51 +452,6 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
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 :
return FALSE;
}
@ -623,23 +492,16 @@ void ColumnEditorDlg::switchTo(bool toText)
UCHAR ColumnEditorDlg::getFormat()
{
UCHAR f = BASE_10; // Dec by default
UCHAR f = 0; // Dec by default
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))
f = BASE_08;
f = 2;
else if (isCheckedOrNot(IDC_COL_BIN_RADIO))
f = BASE_02;
f = 3;
return f;
}
UCHAR ColumnEditorDlg::getHexCase()
{
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 leading = ColumnEditorParam::noneLeading;
@ -665,147 +527,3 @@ ColumnEditorParam::leadingChoice ColumnEditorDlg::getLeading()
}
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);
UCHAR getFormat();
ColumnEditorParam::leadingChoice getLeading();
UCHAR getHexCase();
protected :
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private :
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"
FONT 8, L"MS Shell Dlg", 0, 0, 0x0
BEGIN
CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,6,124,10
CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,68,204,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 | WS_GROUP,13,68,204,10
GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,8,14,124,46
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
RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,140,76,8
EDITTEXT IDC_COL_INITNUM_EDIT,90,138,38,12
RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,157,75,8
EDITTEXT IDC_COL_INCREASENUM_EDIT,90,155,38,12
RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,174,75,8
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,172,38,12
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,191,75,8
COMBOBOX IDC_COL_LEADING_COMBO,90,189,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,89,76,8
EDITTEXT IDC_COL_INITNUM_EDIT,90,87,38,12,ES_NUMBER
RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,106,75,8
EDITTEXT IDC_COL_INCREASENUM_EDIT,90,104,38,12,ES_NUMBER
RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,123,75,8
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,121,38,12,ES_NUMBER
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,140,75,8
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
PUSHBUTTON "Cancel",IDCANCEL,142,36,70,14

View File

@ -37,7 +37,4 @@
#define IDC_COL_REPEATNUM_EDIT (IDD_COLUMNEDIT + 17)
#define IDC_COL_LEADING_STATIC (IDD_COLUMNEDIT + 18)
#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

View File

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

View File

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

View File

@ -1039,7 +1039,7 @@ void CustomFileDialog::setSaveAsCopy(bool isSavingAsCopy)
}
}
bool CustomFileDialog::getOpenTheCopyAfterSaveAsCopy()
bool CustomFileDialog::getOpenTheCopyAfterSaveAsCopy(void)
{
return (_impl->_savingAsCopyInfo & SAVE_AS_COPY_OPEN) != 0;
}
@ -1077,7 +1077,7 @@ wstring CustomFileDialog::doSaveDlg()
CurrentDirBackup backup;
_impl->addFlags(FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM | FOS_NOTESTFILECREATE);
_impl->addFlags(FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST | FOS_FORCEFILESYSTEM);
bool bOk = _impl->show();
return bOk ? _impl->getResultFilename() : L"";
}

View File

@ -38,7 +38,7 @@ public:
void setCheckbox(const wchar_t* text, bool isActive = true);
void setExtIndex(int extTypeIndex);
void setSaveAsCopy(bool isSavingAsCopy);
bool getOpenTheCopyAfterSaveAsCopy();
bool getOpenTheCopyAfterSaveAsCopy(void);
void enableFileTypeCheckbox(const std::wstring& text, bool value);
bool getFileTypeCheckboxValue() const;

View File

@ -419,26 +419,21 @@ BEGIN
END
IDD_PREFERENCE_SUB_SEARCHING DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "When Find Dialog is Invoked",IDD_FILL_FIND_FIELD_GRP_STATIC,31,4,330,102,BS_CENTER
RTEXT "Minimum Size for Auto-Checking ""In selection"":",IDC_INSELECTION_THRESHOLD_STATIC,37,16,210,8
EDITTEXT IDC_INSELECTION_THRESHOLD_EDIT,250,15,27,12,ES_CENTER | ES_NUMBER
LTEXT "(?)",IDC_INSELECTION_THRESH_QUESTION_BUTTON,283,16,10,8,SS_NOTIFY
CONTROL "Fill Find in Files Directory Field Based On Active Document",IDC_CHECK_FILL_DIR_FIELD_FROM_ACTIVE_DOC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,43,311,8
CONTROL "Fill Find Field with Selected Text",IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,59,300,10
LTEXT "(?)",IDC_FILLFINDWHAT_THRESH_QUESTION_BUTTON,52,73,10,8,SS_NOTIFY
EDITTEXT IDC_FILLFINDWHAT_THRESHOLD_EDIT,64,72,27,12,ES_CENTER | ES_NUMBER
LTEXT ": Max Characters to Auto-Fill Find Field from Selection",IDC_FILLFINDWHAT_THRESHOLD_STATIC,92,73,260,8
CONTROL "Select Word Under Caret when Nothing Selected",IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,52,88,275,10
CONTROL "Use Monospaced font in Find dialog (Need to restart Notepad++)",IDC_CHECK_MONOSPACEDFONT_FINDDLG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,117,350,10
CONTROL "Find dialog remains open after search that outputs to results window",IDC_CHECK_FINDDLG_ALWAYS_VISIBLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,132,350,10
CONTROL "Confirm Replace All in All Opened Documents",IDC_CHECK_CONFIRMREPLOPENDOCS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,147,350,10
CONTROL "Replace: Don't move to the following occurrence",IDC_CHECK_REPLACEANDSTOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,162,350,10
CONTROL "Search Result window: show only one entry per found line if possible",IDC_CHECK_SHOWONCEPERFOUNDLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,177,350,10
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "When Find Dialog is Invoked", IDD_FILL_FIND_FIELD_GRP_STATIC, 31, 4, 323, 85, BS_CENTER
RTEXT "Minimum Size for Auto-Checking ""In selection"":", IDC_INSELECTION_THRESHOLD_STATIC, 37, 16, 210, 8
LTEXT "(?)",IDC_INSELECTION_THRESH_QUESTION_BUTTON,283, 16,10,8,SS_NOTIFY
EDITTEXT IDC_INSELECTION_THRESHOLD_EDIT, 250, 15, 27, 12, ES_CENTER | ES_NUMBER
CONTROL "Fill Find Field with Selected Text", IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 59, 300, 10
CONTROL "Select Word Under Caret when Nothing Selected", IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 52, 73, 275, 10
CONTROL "Fill Find in Files Directory Field Based On Active Document", IDC_CHECK_FILL_DIR_FIELD_FROM_ACTIVE_DOC, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 44, 311, 8
CONTROL "Use Monospaced font in Find dialog (Need to restart Notepad++)", IDC_CHECK_MONOSPACEDFONT_FINDDLG, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 104, 350, 10
CONTROL "Find dialog remains open after search that outputs to results window", IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 119, 350, 10
CONTROL "Confirm Replace All in All Opened Documents", IDC_CHECK_CONFIRMREPLOPENDOCS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 134, 350, 10
CONTROL "Replace: Don't move to the following occurrence", IDC_CHECK_REPLACEANDSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 149, 350, 10
CONTROL "Search Result window: show only one entry per found line if possible", IDC_CHECK_SHOWONCEPERFOUNDLINE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 37, 164, 350, 10
END
IDD_PREFERENCE_SUB_BACKUP DIALOGEX 115, 10, 460, 205

View File

@ -311,8 +311,6 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
NppDarkMode::setDarkTooltips(_performanceSubDlg._largeFileRestrictionTip, NppDarkMode::ToolTipsType::tooltip);
if (_searchingSubDlg._tipInSelThresh != nullptr)
NppDarkMode::setDarkTooltips(_searchingSubDlg._tipInSelThresh, NppDarkMode::ToolTipsType::tooltip);
if (_searchingSubDlg._tipFillFindWhatThresh != nullptr)
NppDarkMode::setDarkTooltips(_searchingSubDlg._tipFillFindWhatThresh, NppDarkMode::ToolTipsType::tooltip);
if (_indentationSubDlg._tipAutoIndentBasic)
NppDarkMode::setDarkTooltips(_indentationSubDlg._tipAutoIndentBasic, NppDarkMode::ToolTipsType::tooltip);
@ -6860,13 +6858,7 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET, BM_SETCHECK, nppGUI._fillFindFieldSelectCaret, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_MONOSPACEDFONT_FINDDLG, BM_SETCHECK, nppGUI._monospacedFontFindDlg, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_FINDDLG_ALWAYS_VISIBLE, BM_SETCHECK, nppGUI._findDlgAlwaysVisible, 0);
::SetDlgItemInt(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT, nppGUI._fillFindWhatThreshold, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_FILLFINDWHAT_THRESH_QUESTION_BUTTON), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_STATIC), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::SendDlgItemMessage(_hSelf, IDC_CHECK_CONFIRMREPLOPENDOCS, BM_SETCHECK, nppGUI._confirmReplaceInAllOpenDocs, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_REPLACEANDSTOP, BM_SETCHECK, nppGUI._replaceStopsWithoutFindingNext, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_SHOWONCEPERFOUNDLINE, BM_SETCHECK, nppGUI._finderShowOnlyOneEntryPerFoundLine, 0);
@ -6874,11 +6866,10 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILL_DIR_FIELD_FROM_ACTIVE_DOC, BM_SETCHECK, nppGUI._fillDirFieldFromActiveDoc, 0);
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
wstring tipInSelectionText = pNativeSpeaker->getLocalizedStrFromID("searchingInSelThresh-tip", L"Minimum number of selected characters in edit zone to automatically check the \"In selection\" checkbox when the Find dialog is activated. The maximum value is $INT_REPLACE$. Set the value to 0 to disable auto-checking.");
tipInSelectionText = stringReplace(tipInSelectionText, L"$INT_REPLACE$", std::to_wstring(FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT));
wstring tipText = pNativeSpeaker->getLocalizedStrFromID("searchingInSelThresh-tip", L"Number of selected characters in edit zone to automatically check the \"In selection\" checkbox when the Find dialog is activated. The maximum value is 1024. Set the value to 0 to disable auto-checking.");
_tipInSelThresh = CreateToolTip(IDC_INSELECTION_THRESH_QUESTION_BUTTON, _hSelf, _hInst, const_cast<PTSTR>(tipText.c_str()), pNativeSpeaker->isRTL());
_tipInSelThresh = CreateToolTip(IDC_INSELECTION_THRESH_QUESTION_BUTTON, _hSelf, _hInst, const_cast<PTSTR>(tipInSelectionText.c_str()), pNativeSpeaker->isRTL());
if (_tipInSelThresh != nullptr)
{
::SendMessage(_tipInSelThresh, TTM_SETMAXTIPWIDTH, 0, 260);
@ -6887,18 +6878,6 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SendMessage(_tipInSelThresh, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((30000), (0)));
}
wstring tipFillFindWhatText = pNativeSpeaker->getLocalizedStrFromID("searchingFillFindWhat-tip", L"Maximum number of selected characters in edit zone to fill automatically the \"Find what\" field when the Ctrl-F is triggered. The maximum value is $INT_REPLACE$, which is the maximum size of \"Find what\" field, limited by the system.");
tipFillFindWhatText = stringReplace(tipFillFindWhatText, L"$INT_REPLACE$", std::to_wstring(FINDREPLACE_MAXLENGTH - 1));
_tipFillFindWhatThresh = CreateToolTip(IDC_FILLFINDWHAT_THRESH_QUESTION_BUTTON, _hSelf, _hInst, const_cast<PTSTR>(tipFillFindWhatText.c_str()), pNativeSpeaker->isRTL());
if (_tipFillFindWhatThresh != nullptr)
{
::SendMessage(_tipFillFindWhatThresh, TTM_SETMAXTIPWIDTH, 0, 260);
// Make tip stay 30 seconds
::SendMessage(_tipFillFindWhatThresh, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELPARAM((30000), (0)));
}
return TRUE;
}
@ -6916,7 +6895,7 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
auto hdc = reinterpret_cast<HDC>(wParam);
const int dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
if (dlgCtrlID == IDC_INSELECTION_THRESH_QUESTION_BUTTON || dlgCtrlID == IDC_FILLFINDWHAT_THRESH_QUESTION_BUTTON)
if (dlgCtrlID == IDC_INSELECTION_THRESH_QUESTION_BUTTON)
{
return NppDarkMode::onCtlColorDlgLinkText(hdc, true);
}
@ -6935,72 +6914,35 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
case WM_COMMAND:
{
if (HIWORD(wParam) == EN_CHANGE)
if ((LOWORD(wParam) == IDC_INSELECTION_THRESHOLD_EDIT) &&
(HIWORD(wParam) == EN_CHANGE))
{
if (LOWORD(wParam) == IDC_INSELECTION_THRESHOLD_EDIT)
constexpr int stringSize = 5;
wchar_t str[stringSize]{};
::GetDlgItemText(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, str, stringSize);
if (lstrcmp(str, L"") == 0)
{
constexpr int stringSize = 5;
wchar_t str[stringSize]{};
::GetDlgItemText(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, str, stringSize);
if (lstrcmp(str, L"") == 0)
{
::SetDlgItemInt(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT, FALSE);
return TRUE;
}
UINT newValue = ::GetDlgItemInt(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, nullptr, FALSE);
if (static_cast<int>(newValue) == nppGUI._inSelectionAutocheckThreshold)
{
return TRUE;
}
if (newValue > FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT)
{
::SetDlgItemInt(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT, FALSE);
newValue = FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT;
}
nppGUI._inSelectionAutocheckThreshold = newValue;
return TRUE;
::SetDlgItemInt(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, nppGUI._inSelectionAutocheckThreshold, FALSE);
return FALSE;
}
else if (LOWORD(wParam) == IDC_FILLFINDWHAT_THRESHOLD_EDIT)
UINT newValue = ::GetDlgItemInt(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, nullptr, FALSE);
if (static_cast<int>(newValue) == nppGUI._inSelectionAutocheckThreshold)
{
constexpr int stringSize = 6;
wchar_t str[stringSize]{};
::GetDlgItemText(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT, str, stringSize);
if (lstrcmp(str, L"") == 0)
{
::SetDlgItemInt(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT, FILL_FINDWHAT_THRESHOLD_DEFAULT, FALSE);
return TRUE;
}
UINT newValue = ::GetDlgItemInt(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT, nullptr, FALSE);
if (static_cast<int>(newValue) == nppGUI._fillFindWhatThreshold)
{
return TRUE;
}
if (newValue >= FINDREPLACE_MAXLENGTH)
{
newValue = FINDREPLACE_MAXLENGTH - 1;
::SetDlgItemInt(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT, newValue, FALSE);
}
if (newValue == 0)
{
newValue = 1;
::SetDlgItemInt(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT, newValue, FALSE);
}
nppGUI._fillFindWhatThreshold = newValue;
return TRUE;
return FALSE;
}
if (newValue > FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT)
{
::SetDlgItemInt(_hSelf, IDC_INSELECTION_THRESHOLD_EDIT, FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT, FALSE);
newValue = FINDREPLACE_INSELECTION_THRESHOLD_DEFAULT;
}
nppGUI._inSelectionAutocheckThreshold = newValue;
return TRUE;
}
switch (wParam)
@ -7009,10 +6951,6 @@ intptr_t CALLBACK SearchingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
nppGUI._fillFindFieldWithSelected = isCheckedOrNot(IDC_CHECK_FILL_FIND_FIELD_WITH_SELECTED);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_FILLFINDWHAT_THRESH_QUESTION_BUTTON), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_EDIT), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_FILLFINDWHAT_THRESHOLD_STATIC), nppGUI._fillFindFieldWithSelected ? TRUE : FALSE);
if (!nppGUI._fillFindFieldWithSelected)
{
::SendDlgItemMessage(_hSelf, IDC_CHECK_FILL_FIND_FIELD_SELECT_CARET, BM_SETCHECK, BST_UNCHECKED, 0);

View File

@ -273,7 +273,6 @@ public:
private:
HWND _tipInSelThresh = nullptr;
HWND _tipFillFindWhatThresh = nullptr;
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
};

View File

@ -474,9 +474,6 @@
#define IDC_INSELECTION_THRESHOLD_EDIT 6911
#define IDC_INSELECTION_THRESH_QUESTION_BUTTON 6912
#define IDC_CHECK_FILL_DIR_FIELD_FROM_ACTIVE_DOC 6913
#define IDC_FILLFINDWHAT_THRESH_QUESTION_BUTTON 6914
#define IDC_FILLFINDWHAT_THRESHOLD_EDIT 6915
#define IDC_FILLFINDWHAT_THRESHOLD_STATIC 6916
#define IDD_PREFERENCE_SUB_DARKMODE 7100

View File

@ -1774,7 +1774,7 @@
<!-- 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="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="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 -->
@ -1825,6 +1825,6 @@
<WidgetStyle name="Document map" styleID="0" fgColor="FF8000" bgColor="FFFFFF" />
<WidgetStyle name="EOL custom color" styleID="0" fgColor="DADADA" />
<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>
</NotepadPlus>

View File

@ -408,101 +408,6 @@ bool launchUpdater(const std::wstring& updaterFullPath, const std::wstring& upda
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
@ -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*/)
{
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;
::SetLastError(NO_ERROR);