-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: Add support for toml manifests and metas
ref #20
- Loading branch information
Showing
13 changed files
with
525 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../libhyprcursor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "VarList.hpp" | ||
#include <ranges> | ||
#include <algorithm> | ||
|
||
static std::string removeBeginEndSpacesTabs(std::string str) { | ||
if (str.empty()) | ||
return str; | ||
|
||
int countBefore = 0; | ||
while (str[countBefore] == ' ' || str[countBefore] == '\t') { | ||
countBefore++; | ||
} | ||
|
||
int countAfter = 0; | ||
while ((int)str.length() - countAfter - 1 >= 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) { | ||
countAfter++; | ||
} | ||
|
||
str = str.substr(countBefore, str.length() - countBefore - countAfter); | ||
|
||
return str; | ||
} | ||
|
||
CVarList::CVarList(const std::string& in, const size_t lastArgNo, const char delim, const bool removeEmpty) { | ||
if (in.empty()) | ||
m_vArgs.emplace_back(""); | ||
|
||
std::string args{in}; | ||
size_t idx = 0; | ||
size_t pos = 0; | ||
std::ranges::replace_if( | ||
args, [&](const char& c) { return delim == 's' ? std::isspace(c) : c == delim; }, 0); | ||
|
||
for (const auto& s : args | std::views::split(0)) { | ||
if (removeEmpty && s.empty()) | ||
continue; | ||
if (++idx == lastArgNo) { | ||
m_vArgs.emplace_back(removeBeginEndSpacesTabs(in.substr(pos))); | ||
break; | ||
} | ||
pos += s.size() + 1; | ||
m_vArgs.emplace_back(removeBeginEndSpacesTabs(std::string_view{s}.data())); | ||
} | ||
} | ||
|
||
std::string CVarList::join(const std::string& joiner, size_t from, size_t to) const { | ||
size_t last = to == 0 ? size() : to; | ||
|
||
std::string rolling; | ||
for (size_t i = from; i < last; ++i) { | ||
rolling += m_vArgs[i] + (i + 1 < last ? joiner : ""); | ||
} | ||
|
||
return rolling; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pragma once | ||
#include <functional> | ||
#include <vector> | ||
#include <string> | ||
|
||
class CVarList { | ||
public: | ||
/** Split string into arg list | ||
@param lastArgNo stop splitting after argv reaches maximum size, last arg will contain rest of unsplit args | ||
@param delim if delimiter is 's', use std::isspace | ||
@param removeEmpty remove empty args from argv | ||
*/ | ||
CVarList(const std::string& in, const size_t maxSize = 0, const char delim = ',', const bool removeEmpty = false); | ||
|
||
~CVarList() = default; | ||
|
||
size_t size() const { | ||
return m_vArgs.size(); | ||
} | ||
|
||
std::string join(const std::string& joiner, size_t from = 0, size_t to = 0) const; | ||
|
||
void map(std::function<void(std::string&)> func) { | ||
for (auto& s : m_vArgs) | ||
func(s); | ||
} | ||
|
||
void append(const std::string arg) { | ||
m_vArgs.emplace_back(arg); | ||
} | ||
|
||
std::string operator[](const size_t& idx) const { | ||
if (idx >= m_vArgs.size()) | ||
return ""; | ||
return m_vArgs[idx]; | ||
} | ||
|
||
// for range-based loops | ||
std::vector<std::string>::iterator begin() { | ||
return m_vArgs.begin(); | ||
} | ||
std::vector<std::string>::const_iterator begin() const { | ||
return m_vArgs.begin(); | ||
} | ||
std::vector<std::string>::iterator end() { | ||
return m_vArgs.end(); | ||
} | ||
std::vector<std::string>::const_iterator end() const { | ||
return m_vArgs.end(); | ||
} | ||
|
||
bool contains(const std::string& el) { | ||
for (auto& a : m_vArgs) { | ||
if (a == el) | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private: | ||
std::vector<std::string> m_vArgs; | ||
}; |
Oops, something went wrong.