Skip to content

Commit

Permalink
src: clang-format
Browse files Browse the repository at this point in the history
Adds `make fmt` as well.
  • Loading branch information
woodruffw committed Apr 3, 2019
1 parent 3396332 commit 4078ea6
Show file tree
Hide file tree
Showing 19 changed files with 3,221 additions and 3,985 deletions.
109 changes: 109 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 2
UseTab: Never
...

7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1

ALL_SOURCES = $(shell find . -type f \( -name '*.c' -o -name '*.h' \))

SOURCES = $(wildcard ./src/*.c)
OBJS = $(SOURCES:.c=.o)

Expand Down Expand Up @@ -103,7 +105,10 @@ clean:
rm -f gltest
rm -f screenfetch-c screenfetch-c.exe

fmt:
clang-format -i -style=file $(ALL_SOURCES)

$(OLDTARGETS): all

.PHONY: all install uninstall clean $(OLDTARGETS)
.PHONY: all install uninstall clean fmt $(OLDTARGETS)

49 changes: 8 additions & 41 deletions src/arrays.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
** initialized in this file.
*/


#include "arrays.h"
#include "misc.h"
#include "colors.h"
Expand All @@ -32,44 +31,12 @@ char font_str[MAX_STRLEN] = "Unknown";

char host_color[MAX_STRLEN] = TNRM;

char *detected_arr[DETECTED_ARR_LEN] =
{
host_str,
distro_str,
kernel_str,
cpu_str,
gpu_str,
shell_str,
pkgs_str,
disk_str,
mem_str,
uptime_str,
res_str,
de_str,
wm_str,
wm_theme_str,
gtk_str,
icon_str,
font_str
};
char *detected_arr[DETECTED_ARR_LEN] = {host_str, distro_str, kernel_str, cpu_str, gpu_str,
shell_str, pkgs_str, disk_str, mem_str, uptime_str,
res_str, de_str, wm_str, wm_theme_str, gtk_str,
icon_str, font_str};

char *detected_arr_names[DETECTED_ARR_LEN] =
{
"",
"OS: ",
"Kernel: ",
"CPU: ",
"GPU: ",
"Shell: ",
"Packages: ",
"Disk: ",
"Memory: ",
"Uptime: ",
"Resolution: ",
"DE: ",
"WM: ",
"WM Theme: ",
"GTK: ",
"Icon Theme: ",
"Font: "
};
char *detected_arr_names[DETECTED_ARR_LEN] = {
"", "OS: ", "Kernel: ", "CPU: ", "GPU: ", "Shell: ",
"Packages: ", "Disk: ", "Memory: ", "Uptime: ", "Resolution: ", "DE: ",
"WM: ", "WM Theme: ", "GTK: ", "Icon Theme: ", "Font: "};
2 changes: 1 addition & 1 deletion src/colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#else

#define TNRM "\x1B[0m" /* normal */
#define TNRM "\x1B[0m" /* normal */
#define TBLK "\x1B[0;30m" /* black */
#define TRED "\x1B[0;31m" /* red */
#define TGRN "\x1B[0;32m" /* green */
Expand Down
Loading

0 comments on commit 4078ea6

Please sign in to comment.