Skip to content

Commit 9dc6355

Browse files
committed
Merge pull request #9 from nananankona/a
2 parents bc23ab5 + 9d6ab50 commit 9dc6355

19 files changed

Lines changed: 802 additions & 126 deletions

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ endif()
2828
add_executable(legacy-notepad WIN32
2929
src/main.cpp
3030
src/core/globals.cpp
31+
src/lang/lang.cpp
3132
src/modules/theme.cpp
3233
src/modules/editor.cpp
3334
src/modules/file.cpp
3435
src/modules/ui.cpp
3536
src/modules/background.cpp
3637
src/modules/dialog.cpp
3738
src/modules/commands.cpp
39+
src/modules/menu.cpp
3840
src/modules/settings.cpp
3941
src/notepad.rc
4042
)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ A lightweight, 25x fast, Windows notepad alternative built with C++17 and Win32
1111

1212
## Features
1313

14+
- **Multi-language support**: English and Japanese translations with runtime switching.
1415
- **Multi-encoding text**: UTF-8, UTF-8 BOM, UTF-16 LE/BE, ANSI with line-ending selection.
1516
- **Rich editing**: word wrap toggle, font selection, zoom, time/date stamp, find/replace/goto.
1617
- **Backgrounds**: optional image with tile/stretch/fit/fill/anchor modes and opacity control. (known issues)
18+
- **Always on top**: window pinning support.
1719
- **Printing**: print and page setup dialogs.
1820
- **Customizable icon**: change the application icon to any .ico file, including classic Notepad icons.
1921

src/core/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ struct AppState
120120
bool fontItalic = false;
121121
bool fontUnderline = false;
122122
BYTE windowOpacity = 255;
123+
bool alwaysOnTop = false;
123124
bool closing = false;
124125
HFONT hFont = nullptr;
125126
std::deque<std::wstring> recentFiles;

src/lang/en.h

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#pragma once
2+
3+
#include "lang.h"
4+
5+
inline LangStrings g_langEN = {
6+
L"Notepad",
7+
L"Untitled",
8+
9+
L"&File",
10+
L"&New\tCtrl+N",
11+
L"&Open...\tCtrl+O",
12+
L"&Save\tCtrl+S",
13+
L"Save &As...\tCtrl+Shift+S",
14+
L"&Print...\tCtrl+P",
15+
L"Page Set&up...",
16+
L"E&xit",
17+
L"Recent Files",
18+
19+
L"&Edit",
20+
L"&Undo\tCtrl+Z",
21+
L"&Redo\tCtrl+Y",
22+
L"Cu&t\tCtrl+X",
23+
L"&Copy\tCtrl+C",
24+
L"&Paste\tCtrl+V",
25+
L"De&lete\tDel",
26+
L"&Find...\tCtrl+F",
27+
L"Find &Next\tF3",
28+
L"Find Pre&vious\tShift+F3",
29+
L"&Replace...\tCtrl+H",
30+
L"&Go To...\tCtrl+G",
31+
L"Select &All\tCtrl+A",
32+
L"Time/&Date\tF5",
33+
34+
L"F&ormat",
35+
L"&Word Wrap",
36+
L"&Font...",
37+
38+
L"&View",
39+
L"Zoom &In\tCtrl+Plus",
40+
L"Zoom &Out\tCtrl+Minus",
41+
L"&Restore Default Zoom\tCtrl+0",
42+
L"&Status Bar",
43+
L"&Dark Mode",
44+
L"&Background",
45+
L"&Select Image...",
46+
L"&Clear Background",
47+
L"&Opacity...",
48+
L"&Position",
49+
L"Top Left",
50+
L"Top Center",
51+
L"Top Right",
52+
L"Center Left",
53+
L"Center",
54+
L"Center Right",
55+
L"Bottom Left",
56+
L"Bottom Center",
57+
L"Bottom Right",
58+
L"Tile",
59+
L"Stretch",
60+
L"Fit",
61+
L"Fill",
62+
L"Window &Transparency...",
63+
L"Always on &Top",
64+
65+
L"&Help",
66+
L"&About Notepad",
67+
68+
L"&Language",
69+
L"&English",
70+
L"&Japanese",
71+
72+
L"Find",
73+
L"Find and Replace",
74+
L"Go To Line",
75+
L"Window Transparency",
76+
L"Find:",
77+
L"Replace:",
78+
L"Find Next",
79+
L"Replace",
80+
L"Replace All",
81+
L"Close",
82+
L"Line number:",
83+
L"OK",
84+
L"Cancel",
85+
L"Opacity (10-100%):",
86+
87+
L"Cannot find \"",
88+
L"Do you want to save changes to ",
89+
L"Cannot open file.",
90+
L"Cannot save file.",
91+
L"Error",
92+
L"Legacy Notepad v1.1.1\n\nA fast, lightweight text editor.\n\nBuilt with C++ and Win32 API.\n", //\nModify by 0x2o.net",
93+
94+
L" Ln ",
95+
L", Col ",
96+
97+
L"UTF-8",
98+
L"UTF-8 with BOM",
99+
L"UTF-16 LE",
100+
L"UTF-16 BE",
101+
L"ANSI",
102+
103+
L"Windows (CRLF)",
104+
L"Unix (LF)",
105+
L"Macintosh (CR)"};

src/lang/ja.h

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#pragma once
2+
3+
#include "lang.h"
4+
5+
inline LangStrings g_langJA = {
6+
L"メモ帳",
7+
L"無題",
8+
9+
L"ファイル(&F)",
10+
L"新規(&N)\tCtrl+N",
11+
L"開く(&O)...\tCtrl+O",
12+
L"上書き保存(&S)\tCtrl+S",
13+
L"名前を付けて保存(&A)...\tCtrl+Shift+S",
14+
L"印刷(&P)...\tCtrl+P",
15+
L"ページ設定(&U)...",
16+
L"終了(&X)",
17+
L"最近使ったファイル",
18+
19+
L"編集(&E)",
20+
L"元に戻す(&U)\tCtrl+Z",
21+
L"やり直し(&R)\tCtrl+Y",
22+
L"切り取り(&T)\tCtrl+X",
23+
L"コピー(&C)\tCtrl+C",
24+
L"貼り付け(&P)\tCtrl+V",
25+
L"削除(&L)\tDel",
26+
L"検索(&F)...\tCtrl+F",
27+
L"次を検索(&N)\tF3",
28+
L"前を検索(&V)\tShift+F3",
29+
L"置換(&H)...\tCtrl+H",
30+
L"ジャンプ(&G)...\tCtrl+G",
31+
L"すべて選択(&A)\tCtrl+A",
32+
L"日時(&D)\tF5",
33+
34+
L"書式(&O)",
35+
L"折り返し(&W)",
36+
L"フォント(&F)...",
37+
38+
L"表示(&V)",
39+
L"拡大(&I)\tCtrl+Plus",
40+
L"縮小(&O)\tCtrl+Minus",
41+
L"既定のサイズに戻す(&R)\tCtrl+0",
42+
L"ステータスバー(&S)",
43+
L"ダークモード(&D)",
44+
L"背景(&B)",
45+
L"画像を選択(&S)...",
46+
L"背景をクリア(&C)",
47+
L"不透明度(&O)...",
48+
L"位置(&P)",
49+
L"左上",
50+
L"上中央",
51+
L"右上",
52+
L"中央左",
53+
L"中央",
54+
L"中央右",
55+
L"左下",
56+
L"下中央",
57+
L"右下",
58+
L"並べて表示",
59+
L"拡大",
60+
L"サイズに合わせる",
61+
L"フィル",
62+
L"ウィンドウの透明度(&T)...",
63+
L"常に最前面に表示(&T)",
64+
65+
L"ヘルプ(&H)",
66+
L"メモ帳について(&A)",
67+
68+
L"言語(&L)",
69+
L"英語(&E)",
70+
L"日本語(&J)",
71+
72+
L"検索",
73+
L"検索と置換",
74+
L"行へジャンプ",
75+
L"ウィンドウの透明度",
76+
L"検索:",
77+
L"置換:",
78+
L"次を検索",
79+
L"置換",
80+
L"すべて置換",
81+
L"閉じる",
82+
L"行番号:",
83+
L"OK",
84+
L"キャンセル",
85+
L"不透明度 (10-100%):",
86+
87+
L"「",
88+
L"次のファイルに変更を保存しますか: ",
89+
L"ファイルを開けません。",
90+
L"ファイルを保存できません。",
91+
L"エラー",
92+
L"Legacy Notepad v1.1.1\n\n高速で軽量なテキストエディタ。\n\nC++ Win32 API で構築。\n", //\nModify by 0x2o.net",
93+
94+
L" 行 ",
95+
L", 列 ",
96+
97+
L"UTF-8",
98+
L"UTF-8 (BOM付き)",
99+
L"UTF-16 LE",
100+
L"UTF-16 BE",
101+
L"ANSI",
102+
103+
L"Windows (CRLF)",
104+
L"Unix (LF)",
105+
L"Macintosh (CR)"};

src/lang/lang.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include "lang.h"
2+
#include "en.h"
3+
#include "ja.h"
4+
#include <windows.h>
5+
6+
static LangID g_currentLang = LangID::EN;
7+
static const LangStrings *g_currentStrings = &g_langEN;
8+
9+
LangID LoadLanguageSetting()
10+
{
11+
HKEY hKey;
12+
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\LegacyNotepad", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
13+
{
14+
DWORD value = 0, size = sizeof(value);
15+
if (RegQueryValueExW(hKey, L"Language", nullptr, nullptr, reinterpret_cast<LPBYTE>(&value), &size) == ERROR_SUCCESS)
16+
{
17+
RegCloseKey(hKey);
18+
return static_cast<LangID>(value);
19+
}
20+
RegCloseKey(hKey);
21+
}
22+
return LangID::EN;
23+
}
24+
25+
void SaveLanguageSetting()
26+
{
27+
HKEY hKey;
28+
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\LegacyNotepad", 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &hKey, nullptr) == ERROR_SUCCESS)
29+
{
30+
DWORD value = static_cast<DWORD>(g_currentLang);
31+
RegSetValueExW(hKey, L"Language", 0, REG_DWORD, reinterpret_cast<const BYTE *>(&value), sizeof(value));
32+
RegCloseKey(hKey);
33+
}
34+
}
35+
36+
void InitLanguage()
37+
{
38+
LangID savedLang = LoadLanguageSetting();
39+
SetLanguage(savedLang);
40+
}
41+
42+
void SetLanguage(LangID lang)
43+
{
44+
g_currentLang = lang;
45+
SaveLanguageSetting();
46+
47+
switch (lang)
48+
{
49+
case LangID::JA:
50+
g_currentStrings = &g_langJA;
51+
break;
52+
case LangID::EN:
53+
default:
54+
g_currentStrings = &g_langEN;
55+
break;
56+
}
57+
58+
SaveLanguageSetting();
59+
}
60+
61+
LangID GetCurrentLanguage()
62+
{
63+
return g_currentLang;
64+
}
65+
66+
const LangStrings &GetLangStrings()
67+
{
68+
return *g_currentStrings;
69+
}
70+
71+
const std::wstring &GetString([[maybe_unused]] const std::wstring &key)
72+
{
73+
static std::wstring empty;
74+
return empty;
75+
}

0 commit comments

Comments
 (0)