MCPcopy Create free account
hub / github.com/NPP-JSONViewer/JSON-Viewer / GetJsonText

Method GetJsonText

src/NppJsonViewer/ScintillaEditor.cpp:20–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20auto ScintillaEditor::GetJsonText() -> ScintillaData
21{
22 if (!m_hScintilla)
23 return ScintillaCode::NotInitialized;
24
25 // Multi selection is not supported
26 size_t nSelections = ::SendMessage(m_hScintilla, SCI_GETSELECTIONS, 0, 0);
27 if (nSelections > 1)
28 return ScintillaCode::MultiLineSelection;
29
30 // Adjust the selection position
31 RefreshSelectionPos();
32
33 // Get only selected text if any else select all text
34 size_t asciiTextLen = m_nEndPos - m_nStartPos;
35 if (asciiTextLen == 0)
36 {
37 asciiTextLen = ::SendMessage(m_hScintilla, SCI_GETLENGTH, 0, 0);
38 ::SendMessage(m_hScintilla, SCI_SETSELECTIONSTART, 0, 0);
39 ::SendMessage(m_hScintilla, SCI_SETSELECTIONEND, asciiTextLen, 0);
40 }
41 std::unique_ptr<CHAR[]> chSelectedText = std::make_unique<CHAR[]>(asciiTextLen + 1);
42 ::SendMessage(m_hScintilla, SCI_GETSELTEXT, 0, reinterpret_cast<LPARAM>(chSelectedText.get()));
43
44 // Update selection position
45 RefreshSelectionPos();
46
47 return chSelectedText.get();
48}
49
50void ScintillaEditor::SetLangAsJson() const
51{

Callers 5

FormatJsonMethod · 0.80
CompressJsonMethod · 0.80
SortJsonByKeyMethod · 0.80
ValidateJsonMethod · 0.80
DrawJsonTreeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected