9 : directory(ospath.parent_path().string())
10 , basename(ospath.filename().string())
11 , io(
ctu::Io::file(ospath.string().c_str()))
21 void SourceView::build_line_offsets()
24 line_offsets.push_back(0);
26 for (
size_t i = 0; i < source.size(); i++)
28 if (source[i] ==
'\n')
30 line_offsets.push_back(i + 1);
35 static constexpr ImGuiWindowFlags kSourceFlags
36 = ImGuiWindowFlags_HorizontalScrollbar;
37 static constexpr ImGuiChildFlags kChildFlags
38 = ImGuiChildFlags_AutoResizeY
39 | ImGuiChildFlags_AutoResizeX;
43 if (ImGui::BeginChild(
get_path(), ImVec2(0, 0), kChildFlags, kSourceFlags))
47 ImGui::Text(
"Failed to open file: %s", error.
what());
51 ImGui::TextUnformatted(source.data(), source.data() + source.size());
std::string_view text() const
const char * what() const
const char * get_path() const
SourceView(const fs::path &ospath)