diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..e25352dd8 --- /dev/null +++ b/.clang-format @@ -0,0 +1,85 @@ +--- +# Nuklear clang-format config. For more info see +# https://clang.llvm.org/docs/ClangFormat.html +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html + +# llvm docs recommend using Cpp for C and C++ +Language: Cpp + +#AlignAfterOpenBracket: DontAlign +AlignArrayOfStructures: Right +AlignConsecutiveAssignments: + Enabled: true + AcrossComments: false + AcrossEmptyLines: false + AlignCompound: true + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossComments: false + AcrossEmptyLines: false + AlignCompound: true + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossComments: false + AcrossEmptyLines: false +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossComments: true + AcrossEmptyLines: true + AlignCaseColons: false +AlignEscapedNewlines: Left +AlignOperands: AlignAfterOperator +AlignTrailingComments: Always +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: All +BraceWrapping: + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterStruct: false + AfterUnion: false + BeforeElse: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false +BreakAdjacentStringLiterals: false +BreakBeforeBinaryOperators: true +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: true +BreakStringLiterals: true +# 160 is arbitrary, if set to 0 will cause some short enums to be split on multiple lines +ColumnLimit: 160 +ContinuationIndentWidth: 4 +DerivePointerAlignment: true +ForEachMacros: [nk_foreach] +IndentCaseLabels: true +IndentGotoLabels: false +# Not perfect but does improve readability +IndentPPDirectives: AfterHash +IndentWidth: 4 +LineEnding: LF +# docs show ReflowComments is type "ReflowCommentsStyle" but when run with clang-format (v19.1.7) gives "invalid boolean" error +ReflowComments: false +SortIncludes: Never +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false + +... +# This file is avaliable under either the MIT License or public domain. See LICENSE for more info. diff --git a/src/build.py b/src/build.py index ff5c455d8..003402f70 100644 --- a/src/build.py +++ b/src/build.py @@ -139,7 +139,7 @@ def fix_comments(str): # print("\n#ifndef " + macro + "_SINGLE_HEADER"); # print("#define " + macro + "_SINGLE_HEADER"); print("#ifndef NK_SINGLE_FILE"); -print(" #define NK_SINGLE_FILE"); +print("# define NK_SINGLE_FILE"); print("#endif"); print(""); diff --git a/src/clang_format.sh b/src/clang_format.sh new file mode 100644 index 000000000..21b5f669b --- /dev/null +++ b/src/clang_format.sh @@ -0,0 +1,2 @@ +#!/bin/sh +clang-format --style=file:../.clang-format -i nuklear.h nuklear_internal.h nuklear_math.c nuklear_util.c nuklear_color.c nuklear_utf8.c nuklear_buffer.c nuklear_string.c nuklear_draw.c nuklear_vertex.c nuklear_font.c nuklear_input.c nuklear_style.c nuklear_context.c nuklear_pool.c nuklear_page_element.c nuklear_table.c nuklear_panel.c nuklear_window.c nuklear_popup.c nuklear_contextual.c nuklear_menu.c nuklear_layout.c nuklear_tree.c nuklear_group.c nuklear_list_view.c nuklear_widget.c nuklear_text.c nuklear_image.c nuklear_9slice.c nuklear_button.c nuklear_toggle.c nuklear_selectable.c nuklear_slider.c nuklear_knob.c nuklear_progress.c nuklear_scrollbar.c nuklear_text_editor.c nuklear_edit.c nuklear_property.c nuklear_chart.c nuklear_color_picker.c nuklear_combo.c nuklear_tooltip.c