| 5165 | } |
| 5166 | |
| 5167 | void Editor::NewLine() |
| 5168 | { |
| 5169 | // Remove non-main ranges |
| 5170 | InvalidateSelection ( sel.RangeMain(), true ); |
| 5171 | sel.SetSelection ( sel.RangeMain() ); |
| 5172 | // Clear main range and insert line end |
| 5173 | bool needGroupUndo = !sel.Empty(); |
| 5174 | if ( needGroupUndo ) { |
| 5175 | pdoc->BeginUndoAction(); |
| 5176 | } |
| 5177 | if ( !sel.Empty() ) { |
| 5178 | ClearSelection(); |
| 5179 | } |
| 5180 | const char *eol = "\n"; |
| 5181 | if ( pdoc->eolMode == SC_EOL_CRLF ) { |
| 5182 | eol = "\r\n"; |
| 5183 | } else if ( pdoc->eolMode == SC_EOL_CR ) { |
| 5184 | eol = "\r"; |
| 5185 | } // else SC_EOL_LF -> "\n" already set |
| 5186 | bool inserted = pdoc->InsertCString ( sel.MainCaret(), eol ); |
| 5187 | // Want to end undo group before NotifyChar as applications often modify text here |
| 5188 | if ( needGroupUndo ) { |
| 5189 | pdoc->EndUndoAction(); |
| 5190 | } |
| 5191 | if ( inserted ) { |
| 5192 | SetEmptySelection ( sel.MainCaret() + istrlen ( eol ) ); |
| 5193 | while ( *eol ) { |
| 5194 | NotifyChar ( *eol ); |
| 5195 | if ( recordingMacro ) { |
| 5196 | char txt[2]; |
| 5197 | txt[0] = *eol; |
| 5198 | txt[1] = '\0'; |
| 5199 | NotifyMacroRecord ( SCI_REPLACESEL, 0, reinterpret_cast<sptr_t> ( txt ) ); |
| 5200 | } |
| 5201 | eol++; |
| 5202 | } |
| 5203 | } |
| 5204 | SetLastXChosen(); |
| 5205 | SetScrollBars(); |
| 5206 | EnsureCaretVisible(); |
| 5207 | // Avoid blinking during rapid typing: |
| 5208 | ShowCaretAtCurrentPosition(); |
| 5209 | } |
| 5210 | |
| 5211 | void Editor::CursorUpOrDown ( int direction, Selection::selTypes selt ) |
| 5212 | { |
nothing calls this directly
no test coverage detected