diff options
author | zakk4223 <[email protected]> | 2024-03-20 21:55:13 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2024-03-21 01:55:13 +0000 |
commit | 4c796683c05a0eaccc14aae8875f06972f9f3c5e (patch) | |
tree | a2605abdd24aa8a1c444adceee70cbdb450d296b /src/hyprerror | |
parent | 214ec82ba7dcbb33b45963d13b84f9bd6c913614 (diff) | |
download | Hyprland-4c796683c05a0eaccc14aae8875f06972f9f3c5e.tar.gz Hyprland-4c796683c05a0eaccc14aae8875f06972f9f3c5e.zip |
config: Config error limit/hyprctl (#5165)
* Add error_limit to limit the number of config error messages shown in notification
* Add configerrors hyprctl command
* Formatting
* Formatting for not my code
* Use CVarList, add escapeJSONStrings
* Add indication there are more undisplayed errors
* Restore suppress_errors; move getErrors() to ConfigManager
* Formatting, wtf
* Format
Diffstat (limited to 'src/hyprerror')
-rw-r--r-- | src/hyprerror/HyprError.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp index 97a18e8c..a7636b1c 100644 --- a/src/hyprerror/HyprError.cpp +++ b/src/hyprerror/HyprError.cpp @@ -1,5 +1,6 @@ #include "HyprError.hpp" #include "../Compositor.hpp" +#include "../config/ConfigValue.hpp" CHyprError::CHyprError() { m_fFadeOpacity.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_NONE); @@ -58,6 +59,10 @@ void CHyprError::createQueued() { cairo_restore(CAIRO); const auto LINECOUNT = 1 + std::count(m_szQueued.begin(), m_szQueued.end(), '\n'); + static auto LINELIMIT = CConfigValue<Hyprlang::INT>("debug:error_limit"); + + const auto VISLINECOUNT = std::min(LINECOUNT, *LINELIMIT); + const auto EXTRALINES = (VISLINECOUNT < LINECOUNT) ? 1 : 0; const double DEGREES = M_PI / 180.0; @@ -66,7 +71,7 @@ void CHyprError::createQueued() { const double X = PAD; const double Y = PAD; const double WIDTH = PMONITOR->vecPixelSize.x - PAD * 2; - const double HEIGHT = (FONTSIZE + 2 * (FONTSIZE / 10.0)) * LINECOUNT + 3; + const double HEIGHT = (FONTSIZE + 2 * (FONTSIZE / 10.0)) * (VISLINECOUNT + EXTRALINES) + 3; const double RADIUS = PAD > HEIGHT / 2 ? HEIGHT / 2 - 1 : PAD; m_bDamageBox = {0, 0, (int)PMONITOR->vecPixelSize.x, (int)HEIGHT + (int)PAD * 2}; @@ -91,8 +96,9 @@ void CHyprError::createQueued() { cairo_set_font_size(CAIRO, FONTSIZE); cairo_set_source_rgba(CAIRO, textColor.r, textColor.g, textColor.b, textColor.a); - float yoffset = FONTSIZE; - while (m_szQueued != "") { + float yoffset = FONTSIZE; + int renderedcnt = 0; + while (m_szQueued != "" && renderedcnt < VISLINECOUNT) { std::string current = m_szQueued.substr(0, m_szQueued.find('\n')); if (const auto NEWLPOS = m_szQueued.find('\n'); NEWLPOS != std::string::npos) m_szQueued = m_szQueued.substr(NEWLPOS + 1); @@ -101,7 +107,14 @@ void CHyprError::createQueued() { cairo_move_to(CAIRO, PAD + 1 + RADIUS, yoffset + PAD + 1); cairo_show_text(CAIRO, current.c_str()); yoffset += FONTSIZE + (FONTSIZE / 10.f); + renderedcnt++; + } + if (VISLINECOUNT < LINECOUNT) { + std::string moreString = std::format("({} more...)", LINECOUNT - VISLINECOUNT); + cairo_move_to(CAIRO, PAD + 1 + RADIUS, yoffset + PAD + 1); + cairo_show_text(CAIRO, moreString.c_str()); } + m_szQueued = ""; cairo_surface_flush(CAIROSURFACE); |