| 18 | } |
| 19 | |
| 20 | auto 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 | |
| 50 | void ScintillaEditor::SetLangAsJson() const |
| 51 | { |
no outgoing calls
no test coverage detected