Skip to content

Commit cbc074b

Browse files
committed
misc: format some code in src/ and include/
1 parent 2c96c90 commit cbc074b

File tree

7 files changed

+88
-84
lines changed

7 files changed

+88
-84
lines changed

.clang-format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ SpaceInEmptyParentheses: false
4848
SpacesInSquareBrackets: false
4949
IndentAccessModifiers: false
5050
AccessModifierOffset: -4
51+
IndentCaseBlocks: false
52+
IndentCaseLabels: true
5153

5254
# Control formatting of C++11 features
5355
Cpp11BracedListStyle: false
@@ -62,7 +64,6 @@ ReflowComments: true
6264
AllowShortIfStatementsOnASingleLine: false
6365
AllowShortLoopsOnASingleLine: false
6466
AllowShortFunctionsOnASingleLine: All
65-
IndentCaseLabels: true
6667

6768
AlignConsecutiveShortCaseStatements:
6869
Enabled: true

include/query.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#include "config.hpp"
1212
#include "util.hpp"
1313

14-
extern "C"
15-
{
14+
extern "C" {
1615
#include <mntent.h>
1716
#include <pwd.h>
1817
#include <sys/stat.h>
@@ -22,7 +21,8 @@ extern "C"
2221
#include <unistd.h>
2322
}
2423

25-
using systemInfo_t = std::unordered_map<std::string, std::unordered_map<std::string, std::variant<std::string, size_t, float>>>;
24+
using systemInfo_t =
25+
std::unordered_map<std::string, std::unordered_map<std::string, std::variant<std::string, size_t, float>>>;
2626
using variant = std::variant<std::string, size_t, float>;
2727

2828
namespace Query
@@ -163,10 +163,10 @@ class CPU
163163

164164
std::string& name();
165165
std::string& nproc();
166-
float& freq_max();
167-
float& freq_min();
168-
float& freq_cur();
169-
float& freq_bios_limit();
166+
float& freq_max();
167+
float& freq_min();
168+
float& freq_cur();
169+
float& freq_bios_limit();
170170

171171
private:
172172
static bool m_bInit;

src/display.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
148148

149149
// erase each element for each instance of MAGIC_LINE
150150
layout.erase(std::remove_if(layout.begin(), layout.end(),
151-
[](const std::string_view str) { return str.find(MAGIC_LINE) != std::string::npos; }),
152-
layout.end());
151+
[](const std::string_view str) { return str.find(MAGIC_LINE) != std::string::npos; }),
152+
layout.end());
153153

154154
size_t i;
155155
for (i = 0; i < layout.size(); i++)
@@ -167,7 +167,7 @@ std::vector<std::string> Display::render(const Config& config, const colors_t& c
167167
}
168168

169169
const size_t& spaces = (maxLineLength + (config.m_disable_source ? 1 : config.offset)) -
170-
(i < asciiArt.size() ? pureAsciiArtLens.at(i) : 0);
170+
(i < asciiArt.size() ? pureAsciiArtLens.at(i) : 0);
171171

172172
debug("spaces: {}", spaces);
173173

src/gui.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#ifdef GUI_MODE
22

33
#define STB_IMAGE_IMPLEMENTATION
4+
#include "gui.hpp"
5+
6+
#include <array>
47
#include <filesystem>
58
#include <fstream>
6-
#include <array>
79

810
#include "config.hpp"
911
#include "display.hpp"
1012
#include "fmt/ranges.h"
1113
#include "gdkmm/pixbufanimation.h"
1214
#include "gtkmm/enums.h"
13-
#include "gui.hpp"
1415
#include "pangomm/fontdescription.h"
1516
#include "parse.hpp"
1617
#include "query.hpp"
@@ -52,8 +53,8 @@ static std::vector<std::string> render_with_image(const Config& config, const co
5253

5354
// erase each element for each instance of MAGIC_LINE
5455
layout.erase(std::remove_if(layout.begin(), layout.end(),
55-
[](const std::string_view str) { return str.find(MAGIC_LINE) != std::string::npos; }),
56-
layout.end());
56+
[](const std::string_view str) { return str.find(MAGIC_LINE) != std::string::npos; }),
57+
layout.end());
5758

5859
for (size_t i = 0; i < layout.size(); i++)
5960
{

src/query/unix/utils/dewm.cpp

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -66,68 +66,68 @@ std::string prettify_wm_name(const std::string_view name) noexcept
6666
// ngl this looks beatiful thanks to clang-format :D
6767
switch (fnv1a16::hash(str_tolower(name.data())))
6868
{
69-
case "2bwm"_fnv1a16: return "2bwm";
70-
case "9wm"_fnv1a16: return "9wm";
71-
case "awesome"_fnv1a16: return "awesome";
72-
case "beryl"_fnv1a16: return "beryl";
73-
case "blackbox"_fnv1a16: return "blackbox";
74-
case "bspwm"_fnv1a16: return "bspwm";
75-
case "budgie-wm"_fnv1a16: return "budgie-wm";
76-
case "chromeos-wm"_fnv1a16: return "chromeos-wm";
77-
case "cinnamon"_fnv1a16: return "Muffin";
78-
case "compiz"_fnv1a16: return "compiz";
79-
case "deepin-wm"_fnv1a16: return "deepin-wm";
80-
case "dminiwm"_fnv1a16: return "dminiwm";
81-
case "dtwm"_fnv1a16: return "dtwm";
82-
case "dwm"_fnv1a16: return "dwm";
83-
case "e16"_fnv1a16: return "e16";
84-
case "echinus"_fnv1a16: return "echinus";
85-
case "emerald"_fnv1a16: return "emerald";
86-
case "enlightenment"_fnv1a16: return "enlightenment";
87-
case "finder"_fnv1a16: return "finder";
88-
case "fluxbox"_fnv1a16: return "fluxbox";
89-
case "flwm"_fnv1a16: return "flwm";
90-
case "flwm_topside"_fnv1a16: return "flwm_topside";
91-
case "fvwm"_fnv1a16: return "fvwm";
92-
69+
case "2bwm"_fnv1a16: return "2bwm";
70+
case "9wm"_fnv1a16: return "9wm";
71+
case "awesome"_fnv1a16: return "awesome";
72+
case "beryl"_fnv1a16: return "beryl";
73+
case "blackbox"_fnv1a16: return "blackbox";
74+
case "bspwm"_fnv1a16: return "bspwm";
75+
case "budgie-wm"_fnv1a16: return "budgie-wm";
76+
case "chromeos-wm"_fnv1a16: return "chromeos-wm";
77+
case "cinnamon"_fnv1a16: return "Muffin";
78+
case "compiz"_fnv1a16: return "compiz";
79+
case "deepin-wm"_fnv1a16: return "deepin-wm";
80+
case "dminiwm"_fnv1a16: return "dminiwm";
81+
case "dtwm"_fnv1a16: return "dtwm";
82+
case "dwm"_fnv1a16: return "dwm";
83+
case "e16"_fnv1a16: return "e16";
84+
case "echinus"_fnv1a16: return "echinus";
85+
case "emerald"_fnv1a16: return "emerald";
86+
case "enlightenment"_fnv1a16: return "enlightenment";
87+
case "finder"_fnv1a16: return "finder";
88+
case "fluxbox"_fnv1a16: return "fluxbox";
89+
case "flwm"_fnv1a16: return "flwm";
90+
case "flwm_topside"_fnv1a16: return "flwm_topside";
91+
case "fvwm"_fnv1a16: return "fvwm";
92+
9393
case "gnome-shell"_fnv1a16:
9494
case "gnome-session-binary"_fnv1a16:
95-
case "mutter"_fnv1a16: return "Mutter";
96-
97-
case "herbstluftwm"_fnv1a16: return "herbstluftwm";
98-
case "howm"_fnv1a16: return "howm";
99-
case "hyprland"_fnv1a16: return "Hyprland";
100-
case "i3"_fnv1a16: return "i3";
101-
case "i3wm"_fnv1a16: return "i3wm";
102-
case "icewm"_fnv1a16: return "icewm";
103-
case "kwin"_fnv1a16: return "Kwin";
104-
case "marco"_fnv1a16: return "Marco";
105-
case "metacity"_fnv1a16: return "Metacity";
106-
case "monsterwm"_fnv1a16: return "monsterwm";
107-
case "muffin"_fnv1a16: return "Muffin";
108-
case "musca"_fnv1a16: return "musca";
109-
case "mwm"_fnv1a16: return "mwm";
110-
case "notion"_fnv1a16: return "notion";
111-
case "openbox"_fnv1a16: return "Openbox";
112-
case "pekwm"_fnv1a16: return "pekwm";
113-
case "qtile"_fnv1a16: return "Qtile";
114-
case "ratpoison"_fnv1a16: return "ratpoison";
115-
case "sawfish"_fnv1a16: return "sawfish";
116-
case "scrotwm"_fnv1a16: return "scrotwm";
117-
case "spectrwm"_fnv1a16: return "spectrwm";
118-
case "stumpwm"_fnv1a16: return "stumpwm";
119-
case "subtle"_fnv1a16: return "subtle";
120-
case "sway"_fnv1a16: return "sway";
121-
case "swm"_fnv1a16: return "swm";
122-
case "tinywm"_fnv1a16: return "tinywm";
123-
case "twin"_fnv1a16: return "twin";
124-
case "wayfire"_fnv1a16: return "wayfire";
125-
case "weston"_fnv1a16: return "weston";
126-
case "wmaker"_fnv1a16: return "wmaker";
127-
case "wmfs"_fnv1a16: return "wmfs";
128-
case "wmii"_fnv1a16: return "wmii";
129-
case "xfwm4"_fnv1a16: return "Xfwm4";
130-
case "xmonad"_fnv1a16: return "XMonad";
95+
case "mutter"_fnv1a16: return "Mutter";
96+
97+
case "herbstluftwm"_fnv1a16: return "herbstluftwm";
98+
case "howm"_fnv1a16: return "howm";
99+
case "hyprland"_fnv1a16: return "Hyprland";
100+
case "i3"_fnv1a16: return "i3";
101+
case "i3wm"_fnv1a16: return "i3wm";
102+
case "icewm"_fnv1a16: return "icewm";
103+
case "kwin"_fnv1a16: return "Kwin";
104+
case "marco"_fnv1a16: return "Marco";
105+
case "metacity"_fnv1a16: return "Metacity";
106+
case "monsterwm"_fnv1a16: return "monsterwm";
107+
case "muffin"_fnv1a16: return "Muffin";
108+
case "musca"_fnv1a16: return "musca";
109+
case "mwm"_fnv1a16: return "mwm";
110+
case "notion"_fnv1a16: return "notion";
111+
case "openbox"_fnv1a16: return "Openbox";
112+
case "pekwm"_fnv1a16: return "pekwm";
113+
case "qtile"_fnv1a16: return "Qtile";
114+
case "ratpoison"_fnv1a16: return "ratpoison";
115+
case "sawfish"_fnv1a16: return "sawfish";
116+
case "scrotwm"_fnv1a16: return "scrotwm";
117+
case "spectrwm"_fnv1a16: return "spectrwm";
118+
case "stumpwm"_fnv1a16: return "stumpwm";
119+
case "subtle"_fnv1a16: return "subtle";
120+
case "sway"_fnv1a16: return "sway";
121+
case "swm"_fnv1a16: return "swm";
122+
case "tinywm"_fnv1a16: return "tinywm";
123+
case "twin"_fnv1a16: return "twin";
124+
case "wayfire"_fnv1a16: return "wayfire";
125+
case "weston"_fnv1a16: return "weston";
126+
case "wmaker"_fnv1a16: return "wmaker";
127+
case "wmfs"_fnv1a16: return "wmfs";
128+
case "wmii"_fnv1a16: return "wmii";
129+
case "xfwm4"_fnv1a16: return "Xfwm4";
130+
case "xmonad"_fnv1a16: return "XMonad";
131131
}
132132

133133
return MAGIC_LINE;

src/query/unix/utils/packages.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include "packages.hpp"
22

3+
#include <algorithm>
34
#include <filesystem>
45
#include <fstream>
5-
#include <algorithm>
66
#include <string>
77

88
#include "switch_fnv1a.hpp"

src/util.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ byte_units_t auto_devide_bytes(const size_t num)
141141

142142
bool is_file_image(const unsigned char* bytes)
143143
{
144+
// clang-format off
144145
// https://stackoverflow.com/a/49683945
145146
constexpr std::array<unsigned char, 3> jpeg = { 0xff, 0xd8, 0xff };
146147
constexpr std::array<unsigned char, 8> png = { 0x89, 0x50, 0x4e, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
@@ -150,16 +151,17 @@ bool is_file_image(const unsigned char* bytes)
150151
constexpr std::array<unsigned char, 4> tiffI = { 0x49, 0x49, 0x2A, 0x00 };
151152
constexpr std::array<unsigned char, 4> tiffM = { 0x4D, 0x4D, 0x00, 0x2A };
152153

153-
if (std::memcmp(bytes, png.data(), png.size()) == 0 ||
154-
std::memcmp(bytes, jpeg.data(), jpeg.size()) == 0 ||
155-
std::memcmp(bytes, gif89a.data(), gif89a.size()) == 0 ||
156-
std::memcmp(bytes, gif87a.data(), gif87a.size()) == 0 ||
157-
std::memcmp(bytes, tiffM.data(), tiffM.size()) == 0 ||
158-
std::memcmp(bytes, tiffI.data(), tiffI.size()) == 0 ||
159-
std::memcmp(bytes, bmp.data(), bmp.size()) == 0)
160-
return true;
154+
if (std::memcmp(bytes, png.data(), png.size()) == 0 ||
155+
std::memcmp(bytes, jpeg.data(), jpeg.size()) == 0 ||
156+
std::memcmp(bytes, gif89a.data(), gif89a.size()) == 0 ||
157+
std::memcmp(bytes, gif87a.data(), gif87a.size()) == 0 ||
158+
std::memcmp(bytes, tiffM.data(), tiffM.size()) == 0 ||
159+
std::memcmp(bytes, tiffI.data(), tiffI.size()) == 0 ||
160+
std::memcmp(bytes, bmp.data(), bmp.size()) == 0)
161+
return true;
161162

162163
return false;
164+
// clang-format on
163165
}
164166

165167
/**

0 commit comments

Comments
 (0)