7#include "absl/strings/str_cat.h"
20 const std::vector<std::string>& files,
21 const std::vector<std::string>& ignored_files) {
22 std::vector<std::string> filtered_files;
23 for (
const auto& file : files) {
25 if (file.find(
'/') != std::string::npos) {
29 if (file.find(
'.') == std::string::npos) {
32 if (std::find(ignored_files.begin(), ignored_files.end(), file) ==
33 ignored_files.end()) {
34 filtered_files.push_back(file);
37 return filtered_files;
42 std::ifstream gitignore(folder +
"/.gitignore");
43 std::vector<std::string> ignored_files;
44 if (gitignore.good()) {
46 while (std::getline(gitignore, line)) {
54 ignored_files.push_back(line);
59 current_folder.
name = folder;
63 for (
const auto& subfolder :
66 folder_item.
name = subfolder;
67 std::string full_folder = current_folder.
name +
"/" + subfolder;
69 for (
const auto& files : folder_files) {
71 if (files.find(
'/') != std::string::npos) {
75 if (files.find(
'.') == std::string::npos) {
78 if (std::find(ignored_files.begin(), ignored_files.end(), files) !=
79 ignored_files.end()) {
82 folder_item.
files.push_back(files);
85 for (
const auto& subdir :
88 subfolder_item.
name = subdir;
90 folder_item.
subfolders.push_back(subfolder_item);
92 current_folder.
subfolders.push_back(folder_item);
95 return current_folder;
105 ImGui::Begin(
"Assembly Editor", &is_loaded);
106 if (ImGui::BeginMenuBar()) {
114 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
129 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
140 ImGui::BeginTable(
"##table_view", 2,
141 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
142 ImGuiTableFlags_Resizable);
145 ImGui::TableSetupColumn(
"Files", ImGuiTableColumnFlags_WidthFixed, 256.0f);
146 ImGui::TableSetupColumn(
"Editor", ImGuiTableColumnFlags_WidthStretch);
148 ImGui::TableHeadersRow();
151 ImGui::TableNextRow();
152 ImGui::TableNextColumn();
156 if (ImGui::Button(
"Open Folder")) {
161 ImGui::TableNextColumn();
165 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
178 if (ImGui::BeginChild(
"##current_folder", ImVec2(0, 0),
true,
179 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
180 if (ImGui::BeginTable(
"##file_table", 2,
181 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
182 ImGuiTableFlags_Resizable |
183 ImGuiTableFlags_Sortable)) {
184 ImGui::TableSetupColumn(
"Name", ImGuiTableColumnFlags_WidthFixed, 256.0f);
185 ImGui::TableSetupColumn(
"Type", ImGuiTableColumnFlags_WidthStretch);
187 ImGui::TableHeadersRow();
190 ImGui::TableNextRow();
191 ImGui::TableNextColumn();
192 if (ImGui::Selectable(file.c_str())) {
195 ImGui::TableNextColumn();
200 ImGui::TableNextRow();
201 ImGui::TableNextColumn();
202 if (ImGui::TreeNode(subfolder.name.c_str())) {
203 for (
const auto& file : subfolder.files) {
204 ImGui::TableNextRow();
205 ImGui::TableNextColumn();
206 if (ImGui::Selectable(file.c_str())) {
208 subfolder.name,
"/", file));
210 ImGui::TableNextColumn();
215 ImGui::TableNextColumn();
216 ImGui::Text(
"Folder");
228 static int next_tab_id = 0;
230 if (ImGui::BeginTabBar(
"AssemblyFileTabBar", ImGuiTabBarFlags_None)) {
231 if (ImGui::TabItemButton(
ICON_MD_ADD, ImGuiTabItemFlags_None)) {
245 ImGuiTabItemFlags_None)) {
250 std::string str((std::istreambuf_iterator<char>(t)),
251 std::istreambuf_iterator<char>());
254 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
258 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
281 if (ImGui::BeginMenu(
"File")) {
282 if (ImGui::MenuItem(
"Open",
"Ctrl+O")) {
286 if (ImGui::MenuItem(
"Save",
"Ctrl+S")) {
294 if (ImGui::BeginMenu(
"Edit")) {
295 if (ImGui::MenuItem(
"Undo",
"Ctrl+Z")) {
298 if (ImGui::MenuItem(
"Redo",
"Ctrl+Y")) {
302 if (ImGui::MenuItem(
"Cut",
"Ctrl+X")) {
305 if (ImGui::MenuItem(
"Copy",
"Ctrl+C")) {
308 if (ImGui::MenuItem(
"Paste",
"Ctrl+V")) {
312 if (ImGui::MenuItem(
"Find",
"Ctrl+F")) {
323 std::string str((std::istreambuf_iterator<char>(t)),
324 std::istreambuf_iterator<char>());
327 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error opening file: %s\n",
336 return absl::OkStatus();
341 return absl::OkStatus();
346 return absl::OkStatus();
351 return absl::OkStatus();
356 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_
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.
Main namespace for the application.
std::vector< FolderItem > subfolders
std::vector< std::string > files