fuck git and fuck vs code

This commit is contained in:
2025-11-11 11:25:46 -05:00
parent d07b4dc2eb
commit 07096c487b
62 changed files with 1635 additions and 1301 deletions

View File

@@ -8,37 +8,14 @@
namespace anm2ed::util::filesystem
{
std::string path_pref_get(const char* org, const char* app)
std::string path_preferences_get()
{
auto path = SDL_GetPrefPath(org, app);
auto path = SDL_GetPrefPath(nullptr, "anm2ed");
std::string string = path;
SDL_free(path);
return string;
}
std::string path_preferences_get() { return path_pref_get(nullptr, "anm2ed"); }
std::string path_base_get() { return std::string(SDL_GetBasePath()); }
std::string path_executable_get() { return std::filesystem::path(path_base_get()) / "anm2ed"; }
#ifdef __unix__
std::string path_application_get()
{
return std::filesystem::path(path_pref_get(nullptr, "applications")) / "anm2ed.desktop";
}
std::string path_mime_get()
{
return std::filesystem::path(path_pref_get(nullptr, "mime/application")) / "x-anm2+xml.xml";
}
std::string path_icon_get() { return std::filesystem::path(path_preferences_get()) / "anm2ed.png"; }
std::string path_icon_file_get()
{
return std::filesystem::path(path_preferences_get()) / "application-x-anm2+xml.png";
}
#endif
bool path_is_exist(const std::string& path)
{
std::error_code errorCode;

View File

@@ -5,17 +5,7 @@
namespace anm2ed::util::filesystem
{
#ifdef __unix__
std::string path_application_get();
std::string path_mime_get();
std::string path_icon_get();
std::string path_icon_file_get();
#endif
std::string path_pref_get();
std::string path_preferences_get();
std::string path_base_get();
std::string path_executable_get();
bool path_is_exist(const std::string&);
bool path_is_extension(const std::string&, const std::string&);

View File

@@ -12,15 +12,40 @@ namespace anm2ed::util::vector
return index >= 0 && index < (int)v.size() ? &v[index] : nullptr;
}
template <typename T> bool in_bounds(std::vector<T>& v, int index)
template <typename T> int find_index(std::vector<T>& v, T& value)
{
return index >= 0 && index < (int)v.size();
auto it = std::find(v.begin(), v.end(), value);
if (it == v.end()) return -1;
return (int)(std::distance(v.begin(), it));
}
template <typename T> bool in_bounds(std::vector<T>& v, int index) { return index >= 0 && index < (int)v.size(); }
template <typename T> void clamp_in_bounds(std::vector<T>& v, int& index)
{
index = std::clamp(index, 0, (int)v.size() - 1);
}
template <typename T> int move_index(std::vector<T>& v, int source, int dest)
{
auto size = (int)(v.size());
if (source < 0 || source >= size) return -1;
dest = std::clamp(dest, 0, size - 1);
if (source == dest) return dest;
auto isInsertAfter = source < dest;
T item = std::move(v[source]);
v.erase(v.begin() + source);
if (dest > source) --dest; // destination shifts when removing earlier slot
if (isInsertAfter) ++dest; // drop after original target
dest = std::clamp(dest, 0, (int)(v.size()));
v.insert(v.begin() + dest, std::move(item));
return dest;
}
template <typename T> std::set<int> move_indices(std::vector<T>& v, std::vector<int>& indices, int index)
{
if (indices.empty()) return {};
@@ -60,5 +85,4 @@ namespace anm2ed::util::vector
return moveIndices;
}
}