7#include "absl/strings/str_cat.h"
19 const std::vector<std::string>& files,
20 const std::vector<std::string>& ignored_files) {
21 std::vector<std::string> filtered_files;
22 for (
const auto& file : files) {
24 if (file.contains(
'/')) {
28 if (!file.contains(
'.')) {
31 if (std::ranges::find(ignored_files, file) == ignored_files.end()) {
32 filtered_files.push_back(file);
35 return filtered_files;
40 std::ifstream gitignore(folder +
"/.gitignore");
41 std::vector<std::string> ignored_files;
42 if (gitignore.good()) {
44 while (std::getline(gitignore, line)) {
52 ignored_files.push_back(line);
57 current_folder.
name = folder;
61 for (
const auto& subfolder :
64 folder_item.
name = subfolder;
65 std::string full_folder = current_folder.
name +
"/" + subfolder;
67 for (
const auto& files : folder_files) {
69 if (files.contains(
'/')) {
73 if (!files.contains(
'.')) {
76 if (std::ranges::find(ignored_files, files) != ignored_files.end()) {
79 folder_item.
files.push_back(files);
82 for (
const auto& subdir :
85 subfolder_item.
name = subdir;
87 folder_item.
subfolders.push_back(subfolder_item);
89 current_folder.
subfolders.push_back(folder_item);
92 return current_folder;
108 ImGui::Begin(
"Assembly Editor", &is_loaded);
109 if (ImGui::BeginMenuBar()) {
117 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
131 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
142 ImGui::BeginTable(
"##table_view", 2,
143 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
144 ImGuiTableFlags_Resizable);
147 ImGui::TableSetupColumn(
"Files", ImGuiTableColumnFlags_WidthFixed, 256.0f);
148 ImGui::TableSetupColumn(
"Editor", ImGuiTableColumnFlags_WidthStretch);
150 ImGui::TableHeadersRow();
153 ImGui::TableNextRow();
154 ImGui::TableNextColumn();
158 if (ImGui::Button(
"Open Folder")) {
163 ImGui::TableNextColumn();
167 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
180 if (ImGui::BeginChild(
"##current_folder", ImVec2(0, 0),
true,
181 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
182 if (ImGui::BeginTable(
"##file_table", 2,
183 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
184 ImGuiTableFlags_Resizable |
185 ImGuiTableFlags_Sortable)) {
186 ImGui::TableSetupColumn(
"Name", ImGuiTableColumnFlags_WidthFixed, 256.0f);
187 ImGui::TableSetupColumn(
"Type", ImGuiTableColumnFlags_WidthStretch);
189 ImGui::TableHeadersRow();
192 ImGui::TableNextRow();
193 ImGui::TableNextColumn();
194 if (ImGui::Selectable(file.c_str())) {
197 ImGui::TableNextColumn();
202 ImGui::TableNextRow();
203 ImGui::TableNextColumn();
204 if (ImGui::TreeNode(subfolder.name.c_str())) {
205 for (
const auto& file : subfolder.files) {
206 ImGui::TableNextRow();
207 ImGui::TableNextColumn();
208 if (ImGui::Selectable(file.c_str())) {
210 subfolder.name,
"/", file));
212 ImGui::TableNextColumn();
217 ImGui::TableNextColumn();
218 ImGui::Text(
"Folder");
230 static int next_tab_id = 0;
232 if (ImGui::BeginTabBar(
"AssemblyFileTabBar", ImGuiTabBarFlags_None)) {
233 if (ImGui::TabItemButton(
ICON_MD_ADD, ImGuiTabItemFlags_None)) {
247 ImGuiTabItemFlags_None)) {
252 std::string str((std::istreambuf_iterator<char>(t)),
253 std::istreambuf_iterator<char>());
256 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
260 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
283 if (ImGui::BeginMenu(
"File")) {
284 if (ImGui::MenuItem(
"Open",
"Ctrl+O")) {
288 if (ImGui::MenuItem(
"Save",
"Ctrl+S")) {
296 if (ImGui::BeginMenu(
"Edit")) {
297 if (ImGui::MenuItem(
"Undo",
"Ctrl+Z")) {
300 if (ImGui::MenuItem(
"Redo",
"Ctrl+Y")) {
304 if (ImGui::MenuItem(
"Cut",
"Ctrl+X")) {
307 if (ImGui::MenuItem(
"Copy",
"Ctrl+C")) {
310 if (ImGui::MenuItem(
"Paste",
"Ctrl+V")) {
314 if (ImGui::MenuItem(
"Find",
"Ctrl+F")) {
325 std::string str((std::istreambuf_iterator<char>(t)),
326 std::istreambuf_iterator<char>());
329 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error opening file: %s\n",
338 return absl::OkStatus();
343 return absl::OkStatus();
348 return absl::OkStatus();
353 return absl::OkStatus();
358 return absl::OkStatus();
static std::string ShowOpenFileDialog()
ShowOpenFileDialog opens a file dialog and returns the selected filepath.
std::string current_file_
std::vector< TextEditor > open_files_
absl::Status Load() override
void Initialize() override
void ChangeActiveFile(const std::string_view &filename)
absl::Status Copy() override
void OpenFolder(const std::string &folder_path)
absl::Status Paste() override
FolderItem current_folder_
absl::Status Update() override
std::vector< std::string > files_
absl::Status Redo() override
ImVector< int > active_files_
absl::Status Undo() override
absl::Status Cut() override
static std::vector< std::string > GetFilesInFolder(const std::string &folder_path)
static std::string ShowOpenFolderDialog()
ShowOpenFolderDialog opens a file dialog and returns the selected folder path.
static std::vector< std::string > GetSubdirectoriesInFolder(const std::string &folder_path)
FolderItem LoadFolder(const std::string &folder)
std::vector< std::string > RemoveIgnoredFiles(const std::vector< std::string > &files, const std::vector< std::string > &ignored_files)
Editors are the view controllers for the application.
std::vector< FolderItem > subfolders
std::vector< std::string > files