From 77a43c6c332cead4da66dfb1ca848006760d7f68 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Mon, 16 Nov 2026 11:37:37 +0100 Subject: [PATCH] Add WebTemplate3 for current-file browser preview --- Build/Notepad3.ini | 3 + language/common_res.h | 1 + language/np3_af_za/menu_af_za.rc | 2 + language/np3_be_by/menu_be_by.rc | 2 + language/np3_de_de/menu_de_de.rc | 2 + language/np3_el_gr/menu_el_gr.rc | 2 + language/np3_en_gb/menu_en_gb.rc | 2 + language/np3_en_us/menu_en_us.rc | 2 + language/np3_es_es/menu_es_es.rc | 2 + language/np3_fi_fi/menu_fi_fi.rc | 2 + language/np3_fr_fr/menu_fr_fr.rc | 2 + language/np3_hi_in/menu_hi_in.rc | 2 + language/np3_hu_hu/menu_hu_hu.rc | 2 + language/np3_id_id/menu_id_id.rc | 2 + language/np3_it_it/menu_it_it.rc | 2 + language/np3_ja_jp/menu_ja_jp.rc | 2 + language/np3_ko_kr/menu_ko_kr.rc | 2 + language/np3_nl_nl/menu_nl_nl.rc | 2 + language/np3_pl_pl/menu_pl_pl.rc | 2 + language/np3_pt_br/menu_pt_br.rc | 2 + language/np3_pt_pt/menu_pt_pt.rc | 2 + language/np3_ru_ru/menu_ru_ru.rc | 2 + language/np3_sk_sk/menu_sk_sk.rc | 2 + language/np3_sv_se/menu_sv_se.rc | 2 + language/np3_tr_tr/menu_tr_tr.rc | 2 + language/np3_vi_vn/menu_vi_vn.rc | 2 + language/np3_zh_cn/menu_zh_cn.rc | 2 + language/np3_zh_tw/menu_zh_tw.rc | 2 + readme/KeyboardShortcuts.md | 5 +- readme/MenuEntriesAndCmds.md | 5 +- readme/config/Configuration.md | 37 ++++- src/Config/Config.cpp | 4 + src/Notepad3.c | 272 +++++++++++++++++++++++-------- src/Notepad3.rc | 3 +- src/TypeDefs.h | 2 + 35 files changed, 308 insertions(+), 76 deletions(-) diff --git a/Build/Notepad3.ini b/Build/Notepad3.ini index 7a456cec11..5412b20bd7 100644 --- a/Build/Notepad3.ini +++ b/Build/Notepad3.ini @@ -63,10 +63,13 @@ SettingsVersion=5 ;LaunchInstanceFullVisible=true ;MaxFileDropInstances=20 ;UseOldStyleBraceMatching=0 +;WebTemplates uses HyperlinkShellExURLWithApp below or the default browser; browser handles rendering/reload. ;WebTemplate1=https://google.com/search?q=%s ;WebTmpl1MenuName=Open Web Action 1 ;WebTemplate2=https://en.wikipedia.org/w/index.php?search=%s ;WebTmpl2MenuName=Open Web Action 2 +;WebTemplate3=${FILE_URL} +;WebTmpl3MenuName=Preview current file ;ExtendedWhiteSpaceChars= ;AutoCompleteWordCharSet= ;AutoCompleteFillUpChars= diff --git a/language/common_res.h b/language/common_res.h index 1113b0ddfa..d94ab74c94 100644 --- a/language/common_res.h +++ b/language/common_res.h @@ -582,6 +582,7 @@ #define CMD_CTX_INVERTCASE 20068 #define CMD_CTX_TITLECASE 20069 #define CMD_CTX_SENTENCECASE 20070 +#define CMD_WEBACTION3 20071 #define IDS_MUI_MENU_LANGUAGE 34500 #define IDS_MUI_LANG_EN_US 34501 diff --git a/language/np3_af_za/menu_af_za.rc b/language/np3_af_za/menu_af_za.rc index b331285e9d..785e4aba7a 100644 --- a/language/np3_af_za/menu_af_za.rc +++ b/language/np3_af_za/menu_af_za.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Web Sjabloon &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Web Sjabloon &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Maak die &Vouer met die Seleksie Oop", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Maak &Lêer Oop vanaf Seleksie", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Web Sjabloon 1", CMD_WEBACTION1 MENUITEM "Web Sjabloon 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Maak die Vouer met die Seleksie Oop", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Maak &Lêer Oop vanaf Seleksie", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_be_by/menu_be_by.rc b/language/np3_be_by/menu_be_by.rc index 9666276329..ce17744df7 100644 --- a/language/np3_be_by/menu_be_by.rc +++ b/language/np3_be_by/menu_be_by.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Вэб-шаблон &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Вэб-шаблон &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Адкрыць вэб-дзеянне 1", CMD_WEBACTION1 MENUITEM "Адкрыць вэб-дзеянне 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_de_de/menu_de_de.rc b/language/np3_de_de/menu_de_de.rc index 16041e1612..331d2b1075 100644 --- a/language/np3_de_de/menu_de_de.rc +++ b/language/np3_de_de/menu_de_de.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Web Aufruf &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Web Aufruf &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "O&rdner der Auswahl öffnen", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Datei aus der Auswahl ö&ffnen", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Öffne Web-Aktion 1", CMD_WEBACTION1 MENUITEM "Öffne Web Aktion 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Ordner der Auswahl öffnen", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Datei aus der Auswahl öffnen", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_el_gr/menu_el_gr.rc b/language/np3_el_gr/menu_el_gr.rc index caab5d0b32..899bea991e 100644 --- a/language/np3_el_gr/menu_el_gr.rc +++ b/language/np3_el_gr/menu_el_gr.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Πρότυπο web &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Πρότυπο web &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Άνοιγμα Περικλείοντος Φακέλου από την Επιλογή", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Άνοιγμα Α&ρχείου από την Επιλογή", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Άνοιγμα ενέργειας Web 1", CMD_WEBACTION1 MENUITEM "Άνοιγμα ενέργειας Web 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Άνοιγμα Περικλείοντος Φακέλου από την Επιλογή", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Άνοιγμα Αρχείου από την Επιλογή", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_en_gb/menu_en_gb.rc b/language/np3_en_gb/menu_en_gb.rc index 062894cf7e..d66f11c530 100644 --- a/language/np3_en_gb/menu_en_gb.rc +++ b/language/np3_en_gb/menu_en_gb.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Web Template &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Web Template &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Open Web Action 1", CMD_WEBACTION1 MENUITEM "Open Web Action 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_en_us/menu_en_us.rc b/language/np3_en_us/menu_en_us.rc index 0cad32bb9c..e9eeb29a00 100644 --- a/language/np3_en_us/menu_en_us.rc +++ b/language/np3_en_us/menu_en_us.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Web Template &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Web Template &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Open Web Action 1", CMD_WEBACTION1 MENUITEM "Open Web Action 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_es_es/menu_es_es.rc b/language/np3_es_es/menu_es_es.rc index cb627355c1..d309854632 100644 --- a/language/np3_es_es/menu_es_es.rc +++ b/language/np3_es_es/menu_es_es.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Plantilla Web &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Plantilla Web &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Abrir la &carpeta contenedora la selección", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Abrir a&rchivo desde la selección", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Abrir Web Acción 1", CMD_WEBACTION1 MENUITEM "Abrir Web Acción 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Abrir la carpeta contenedora la selección", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Abrir archivo desde la selección", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_fi_fi/menu_fi_fi.rc b/language/np3_fi_fi/menu_fi_fi.rc index 059b87a122..6105d8a6ff 100644 --- a/language/np3_fi_fi/menu_fi_fi.rc +++ b/language/np3_fi_fi/menu_fi_fi.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Verkkomalli &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Verkkomalli &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Avaa verkkotoiminto 1", CMD_WEBACTION1 MENUITEM "Avaa verkkotoiminto 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_fr_fr/menu_fr_fr.rc b/language/np3_fr_fr/menu_fr_fr.rc index 5ba07adadc..0aaa91a230 100644 --- a/language/np3_fr_fr/menu_fr_fr.rc +++ b/language/np3_fr_fr/menu_fr_fr.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Modèle Web &1\tCtrl+Maj+1", CMD_WEBACTION1 MENUITEM "Modèle Web &2\tCtrl+Maj+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Ouvrir le dossier &contenant la sélection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Ouvrir le &fichier à partir de la sélection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Ouvrir Action Web &1", CMD_WEBACTION1 MENUITEM "Ouvrir Action Web &2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Ouvrir le dossier &contenant la sélection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Ouvrir le &fichier à partir de la sélection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_hi_in/menu_hi_in.rc b/language/np3_hi_in/menu_hi_in.rc index a699d16751..487d4ba24a 100644 --- a/language/np3_hi_in/menu_hi_in.rc +++ b/language/np3_hi_in/menu_hi_in.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "वेब टेम्पलेट 1 (&1)\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "वेब टेम्पलेट 2 (&2)\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "वेब प्रक्रिया 1 खोलें", CMD_WEBACTION1 MENUITEM "वेब प्रक्रिया 2 खोलें", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_hu_hu/menu_hu_hu.rc b/language/np3_hu_hu/menu_hu_hu.rc index 72dea8d38f..15c6f45293 100644 --- a/language/np3_hu_hu/menu_hu_hu.rc +++ b/language/np3_hu_hu/menu_hu_hu.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Web sablon &2\tCtrl+Shift+2", CMD_WEBACTION2 MENUITEM "Web sablon &1\tCtrl+Shift+1", CMD_WEBACTION1 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Kijelölésben lévő &mappa megnyitása", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Fájl me&gnyitása a kijelölésből", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Webes művelet 1", CMD_WEBACTION1 MENUITEM "Webes művelet 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Kijelölésben lévő mappa megnyitása", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Fájl megnyitása a kijelölésből", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_id_id/menu_id_id.rc b/language/np3_id_id/menu_id_id.rc index 13c7f3fcaf..96229039d6 100644 --- a/language/np3_id_id/menu_id_id.rc +++ b/language/np3_id_id/menu_id_id.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Templat Web &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Templat Web &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Buka Aksi Web 1", CMD_WEBACTION1 MENUITEM "Buka Aksi Web 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_it_it/menu_it_it.rc b/language/np3_it_it/menu_it_it.rc index 4cb4c84c3c..7183c71cfc 100644 --- a/language/np3_it_it/menu_it_it.rc +++ b/language/np3_it_it/menu_it_it.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Modello web &1\tCtrl+Maiusc+1", CMD_WEBACTION1 MENUITEM "Modello web &2\tCtrl+Maiusc+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Apri cartella &contenitore della seelzione", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Apri &file dalla selezione", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Apri azione web 1", CMD_WEBACTION1 MENUITEM "Apri azione web 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Apri cartella contenitore della selezione", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Apri file dalla selezione", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_ja_jp/menu_ja_jp.rc b/language/np3_ja_jp/menu_ja_jp.rc index 4142cb493f..2d0647eb7d 100644 --- a/language/np3_ja_jp/menu_ja_jp.rc +++ b/language/np3_ja_jp/menu_ja_jp.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "ウェブ1で開く(&1)\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "ウェブ2で開く(&2)\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "ウェブ1で開く", CMD_WEBACTION1 MENUITEM "ウェブ2で開く", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_ko_kr/menu_ko_kr.rc b/language/np3_ko_kr/menu_ko_kr.rc index ff1562e878..90f9cb8019 100644 --- a/language/np3_ko_kr/menu_ko_kr.rc +++ b/language/np3_ko_kr/menu_ko_kr.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "웹 템플릿 1(&1)\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "웹 템플릿 2(&2)\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "선택 항목이 있는 폴더 열기(&C)", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "선택에서 파일 열기(&F)", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "웹 작업 1 열기", CMD_WEBACTION1 MENUITEM "웹 작업 2 열기", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "선택 항목이 있는 폴더 열기", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "선택에서 파일 열기", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_nl_nl/menu_nl_nl.rc b/language/np3_nl_nl/menu_nl_nl.rc index e8f441a876..688fbae3bc 100644 --- a/language/np3_nl_nl/menu_nl_nl.rc +++ b/language/np3_nl_nl/menu_nl_nl.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Websjabloon &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Websjabloon &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "&Ingesloten map van selectie openen", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "&Bestand van selectie openen", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Websjabloon 1 openen", CMD_WEBACTION1 MENUITEM "Websjabloon 2 openen", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Ingesloten map van selectie openen", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Bestand van selectie openen", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_pl_pl/menu_pl_pl.rc b/language/np3_pl_pl/menu_pl_pl.rc index c558df1883..dbe4a4d193 100644 --- a/language/np3_pl_pl/menu_pl_pl.rc +++ b/language/np3_pl_pl/menu_pl_pl.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Szablon Web &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Szablon Web &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Otwórz Web Action 1", CMD_WEBACTION1 MENUITEM "Otwórz Web Action 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Otwórz folder dotyczący zaznaczenia", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Otwórz plik dotyczący zaznaczenia", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_pt_br/menu_pt_br.rc b/language/np3_pt_br/menu_pt_br.rc index 0d62101e10..57277b6ca6 100644 --- a/language/np3_pt_br/menu_pt_br.rc +++ b/language/np3_pt_br/menu_pt_br.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Modelo Web &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Modelo Web &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Abrir pasta de &trabalho da seleção", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Abrir ar&quivo da seleção", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Abrir Ação Web 1", CMD_WEBACTION1 MENUITEM "Abrir Ação Web 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Abrir pasta de trabalho da seleção", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Abrir arquivo da seleção", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_pt_pt/menu_pt_pt.rc b/language/np3_pt_pt/menu_pt_pt.rc index f88ec767c5..a1066a653e 100644 --- a/language/np3_pt_pt/menu_pt_pt.rc +++ b/language/np3_pt_pt/menu_pt_pt.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Modelo Web &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Modelo Web &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Abrir acção Web 1", CMD_WEBACTION1 MENUITEM "Abrir acção Web 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_ru_ru/menu_ru_ru.rc b/language/np3_ru_ru/menu_ru_ru.rc index 4b11113a28..cadb2390e9 100644 --- a/language/np3_ru_ru/menu_ru_ru.rc +++ b/language/np3_ru_ru/menu_ru_ru.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Веб-шаблон &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Веб-шаблон &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Открыть веб-действие 1", CMD_WEBACTION1 MENUITEM "Открыть веб-действие 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_sk_sk/menu_sk_sk.rc b/language/np3_sk_sk/menu_sk_sk.rc index e24b4ac0e1..e3f67a867a 100644 --- a/language/np3_sk_sk/menu_sk_sk.rc +++ b/language/np3_sk_sk/menu_sk_sk.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Webová šablóna &1\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Webová šablóna &2\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Otvoriť &priečinok obsahujúci výber", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Otvoriť &súbor z výberu", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Webová šablóna 1", CMD_WEBACTION1 MENUITEM "Webová šablóna 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Otvoriť vybratý &priečinok", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Otvoriť vybratý &súbor", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_sv_se/menu_sv_se.rc b/language/np3_sv_se/menu_sv_se.rc index de6fa8cdb6..b40d3bbce0 100644 --- a/language/np3_sv_se/menu_sv_se.rc +++ b/language/np3_sv_se/menu_sv_se.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Webbmall &1\tCtrl+Skift+1", CMD_WEBACTION1 MENUITEM "Webbmall &2\tCtrl+Skift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Öppna &innehållande mapp från markering", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Öppna &fil från markering", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Öppna webbåtgärd 1", CMD_WEBACTION1 MENUITEM "Öppna webbåtgärd 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Öppna innehållande mapp från markering", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Öppna fil från markering", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_tr_tr/menu_tr_tr.rc b/language/np3_tr_tr/menu_tr_tr.rc index b4ff3409d4..1f63c41ff6 100644 --- a/language/np3_tr_tr/menu_tr_tr.rc +++ b/language/np3_tr_tr/menu_tr_tr.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "&1. web kalıbı \tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "&2. web kalıbı\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "1. web işlemini aç", CMD_WEBACTION1 MENUITEM "2. web işlemini aç", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_vi_vn/menu_vi_vn.rc b/language/np3_vi_vn/menu_vi_vn.rc index 894986dfb4..9fd06c2933 100644 --- a/language/np3_vi_vn/menu_vi_vn.rc +++ b/language/np3_vi_vn/menu_vi_vn.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Mẫu web 1(&1)\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "Mẫu web 2(&2)\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open &Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open &File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Mở tác vụ web 1", CMD_WEBACTION1 MENUITEM "Mở tác vụ web 2", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "Open Containing Folder of Selection", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "Open File from Selection", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_zh_cn/menu_zh_cn.rc b/language/np3_zh_cn/menu_zh_cn.rc index ca0e262c61..45073111c0 100644 --- a/language/np3_zh_cn/menu_zh_cn.rc +++ b/language/np3_zh_cn/menu_zh_cn.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "用超链接模板 1 打开(&1)(&1)\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "用超链接模板 2 打开(&2)(&2)\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "打开所选内容所在的文件夹(&C)", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "打开所选内容指向的文件(&F)", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "用超链接模板 1 打开", CMD_WEBACTION1 MENUITEM "用超链接模板 2 打开", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "打开所选内容所在的文件夹", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "打开所选内容指向的文件", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/language/np3_zh_tw/menu_zh_tw.rc b/language/np3_zh_tw/menu_zh_tw.rc index cd050332af..0dcc0327ac 100644 --- a/language/np3_zh_tw/menu_zh_tw.rc +++ b/language/np3_zh_tw/menu_zh_tw.rc @@ -90,6 +90,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "用超連結範本 1 開啟(&1)\tCtrl+Shift+1", CMD_WEBACTION1 MENUITEM "用超連結範本 2 開啟(&2)\tCtrl+Shift+2", CMD_WEBACTION2 + MENUITEM "Preview current file &3\tCtrl+Shift+3", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "開啟選取內容所在的資料夾(&C)", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "開啟選取內容指向的檔案(&F)", IDM_EDIT_OPEN_FILE_FROM_SEL @@ -600,6 +601,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "用超連結模板 1 打開", CMD_WEBACTION1 MENUITEM "用超連結模板 2 打開", CMD_WEBACTION2 + MENUITEM "Preview current file", CMD_WEBACTION3 MENUITEM SEPARATOR MENUITEM "開啟選取內容所在的資料夾", IDM_EDIT_OPEN_CONTAINING_FOLDER_SEL MENUITEM "開啟選取內容指向的檔案", IDM_EDIT_OPEN_FILE_FROM_SEL diff --git a/readme/KeyboardShortcuts.md b/readme/KeyboardShortcuts.md index 9c3cbe5b0c..bb882eed57 100644 --- a/readme/KeyboardShortcuts.md +++ b/readme/KeyboardShortcuts.md @@ -58,8 +58,9 @@ A complete reference for the shortcuts wired into Notepad3 (`src/Notepad3.rc` ac | `Ctrl+L` | Launch document with its associated application | NP2 | | `Alt+L` | "Open with…" external program | NP2 | | `Ctrl+R` | Run command… | NP2 | -| `Ctrl+Shift+1` | Web template 1 (configurable URL — pass selection / file path) | (N3) | -| `Ctrl+Shift+2` | Web template 2 | (N3) | +| `Ctrl+Shift+1` | Web template 1 (`%s` for selected text, or `${FILE_URL}` for current-file preview in the configured or default browser; see [Web Actions](config/Configuration.md#web-actions)) | (N3) | +| `Ctrl+Shift+2` | Web template 2 (same template modes as above) | (N3) | +| `Ctrl+Shift+3` | Web template 3 (defaults to browser preview of the current saved file without a selection; see [Web Actions](config/Configuration.md#web-actions)) | (N3) | ### Encoding diff --git a/readme/MenuEntriesAndCmds.md b/readme/MenuEntriesAndCmds.md index 326e14af1c..3cd87ef379 100644 --- a/readme/MenuEntriesAndCmds.md +++ b/readme/MenuEntriesAndCmds.md @@ -65,7 +65,8 @@ External actions that operate on the current document or its location. | **Execute Document** | `Ctrl+L` | Run the current document through its shell association (e.g. open a `.html` file in the browser). | | **Open with…** | `Alt+L` | Show the Windows *"Open with"* picker for the current file. | | **Command…** | `Ctrl+R` | Open a free-form command-line dialog pre-populated with the current file's directory. | -| **Web Template 1 / 2** | `Ctrl+Shift+1` / `Ctrl+Shift+2` | Run a user-configurable web action. Templates and their menu labels are set via `[Settings2] WebTmplFilePath1/2`, `WebTmpl1MenuName/WebTmpl2MenuName` and friends in `Notepad3.ini`. Selection / file path can be substituted into the URL. See `config/Configuration.md`. | +| **Web Template 1 / 2** | `Ctrl+Shift+1` / `Ctrl+Shift+2` | Run a user-configurable web action. `[Settings2] WebTemplate1/2` and `WebTmpl1MenuName/WebTmpl2MenuName` configure templates and labels. Legacy `%s` templates use selected text; opt-in `${FILE_URL}` templates preview the current saved file without a selection, using the configured browser or the Windows default browser, never the file-extension association. See [Web Actions](config/Configuration.md#web-actions). | +| **Preview current file (Web Template 3)** | `Ctrl+Shift+3` | Preview the current saved file in the configured or default browser without a selection. `[Settings2] WebTemplate3` defaults to `${FILE_URL}` and accepts the same template modes as slots 1/2; `WebTmpl3MenuName` customizes its label. | | **Open File Explorer** | — | Open Windows Explorer with the current file pre-selected. | ### Revert / encoding / line endings @@ -650,7 +651,7 @@ A condensed editing menu reachable via right-click on the text: - **Undo / Redo / Cut / Copy / Paste / Delete / Select All** — standard editing. - **Convert Case → Uppercase / Lowercase / Invert Case / Title Case / Sentence Case** — same conversions as *Edit → Convert*, but apply to the selection **or** to the word at the right-click position when nothing is selected. - **Toggle Current Fold** — collapse or expand the fold containing the right-click line. Equivalent to clicking the fold margin's `+` / `-` glyph. -- **Open Web Action 1 / 2** — same as *File → Launch → Web Template 1 / 2*. Menu labels are customised via `Settings2.WebTmpl1MenuName` / `WebTmpl2MenuName`. +- **Open Web Action 1 / 2 / Preview current file** — same as *File → Launch → Web Templates 1 / 2 / 3*, including their shortcut hints. Menu labels are customised via `Settings2.WebTmpl1MenuName` / `WebTmpl2MenuName` / `WebTmpl3MenuName`. - **Open File Explorer** — open the current document's directory in Windows Explorer with the file selected. ### Bar area (right-click on title / toolbar / status bar / non-client area) diff --git a/readme/config/Configuration.md b/readme/config/Configuration.md index b1c69608f6..450b67d0a6 100644 --- a/readme/config/Configuration.md +++ b/readme/config/Configuration.md @@ -387,12 +387,47 @@ Dark-mode text color. Same `0xBBGGRR` byte order as above. #### `WebTemplate1=https://google.com/search?q=%s` +All three WebTemplates support two separate modes: + +- **Selection:** without `${FILE_URL}`, `%s` receives the selected text, truncated at the first CR, LF, or tab. Existing selection actions and their defaults are unchanged. +- **Current file:** the exact, case-sensitive `${FILE_URL}` token receives the current document's complete escaped file URL. No selection is required, even for an empty saved file. Every occurrence is replaced literally; do not combine this token with `%s`. + +Current-file templates require a saved document. They use the browser in `HyperlinkShellExURLWithApp`, or the Windows default browser (the HTTPS handler) when that setting is empty. The browser receives the file URL and decides how to handle its extension; Windows file-extension associations are never used. A missing or broken default browser reports an error rather than falling back to the document's associated application. + +With an explicit browser, `HyperlinkShellExURLCmdLnArgs` passes the result through its `${URL}` placeholder. For current-file templates, empty browser arguments pass the URL directly; nonempty arguments must contain `${URL}` or preview is rejected before saving. These arguments are ignored when using the default browser. The browser settings are shared with hyperlinks and selection templates. + +WebTemplate3 defaults to current-file preview; WebTemplate1/2 keep their original selection-search defaults. Existing customized templates and labels are preserved, not automatically migrated. For example, the following explicitly configures the third slot's built-in preview behavior: + +```ini +[Settings2] +WebTemplate3=${FILE_URL} +WebTmpl3MenuName=Preview current file +``` + +Press **Ctrl+Shift+3** to preview with the default third template; no configuration or selection is needed for a saved document. Untitled documents are disabled. For current-file templates, **Save before running tools** uses the usual save prompt: **Yes** saves before previewing, **No** previews the disk version, and **Cancel** or a failed save aborts. With the option off, preview uses the existing disk version. Selection templates do not acquire this save behavior. + +Environment variables in the configured file template are expanded before inserting the file URL; percent escapes and environment-looking text in filenames are not expanded afterward. Missing files, mixed `%s`/`${FILE_URL}` templates, conversion errors, and browser launch failures are reported rather than silently launching another application. Windows URL conversion limits apply: extended-length (`\\?\`) paths and over-limit inputs are rejected rather than truncated. + +Markdown rendering and refresh are browser-extension features, not Notepad3 features. Enable the extension's local-file access and autoreload as required; only changes saved to disk can refresh the preview. Notepad3 does not manage existing browser tabs. + +Behavior is covered by the [focused WebTemplate checks](../../test/TestWebTemplates.cpp), which exercise the WebTemplate settings-loading block and production menus/accelerators, stub INI/editor/save/browser-lookup/launch interaction, and use Windows file-URL conversion. + #### `WebTmpl1MenuName=Open Web Action 1` +Customizes the action's label in both **File → Launch** and the text context menu. Both menus retain the keyboard shortcut hint. + #### `WebTemplate2=https://en.wikipedia.org/w/index.php?search=%s` #### `WebTmpl2MenuName=Open Web Action 2` +#### `WebTemplate3=${FILE_URL}` + +Defaults to browser preview of the current saved file via **Ctrl+Shift+3**. Like slots 1/2, it also accepts selection-based `%s` templates. An explicitly empty value disables the action. + +#### `WebTmpl3MenuName=` + +Same menu-label behavior as `WebTmpl1MenuName`. An empty value keeps the localized **Preview current file** label; a custom value overrides it in both menus without removing the shortcut hint. + ### Auto-Completion & Editing #### `ExtendedWhiteSpaceChars=:` @@ -429,7 +464,7 @@ LineCommentPostfixStrg=" " #### `HyperlinkShellExURLWithApp=""` -External application for **Ctrl+Click** on URLs. If empty, the OS default handler is used. +External application for **Ctrl+Click** on URLs and WebTemplates. If empty, the OS default handler is used. [Current-file WebTemplates](#web-actions) specifically use the default browser, never the document's file-extension association. #### `HyperlinkShellExURLCmdLnArgs="${URL}"` diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 31c37f03b0..18f20d6630 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1487,6 +1487,10 @@ void LoadSettings() //~GetMenuStringW(Globals.hMainMenu, CMD_WEBACTION2, WebTmpl2MenuName, COUNTOF(WebTmpl2MenuName), MF_BYCOMMAND)) IniSectionGetStringNoQuotes(IniSecSettings2, L"WebTmpl2MenuName", L"", Settings2.WebTmpl2MenuName, COUNTOF(Settings2.WebTmpl2MenuName)); + IniSectionGetStringNoQuotes(IniSecSettings2, L"WebTemplate3", L"${FILE_URL}", pPathBuffer, PATHLONG_MAX_CCH); + StrgReset(Settings2.WebTemplate3, pPathBuffer); + IniSectionGetStringNoQuotes(IniSecSettings2, L"WebTmpl3MenuName", L"", Settings2.WebTmpl3MenuName, COUNTOF(Settings2.WebTmpl3MenuName)); + Settings2.LexerSQLNumberSignAsComment = IniSectionGetBool(IniSecSettings2, L"LexerSQLNumberSignAsComment", true); Settings2.AtomicFileSave = IniSectionGetBool(IniSecSettings2, L"AtomicFileSave", true); diff --git a/src/Notepad3.c b/src/Notepad3.c index f9f6f3fe69..f4939ed34c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -955,6 +955,7 @@ static void _InitGlobals() Settings2.WebTemplate1 = StrgCreate(NULL); Settings2.WebTemplate2 = StrgCreate(NULL); + Settings2.WebTemplate3 = StrgCreate(NULL); Settings2.HyperlinkShellExURLWithApp = StrgCreate(NULL); Settings2.HyperlinkShellExURLCmdLnArgs = StrgCreate(NULL); Settings2.FileDlgFilters = StrgCreate(NULL); @@ -1136,6 +1137,7 @@ static void _CleanUpResources(const HWND hwnd, bool bIsInitialized) StrgDestroy(Settings2.FileDlgFilters); StrgDestroy(Settings2.HyperlinkShellExURLCmdLnArgs); StrgDestroy(Settings2.HyperlinkShellExURLWithApp); + StrgDestroy(Settings2.WebTemplate3); StrgDestroy(Settings2.WebTemplate2); StrgDestroy(Settings2.WebTemplate1); @@ -4632,14 +4634,7 @@ LRESULT MsgContextMenu(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) imenu = bMargin ? MNU_MARGIN : MNU_EDIT; if (imenu == MNU_EDIT) { - // modify configured items HMENU const hStdCtxMenu = GetSubMenu(hMenuCtx, imenu); - if (StrIsNotEmpty(Settings2.WebTmpl1MenuName)) { - ModifyMenu(hStdCtxMenu, CMD_WEBACTION1, MF_BYCOMMAND | MF_STRING, CMD_WEBACTION1, Settings2.WebTmpl1MenuName); - } - if (StrIsNotEmpty(Settings2.WebTmpl2MenuName)) { - ModifyMenu(hStdCtxMenu, CMD_WEBACTION2, MF_BYCOMMAND | MF_STRING, CMD_WEBACTION2, Settings2.WebTmpl2MenuName); - } // Enable selection-acting commands based on selection-or-word-at-click-position. s_iCtxMenuClickPos = SciCall_CharPositionFromPointClose(pt.x, pt.y); @@ -4818,6 +4813,151 @@ LRESULT MsgExitMenuLoop(HWND hwnd, WPARAM wParam) } +//============================================================================= +// +// WebTemplate preparation +// +static bool _IsFileWebTemplate(LPCWSTR webTemplate) +{ + return StrIsNotEmpty(webTemplate) && (wcsstr(webTemplate, L"${FILE_URL}") != NULL); +} + +static bool _CanRunWebTemplate(LPCWSTR webTemplate, bool canUseSelection) +{ + if (!StrIsNotEmpty(webTemplate)) { + return false; + } + return _IsFileWebTemplate(webTemplate) + ? Path_IsNotEmpty(Paths.CurrentFile) + : canUseSelection; +} + +static void _UpdateWebTemplateMenu(HMENU hmenu, bool canUseSelection) +{ + const struct { + UINT command; + LPCWSTR name; + HSTRINGW webTemplate; + } actions[] = { + { CMD_WEBACTION1, Settings2.WebTmpl1MenuName, Settings2.WebTemplate1 }, + { CMD_WEBACTION2, Settings2.WebTmpl2MenuName, Settings2.WebTemplate2 }, + { CMD_WEBACTION3, Settings2.WebTmpl3MenuName, Settings2.WebTemplate3 } + }; + for (size_t i = 0; i < COUNTOF(actions); ++i) { + WCHAR label[SMALL_BUFFER] = { L'\0' }; + if (!GetMenuStringW(hmenu, actions[i].command, label, COUNTOF(label), MF_BYCOMMAND)) { + continue; + } + WCHAR mainLabel[SMALL_BUFFER] = { L'\0' }; + GetMenuStringW(Globals.hMainMenu, actions[i].command, mainLabel, COUNTOF(mainLabel), MF_BYCOMMAND); + if (StrIsNotEmpty(actions[i].name)) { + StringCchCopyW(label, COUNTOF(label), actions[i].name); + } + LPWSTR oldShortcut = StrChr(label, L'\t'); + if (oldShortcut) { + *oldShortcut = L'\0'; + } + LPCWSTR const shortcut = StrChr(mainLabel, L'\t'); + if (shortcut) { + StringCchCatW(label, COUNTOF(label), shortcut); + } + MENUITEMINFO item = { sizeof(item) }; + item.fMask = MIIM_STRING; + item.dwTypeData = label; + SetMenuItemInfoW(hmenu, actions[i].command, FALSE, &item); + EnableCmd(hmenu, actions[i].command, _CanRunWebTemplate(StrgGet(actions[i].webTemplate), canUseSelection)); + } +} + +static HRESULT _GetDefaultBrowserClass(HSTRINGW browserClass) +{ + DWORD length = 0; + HRESULT hr = AssocQueryStringW(ASSOCF_IS_PROTOCOL, ASSOCSTR_PROGID, L"https", NULL, NULL, &length); + if (FAILED(hr)) { + return hr; + } + if (!length) { + return HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION); + } + LPWSTR buffer = StrgWriteAccessBuf(browserClass, length); + // Failed growth can leave a non-null buffer with its old capacity. + if (!buffer || (StrgGetAllocLength(browserClass) < length)) { + return E_OUTOFMEMORY; + } + hr = AssocQueryStringW((ASSOCF)(ASSOCF_IS_PROTOCOL | ASSOCF_NOTRUNCATE), ASSOCSTR_PROGID, L"https", NULL, buffer, &length); + if (FAILED(hr)) { + return (hr == E_POINTER) ? HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) : hr; + } + StrgSanitize(browserClass); + return StrgIsNotEmpty(browserClass) ? S_OK : HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION); +} + +static bool _PrepareWebTemplate(LPCWSTR webTemplate, HSTRINGW target) +{ + if (!_IsFileWebTemplate(webTemplate)) { + WCHAR selectedText[STRINGW_MAX_URL_LENGTH + 1] = { L'\0' }; + if (EditGetSelectedText(selectedText, COUNTOF(selectedText)) <= 1) { + return false; + } + selectedText[wcscspn(selectedText, L"\r\n\t")] = L'\0'; + StrgFormat(target, webTemplate, selectedText); + ExpandEnvironmentStrgs(target, false); + return true; + } + + if (Path_IsEmpty(Paths.CurrentFile)) { + return false; + } + if (StrgReset(target, webTemplate) <= 0) { + InfoBoxLastError(webTemplate, ERROR_OUTOFMEMORY); + return false; + } + + ExpandEnvironmentStrgs(target, false); + if (wcsstr(StrgGet(target), L"%s")) { + InfoBoxLastError(webTemplate, ERROR_INVALID_PARAMETER); + return false; + } + LPCWSTR const arguments = StrgGet(Settings2.HyperlinkShellExURLCmdLnArgs); + if (StrgIsNotEmpty(Settings2.HyperlinkShellExURLWithApp) && StrIsNotEmpty(arguments) && !wcsstr(arguments, URLPLACEHLDR)) { + InfoBoxLastError(arguments, ERROR_INVALID_PARAMETER); + return false; + } + if (Settings.SaveBeforeRunningTools && !FileSave(FSF_Ask)) { + return false; + } + if (!Path_IsExistingFile(Paths.CurrentFile)) { + InfoBoxLastError(Path_Get(Paths.CurrentFile), ERROR_FILE_NOT_FOUND); + return false; + } + + size_t const pathLength = Path_GetLength(Paths.CurrentFile); + if ((pathLength >= INTERNET_MAX_URL_LENGTH) || (wcsncmp(Path_Get(Paths.CurrentFile), L"\\\\?\\", 4) == 0)) { + InfoBoxLastError(Path_Get(Paths.CurrentFile), ERROR_INVALID_NAME); + return false; + } + + HSTRINGW fileUrl = StrgCreate(NULL); + DWORD urlLength = (DWORD)(pathLength * 3 + COUNTOF(L"file:///")); + LPWSTR urlBuffer = StrgWriteAccessBuf(fileUrl, urlLength); + HRESULT const hr = (urlBuffer && (StrgGetAllocLength(fileUrl) >= urlLength)) + ? UrlCreateFromPathW(Path_Get(Paths.CurrentFile), urlBuffer, &urlLength, 0) + : E_OUTOFMEMORY; + if (SUCCEEDED(hr)) { + StrgSanitize(fileUrl); + // Keep percent escapes and environment-looking filenames out of format/expansion passes. + StrgReplace(target, L"${FILE_URL}", StrgGet(fileUrl)); + } + StrgDestroy(fileUrl); + if (FAILED(hr)) { + DWORD const error = (HRESULT_FACILITY(hr) == FACILITY_WIN32) ? HRESULT_CODE(hr) : (DWORD)hr; + InfoBoxLastError(Path_Get(Paths.CurrentFile), (hr == E_POINTER) ? ERROR_INSUFFICIENT_BUFFER : error); + return false; + } + return true; +} + + //============================================================================= // // MsgInitMenu() - Handles WM_INITMENU @@ -5321,8 +5461,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) bool const bIsHLink = (SciCall_IndicatorValueAt(INDIC_NP3_HYPERLINK, iCurPos) > 0); EnableCmd(hmenu, CMD_OPEN_HYPERLINK, !mrs && bIsHLink); EnableCmd(hmenu, CMD_COPY_HYPERLINK, !mrs && bIsHLink); - EnableCmd(hmenu, CMD_WEBACTION1, !se && !mrs && bPosInSel && !bIsHLink); - EnableCmd(hmenu, CMD_WEBACTION2, !se && !mrs && bPosInSel && !bIsHLink); + _UpdateWebTemplateMenu(hmenu, !se && !mrs && bPosInSel && !bIsHLink); i = (int)Path_IsNotEmpty(Settings2.AdministrationTool); EnableCmd(hmenu, IDM_HELP_ADMINEXE, i); @@ -8197,72 +8336,65 @@ static bool _HandleCmdCommands(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lPara break; case CMD_WEBACTION1: - case CMD_WEBACTION2: { - - const wchar_t* const wchWebTemplate = ((iLoWParam == CMD_WEBACTION1) ? StrgGet(Settings2.WebTemplate1) : StrgGet(Settings2.WebTemplate2)); - - if (StrIsNotEmpty(wchWebTemplate)) { - - WCHAR wszSelection[STRINGW_MAX_URL_LENGTH + 1] = { L'\0' }; - size_t const cchSelection = EditGetSelectedText(wszSelection, COUNTOF(wszSelection)); - - if (1 < cchSelection) { - - HPATHL hdir = Path_Copy(Paths.CurrentFile); - Path_RemoveFileSpec(hdir); + case CMD_WEBACTION2: + case CMD_WEBACTION3: { - // Check lpszSelection and truncate bad WCHARs - WCHAR* lpsz = StrChr(wszSelection, L'\r'); - if (lpsz) { - *lpsz = L'\0'; - } - - lpsz = StrChr(wszSelection, L'\n'); - if (lpsz) { - *lpsz = L'\0'; - } - - lpsz = StrChr(wszSelection, L'\t'); - if (lpsz) { - *lpsz = L'\0'; - } - - HSTRINGW hstr_hyplnk = StrgCreate(NULL); - StrgFormat(hstr_hyplnk, wchWebTemplate, wszSelection); - ExpandEnvironmentStrgs(hstr_hyplnk, false); + HSTRINGW const hstr_webTemplate = (iLoWParam == CMD_WEBACTION1) ? Settings2.WebTemplate1 + : ((iLoWParam == CMD_WEBACTION2) ? Settings2.WebTemplate2 : Settings2.WebTemplate3); + LPCWSTR const wchWebTemplate = StrgGet(hstr_webTemplate); - if (StrgIsNotEmpty(Settings2.HyperlinkShellExURLWithApp)) - { - HSTRINGW hstr_params = StrgCopy(Settings2.HyperlinkShellExURLCmdLnArgs); - StrgReplace(hstr_params, URLPLACEHLDR, StrgGet(hstr_hyplnk)); + if (!_CanRunWebTemplate(wchWebTemplate, true)) { + break; + } + bool const bFileTemplate = _IsFileWebTemplate(wchWebTemplate); + bool const bExplicitBrowser = StrgIsNotEmpty(Settings2.HyperlinkShellExURLWithApp); + HSTRINGW hstr_browserClass = NULL; + if (bFileTemplate && !bExplicitBrowser) { + hstr_browserClass = StrgCreate(NULL); + HRESULT const hr = _GetDefaultBrowserClass(hstr_browserClass); + if (FAILED(hr)) { + DWORD const error = (HRESULT_FACILITY(hr) == FACILITY_WIN32) ? HRESULT_CODE(hr) : (DWORD)hr; + InfoBoxLastError(L"https", error); + StrgDestroy(hstr_browserClass); + break; + } + } + HSTRINGW hstr_hyplnk = StrgCreate(NULL); + if (!_PrepareWebTemplate(wchWebTemplate, hstr_hyplnk)) { + StrgDestroy(hstr_hyplnk); + StrgDestroy(hstr_browserClass); + break; + } - SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) }; - sei.fMask = SEE_MASK_DEFAULT; - sei.hwnd = NULL; - sei.lpVerb = NULL; - sei.lpFile = StrgGet(Settings2.HyperlinkShellExURLWithApp); - sei.lpParameters = StrgGet(hstr_params); - sei.lpDirectory = Path_Get(hdir); - sei.nShow = SW_SHOWNORMAL; - ShellExecuteExW(&sei); + HPATHL hdir = Path_Copy(Paths.CurrentFile); + Path_RemoveFileSpec(hdir); + HSTRINGW hstr_params = NULL; - StrgDestroy(hstr_params); - } - else { - SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) }; - sei.fMask = SEE_MASK_NOZONECHECKS; - sei.hwnd = NULL; - sei.lpVerb = NULL; - sei.lpFile = StrgGet(hstr_hyplnk); - sei.lpParameters = NULL; - sei.lpDirectory = Path_Get(hdir); - sei.nShow = SW_SHOWNORMAL; - ShellExecuteExW(&sei); - } - StrgDestroy(hstr_hyplnk); - Path_Release(hdir); - } + SHELLEXECUTEINFO sei = { sizeof(SHELLEXECUTEINFO) }; + sei.fMask = bFileTemplate ? SEE_MASK_FLAG_NO_UI : SEE_MASK_DEFAULT; + sei.lpFile = StrgGet(hstr_hyplnk); + sei.lpDirectory = Path_Get(hdir); + sei.nShow = SW_SHOWNORMAL; + if (bExplicitBrowser) { + hstr_params = StrgCopy(Settings2.HyperlinkShellExURLCmdLnArgs); + StrgReplace(hstr_params, URLPLACEHLDR, StrgGet(hstr_hyplnk)); + sei.lpFile = StrgGet(Settings2.HyperlinkShellExURLWithApp); + sei.lpParameters = (bFileTemplate && !StrgIsNotEmpty(hstr_params)) ? StrgGet(hstr_hyplnk) : StrgGet(hstr_params); + } else if (bFileTemplate) { + // Force the browser, never the document's file-extension association. + sei.fMask |= SEE_MASK_CLASSNAME; + sei.lpClass = StrgGet(hstr_browserClass); + } else { + sei.fMask = SEE_MASK_NOZONECHECKS; + } + if (!ShellExecuteExW(&sei) && bFileTemplate) { + DWORD const error = GetLastError(); + InfoBoxLastError(sei.lpFile, error); } + StrgDestroy(hstr_params); + Path_Release(hdir); + StrgDestroy(hstr_hyplnk); + StrgDestroy(hstr_browserClass); } break; diff --git a/src/Notepad3.rc b/src/Notepad3.rc index cf8413c78e..4cb8c49be1 100644 --- a/src/Notepad3.rc +++ b/src/Notepad3.rc @@ -225,9 +225,10 @@ BEGIN "0", IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT //~"0", MMMMMMMMMMMMMMMMMM, VIRTKEY, SHIFT, CONTROL, NOINVERT (intercepted?) "1", CMD_STRINGIFY, VIRTKEY, CONTROL, NOINVERT - "1", CMD_WEBACTION1, VIRTKEY, SHIFT, CONTROL, NOINVERT "2", CMD_STRINGIFY2, VIRTKEY, CONTROL, NOINVERT + "1", CMD_WEBACTION1, VIRTKEY, SHIFT, CONTROL, NOINVERT "2", CMD_WEBACTION2, VIRTKEY, SHIFT, CONTROL, NOINVERT + "3", CMD_WEBACTION3, VIRTKEY, SHIFT, CONTROL, NOINVERT "3", CMD_EMBRACE, VIRTKEY, CONTROL, NOINVERT "4", CMD_EMBRACE2, VIRTKEY, CONTROL, NOINVERT "5", CMD_EMBRACE3, VIRTKEY, CONTROL, NOINVERT diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 1e41b84a8f..6de8cbcea7 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -854,6 +854,7 @@ typedef struct SETTINGS2_T { HSTRINGW WebTemplate1; HSTRINGW WebTemplate2; + HSTRINGW WebTemplate3; HSTRINGW HyperlinkShellExURLWithApp; HSTRINGW HyperlinkShellExURLCmdLnArgs; HSTRINGW FileDlgFilters; @@ -876,6 +877,7 @@ typedef struct SETTINGS2_T { WCHAR WebTmpl1MenuName[MICRO_BUFFER]; WCHAR WebTmpl2MenuName[MICRO_BUFFER]; + WCHAR WebTmpl3MenuName[MICRO_BUFFER]; WCHAR DefaultWindowPosition[MINI_BUFFER]; WCHAR PreferredLanguageLocaleName[LOCALE_NAME_MAX_LENGTH + 1];