Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Build/Notepad3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ SettingsVersion=5
;31=Reset Zoom
;32=New Empty Window
[Styles]
;DefaultScheme=2 ; zero-based lexer index (2 = Pure Text Files)
;Use2ndDefaultStyle=false
;AutoSelect=true
;SelectDlgSizeX=305
;SelectDlgSizeY=344
[Window]
;<ResX>x<ResY> DefaultWindowPosition=
[Suppressed Messages]
Expand All @@ -157,6 +162,7 @@ SettingsVersion=5
[2nd Common Base]
[Text Files]
[ANSI Art]
[ANSYS APDL]
[Apache Config Files]
[Assembly Script]
[AutoHotkey Script]
Expand Down Expand Up @@ -216,4 +222,3 @@ SettingsVersion=5
[Recent Files]
[Recent Find]
[Recent Replace]
[ANSYS APDL]
7 changes: 6 additions & 1 deletion Build/Notepad3_pap.ini
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ grepWin.exe=%PORTABLEAPPS_DIR%\grepWinPortable\grepWinPortable.exe
;31=Reset Zoom
;32=New Empty Window
[Styles]
;DefaultScheme=2 ; zero-based lexer index (2 = Pure Text Files)
;Use2ndDefaultStyle=false
;AutoSelect=true
;SelectDlgSizeX=305
;SelectDlgSizeY=344
[Window]
;<ResX>x<ResY> DefaultWindowPosition=
[Suppressed Messages]
Expand All @@ -157,6 +162,7 @@ grepWin.exe=%PORTABLEAPPS_DIR%\grepWinPortable\grepWinPortable.exe
[2nd Common Base]
[Text Files]
[ANSI Art]
[ANSYS APDL]
[Apache Config Files]
[Assembly Script]
[AutoHotkey Script]
Expand Down Expand Up @@ -216,4 +222,3 @@ grepWin.exe=%PORTABLEAPPS_DIR%\grepWinPortable\grepWinPortable.exe
[Recent Files]
[Recent Find]
[Recent Replace]
[ANSYS APDL]
7 changes: 6 additions & 1 deletion Build/Notepad3_ptb_x64.ini
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ Favorites=.\Favorites\
;31=Reset Zoom
;32=New Empty Window
[Styles]
;DefaultScheme=2 ; zero-based lexer index (2 = Pure Text Files)
;Use2ndDefaultStyle=false
;AutoSelect=true
;SelectDlgSizeX=305
;SelectDlgSizeY=344
[Window]
;<ResX>x<ResY> DefaultWindowPosition=
[Suppressed Messages]
Expand All @@ -157,6 +162,7 @@ Favorites=.\Favorites\
[2nd Common Base]
[Text Files]
[ANSI Art]
[ANSYS APDL]
[Apache Config Files]
[Assembly Script]
[AutoHotkey Script]
Expand Down Expand Up @@ -216,4 +222,3 @@ Favorites=.\Favorites\
[Recent Files]
[Recent Find]
[Recent Replace]
[ANSYS APDL]
7 changes: 6 additions & 1 deletion Build/Notepad3_ptb_x86.ini
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ Favorites=.\Favorites\
;31=Reset Zoom
;32=New Empty Window
[Styles]
;DefaultScheme=2 ; zero-based lexer index (2 = Pure Text Files)
;Use2ndDefaultStyle=false
;AutoSelect=true
;SelectDlgSizeX=305
;SelectDlgSizeY=344
[Window]
;<ResX>x<ResY> DefaultWindowPosition=
[Suppressed Messages]
Expand All @@ -157,6 +162,7 @@ Favorites=.\Favorites\
[2nd Common Base]
[Text Files]
[ANSI Art]
[ANSYS APDL]
[Apache Config Files]
[Assembly Script]
[AutoHotkey Script]
Expand Down Expand Up @@ -216,4 +222,3 @@ Favorites=.\Favorites\
[Recent Files]
[Recent Find]
[Recent Replace]
[ANSYS APDL]
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Notepad3 is a free, open-source text editor with syntax highlighting for Windows
### Syntax Highlighting
Over 55 languages supported, including:

> ANSI Art, Apache Config, Assembly, AutoHotkey, AutoIt3, AviSynth, Awk, Batch, C/C++, C#, CMake, CoffeeScript, CSS, CSV, D, Dart, Diff, F77/Fortran, Go, HTML/XML, Java, JavaScript, JSON, Julia, Kotlin, KiXtart, LaTeX, Lua, Makefiles, Markdown, MATLAB, Nim, NSIS, Pascal, Perl, PHP, PowerShell, Python, R/S-Plus, Registry, Resource Script, Ruby, Rust, Shell Script, SQL, SystemVerilog, Tcl, TOML, VBScript, VHDL, Verilog, Visual Basic, YAML, and more.
> ANSI Art, ANSYS APDL, Apache Config, Assembly, AutoHotkey, AutoIt3, AviSynth, Awk, Batch, C/C++, C#, CMake, CoffeeScript, CSS, CSV, D, Dart, Diff, F77/Fortran, Go, HTML/XML, Java, JavaScript, JSON, Julia, Kotlin, KiXtart, LaTeX, Lua, Makefiles, Markdown, MATLAB, Nim, NSIS, Pascal, Perl, PHP, PowerShell, Python, R/S-Plus, Registry, Resource Script, Ruby, Rust, Shell Script, SQL, SystemVerilog, Tcl, TOML, VBScript, VHDL, Verilog, Visual Basic, YAML, and more.

### File Handling
- **[AES-256 Rijndael](readme/encryption/Encryption.md)** encryption/decryption (in-app and command-line batch tool)
Expand Down
2 changes: 1 addition & 1 deletion readme/faq/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ A fast, lightweight, Scintilla/Lexilla-based text editor for Windows. Notepad3 i
Notepad3 keeps the small footprint and most of the Notepad2 shortcut set, while adding plenty of new functionality on top of Notepad2-mod's code folding, bookmarks, mark-all-occurrences, and word auto-completion. The differences you're most likely to notice:

- **Modern regex engine.** Find/Replace uses **PCRE2** (full Perl-compatible regex) instead of Scintilla's basic subset — multi-line search, lookarounds, named groups, and Unicode all work.
- **More languages.** Over 55 syntax lexers, including AutoHotkey, AutoIt3, AviSynth, Awk, CMake, CoffeeScript, CSV, D, Dart, Go, JSON, Julia, Kotlin, LaTeX, Lua, Markdown, MATLAB, Nim, NSIS, R, Registry, Ruby, Rust, SystemVerilog, Tcl, TOML, VHDL, Verilog, YAML, and more.
- **More languages.** Over 55 syntax lexers, including ANSYS APDL, AutoHotkey, AutoIt3, AviSynth, Awk, CMake, CoffeeScript, CSV, D, Dart, Go, JSON, Julia, Kotlin, LaTeX, Lua, Markdown, MATLAB, Nim, NSIS, R, Registry, Ruby, Rust, SystemVerilog, Tcl, TOML, VHDL, Verilog, YAML, and more.
- **Better encoding handling.** Automatic detection via [uchardet](https://www.freedesktop.org/wiki/Software/uchardet/), plus a much wider range of supported code pages.
- **Dark mode** and high-DPI awareness, with crisp toolbar icons at every scale factor.
- **Built-in AES-256 encryption** for sensitive files (with an optional command-line companion).
Expand Down
2 changes: 1 addition & 1 deletion readme/schema/CustomSchema.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Audience: advanced users who want to tweak colours and fonts beyond the built-in
| **Schema** / **Scheme** | A complete set of styles for one language (e.g. *C/C++ Source Code*, *Python Script*). Backed in code by an `EDITLEXER` record plus an array of `EDITSTYLE` entries. |
| **Style** | A single styleable element inside a schema (e.g. *Default Style*, *Keywords*, *Comments*, *Strings*). Each style has a plain-text *style string* describing its font, size, colours, etc. |
| **Theme** | A complete snapshot of all custom colours, schemas and per-schema extensions, stored as a standalone `.ini` file (e.g. `Dark.ini`). Switching themes replaces every schema's style strings at once. |
| **Lexilla lexer** | The underlying syntax-highlighting engine for a schema. Notepad3 ships with ~60 lexers (C++, Python, Markdown, Rust, YAML, …). |
| **Lexilla lexer** | The underlying syntax-highlighting engine for a schema. Notepad3 ships with ~60 lexers (ANSYS APDL, C++, Python, Markdown, Rust, YAML, …). |
| **Custom colours** | A 16-slot colour palette stored per-installation. Used by the *Customize Schemes* colour-picker and exported with every theme. |

Notepad3 ships with roughly 60 schemas; the exact list appears in the *Select Scheme* dialog (**Ctrl+F11**) and in the left-hand tree of *Customize Schemes* (**F12**).
Expand Down
2 changes: 1 addition & 1 deletion src/PathLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ bool PTHAPI Path_CreateFavLnk(LPCWSTR lpszLinkName, const HPATHL hTargetPth, con
//
// Path_CreateDeskLnk()
//
// Modified to create a desktop link to Notepad2
// Modified to create a desktop link to Notepad3
//
bool PTHAPI Path_CreateDeskLnk(const HPATHL hDocumentPath, LPCWSTR pszDescription)
{
Expand Down
135 changes: 93 additions & 42 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ extern COLORREF g_colorCustom[16];

// ----------------------------------------------------------------------------

// This array holds all the lexers...
// Don't forget to change the number of the lexer for HTML and XML
// in Notepad2.c ParseCommandLine() if you change this array!
// Array positions are used by saved DefaultScheme values and numeric lexer selection.
// Append new lexers to preserve existing indices; dialogs sort their displayed entries separately.
static PEDITLEXER g_pLexArray[] = {
&lexStandard, // Default Text
&lexStandard2nd, // 2nd Default Text
Expand All @@ -79,7 +78,6 @@ static PEDITLEXER g_pLexArray[] = {
&lexDart, // Dart Source Code
&lexDIFF, // Diff Files
&lexFortran, // Fortran F90+
//&lexF77, // Fortran F77
&lexGo, // Go Source Code
&lexINNO, // Inno Setup Script
&lexJAVA, // Java Source Code
Expand Down Expand Up @@ -117,7 +115,7 @@ static PEDITLEXER g_pLexArray[] = {
&lexHTML, // Web Source Code
&lexXML, // XML Document
&lexYAML, // YAML
&lexAPDL, // ANSYS APDL (append to preserve saved lexer indices)
&lexAPDL, // ANSYS APDL
};

int Style_NumOfLexers() {
Expand Down Expand Up @@ -4825,6 +4823,69 @@ void Style_GetLexerDisplayName(PEDITLEXER pLexer, LPWSTR lpszName, int cchName)
}
}

static int _GetLexerIndex(PEDITLEXER pLexer)
{
for (int i = 0; i < COUNTOF(g_pLexArray); ++i) {
if (g_pLexArray[i] == pLexer) {
return i;
}
}
return -1;
}

static int CALLBACK _CompareLexersByDisplayName(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
UNREFERENCED_PARAMETER(lParamSort);

PEDITLEXER const pLexer1 = (PEDITLEXER)lParam1;
PEDITLEXER const pLexer2 = (PEDITLEXER)lParam2;
if (pLexer1 == pLexer2) {
return 0;
}

// Keep the two default schemes and Pure Text at the top in their existing order.
for (int i = 0; i < 3; ++i) {
if (pLexer1 == g_pLexArray[i]) {
return -1;
}
if (pLexer2 == g_pLexArray[i]) {
return 1;
}
}

WCHAR name1[MIDSZ_BUFFER] = { L'\0' };
WCHAR name2[MIDSZ_BUFFER] = { L'\0' };
Style_GetLexerDisplayName(pLexer1, name1, COUNTOF(name1));
Style_GetLexerDisplayName(pLexer2, name2, COUNTOF(name2));

int const cmp = StrCmpIW(name1, name2);
return (cmp != 0) ? cmp : _GetLexerIndex(pLexer1) - _GetLexerIndex(pLexer2);
}

static HTREEITEM _FindLexerTreeItem(HWND hwndTV, PEDITLEXER pLexer)
{
for (HTREEITEM hItem = TreeView_GetRoot(hwndTV); hItem; hItem = TreeView_GetNextSibling(hwndTV, hItem)) {
TVITEM tvi = { 0 };
tvi.mask = TVIF_PARAM;
tvi.hItem = hItem;
if (TreeView_GetItem(hwndTV, &tvi) && ((PEDITLEXER)tvi.lParam == pLexer)) {
return hItem;
}
}
return NULL;
}

static PEDITLEXER _GetListViewLexer(HWND hwndLV, int iItem)
{
if (iItem < 0) {
return NULL;
}
LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM;
lvi.iItem = iItem;
return ListView_GetItem(hwndLV, &lvi) ? (PEDITLEXER)lvi.lParam : NULL;
}


//=============================================================================
//
Expand Down Expand Up @@ -5111,14 +5172,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
flagIconSize | SHGFI_SYSICONINDEX | SHGFI_USEFILEATTRIBUTES),
TVSIL_NORMAL);

// findlexer
int found = -1;
for (int i = 0; i < COUNTOF(g_pLexArray); ++i) {
if (g_pLexArray[i] == s_pLexCurrent) {
found = i;
break;
}
}
int const found = _GetLexerIndex(s_pLexCurrent);

// Build lexer tree view
HTREEITEM hCurrentTVLex = NULL;
Expand All @@ -5129,11 +5183,11 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
Style_AddLexerToTreeView(hwndTV, g_pLexArray[i]);
}
}
TV_SORTCB tvSort = { NULL, _CompareLexersByDisplayName, 0 };
TreeView_SortChildrenCB(hwndTV, &tvSort, FALSE);
if (!hCurrentTVLex) {
hCurrentTVLex = TreeView_GetRoot(hwndTV);
if (Style_GetUse2ndDefault()) {
hCurrentTVLex = TreeView_GetNextSibling(hwndTV, hCurrentTVLex);
}
PEDITLEXER const pDefaultTextLexer = Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard;
hCurrentTVLex = _FindLexerTreeItem(hwndTV, pDefaultTextLexer);
}
TreeView_Select(hwndTV, hCurrentTVLex, TVGN_CARET);
TreeView_Expand(hwndTV, hCurrentTVLex, TVE_EXPAND);
Expand Down Expand Up @@ -5518,16 +5572,13 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
switch (LOWORD(wParam)) {
case IDC_SETCURLEXERTV: {
// find current lexer's tree entry
HTREEITEM hCurrentTVLex = TreeView_GetRoot(hwndTV);
for (int i = 0; i < COUNTOF(g_pLexArray); ++i) {
if (g_pLexArray[i] == s_pLexCurrent) {
break;
}
hCurrentTVLex = TreeView_GetNextSibling(hwndTV, hCurrentTVLex); // next
}
if (s_pLexCurrent == pCurrentLexer) {
break; // no change
}
HTREEITEM hCurrentTVLex = _FindLexerTreeItem(hwndTV, s_pLexCurrent);
if (!hCurrentTVLex) {
break;
}

// collaps current node
HTREEITEM hSel = TreeView_GetSelection(hwndTV);
Expand Down Expand Up @@ -5773,14 +5824,15 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR

static HWND hwndLV = NULL;

static int iInternalDefault = 0;
static PEDITLEXER pDefaultLexer = NULL;
static PEDITLEXER* pSelectedLexer = NULL;


switch(umsg) {
case WM_INITDIALOG: {

pSelectedLexer = (PEDITLEXER*)lParam;
pDefaultLexer = GetDefaultLexer();

SetDialogIconNP3(hwnd);
InitWindowCommon(hwnd, true);
Expand Down Expand Up @@ -5824,25 +5876,21 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
for (int i = 0; i < COUNTOF(g_pLexArray); i++) {
Style_AddLexerToListView(hwndLV, g_pLexArray[i]);
}
ListView_SortItems(hwndLV, _CompareLexersByDisplayName, 0);
ListView_SetColumnWidth(hwndLV,0,LVSCW_AUTOSIZE_USEHEADER);

// Select current lexer
int lvItems = ListView_GetItemCount(hwndLV);
LVITEM lvi = { 0 };
lvi.mask = LVIF_PARAM;
for (int i = 0; i < lvItems; i++) {
lvi.iItem = i;
ListView_GetItem(hwndLV,&lvi);

if (((PEDITLEXER)lvi.lParam)->resID == (*pSelectedLexer)->resID) {
PEDITLEXER const pLexer = _GetListViewLexer(hwndLV, i);
if (pLexer && (pLexer->resID == (*pSelectedLexer)->resID)) {
ListView_SetItemState(hwndLV,i,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
ListView_EnsureVisible(hwndLV,i,false);
CheckDlgButton(hwnd, IDC_DEFAULTSCHEME, SetBtn(s_iDefaultLexer == i));
CheckDlgButton(hwnd, IDC_DEFAULTSCHEME, SetBtn(pLexer == pDefaultLexer));
break;
}
}

iInternalDefault = s_iDefaultLexer;
CheckDlgButton(hwnd,IDC_AUTOSELECT, SetBtn(s_bAutoSelect));

CenterDlgInParent(hwnd, false);
Expand Down Expand Up @@ -5925,7 +5973,9 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
case LVN_ITEMCHANGED:
case LVN_DELETEITEM: {
int i = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
CheckDlgButton(hwnd, IDC_DEFAULTSCHEME, SetBtn(iInternalDefault == i));
PEDITLEXER const pSelected = _GetListViewLexer(hwndLV, i);
CheckDlgButton(hwnd, IDC_DEFAULTSCHEME,
SetBtn(pSelected && (pSelected == pDefaultLexer)));
DialogEnableControl(hwnd, IDC_DEFAULTSCHEME, i != -1);
DialogEnableControl(hwnd, IDOK, i != -1);
}
Expand All @@ -5940,20 +5990,21 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPAR
switch (LOWORD(wParam)) {
case IDC_DEFAULTSCHEME:
if (IsButtonChecked(hwnd, IDC_DEFAULTSCHEME)) {
iInternalDefault = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
int const iSelected = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
PEDITLEXER const pSelected = _GetListViewLexer(hwndLV, iSelected);
pDefaultLexer = pSelected ? pSelected : &lexStandard;
} else {
iInternalDefault = 0;
pDefaultLexer = &lexStandard;
}
break;


case IDOK: {
LVITEM lvi = {0};
lvi.mask = LVIF_PARAM;
lvi.iItem = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
if (ListView_GetItem(hwndLV, &lvi)) {
*pSelectedLexer = (PEDITLEXER)lvi.lParam;
s_iDefaultLexer = iInternalDefault;
int const iSelected = ListView_GetNextItem(hwndLV, -1, LVNI_ALL | LVNI_SELECTED);
PEDITLEXER const pSelected = _GetListViewLexer(hwndLV, iSelected);
if (pSelected) {
*pSelectedLexer = pSelected;
s_iDefaultLexer = _GetLexerIndex(pDefaultLexer);
s_bAutoSelect = IsButtonChecked(hwnd, IDC_AUTOSELECT);
//@@@??? Flags.bHugeFileLoadState = false; // user choice
EndDialog(hwnd,IDOK);
Expand Down