From 6fb48c8e6f3322e1fe8eed9092c155a5a828b99a Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 13 Jan 2017 11:04:43 +0100 Subject: [PATCH] feat(build): Add flag for drawing visible whitespace --- cmake/build/options.cmake | 7 ++++++- cmake/build/summary.cmake | 3 ++- include/components/logger.hpp | 2 +- include/settings.hpp.cmake | 3 ++- src/components/bar.cpp | 2 +- src/components/parser.cpp | 8 ++++++++ 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/cmake/build/options.cmake b/cmake/build/options.cmake index 4b9d23ba..264678dc 100644 --- a/cmake/build/options.cmake +++ b/cmake/build/options.cmake @@ -51,8 +51,13 @@ option(CXXLIB_GCC "Link against stdlibc++" OFF) option(BUILD_IPC_MSG "Build ipc messager" ON) option(BUILD_TESTS "Build testsuite" OFF) option(DEBUG_LOGGER "Enable extra debug logging" OFF) -option(VERBOSE_TRACELOG "Enable verbose trace logs" OFF) +option(DEBUG_LOGGER_TRACE "Enable verbose trace logs" OFF) option(DEBUG_HINTS "Enable hints rendering" OFF) +option(DEBUG_WHITESPACE "Enable whitespace debug" OFF) + +if(NOT DEBUG_LOGGER AND DEBUG_LOGGER_TRACE) + set(DEBUG_LOGGER_TRACE OFF) +endif() option(ENABLE_CCACHE "Enable ccache support" OFF) option(ENABLE_ALSA "Enable alsa support" ON) diff --git a/cmake/build/summary.cmake b/cmake/build/summary.cmake index a46cbb9d..ae2abe07 100644 --- a/cmake/build/summary.cmake +++ b/cmake/build/summary.cmake @@ -56,8 +56,9 @@ message(STATUS "--------------------------") colored_option(STATUS " Build polybar-msg ${BUILD_IPC_MSG}" BUILD_IPC_MSG "32;1" "37;2") colored_option(STATUS " Build testsuite ${BUILD_TESTS}" BUILD_TESTS "32;1" "37;2") colored_option(STATUS " Debug logging ${DEBUG_LOGGER}" DEBUG_LOGGER "32;1" "37;2") -colored_option(STATUS " Verbose tracing ${VERBOSE_TRACELOG}" VERBOSE_TRACELOG "32;1" "37;2") +colored_option(STATUS " + Verbose tracing ${DEBUG_LOGGER_TRACE}" DEBUG_LOGGER_TRACE "32;1" "37;2") colored_option(STATUS " Draw debug hints ${DEBUG_HINTS}" DEBUG_HINTS "32;1" "37;2") +colored_option(STATUS " Draw whitespace ${DEBUG_WHITESPACE}" DEBUG_WHITESPACE "32;1" "37;2") colored_option(STATUS " Enable ccache ${ENABLE_CCACHE}" ENABLE_CCACHE "32;1" "37;2") message(STATUS "--------------------------") colored_option(STATUS " Enable alsa ${ENABLE_ALSA}" ENABLE_ALSA "32;1" "37;2") diff --git a/include/components/logger.hpp b/include/components/logger.hpp index 03f90634..c76c8342 100644 --- a/include/components/logger.hpp +++ b/include/components/logger.hpp @@ -40,7 +40,7 @@ class logger { void trace(string message, Args... args) const { output(loglevel::TRACE, message, args...); } -#ifdef VERBOSE_TRACELOG +#ifdef DEBUG_LOGGER_TRACE template void trace_x(string message, Args... args) const { output(loglevel::TRACE, message, args...); diff --git a/include/settings.hpp.cmake b/include/settings.hpp.cmake index a8a890a7..51a836d6 100644 --- a/include/settings.hpp.cmake +++ b/include/settings.hpp.cmake @@ -41,8 +41,9 @@ #cmakedefine XPP_EXTENSION_LIST @XPP_EXTENSION_LIST@ #cmakedefine DEBUG_LOGGER -#cmakedefine VERBOSE_TRACELOG +#cmakedefine DEBUG_LOGGER_TRACE #cmakedefine DEBUG_HINTS +#cmakedefine DEBUG_WHITESPACE static const size_t EVENT_SIZE = 64; diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 98830007..e2979cd5 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -616,7 +616,7 @@ void bar::handle(const evt::expose& evt) { * pseudo-transparent background when it changes */ void bar::handle(const evt::property_notify& evt) { -#ifdef VERBOSE_TRACELOG +#ifdef DEBUG_LOGGER_TRACE string atom_name = m_connection.get_atom_name(evt->atom).name(); m_log.trace_x("bar: property_notify(%s)", atom_name); #endif diff --git a/src/components/parser.cpp b/src/components/parser.cpp index 94756f94..4e90272b 100644 --- a/src/components/parser.cpp +++ b/src/components/parser.cpp @@ -1,5 +1,6 @@ #include +#include "settings.hpp" #include "components/parser.hpp" #include "components/types.hpp" #include "events/signal.hpp" @@ -165,6 +166,13 @@ void parser::codeblock(string&& data, const bar_settings& bar) { * Process text contents */ size_t parser::text(string&& data) { +#ifdef DEBUG_WHITESPACE + string::size_type p; + while ((p = data.find(' ')) != string::npos) { + data.replace(p, 1, "-"s); + } +#endif + const uint8_t* utf{reinterpret_cast(&data[0])}; // clang-format off