MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / insertTextStartingAtCurrentColumn

Method insertTextStartingAtCurrentColumn

src/dialogs/ColumnEditorDialog.cpp:70–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void ColumnEditorDialog::insertTextStartingAtCurrentColumn(const std::function<QString ()> &f)
71{
72 ScintillaNext *editor = parent->currentEditor();
73
74 if (editor->selectionMode() == SC_SEL_STREAM && editor->selections() == 1 && editor->selectionEmpty()) {
75 const int currentPos = editor->selectionNCaret(0);
76
77 // If the cursor is in virtual space, the call to selectionNCaretVirtualSpace will be > 0
78 const int currentColumn = editor->column(currentPos) + editor->selectionNCaretVirtualSpace(0);
79
80 const UndoAction ua(editor);
81 for (int line = editor->lineFromPosition(currentPos); line < editor->lineCount(); ++line) {
82 insertTextAtColumn(editor, line, currentColumn, f());
83 }
84 }
85 else/* if (editor->selectionMode() == SC_SEL_RECTANGLE || editor->selections() > 0)*/ {
86 const int totalSelections = editor->selections();
87
88 // TODO: sort selections from top to bottom?
89
90 const UndoAction ua(editor);
91 for(int selection = 0; selection < totalSelections; ++selection) {
92 const int start = editor->selectionNStart(selection) + editor->selectionNStartVirtualSpace(selection);
93 const int end = editor->selectionNEnd(selection) + editor->selectionNEndVirtualSpace(selection);
94
95 editor->setTargetRange(start, end);
96 editor->replaceTarget(-1, f().toUtf8().constData());
97 }
98 }
99}
100
101void ColumnEditorDialog::insertTextAtColumn(ScintillaNext *editor, int line, int column, const QString &str)
102{

Callers

nothing calls this directly

Calls 1

currentEditorMethod · 0.80

Tested by

no test coverage detected