MCPcopy Create free account
hub / github.com/crosire/reshade / set_text

Method set_text

source/imgui_code_editor.cpp:791–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789}
790
791void reshade::imgui::code_editor::set_text(const std::string_view text)
792{
793 _lines.clear();
794 _lines.emplace_back();
795
796 _undo.clear();
797 _undo_index = 0;
798 _undo_base_index = 0;
799 _errors.clear();
800
801 std::string_view::const_iterator it = text.begin();
802 if (utf8::starts_with_bom(it, text.end()))
803 it += std::size(utf8::bom);
804 for (; it < text.end();)
805 {
806 const utf8::utfchar32_t c = utf8::unchecked::next(it);
807 if (c == '\r')
808 continue; // Ignore the carriage return character
809 else if (c == '\n')
810 _lines.emplace_back();
811 else
812 _lines.back().push_back({ c, color_default });
813 }
814
815 // Restrict cursor position to new text bounds
816 _select_beg = _select_end = text_pos();
817 _interactive_beg = _interactive_end = text_pos();
818 _cursor_pos.line = std::min(_cursor_pos.line, _lines.size() - 1);
819 _cursor_pos.column = std::min(_cursor_pos.column, _lines[_cursor_pos.line].size());
820
821 _colorize_line_beg = 0;
822 _colorize_line_end = _lines.size();
823}
824void reshade::imgui::code_editor::clear_text()
825{
826 set_text(std::string_view());

Callers 1

open_code_editorMethod · 0.80

Calls 2

text_posClass · 0.85
clearMethod · 0.45

Tested by

no test coverage detected