MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / NewLine

Method NewLine

scintilla/src/Editor.cxx:5167–5209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5165}
5166
5167void 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
5211void Editor::CursorUpOrDown ( int direction, Selection::selTypes selt )
5212{

Callers

nothing calls this directly

Calls 7

istrlenFunction · 0.85
InsertCStringMethod · 0.80
MainCaretMethod · 0.80
SetSelectionMethod · 0.45
EmptyMethod · 0.45
BeginUndoActionMethod · 0.45
EndUndoActionMethod · 0.45

Tested by

no test coverage detected