| 2811 | } |
| 2812 | |
| 2813 | void ScintillaEditView::convertSelectedTextTo(const TextCaseType & caseToConvert) |
| 2814 | { |
| 2815 | int selectionStart = execute(SCI_GETSELECTIONSTART); |
| 2816 | int selectionEnd = execute(SCI_GETSELECTIONEND); |
| 2817 | |
| 2818 | int strLen = (selectionEnd - selectionStart); |
| 2819 | if (strLen != 0) |
| 2820 | { |
| 2821 | int strSize = strLen + 1; |
| 2822 | |
| 2823 | char *selectedStr = new char[strSize]; |
| 2824 | |
| 2825 | execute(SCI_GETSELTEXT, 0, reinterpret_cast<sptr_t>(selectedStr)); |
| 2826 | |
| 2827 | QString utf8Str(selectedStr); |
| 2828 | changeCase(caseToConvert, utf8Str); |
| 2829 | |
| 2830 | QByteArray bytes = utf8Str.toUtf8(); |
| 2831 | |
| 2832 | execute(SCI_SETTARGETRANGE, selectionStart, selectionEnd); |
| 2833 | |
| 2834 | execute(SCI_BEGINUNDOACTION); |
| 2835 | execute(SCI_REPLACETARGET, strLen, reinterpret_cast<sptr_t>(bytes.data())); |
| 2836 | execute(SCI_ENDUNDOACTION); |
| 2837 | execute(SCI_SETSEL, selectionStart, selectionEnd); |
| 2838 | delete[] selectedStr; |
| 2839 | } |
| 2840 | } |
| 2841 | |
| 2842 | //获取当前选择的行范围 |
| 2843 | std::pair<size_t, size_t> ScintillaEditView::getSelectionLinesRange(intptr_t selectionNumber /* = -1 */) const |
no test coverage detected