Skip to content

Commit 8e6bd0a

Browse files
committed
Added function to get filename
1 parent d69eeb9 commit 8e6bd0a

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

NppJSONViewer/NppJsonViewer/NppJsonPlugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ void NppJsonPlugin::PluginInit(HMODULE hModule)
1818

1919
void NppJsonPlugin::PluginCleanup() {}
2020

21-
void NppJsonPlugin::SetInfo(const NppData &notpadPlusData)
21+
void NppJsonPlugin::SetInfo(const NppData &nppData)
2222
{
23-
m_NppData = notpadPlusData;
23+
m_NppData = nppData;
2424
InitCommandMenu();
2525
InitToolbarIcon();
2626
InitConfigPath();

NppJSONViewer/NppJsonViewer/NppJsonPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class NppJsonPlugin
2020
void PluginCleanup();
2121

2222
// Notepad++ APIs to be implemented
23-
void SetInfo(const NppData &notpadPlusData);
23+
void SetInfo(const NppData &nppData);
2424

2525
const TCHAR *GetPluginName() const;
2626

NppJSONViewer/NppJsonViewer/ScintillaEditor.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void ScintillaEditor::RefreshViewHandle()
1717
m_hScintilla = (which == 0) ? m_NppData._scintillaMainHandle : m_NppData._scintillaSecondHandle;
1818
}
1919

20-
std::string ScintillaEditor::GetJsonText()
20+
auto ScintillaEditor::GetJsonText() -> std::string
2121
{
2222
if (!m_hScintilla)
2323
return std::string();
@@ -54,6 +54,13 @@ bool ScintillaEditor::IsJsonFile() const
5454
return langType == LangType::L_JSON;
5555
}
5656

57+
auto ScintillaEditor::GetCurrentFileName() const -> std::wstring
58+
{
59+
wchar_t fileName[MAX_PATH] {};
60+
::SendMessage(m_NppData._nppHandle, NPPM_GETFILENAME, 0, reinterpret_cast<LPARAM>(&fileName));
61+
return fileName;
62+
}
63+
5764
void ScintillaEditor::ReplaceSelection(const std::string &text) const
5865
{
5966
::SendMessage(m_hScintilla, SCI_REPLACESEL, 0, reinterpret_cast<LPARAM>(text.c_str()));

NppJSONViewer/NppJsonViewer/ScintillaEditor.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ class ScintillaEditor
99
explicit ScintillaEditor(const NppData &nppData);
1010
~ScintillaEditor() = default;
1111

12-
void RefreshViewHandle();
13-
std::string GetJsonText();
14-
void SetLangAsJson() const;
15-
bool IsJsonFile() const;
12+
void RefreshViewHandle();
13+
auto GetJsonText() -> std::string;
14+
void SetLangAsJson() const;
15+
bool IsJsonFile() const;
16+
auto GetCurrentFileName() const -> std::wstring;
1617

1718
void ReplaceSelection(const std::string &text) const;
1819

0 commit comments

Comments
 (0)