MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / toggle_bookmark

Method toggle_bookmark

editor/gui/code_editor.cpp:1754–1785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1752}
1753
1754void CodeTextEditor::toggle_bookmark() {
1755 Vector<int> sorted_carets = text_editor->get_sorted_carets();
1756 int last_line = -1;
1757 for (const int &c : sorted_carets) {
1758 int from = text_editor->get_selection_from_line(c);
1759 from += from == last_line ? 1 : 0;
1760 int to = text_editor->get_selection_to_line(c);
1761 if (to < from) {
1762 continue;
1763 }
1764 // Check first if there's any bookmarked lines in the selection.
1765 bool selection_has_bookmarks = false;
1766 for (int line = from; line <= to; line++) {
1767 if (text_editor->is_line_bookmarked(line)) {
1768 selection_has_bookmarks = true;
1769 break;
1770 }
1771 }
1772
1773 // Set bookmark on caret or remove all bookmarks from the selection.
1774 if (!selection_has_bookmarks) {
1775 if (text_editor->get_caret_line(c) != last_line) {
1776 text_editor->set_line_as_bookmarked(text_editor->get_caret_line(c), true);
1777 }
1778 } else {
1779 for (int line = from; line <= to; line++) {
1780 text_editor->set_line_as_bookmarked(line, false);
1781 }
1782 }
1783 last_line = to;
1784 }
1785}
1786
1787void CodeTextEditor::goto_next_bookmark() {
1788 PackedInt32Array bmarks = text_editor->get_bookmarked_lines();

Callers 3

_edit_optionMethod · 0.80
_edit_optionMethod · 0.80
_menu_optionMethod · 0.80

Calls 6

get_sorted_caretsMethod · 0.80
get_selection_to_lineMethod · 0.80
is_line_bookmarkedMethod · 0.80
get_caret_lineMethod · 0.80

Tested by

no test coverage detected