Skip to content

Commit 000fbb3

Browse files
committed
chore: add .clang-format config
1 parent 0c11d73 commit 000fbb3

12 files changed

Lines changed: 71 additions & 20 deletions

.clang-format

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
# BasedOnStyle: LLVM
3+
Language: Cpp
4+
5+
IndentWidth: 4
6+
ContinuationIndentWidth: 4
7+
UseTab: Never
8+
ColumnLimit: 130
9+
PPIndentWidth: -1
10+
11+
AlignAfterOpenBracket: BlockIndent
12+
AlignOperands: AlignAfterOperator
13+
AllowShortBlocksOnASingleLine: Empty
14+
AllowShortEnumsOnASingleLine: false
15+
AllowShortFunctionsOnASingleLine: Inline
16+
AlwaysBreakTemplateDeclarations: Yes
17+
BinPackArguments: false
18+
BinPackLongBracedList: false
19+
BinPackParameters: OnePerLine
20+
ExperimentalAutoDetectBinPacking: true
21+
IndentPPDirectives: AfterHash
22+
NamespaceIndentation: All
23+
PenaltyReturnTypeOnItsOwnLine: 300
24+
PointerAlignment: Left
25+
QualifierAlignment: Left
26+
SpaceAfterTemplateKeyword: false
27+
SpaceBeforeCpp11BracedList: true
28+
29+
IncludeBlocks: Regroup
30+
IncludeCategories:
31+
- Regex: '^".*"'
32+
Priority: 1
33+
- Regex: '^<[a-z0-9_]+>$'
34+
Priority: 2
35+
# Make sure 'net/if.h' comes before 'ifaddrs.h'
36+
- Regex: '^<net/if\.h>$'
37+
Priority: 3
38+
- Regex: '^<[^/]+\.h>$'
39+
Priority: 3
40+
SortPriority: 4
41+
- Regex: '^<(arpa|linux|net(inet)?|prop|sys|u?vm)/'
42+
Priority: 3
43+
SortPriority: 4
44+
- Regex: '.*'
45+
Priority: 5
46+

src/btop_draw.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ namespace Symbols {
6060
const array<string, 10> superscript = { "", "¹", "²", "³", "", "", "", "", "", "" };
6161

6262
const std::unordered_map<string, vector<string>> graph_symbols = {
63-
{ "braille_up", {
63+
// clang-format off
64+
{"braille_up", {
6465
" ", "", "", "", "",
6566
"", "", "", "", "",
6667
"", "", "", "", "",
@@ -102,6 +103,7 @@ namespace Symbols {
102103
"", "", "", "", "",
103104
"", "", "", "", ""
104105
}}
106+
// clang-format on
105107
};
106108

107109
}

src/btop_menu.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ namespace Menu {
6060

6161
const array<string, 32> P_Signals = {
6262
"0",
63+
// clang-format off
6364
#ifdef __linux__
6465
#if defined(__hppa__)
6566
"SIGHUP", "SIGINT", "SIGQUIT", "SIGILL",
@@ -126,11 +127,13 @@ namespace Menu {
126127
"25", "26", "27", "28",
127128
"29", "30", "31"
128129
#endif
130+
// clang-format on
129131
};
130132

131133
std::unordered_map<string, Input::Mouse_loc> mouse_mappings;
132134

133135
const array<array<string, 3>, 3> menu_normal = {
136+
// clang-format off
134137
array<string, 3>{
135138
"┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐",
136139
"│ │├─┘ │ ││ ││││└─┐",
@@ -146,9 +149,11 @@ namespace Menu {
146149
"│─┼┐│ │ │ │ ",
147150
"└─┘└└─┘ ┴ ┴ "
148151
}
152+
// clang-format off
149153
};
150154

151155
const array<array<string, 3>, 3> menu_selected = {
156+
// clang-format off
152157
array<string, 3>{
153158
"╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗",
154159
"║ ║╠═╝ ║ ║║ ║║║║╚═╗",
@@ -164,6 +169,7 @@ namespace Menu {
164169
"║═╬╗║ ║ ║ ║ ",
165170
"╚═╝╚╚═╝ ╩ ╩ "
166171
}
172+
// clang-format on
167173
};
168174

169175
const array<int, 3> menu_width = {19, 12, 12};

src/btop_shared.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ tab-size = 4
3232

3333
#include <unistd.h>
3434

35-
// From `man 3 getifaddrs`: <net/if.h> must be included before <ifaddrs.h>
36-
// clang-format off
3735
#include <net/if.h>
3836
#include <ifaddrs.h>
39-
// clang-format on
4037

4138
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
4239
# include <kvm.h>

src/btop_tools.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tab-size = 4
2222
# define BTOP_DEBUG
2323
#endif
2424

25-
#include <algorithm> // for std::ranges::count_if
25+
#include <algorithm>
2626
#include <array>
2727
#include <atomic>
2828
#include <chrono>

src/freebsd/btop_collect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
indent = tab
1616
tab-size = 4
1717
*/
18+
1819
#include <arpa/inet.h>
1920
#include <cstdio>
2021
#include <cstdlib>
2122
#include <cstring>
2223
#include <libproc.h>
23-
// man 3 getifaddrs: "BUGS: If both <net/if.h> and <ifaddrs.h> are being included, <net/if.h> must be included before <ifaddrs.h>"
2424
#include <net/if.h>
2525
#include <ifaddrs.h>
2626
#include <net/if_dl.h>
2727
#include <net/route.h>
2828
#include <netdb.h>
2929
#include <netinet/tcp_fsm.h>
30-
#include <netinet/in.h> // for inet_ntop stuff
30+
#include <netinet/in.h>
3131
#include <pwd.h>
3232
#include <sys/_timeval.h>
3333
#include <sys/endian.h>

src/linux/btop_collect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ tab-size = 4
3232
#include <unordered_set>
3333
#include <utility>
3434

35-
#include <arpa/inet.h> // for inet_ntop()
35+
#include <arpa/inet.h>
3636
#include <dlfcn.h>
3737
#include <ifaddrs.h>
3838
#include <net/if.h>
@@ -1496,8 +1496,8 @@ namespace Gpu {
14961496
const array libRocAlts = {
14971497
"/opt/rocm/lib/librocm_smi64.so",
14981498
"librocm_smi64.so",
1499-
"librocm_smi64.so.5", // fedora
1500-
"librocm_smi64.so.1.0", // debian
1499+
"librocm_smi64.so.5", // Fedora
1500+
"librocm_smi64.so.1.0", // Debian
15011501
"librocm_smi64.so.6"
15021502
};
15031503

src/netbsd/btop_collect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
indent = tab
1717
tab-size = 4
1818
*/
19+
1920
#include <arpa/inet.h>
2021
#include <cstddef>
2122
#include <cstdio>
2223
#include <cstdlib>
2324
#include <cstring>
24-
// man 3 getifaddrs: "BUGS: If both <net/if.h> and <ifaddrs.h> are being included, <net/if.h> must be included before <ifaddrs.h>"
2525
#include <net/if.h>
2626
#include <ifaddrs.h>
2727
#include <net/if_dl.h>
2828
#include <net/route.h>
2929
#include <netdb.h>
3030
#include <netinet/tcp_fsm.h>
31-
#include <netinet/in.h> // for inet_ntop stuff
31+
#include <netinet/in.h>
3232
#include <pwd.h>
3333
#include <prop/proplib.h>
3434
#include <sys/endian.h>

src/openbsd/btop_collect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
indent = tab
1616
tab-size = 4
1717
*/
18+
1819
#include <arpa/inet.h>
1920
#include <cstddef>
2021
#include <cstdio>
2122
#include <cstdlib>
2223
#include <cstring>
23-
// man 3 getifaddrs: "BUGS: If both <net/if.h> and <ifaddrs.h> are being included, <net/if.h> must be included before <ifaddrs.h>"
2424
#include <net/if.h>
2525
#include <ifaddrs.h>
2626
#include <net/if_dl.h>
2727
#include <net/route.h>
2828
#include <netdb.h>
2929
#include <netinet/tcp_fsm.h>
30-
#include <netinet/in.h> // for inet_ntop stuff
30+
#include <netinet/in.h>
3131
#include <pwd.h>
3232
#include <sys/endian.h>
3333
#include <sys/resource.h>
@@ -71,7 +71,7 @@ tab-size = 4
7171
#include "../btop_shared.hpp"
7272
#include "../btop_tools.hpp"
7373

74-
#include "./sysctlbyname.h"
74+
#include "sysctlbyname.h"
7575

7676
using std::clamp, std::string_literals::operator""s, std::cmp_equal, std::cmp_less, std::cmp_greater;
7777
using std::ifstream, std::numeric_limits, std::streamsize, std::round, std::max, std::min;

src/openbsd/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*/
1616

17+
#pragma once
18+
1719
struct sysctls {
1820
const char *name;
1921
int mib0;

0 commit comments

Comments
 (0)