Closed emoon closed 4 years ago
Hi Daniel, I guess the easiest way is to look at the Edbee-app sample, gotowidget. https://github.com/edbee/edbee-app/blob/master/edbee-app/ui/gotowidget.cpp
It has a goto line function .
It uses the controller function to move the caret. (It makes sure the caret is placed inside the document)
edbee::TextEditorController* controller = editorRef_->controller();
controller->moveCaretTo(line,column,false);
controller->scrollCaretVisible();
Internally the command used (by moveCaretTo) is the following. The editor works with commands which can be passed to 'executeCommand'.
SelectionCommand command( SelectionCommand::MoveCaretToExactOffset, offset, keepAnchors, rangeIndex );
executeCommand( &command );
Best Regards, Rick
Great! Thanks :)
This works great! Just another question: What is the best way to clear all text? I figured one way would be to select all text and doing a cut, but I figured there would be a better way to do it? What I tried to do is editor->textDocument()->lineDataManager()->clear();
but when trying to insert some new data I get an assert.
This should be a separate question so we don't start a thread of questions here :)
We use the following: https://github.com/Mudlet/Mudlet/blob/development/src/dlgTriggerEditor.cpp#L8692
Closing this one now also as the original question has an answer now :)
Hi,
I wonder what the current recommended way is to update the current line (for the caret) and to make sure that it's centered on the screen (if possible) Imagine how a debugger works when you step and you want to updated the location from "outside"