From 2c112af865add6e99ea05461506d284dfb73edd4 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Tue, 19 Dec 2017 12:41:47 +0000 Subject: [PATCH] Add an experimental .clang-format file. This file can be used with clang-format to format c and c++ source files according to the FLTK CMP -- at least "almost" in its current version. It should not (yet) be used without further checking of the result. Note: there are some deliberate non-conformant formattings in current source files, such as formatting like (better readable?) tables with columns etc.. Such special formatting can be preserved with clang-format "pragma's" (see documentation in .clang-format), but this needs source file changes before formatting. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12598 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- .clang-format | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100755 index 000000000..3b693bf0b --- /dev/null +++ b/.clang-format @@ -0,0 +1,144 @@ +# +# "$Id$" +# +# clang-format control file for the FLTK project. +# +# Copyright 2017 by Bill Spitzak and others. +# +# This library is free software. Distribution and use rights are outlined in +# the file "COPYING" which should have been included with this file. If this +# file is missing or damaged, see the license at: +# +# http://www.fltk.org/COPYING.php +# +# Please report all bugs and problems on the following page: +# +# http://www.fltk.org/str.php +# +# +# Important notes: +# +# This is a preliminary, experimental version of a clang-format control file. +# To use all options including embedded comments to switch formatting on +# and off in source files (see below) clang-format 3.6 or later is required. +# +# DO NOT USE WITHOUT CHECKING THE RESULT OF FORMATTING FOR CORRECTNESS +# AND COMPATIBILITY WITH THE FLTK CMP! +# +# For more information about clang-format please refer to the online docs at: +# http://clang.llvm.org/docs/ClangFormat.html +# http://clang.llvm.org/docs/ClangFormatStyleOptions.html +# +# Embedded comments ("pragma"s) in the source code: +# // clang-format on +# // clang-format off +# The above comments or their C equivalents /* clang-format on|off */ +# can be used to switch clang-format(ting) temporary off in a source file. +# This is particularly useful for embedded pixmaps and other tables +# like menu arrays that are pre-formatted for better readability. + + +# The options used for FLTK are based on pre-defined style options of LLVM + +BasedOnStyle: LLVM + +# The Language tag marks C++ options + +Language: Cpp + +# The following block of commented options is an excerpt of all +# LLVM style options with their respective values. +# For a full list of LLVM options please use: +# clang-format -style=llvm -dump-config + +# Please do not change the following block of comments unless the LLVM +# default values have changed or to add or remove (ir)relevant options. + +# IndentWidth: 2 +# TabWidth: 8 +# ColumnLimit: 80 +# UseTab: Never +# AccessModifierOffset: -2 +# AllowShortBlocksOnASingleLine: false +# AllowShortFunctionsOnASingleLine: All +# AllowShortIfStatementsOnASingleLine: false +# AllowShortLoopsOnASingleLine: false +# MaxEmptyLinesToKeep: 1 +# KeepEmptyLinesAtTheStartOfBlocks: true +# PenaltyBreakBeforeFirstCallParameter: 19 +# PenaltyBreakComment: 300 +# PenaltyBreakString: 1000 +# PenaltyBreakFirstLessLess: 120 +# PenaltyExcessCharacter: 1000000 +# PenaltyReturnTypeOnItsOwnLine: 60 +# PointerAlignment: Right +# BreakBeforeBraces: Attach +# ContinuationIndentWidth: 4 +# SpaceBeforeParens: ControlStatements + +# FLTK specific settings (currently experimental). +# The following options override the LLVM style definitions, if set. +# Refer to the default values above. + +# Uncomment the next option if indenting with tabs should be used. +# Note: tab spacing is still 8 columns, tabs are only used for +# indents of 8 columns or more. +# Might have bugs counting columns, comments may not be adjusted +# as expected (as of clang-format 3.6 and 3.8). +# UseTab can be set to 'Never' or 'ForIndentation' to avoid this +# annoying bug of clang-format. +# UseTab: Always +# UseTab: Never +UseTab: ForIndentation + +# Should we extend beyond 80 columns ? +# ColumnLimit: 100 +ColumnLimit: 120 + +# LLVM: IndentCaseLabels: false +IndentCaseLabels: true + +# There are sometimes more than 1 empty lines; should we keep 2 or more ? + +# Default (LLVM): 1 +MaxEmptyLinesToKeep: 2 + +# The existent FLTK source code has some short blocks and if statements +# in one line, but we should better make it consistent and NOT use the +# following two "Allow..." statements (leave them commented out): + +# AllowShortBlocksOnASingleLine: true +# AllowShortIfStatementsOnASingleLine: true + +# Short inline functions in header files are an exception to the above "rule": + +# LLVM: AllowShortFunctionsOnASingleLine: All +AllowShortFunctionsOnASingleLine: Inline + +# This is particularly useful for macros with continuation lines: + +AlignEscapedNewlinesLeft: true + +# Include files should be left as-is until we know we can sort them +# without any bad side effects: + +SortIncludes: false + +# Multiple constructor initializers must be on consecutive lines: + +BreakConstructorInitializersBeforeComma: true + +# Constructor initializers will be indented by 2 spaces: + +# LLVM: ConstructorInitializerIndentWidth: 4 +ConstructorInitializerIndentWidth: 2 + +# *FIXME* Default (LLVM): 4 +# ContinuationIndentWidth: 2 + +PointerAlignment: Right +DerivePointerAlignment: false + +# +# End of "$Id$". +#