summaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/HyprCtl.cpp55
-rw-r--r--src/debug/Log.cpp2
-rw-r--r--src/debug/Log.hpp20
3 files changed, 46 insertions, 31 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index e805bca6..b0f70e98 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -14,6 +14,7 @@
#include <sstream>
#include <string>
+#include <typeindex>
static void trimTrailingComma(std::string& str) {
if (!str.empty() && str.back() == ',')
@@ -856,7 +857,7 @@ std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in) {
const auto VALUE = in.substr(in.find_first_of(' ') + 1);
- std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE, true);
+ std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE);
if (COMMAND == "monitor")
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
@@ -868,8 +869,10 @@ std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in) {
g_pInputManager->setTabletConfigs(); // update tablets
}
+ static auto* const PLAYOUT = (Hyprlang::STRING const*)g_pConfigManager->getConfigValuePtr("general:layout");
+
if (COMMAND.contains("general:layout"))
- g_pLayoutManager->switchToLayout(g_pConfigManager->getString("general:layout")); // update layout
+ g_pLayoutManager->switchToLayout(*PLAYOUT); // update layout
if (COMMAND.contains("decoration:screen_shader"))
g_pHyprOpenGL->m_bReloadScreenShader = true;
@@ -1193,28 +1196,40 @@ std::string dispatchGetOption(eHyprCtlOutputFormat format, std::string request)
nextItem();
nextItem();
- const auto PCFGOPT = g_pConfigManager->getConfigValuePtrSafe(curitem);
+ const auto VAR = g_pConfigManager->getHyprlangConfigValuePtr(curitem);
- if (!PCFGOPT)
+ if (!VAR)
return "no such option";
- if (format == eHyprCtlOutputFormat::FORMAT_NORMAL)
- return std::format("option {}\n\tint: {}\n\tfloat: {:.5f}\n\tstr: \"{}\"\n\tdata: {:x}\n\tset: {}", curitem, PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue,
- (uintptr_t)PCFGOPT->data.get(), PCFGOPT->set);
- else {
- return std::format(
- R"#(
-{{
- "option": "{}",
- "int": {},
- "float": {:.5f},
- "str": "{}",
- "data": "0x{:x}",
- "set": {}
-}}
-)#",
- curitem, PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue, (uintptr_t)PCFGOPT->data.get(), PCFGOPT->set);
+ const auto VAL = VAR->getValue();
+ const auto TYPE = std::type_index(VAL.type());
+
+ if (format == FORMAT_NORMAL) {
+ if (TYPE == typeid(Hyprlang::INT))
+ return std::format("int: {}\nset: {}", std::any_cast<Hyprlang::INT>(VAL), VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::FLOAT))
+ return std::format("float: {:2f}\nset: {}", std::any_cast<Hyprlang::FLOAT>(VAL), VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::VEC2))
+ return std::format("vec2: [{}, {}]\nset: {}", std::any_cast<Hyprlang::VEC2>(VAL).x, std::any_cast<Hyprlang::VEC2>(VAL).y, VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::STRING))
+ return std::format("str: {}\nset: {}", std::any_cast<Hyprlang::STRING>(VAL), VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::CUSTOMTYPE*))
+ return std::format("custom type at: {:x}\nset: {}", (uintptr_t)std::any_cast<Hyprlang::CUSTOMTYPE*>(VAL), VAR->m_bSetByUser);
+ } else {
+ if (TYPE == typeid(Hyprlang::INT))
+ return std::format("{{\"option\": \"{}\", \"int\": {}, \"set\": {} }}", curitem, std::any_cast<Hyprlang::INT>(VAL), VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::FLOAT))
+ return std::format("{{\"option\": \"{}\", \"float\": {:2f}, \"set\": {} }}", curitem, std::any_cast<Hyprlang::FLOAT>(VAL), VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::VEC2))
+ return std::format("{{\"option\": \"{}\", \"vec2\": [{},{}], \"set\": {} }}", curitem, std::any_cast<Hyprlang::VEC2>(VAL).x, std::any_cast<Hyprlang::VEC2>(VAL).y,
+ VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::STRING))
+ return std::format("{{\"option\": \"{}\", \"str\": \"{}\", \"set\": {} }}", curitem, escapeJSONStrings(std::any_cast<Hyprlang::STRING>(VAL)), VAR->m_bSetByUser);
+ else if (TYPE == typeid(Hyprlang::CUSTOMTYPE*))
+ return std::format("{{\"option\": \"{}\", \"custom\": \"{:x}\", \"set\": {} }}", curitem, (uintptr_t)std::any_cast<Hyprlang::CUSTOMTYPE*>(VAL), VAR->m_bSetByUser);
}
+
+ return "invalid type (internal error)";
}
std::string decorationRequest(eHyprCtlOutputFormat format, std::string request) {
diff --git a/src/debug/Log.cpp b/src/debug/Log.cpp
index 404904a2..66c430d5 100644
--- a/src/debug/Log.cpp
+++ b/src/debug/Log.cpp
@@ -22,7 +22,7 @@ void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
rollingLog += output + "\n";
- if (!disableLogs || !*disableLogs) {
+ if (!disableLogs || !**disableLogs) {
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);
ofs << "[wlr] " << output << "\n";
diff --git a/src/debug/Log.hpp b/src/debug/Log.hpp
index 3d2ed48c..a43d6fee 100644
--- a/src/debug/Log.hpp
+++ b/src/debug/Log.hpp
@@ -21,16 +21,16 @@ enum LogLevel {
};
namespace Debug {
- inline std::string logFile;
- inline int64_t* disableLogs = nullptr;
- inline int64_t* disableTime = nullptr;
- inline bool disableStdout = false;
- inline bool trace = false;
- inline bool shuttingDown = false;
+ inline std::string logFile;
+ inline int64_t* const* disableLogs = nullptr;
+ inline int64_t* const* disableTime = nullptr;
+ inline bool disableStdout = false;
+ inline bool trace = false;
+ inline bool shuttingDown = false;
- inline std::string rollingLog = ""; // rolling log contains the ROLLING_LOG_SIZE tail of the log
+ inline std::string rollingLog = ""; // rolling log contains the ROLLING_LOG_SIZE tail of the log
- void init(const std::string& IS);
+ void init(const std::string& IS);
template <typename... Args>
void log(LogLevel level, std::format_string<Args...> fmt, Args&&... args) {
if (level == TRACE && !trace)
@@ -52,7 +52,7 @@ namespace Debug {
}
// print date and time to the ofs
- if (disableTime && !*disableTime) {
+ if (disableTime && !**disableTime) {
#ifndef _LIBCPP_VERSION
logMsg += std::format("[{:%T}] ", std::chrono::hh_mm_ss{std::chrono::system_clock::now() - std::chrono::floor<std::chrono::days>(std::chrono::system_clock::now())});
#else
@@ -73,7 +73,7 @@ namespace Debug {
if (rollingLog.size() > ROLLING_LOG_SIZE)
rollingLog = rollingLog.substr(rollingLog.size() - ROLLING_LOG_SIZE);
- if (!disableLogs || !*disableLogs) {
+ if (!disableLogs || !**disableLogs) {
// log to a file
std::ofstream ofs;
ofs.open(logFile, std::ios::out | std::ios::app);