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 return absl::OkStatus();
113 ImGui::Begin(
"Assembly Editor", &is_loaded);
114 if (ImGui::BeginMenuBar()) {
122 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
137 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
148 ImGui::BeginTable(
"##table_view", 2,
149 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
150 ImGuiTableFlags_Resizable);
153 ImGui::TableSetupColumn(
"Files", ImGuiTableColumnFlags_WidthFixed, 256.0f);
154 ImGui::TableSetupColumn(
"Editor", ImGuiTableColumnFlags_WidthStretch);
156 ImGui::TableHeadersRow();
159 ImGui::TableNextRow();
160 ImGui::TableNextColumn();
164 if (ImGui::Button(
"Open Folder")) {
169 ImGui::TableNextColumn();
173 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
186 if (ImGui::BeginChild(
"##current_folder", ImVec2(0, 0),
true,
187 ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
188 if (ImGui::BeginTable(
"##file_table", 2,
189 ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg |
190 ImGuiTableFlags_Resizable |
191 ImGuiTableFlags_Sortable)) {
192 ImGui::TableSetupColumn(
"Name", ImGuiTableColumnFlags_WidthFixed, 256.0f);
193 ImGui::TableSetupColumn(
"Type", ImGuiTableColumnFlags_WidthStretch);
195 ImGui::TableHeadersRow();
198 ImGui::TableNextRow();
199 ImGui::TableNextColumn();
200 if (ImGui::Selectable(file.c_str())) {
203 ImGui::TableNextColumn();
208 ImGui::TableNextRow();
209 ImGui::TableNextColumn();
210 if (ImGui::TreeNode(subfolder.name.c_str())) {
211 for (
const auto& file : subfolder.files) {
212 ImGui::TableNextRow();
213 ImGui::TableNextColumn();
214 if (ImGui::Selectable(file.c_str())) {
216 subfolder.name,
"/", file));
218 ImGui::TableNextColumn();
223 ImGui::TableNextColumn();
224 ImGui::Text(
"Folder");
236 static int next_tab_id = 0;
238 if (ImGui::BeginTabBar(
"AssemblyFileTabBar", ImGuiTabBarFlags_None)) {
239 if (ImGui::TabItemButton(
ICON_MD_ADD, ImGuiTabItemFlags_None)) {
253 ImGuiTabItemFlags_None)) {
258 std::string str((std::istreambuf_iterator<char>(t)),
259 std::istreambuf_iterator<char>());
262 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
266 ImGui::Text(
"%6d/%-6d %6d lines | %s | %s | %s | %s", cpos.mLine + 1,
289 if (ImGui::BeginMenu(
"File")) {
290 if (ImGui::MenuItem(
"Open",
"Ctrl+O")) {
294 if (ImGui::MenuItem(
"Save",
"Ctrl+S")) {
302 if (ImGui::BeginMenu(
"Edit")) {
303 if (ImGui::MenuItem(
"Undo",
"Ctrl+Z")) {
306 if (ImGui::MenuItem(
"Redo",
"Ctrl+Y")) {
310 if (ImGui::MenuItem(
"Cut",
"Ctrl+X")) {
313 if (ImGui::MenuItem(
"Copy",
"Ctrl+C")) {
316 if (ImGui::MenuItem(
"Paste",
"Ctrl+V")) {
320 if (ImGui::MenuItem(
"Find",
"Ctrl+F")) {
331 std::string str((std::istreambuf_iterator<char>(t)),
332 std::istreambuf_iterator<char>());
335 SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Error opening file: %s\n",
344 return absl::OkStatus();
349 return absl::OkStatus();
354 return absl::OkStatus();
359 return absl::OkStatus();
364 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.
Main namespace for the application.
std::vector< FolderItem > subfolders
std::vector< std::string > files