diff --git a/Makefile b/Makefile index 4e0086dc..3f53525a 100644 --- a/Makefile +++ b/Makefile @@ -106,10 +106,18 @@ find-filename-conflicts: .PHONY: format check-formatting cpplint cpplint-noisy shellcheck smoke-examples find-filename-conflicts prepare-virtual checkout-platform adjust-git-timestamps docker-bash docker-simulator-tests run-tests simulator-tests setup format: - bin/format-code.sh + bin/format-code.py \ + --exclude-dir 'testing/googletest' \ + --exclude-file 'generated-testcase.cpp' \ + src plugins examples testing check-formatting: - bin/format-code.sh --check + bin/format-code.py \ + --exclude-dir 'testing/googletest' \ + --exclude-file 'generated-testcase.cpp' \ + --check \ + --verbose \ + src plugins examples testing cpplint-noisy: -bin/cpplint.py --config=.cpplint-noisy --recursive src plugins examples diff --git a/bin/format-code.py b/bin/format-code.py new file mode 100755 index 00000000..a71c19ba --- /dev/null +++ b/bin/format-code.py @@ -0,0 +1,271 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# Copyright (c) 2022 Michael Richters + +# This is free and unencumbered software released into the public domain. + +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. + +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +# For more information, please refer to +# ------------------------------------------------------------------------------ +"""This script runs clang-format on Kaleidoscope's codebase.""" + +import argparse +import glob +import logging +import os +import re +import subprocess +import sys + + +# ============================================================================== +def parse_args(args): + """Parse command line parameters + + Args: + args (List[str]): command line parameters as list of strings + (for example ``["--help"]``). + + Returns: + :obj:`argparse.Namespace`: command line parameters namespace + """ + parser = argparse.ArgumentParser( + description=""" + Recursively search specified directories and format source files with + clang-format. By default, it operates on Arduino C++ source files with + extensions: *.{cpp,h,hpp,inc,ino}.""") + parser.add_argument( + '-v', + '--verbose', + dest='loglevel', + help="Verbose output", + action='store_const', + const=logging.INFO, + ) + parser.add_argument( + '-q', + '--quiet', + dest='loglevel', + help="Suppress all non-error output", + action='store_const', + const=logging.ERROR, + ) + parser.add_argument( + '-X', + '--exclude-dir', + metavar="", + dest='exclude_dirs', + help="Exclude dir from search (path relative to the pwd)", + action='append', + default=[], + ) + parser.add_argument( + '-x', + '--exclude-file', + metavar="", + dest='exclude_files', + help="Exclude (base name only, not a full path) from formatting", + action='append', + default=[], + ) + parser.add_argument( + '-e', + '--regex', + metavar="", + dest='src_re_str', + help="Regular expression for matching source file names", + default=r'\.(cpp|h|hpp|inc|ino)$', + ) + parser.add_argument( + '-f', + '--force', + action='store_true', + help="Format code even if there are unstaged changes", + ) + parser.add_argument( + '--check', + action='store_true', + help="Check for changes after formatting", + ) + parser.add_argument( + 'targets', + metavar="", + nargs='+', + help="""A list of files and/or directories to search for source files to format""", + ) + return parser.parse_args(args) + + +# ============================================================================== +def setup_logging(loglevel): + """Setup basic logging + + Args: + loglevel (int): minimum loglevel for emitting messages + """ + logformat = "%(message)s" + logging.basicConfig( + level=loglevel, + stream=sys.stdout, + format=logformat, + datefmt="", + ) + return logging.getLogger() + + +# ============================================================================== +def format_code(path, opts, clang_format_cmd): + """Run clang-format on a directory.""" + logging.info("Formatting code in %s...", path) + + src_regex = re.compile(opts.src_re_str) + + src_files = [] + + for root, dirs, files in os.walk(path): + for exclude_path in opts.exclude_dirs: + exclude_path = exclude_path.rstrip(os.path.sep) + if os.path.dirname(exclude_path) == root: + exclude_dir = os.path.basename(exclude_path) + if exclude_dir in dirs: + dirs.remove(exclude_dir) + + for name in files: + if name in opts.exclude_files: + continue + if src_regex.search(name): + src_files.append(os.path.join(root, name)) + + proc = subprocess.run(clang_format_cmd + src_files) + if proc.returncode != 0: + logging.error("Error: clang-format returned non-zero status: %s", proc.returncode) + return + + +# ============================================================================== +def build_file_list(path, src_regex): + """Docstring""" + + # If the specified path is a filename, return it (as a list), regardless of + # whether or not it matches the regex. + if os.path.isfile(path): + return [path] + + # If the specified path is not valid, just return an empty list. + if not os.path.isdir(path): + return [] + + # The specified path is a directory, so we search recursively for files + # contained therein that match the specified regular expression. + source_files = [] + for root, dirs, files in os.walk(path): + # First, ignore all dotfiles (and directories). + dotfiles = set(glob.glob('.*')) + dirs = set(dirs) - dotfiles + files = set(dirs) - dotfiles + + # Check for a list of file glob patterns that should be excluded. + if IWYU_IGNORE_FILE in files: + with open(os.path.join(root, IWYU_IGNORE_FILE)) as f: + for pattern in f.read().splitlines(): + matches = set(glob.glob(os.path.join(root, pattern))) + dirs = set(dirs) - matches + files = set(files) - matches + + # Add all matching files to the list of source files to be formatted. + for f in filter(src_regex.search, files): + source_files.append(os.path.join(root, f)) + + return source_files + + +# ============================================================================== +def warn_if_output(byte_str, msg): + """Convert a string of bytes to a UTF-8 string, break it on newlines. If + there is any output, print a warning message, followed by each line, + indented by four spaces.""" + lines = byte_str.decode('utf-8').splitlines() + if '' in lines: + lines.remove('') + if len(lines) > 0: + logging.warning('%s', msg) + for line in lines: + logging.warning(' %s', line) + return + + +# ============================================================================== +def main(cli_args): + """Parse command-line arguments and format source files.""" + args = parse_args(cli_args) + if args.loglevel is None: + args.loglevel = logging.WARNING + setup_logging(args.loglevel) + + clang_format = os.getenv('CLANG_FORMAT_CMD') + if clang_format is None: + clang_format = 'clang-format' + + clang_format_cmd = [clang_format, '-i'] + + git_diff_cmd = ['git', 'diff', '--exit-code'] + + proc = subprocess.run(git_diff_cmd + ['--name-only'], capture_output=True) + if proc.returncode != 0: + warn_if_output(proc.stdout, 'Warning: you have unstaged changes to these files:') + if not args.force: + logging.warning( + 'Formatting aborted. Stage your changes or use --force to override.') + sys.exit(proc.returncode) + + if args.loglevel >= logging.WARNING: + git_diff_cmd.append('--quiet') + elif args.loglevel <= logging.INFO: + git_diff_cmd.append('--name-only') + + for path in args.targets: + format_code(path, args, clang_format_cmd) + + if args.check: + logging.warning('Checking for changes made by the formatter...') + + proc = subprocess.run(git_diff_cmd + ['--cached'], capture_output=True) + if proc.returncode != 0: + logging.warning( + 'Warning: Your working tree has staged changes. ' + + 'Committed changes might not pass this check.') + warn_if_output(proc.stdout, 'The following files have unstaged changes:') + + proc = subprocess.run(git_diff_cmd, capture_output=True) + if proc.returncode != 0: + warn_if_output(proc.stdout, 'The following files have changes:') + logging.error( + 'Check failed: Please commit formatting changes before submitting.') + sys.exit(proc.returncode) + return + + +# ============================================================================== +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/bin/format-code.sh b/bin/format-code.sh index e81dda2e..db0cc137 100755 --- a/bin/format-code.sh +++ b/bin/format-code.sh @@ -1,25 +1,12 @@ #!/usr/bin/env bash -# Allow the caller to specify a particular version of clang-format to use: -: "${CLANG_FORMAT_CMD:=clang-format}" +: "${KALEIDOSCOPE_DIR:=$(pwd)}" +cd "${KALEIDOSCOPE_DIR}" || exit 1 -# Find all *.cpp and *.h files, except those in `testing/googletest/` and files -# generated by testcase scripts, and run `clang-format` on them: -find ./* -type f \( -name '*.h' -o -name '*.cpp' \) \ - -not \( -path './testing/googletest/*' -o -name 'generated-testcase.cpp' \) \ - -print0 | \ - xargs -0 "${CLANG_FORMAT_CMD}" -i +: "${VERBOSE:=}" -# If we get the `--check` option, return an error if there are any changes to -# the git working tree after running `clang-format`: -if [[ $1 == '--check' ]]; then - - if ! git diff --quiet; then - cat >&2 < #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(CycleTimeReport); diff --git a/examples/Features/EEPROM/DynamicMacros/DynamicMacros.ino b/examples/Features/EEPROM/DynamicMacros/DynamicMacros.ino index 60bc9f24..1a6267c0 100644 --- a/examples/Features/EEPROM/DynamicMacros/DynamicMacros.ino +++ b/examples/Features/EEPROM/DynamicMacros/DynamicMacros.ino @@ -21,7 +21,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -40,14 +40,13 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS( EEPROMSettings, EEPROMKeymap, DynamicMacros, - Focus -); + Focus); void setup() { Kaleidoscope.setup(); diff --git a/examples/Features/EEPROM/EEPROM-Keymap-Programmer/EEPROM-Keymap-Programmer.ino b/examples/Features/EEPROM/EEPROM-Keymap-Programmer/EEPROM-Keymap-Programmer.ino index a3ddd53d..e614907b 100644 --- a/examples/Features/EEPROM/EEPROM-Keymap-Programmer/EEPROM-Keymap-Programmer.ino +++ b/examples/Features/EEPROM/EEPROM-Keymap-Programmer/EEPROM-Keymap-Programmer.ino @@ -21,7 +21,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (M(0), Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -40,7 +40,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { if (macro_id == 0 && keyToggledOff(event.state)) { diff --git a/examples/Features/EEPROM/EEPROM-Keymap/EEPROM-Keymap.ino b/examples/Features/EEPROM/EEPROM-Keymap/EEPROM-Keymap.ino index 89c331ca..7f7f1b89 100644 --- a/examples/Features/EEPROM/EEPROM-Keymap/EEPROM-Keymap.ino +++ b/examples/Features/EEPROM/EEPROM-Keymap/EEPROM-Keymap.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(EEPROMKeymap, Focus); diff --git a/examples/Features/EEPROM/EEPROM-Settings/EEPROM-Settings.ino b/examples/Features/EEPROM/EEPROM-Settings/EEPROM-Settings.ino index 81e3f3f6..54230144 100644 --- a/examples/Features/EEPROM/EEPROM-Settings/EEPROM-Settings.ino +++ b/examples/Features/EEPROM/EEPROM-Settings/EEPROM-Settings.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -37,7 +37,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings); diff --git a/examples/Features/FocusSerial/FocusSerial.ino b/examples/Features/FocusSerial/FocusSerial.ino index 26de9f28..dd6c00d7 100644 --- a/examples/Features/FocusSerial/FocusSerial.ino +++ b/examples/Features/FocusSerial/FocusSerial.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -37,7 +37,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-OFF* +// clang-format on namespace kaleidoscope { class FocusTestCommand : public Plugin { @@ -70,7 +70,7 @@ class FocusHelpCommand : public Plugin { } }; -} +} // namespace kaleidoscope kaleidoscope::FocusTestCommand FocusTestCommand; kaleidoscope::FocusHelpCommand FocusHelpCommand; diff --git a/examples/Features/GhostInTheFirmware/GhostInTheFirmware.ino b/examples/Features/GhostInTheFirmware/GhostInTheFirmware.ino index 5cd5a108..2236c728 100644 --- a/examples/Features/GhostInTheFirmware/GhostInTheFirmware.ino +++ b/examples/Features/GhostInTheFirmware/GhostInTheFirmware.ino @@ -27,7 +27,7 @@ // will type out the letters from A to N, but the right palm key can be used to // toggle the custom EventDropper plugin to suppress USB output. -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (___, ___, ___, ___, ___, ___, ___, @@ -46,7 +46,7 @@ KEYMAPS( ___, ___, ___, ___, M(1)), ) -// *INDENT-ON* +// clang-format on namespace kaleidoscope { namespace plugin { @@ -61,12 +61,13 @@ class EventDropper : public Plugin { void toggle() { active_ = !active_; } + private: bool active_ = false; }; -} // namespace plugin -} // namespace kaleidoscope +} // namespace plugin +} // namespace kaleidoscope kaleidoscope::plugin::EventDropper EventDropper; @@ -95,8 +96,7 @@ static const kaleidoscope::plugin::GhostInTheFirmware::GhostKey ghost_keys[] PRO {KeyAddr(3, 14), 200, 50}, {KeyAddr(3, 15), 200, 50}, - {KeyAddr::none(), 0, 0} -}; + {KeyAddr::none(), 0, 0}}; KALEIDOSCOPE_INIT_PLUGINS(GhostInTheFirmware, LEDControl, @@ -107,7 +107,7 @@ KALEIDOSCOPE_INIT_PLUGINS(GhostInTheFirmware, void setup() { Kaleidoscope.setup(); - StalkerEffect.variant = STALKER(BlazingTrail); + StalkerEffect.variant = STALKER(BlazingTrail); GhostInTheFirmware.ghost_keys = ghost_keys; } diff --git a/examples/Features/HostOS/HostOS.ino b/examples/Features/HostOS/HostOS.ino index 8803f9d7..802c5491 100644 --- a/examples/Features/HostOS/HostOS.ino +++ b/examples/Features/HostOS/HostOS.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, HostOS); diff --git a/examples/Features/HostPowerManagement/HostPowerManagement.ino b/examples/Features/HostPowerManagement/HostPowerManagement.ino index cb5c9f49..d159eca6 100644 --- a/examples/Features/HostPowerManagement/HostPowerManagement.ino +++ b/examples/Features/HostPowerManagement/HostPowerManagement.ino @@ -20,7 +20,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -41,7 +41,7 @@ KEYMAPS( Key_NoKey ), ) -// *INDENT-ON* +// clang-format on void hostPowerManagementEventHandler(kaleidoscope::plugin::HostPowerManagement::Event event) { switch (event) { diff --git a/examples/Features/Layers/Layers.ino b/examples/Features/Layers/Layers.ino index a1f749c4..b5cfd177 100644 --- a/examples/Features/Layers/Layers.ino +++ b/examples/Features/Layers/Layers.ino @@ -19,9 +19,13 @@ #include #include -enum { PRIMARY, NUMPAD, FUNCTION }; // layers +enum { + PRIMARY, + NUMPAD, + FUNCTION, +}; // layers -// *INDENT-OFF* +// clang-format off KEYMAPS( [PRIMARY] = KEYMAP_STACKED (___, Key_1, Key_2, Key_3, Key_4, Key_5, XXX, @@ -68,10 +72,10 @@ KEYMAPS( ___, ___, Key_Enter, ___, ___) ) -// *INDENT-OFF* +// clang-format on namespace kaleidoscope { -class LayerDumper: public Plugin { +class LayerDumper : public Plugin { public: LayerDumper() {} @@ -89,7 +93,7 @@ class LayerDumper: public Plugin { } }; -} +} // namespace kaleidoscope kaleidoscope::LayerDumper LayerDumper; diff --git a/examples/Features/ShiftBlocker/ShiftBlocker.ino b/examples/Features/ShiftBlocker/ShiftBlocker.ino index 46770e8c..02400dbd 100644 --- a/examples/Features/ShiftBlocker/ShiftBlocker.ino +++ b/examples/Features/ShiftBlocker/ShiftBlocker.ino @@ -18,7 +18,7 @@ #include "Kaleidoscope.h" #include "Kaleidoscope-Macros.h" -/* *INDENT-OFF* */ +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -39,7 +39,7 @@ KEYMAPS( M(0) ), ) -/* *INDENT-ON* */ +// clang-format on namespace kaleidoscope { namespace plugin { @@ -64,11 +64,10 @@ class ShiftBlocker : public Plugin { private: bool active_{false}; - }; -} // namespace plugin -} // namespace kaleidoscope +} // namespace plugin +} // namespace kaleidoscope kaleidoscope::plugin::ShiftBlocker ShiftBlocker; diff --git a/examples/Features/Steno/Steno.ino b/examples/Features/Steno/Steno.ino index 91f4e709..0415d5cc 100644 --- a/examples/Features/Steno/Steno.ino +++ b/examples/Features/Steno/Steno.ino @@ -20,7 +20,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -56,7 +56,7 @@ KEYMAPS( S(E), S(U), XXX, S(RE2), ___), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(GeminiPR); diff --git a/examples/Features/TypingBreaks/TypingBreaks.ino b/examples/Features/TypingBreaks/TypingBreaks.ino index c031cb77..687e43a0 100644 --- a/examples/Features/TypingBreaks/TypingBreaks.ino +++ b/examples/Features/TypingBreaks/TypingBreaks.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -39,7 +39,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, TypingBreaks); diff --git a/examples/Internal/Sketch_Exploration/Sketch_Exploration.ino b/examples/Internal/Sketch_Exploration/Sketch_Exploration.ino index 980de7f6..91c3ef2c 100644 --- a/examples/Internal/Sketch_Exploration/Sketch_Exploration.ino +++ b/examples/Internal/Sketch_Exploration/Sketch_Exploration.ino @@ -21,7 +21,7 @@ // This example demonstrates how a plugin can gather information about // the keymap at compile time, e.g. to adapt its behavior, safe resources, ... -/* *INDENT-OFF* */ +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -42,9 +42,9 @@ KEYMAPS( Key_NoKey ), ) -/* *INDENT-ON* */ +// clang-format on -using namespace kaleidoscope::sketch_exploration; // NOLINT(build/namespaces) +using namespace kaleidoscope::sketch_exploration; // NOLINT(build/namespaces) class BPlugin : public kaleidoscope::Plugin {}; class CPlugin : public kaleidoscope::Plugin {}; @@ -54,7 +54,8 @@ class CPlugin : public kaleidoscope::Plugin {}; class APlugin : public kaleidoscope::Plugin { public: - APlugin() : has_key_1_{false} {} + APlugin() + : has_key_1_{false} {} template kaleidoscope::EventHandlerResult exploreSketch() { @@ -72,7 +73,7 @@ class APlugin : public kaleidoscope::Plugin { constexpr bool has_key_1 = K::collect(HasKey{Key_1}); static_assert(has_key_1, "Error querying key existence"); - has_key_1_ = has_key_1; // Assign the temporary that was computed + has_key_1_ = has_key_1; // Assign the temporary that was computed // at compile time. constexpr Key max_key = K::collect(MaxKeyRaw{}); @@ -81,7 +82,7 @@ class APlugin : public kaleidoscope::Plugin { static_assert(K::getKey(0 /*layer*/, KeyAddr{2, 3}) == Key_D, "Key lookup failed"); - constexpr auto n_layers = K::nLayers(); + constexpr auto n_layers = K::nLayers(); constexpr auto layer_size = K::layerSize(); // Plugin exploration @@ -117,7 +118,6 @@ class APlugin : public kaleidoscope::Plugin { } private: - bool has_key_1_; }; @@ -127,8 +127,7 @@ BPlugin b_plugin; KALEIDOSCOPE_INIT_PLUGINS( a_plugin1, b_plugin, - a_plugin2 -) + a_plugin2) void setup() { Kaleidoscope.setup(); diff --git a/examples/Keystrokes/AutoShift/AutoShift.ino b/examples/Keystrokes/AutoShift/AutoShift.ino index 333e9d58..4b6cbc35 100644 --- a/examples/Keystrokes/AutoShift/AutoShift.ino +++ b/examples/Keystrokes/AutoShift/AutoShift.ino @@ -12,7 +12,7 @@ enum { TOGGLE_AUTOSHIFT, }; -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -33,7 +33,7 @@ KEYMAPS( XXX ), ) -// *INDENT-ON* +// clang-format on // Defining a macro (on the "any" key: see above) to turn AutoShift on and off const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { @@ -56,8 +56,8 @@ KALEIDOSCOPE_INIT_PLUGINS( FocusEEPROMCommand, // for AutoShiftConfig FocusSettingsCommand, // for AutoShiftConfig AutoShift, - AutoShiftConfig, // for AutoShiftConfig - Macros // for toggle AutoShift Macro + AutoShiftConfig, // for AutoShiftConfig + Macros // for toggle AutoShift Macro ); void setup() { diff --git a/examples/Keystrokes/CharShift/CharShift.ino b/examples/Keystrokes/CharShift/CharShift.ino index b1aa83ec..ac3ad49c 100644 --- a/examples/Keystrokes/CharShift/CharShift.ino +++ b/examples/Keystrokes/CharShift/CharShift.ino @@ -4,7 +4,7 @@ #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -25,15 +25,15 @@ KEYMAPS( XXX ), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(CharShift); void setup() { CS_KEYS( - kaleidoscope::plugin::CharShift::KeyPair(Key_Comma, Key_Semicolon), // CS(0) - kaleidoscope::plugin::CharShift::KeyPair(Key_Period, LSHIFT(Key_Semicolon)), // CS(1) - kaleidoscope::plugin::CharShift::KeyPair(LSHIFT(Key_Comma), LSHIFT(Key_Period)), // CS(2) + kaleidoscope::plugin::CharShift::KeyPair(Key_Comma, Key_Semicolon), // CS(0) + kaleidoscope::plugin::CharShift::KeyPair(Key_Period, LSHIFT(Key_Semicolon)), // CS(1) + kaleidoscope::plugin::CharShift::KeyPair(LSHIFT(Key_Comma), LSHIFT(Key_Period)), // CS(2) ); Kaleidoscope.setup(); } diff --git a/examples/Keystrokes/Cycle/Cycle.ino b/examples/Keystrokes/Cycle/Cycle.ino index b8b33dd0..aed91b32 100644 --- a/examples/Keystrokes/Cycle/Cycle.ino +++ b/examples/Keystrokes/Cycle/Cycle.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -37,7 +37,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_Cycle), ) -// *INDENT-ON* +// clang-format on void cycleAction(Key previous_key, uint8_t cycle_count) { if (previous_key == Key_E) { diff --git a/examples/Keystrokes/DynamicTapDance/DynamicTapDance.ino b/examples/Keystrokes/DynamicTapDance/DynamicTapDance.ino index aacc4b01..b70501af 100644 --- a/examples/Keystrokes/DynamicTapDance/DynamicTapDance.ino +++ b/examples/Keystrokes/DynamicTapDance/DynamicTapDance.ino @@ -22,7 +22,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -42,7 +42,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, TD(2), TD(1)), ) -// *INDENT-ON* +// clang-format on enum { TD_TAB_ESC, diff --git a/examples/Keystrokes/Escape-OneShot/Escape-OneShot.ino b/examples/Keystrokes/Escape-OneShot/Escape-OneShot.ino index 921d4d92..da312d23 100644 --- a/examples/Keystrokes/Escape-OneShot/Escape-OneShot.ino +++ b/examples/Keystrokes/Escape-OneShot/Escape-OneShot.ino @@ -21,7 +21,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -61,7 +61,7 @@ KEYMAPS( ___ ), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, Focus, diff --git a/examples/Keystrokes/Leader/Leader.ino b/examples/Keystrokes/Leader/Leader.ino index fc6f65c2..b1c1163d 100644 --- a/examples/Keystrokes/Leader/Leader.ino +++ b/examples/Keystrokes/Leader/Leader.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -37,7 +37,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, LEAD(0)), ) -// *INDENT-ON* +// clang-format on auto &serial_port = Kaleidoscope.serialPort(); @@ -50,8 +50,8 @@ static void leaderTestAA(uint8_t seq_index) { } static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM = -LEADER_DICT({LEADER_SEQ(LEAD(0), Key_A), leaderTestA}, -{LEADER_SEQ(LEAD(0), Key_A, Key_A), leaderTestAA}); + LEADER_DICT({LEADER_SEQ(LEAD(0), Key_A), leaderTestA}, + {LEADER_SEQ(LEAD(0), Key_A, Key_A), leaderTestAA}); KALEIDOSCOPE_INIT_PLUGINS(Leader); diff --git a/examples/Keystrokes/LeaderPrefix/LeaderPrefix.ino b/examples/Keystrokes/LeaderPrefix/LeaderPrefix.ino index 6de00bf6..14ee4a33 100644 --- a/examples/Keystrokes/LeaderPrefix/LeaderPrefix.ino +++ b/examples/Keystrokes/LeaderPrefix/LeaderPrefix.ino @@ -24,7 +24,7 @@ #include "kaleidoscope/LiveKeys.h" #include "kaleidoscope/plugin.h" -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -43,7 +43,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, LEAD(0)), ) -// *INDENT-ON* +// clang-format on namespace kaleidoscope { namespace plugin { @@ -74,7 +74,7 @@ class LeaderPrefix : public Plugin { if (keyToggledOn(event.state) && isLeaderKey(event.key)) { // A Leader key toggled on, so we set our state to "active", and set the // arg value to zero. - active_ = true; + active_ = true; leader_arg_ = 0; } // Whether or not the plugin just became active, there's nothing more to @@ -122,8 +122,16 @@ class LeaderPrefix : public Plugin { private: // The "digit keys": these are the keys on the number row of the Model01. KeyAddr digit_addrs_[10] = { - KeyAddr(0, 14), KeyAddr(0, 1), KeyAddr(0, 2), KeyAddr(0, 3), KeyAddr(0, 4), - KeyAddr(0, 5), KeyAddr(0, 10), KeyAddr(0, 11), KeyAddr(0, 12), KeyAddr(0, 13), + KeyAddr(0, 14), + KeyAddr(0, 1), + KeyAddr(0, 2), + KeyAddr(0, 3), + KeyAddr(0, 4), + KeyAddr(0, 5), + KeyAddr(0, 10), + KeyAddr(0, 11), + KeyAddr(0, 12), + KeyAddr(0, 13), }; // This event tracker is necessary to prevent re-processing events. Any @@ -144,8 +152,8 @@ class LeaderPrefix : public Plugin { } }; -} // namespace plugin -} // namespace kaleidoscope +} // namespace plugin +} // namespace kaleidoscope // This creates our plugin object. kaleidoscope::plugin::LeaderPrefix LeaderPrefix; @@ -172,9 +180,9 @@ void leaderTestPrefix(uint8_t seq_index) { } static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM = -LEADER_DICT({LEADER_SEQ(LEAD(0), Key_X), leaderTestX}, -{LEADER_SEQ(LEAD(0), Key_X, Key_X), leaderTestXX}, -{LEADER_SEQ(LEAD(0), Key_Z), leaderTestPrefix}); + LEADER_DICT({LEADER_SEQ(LEAD(0), Key_X), leaderTestX}, + {LEADER_SEQ(LEAD(0), Key_X, Key_X), leaderTestXX}, + {LEADER_SEQ(LEAD(0), Key_Z), leaderTestPrefix}); // The order matters here; LeaderPrefix won't work unless it precedes Leader in // this list. If there are other plugins in the list, these two should ideally diff --git a/examples/Keystrokes/Macros/Macros.ino b/examples/Keystrokes/Macros/Macros.ino index 5e0badb4..c7fba475 100644 --- a/examples/Keystrokes/Macros/Macros.ino +++ b/examples/Keystrokes/Macros/Macros.ino @@ -24,7 +24,7 @@ enum { TOGGLE_ONESHOT, }; -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (___, M(1), M(2), M(3), M(4), M(5), ___, @@ -61,7 +61,7 @@ KEYMAPS( ___, ___, ___, ___, ___), ) -// *INDENT-ON* +// clang-format on // Example macro for typing a string of characters. void macroTypeString(KeyEvent &event) { @@ -71,7 +71,7 @@ void macroTypeString(KeyEvent &event) { } // Example macro for macro step sequence. -const macro_t* macroSteps(KeyEvent &event) { +const macro_t *macroSteps(KeyEvent &event) { if (keyToggledOn(event.state)) { // Note that the following sequence leaves two keys down (`Key_RightAlt` and // `Key_C`). These virtual keys will remain in effect until the Macros key @@ -82,7 +82,7 @@ const macro_t* macroSteps(KeyEvent &event) { } // Example macro that sets `event.key`. -const macro_t* macroNewSentence1(KeyEvent &event) { +const macro_t *macroNewSentence1(KeyEvent &event) { if (keyToggledOn(event.state)) { event.key = OSM(LeftShift); return MACRO(Tc(Period), Tc(Spacebar), Tc(Spacebar)); @@ -114,7 +114,7 @@ void macroNewSentence3(KeyEvent &event) { // Macro that auto-repeats? -const macro_t* macroAction(uint8_t macro_id, KeyEvent &event) { +const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { switch (macro_id) { case 0: diff --git a/examples/Keystrokes/MagicCombo/MagicCombo.ino b/examples/Keystrokes/MagicCombo/MagicCombo.ino index 0bb6606b..7b1ed943 100644 --- a/examples/Keystrokes/MagicCombo/MagicCombo.ino +++ b/examples/Keystrokes/MagicCombo/MagicCombo.ino @@ -29,7 +29,7 @@ void kindOfMagic(uint8_t combo_index) { USE_MAGIC_COMBOS([KIND_OF_MAGIC] = {.action = kindOfMagic, .keys = {R3C6, R3C9}}); -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -49,7 +49,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(MagicCombo, Macros); diff --git a/examples/Keystrokes/OneShot/OneShot.ino b/examples/Keystrokes/OneShot/OneShot.ino index 96a249ca..4cff49a0 100644 --- a/examples/Keystrokes/OneShot/OneShot.ino +++ b/examples/Keystrokes/OneShot/OneShot.ino @@ -24,7 +24,7 @@ enum { TOGGLE_ONESHOT, }; -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -62,7 +62,7 @@ KEYMAPS( ___, ___, ___, ___, ___), ) -// *INDENT-ON* +// clang-format on void macroToggleOneShot() { OneShot.toggleAutoOneShot(); diff --git a/examples/Keystrokes/OneShotMetaKeys/OneShotMetaKeys.ino b/examples/Keystrokes/OneShotMetaKeys/OneShotMetaKeys.ino index 1a155c4a..389ba845 100644 --- a/examples/Keystrokes/OneShotMetaKeys/OneShotMetaKeys.ino +++ b/examples/Keystrokes/OneShotMetaKeys/OneShotMetaKeys.ino @@ -25,7 +25,7 @@ enum { TOGGLE_ONESHOT, }; -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -63,7 +63,7 @@ KEYMAPS( ___, ___, ___, ___, ___), ) -// *INDENT-ON* +// clang-format on void macroToggleOneShot() { OneShot.toggleAutoOneShot(); diff --git a/examples/Keystrokes/Qukeys/Qukeys.ino b/examples/Keystrokes/Qukeys/Qukeys.ino index bee8538e..c1fe890f 100644 --- a/examples/Keystrokes/Qukeys/Qukeys.ino +++ b/examples/Keystrokes/Qukeys/Qukeys.ino @@ -11,7 +11,7 @@ enum { MACRO_TOGGLE_QUKEYS }; // for the home row on the right side of the keymap (and one of the palm keys) // below. -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -51,7 +51,7 @@ KEYMAPS( ___ ), ) -// *INDENT-ON* +// clang-format on // Defining a macro (on the "any" key: see above) to toggle Qukeys on and off const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { diff --git a/examples/Keystrokes/Redial/Redial.ino b/examples/Keystrokes/Redial/Redial.ino index ebc7bdf4..e9bb976f 100644 --- a/examples/Keystrokes/Redial/Redial.ino +++ b/examples/Keystrokes/Redial/Redial.ino @@ -25,7 +25,7 @@ bool kaleidoscope::plugin::Redial::shouldRemember(Key mapped_key) { return false; } -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -45,7 +45,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_Redial), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(Redial); diff --git a/examples/Keystrokes/ShapeShifter/ShapeShifter.ino b/examples/Keystrokes/ShapeShifter/ShapeShifter.ino index 372bcae0..8572e698 100644 --- a/examples/Keystrokes/ShapeShifter/ShapeShifter.ino +++ b/examples/Keystrokes/ShapeShifter/ShapeShifter.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on static const kaleidoscope::plugin::ShapeShifter::dictionary_t shape_shift_dictionary[] PROGMEM = { {Key_1, Key_2}, diff --git a/examples/Keystrokes/SpaceCadet/SpaceCadet.ino b/examples/Keystrokes/SpaceCadet/SpaceCadet.ino index 11ff205a..c9b983ca 100644 --- a/examples/Keystrokes/SpaceCadet/SpaceCadet.ino +++ b/examples/Keystrokes/SpaceCadet/SpaceCadet.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(SpaceCadet); @@ -49,14 +49,14 @@ void setup() { //Setting is {KeyThatWasPressed, AlternativeKeyToSend, TimeoutInMS} //Note: must end with the SPACECADET_MAP_END delimiter static kaleidoscope::plugin::SpaceCadet::KeyBinding spacecadetmap[] = { - {Key_LeftShift, Key_LeftParen, 250} - , {Key_RightShift, Key_RightParen, 250} - , {Key_LeftGui, Key_LeftCurlyBracket, 250} - , {Key_RightAlt, Key_RightCurlyBracket, 250} - , {Key_LeftAlt, Key_RightCurlyBracket, 250} - , {Key_LeftControl, Key_LeftBracket, 250} - , {Key_RightControl, Key_RightBracket, 250} - , SPACECADET_MAP_END + {Key_LeftShift, Key_LeftParen, 250}, + {Key_RightShift, Key_RightParen, 250}, + {Key_LeftGui, Key_LeftCurlyBracket, 250}, + {Key_RightAlt, Key_RightCurlyBracket, 250}, + {Key_LeftAlt, Key_RightCurlyBracket, 250}, + {Key_LeftControl, Key_LeftBracket, 250}, + {Key_RightControl, Key_RightBracket, 250}, + SPACECADET_MAP_END, }; //Set the map. SpaceCadet.map = spacecadetmap; diff --git a/examples/Keystrokes/Syster/Syster.ino b/examples/Keystrokes/Syster/Syster.ino index ba82a04b..387dacf6 100644 --- a/examples/Keystrokes/Syster/Syster.ino +++ b/examples/Keystrokes/Syster/Syster.ino @@ -21,7 +21,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -41,7 +41,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, SYSTER), ) -// *INDENT-ON* +// clang-format on void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *symbol) { switch (action) { diff --git a/examples/Keystrokes/TapDance/TapDance.ino b/examples/Keystrokes/TapDance/TapDance.ino index 1e14eb94..5d282924 100644 --- a/examples/Keystrokes/TapDance/TapDance.ino +++ b/examples/Keystrokes/TapDance/TapDance.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, TD(1)), ) -// *INDENT-ON* +// clang-format on static void tapDanceEsc(uint8_t tap_dance_index, uint8_t tap_count, kaleidoscope::plugin::TapDance::ActionType tap_dance_action) { tapDanceActionKeys(tap_count, tap_dance_action, Key_Escape, Key_Tab); diff --git a/examples/Keystrokes/TopsyTurvy/TopsyTurvy.ino b/examples/Keystrokes/TopsyTurvy/TopsyTurvy.ino index e01babb9..dd705364 100644 --- a/examples/Keystrokes/TopsyTurvy/TopsyTurvy.ino +++ b/examples/Keystrokes/TopsyTurvy/TopsyTurvy.ino @@ -18,7 +18,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(TopsyTurvy); diff --git a/examples/Keystrokes/Turbo/Turbo.ino b/examples/Keystrokes/Turbo/Turbo.ino index 5827c5b1..892a4c90 100644 --- a/examples/Keystrokes/Turbo/Turbo.ino +++ b/examples/Keystrokes/Turbo/Turbo.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, @@ -38,7 +38,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, Turbo); diff --git a/examples/Keystrokes/Unicode/Unicode.ino b/examples/Keystrokes/Unicode/Unicode.ino index 34c00e7c..22a2503a 100644 --- a/examples/Keystrokes/Unicode/Unicode.ino +++ b/examples/Keystrokes/Unicode/Unicode.ino @@ -23,7 +23,7 @@ enum { MACRO_KEYBOARD_EMOJI }; -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED @@ -44,7 +44,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on static void unicode(uint32_t character, uint8_t keyState) { if (keyToggledOn(keyState)) { diff --git a/examples/Keystrokes/WinKeyToggle/WinKeyToggle.ino b/examples/Keystrokes/WinKeyToggle/WinKeyToggle.ino index b75fdf01..c4a69b9b 100644 --- a/examples/Keystrokes/WinKeyToggle/WinKeyToggle.ino +++ b/examples/Keystrokes/WinKeyToggle/WinKeyToggle.ino @@ -28,11 +28,10 @@ void toggleWinKey(uint8_t index) { } USE_MAGIC_COMBOS([WINKEYTOGGLE] = { - .action = toggleWinKey, - .keys = {R3C6, R3C9} -}); + .action = toggleWinKey, + .keys = {R3C6, R3C9}}); -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -52,7 +51,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(MagicCombo, WinKeyToggle); diff --git a/examples/LEDs/Colormap/Colormap.ino b/examples/LEDs/Colormap/Colormap.ino index f26d6054..4699b093 100644 --- a/examples/LEDs/Colormap/Colormap.ino +++ b/examples/LEDs/Colormap/Colormap.ino @@ -22,7 +22,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, @@ -42,7 +42,7 @@ KEYMAPS( Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, LEDPaletteTheme, diff --git a/examples/LEDs/FingerPainter/FingerPainter.ino b/examples/LEDs/FingerPainter/FingerPainter.ino index da0b58fc..1894a4f5 100644 --- a/examples/LEDs/FingerPainter/FingerPainter.ino +++ b/examples/LEDs/FingerPainter/FingerPainter.ino @@ -22,7 +22,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, @@ -41,7 +41,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, LEDOff, diff --git a/examples/LEDs/Heatmap/Heatmap.ino b/examples/LEDs/Heatmap/Heatmap.ino index 49ee4855..30cc6978 100644 --- a/examples/LEDs/Heatmap/Heatmap.ino +++ b/examples/LEDs/Heatmap/Heatmap.ino @@ -20,7 +20,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED (Key_LEDEffectNext, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext, @@ -39,7 +39,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, HeatmapEffect); diff --git a/examples/LEDs/IdleLEDs/IdleLEDs.ino b/examples/LEDs/IdleLEDs/IdleLEDs.ino index 44732f37..55018e51 100644 --- a/examples/LEDs/IdleLEDs/IdleLEDs.ino +++ b/examples/LEDs/IdleLEDs/IdleLEDs.ino @@ -22,7 +22,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -42,7 +42,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, EEPROMSettings, @@ -56,7 +56,7 @@ void setup() { Kaleidoscope.setup(); - PersistentIdleLEDs.setIdleTimeoutSeconds(300); // 5 minutes + PersistentIdleLEDs.setIdleTimeoutSeconds(300); // 5 minutes LEDRainbowWaveEffect.activate(); } diff --git a/examples/LEDs/LED-ActiveLayerColor/LED-ActiveLayerColor.ino b/examples/LEDs/LED-ActiveLayerColor/LED-ActiveLayerColor.ino index 714a9902..fcd36c5e 100644 --- a/examples/LEDs/LED-ActiveLayerColor/LED-ActiveLayerColor.ino +++ b/examples/LEDs/LED-ActiveLayerColor/LED-ActiveLayerColor.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -58,7 +58,7 @@ KEYMAPS( ShiftToLayer(0) ) ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, LEDActiveLayerColorEffect); @@ -66,8 +66,7 @@ KALEIDOSCOPE_INIT_PLUGINS(LEDControl, void setup() { static const cRGB layerColormap[] PROGMEM = { CRGB(128, 0, 0), - CRGB(0, 128, 0) - }; + CRGB(0, 128, 0)}; Kaleidoscope.setup(); LEDActiveLayerColorEffect.setColormap(layerColormap); diff --git a/examples/LEDs/LED-ActiveModColor/LED-ActiveModColor.ino b/examples/LEDs/LED-ActiveModColor/LED-ActiveModColor.ino index 6213dd36..b1b86767 100644 --- a/examples/LEDs/LED-ActiveModColor/LED-ActiveModColor.ino +++ b/examples/LEDs/LED-ActiveModColor/LED-ActiveModColor.ino @@ -20,7 +20,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -40,7 +40,7 @@ KEYMAPS( OSM(RightShift), OSM(RightAlt), Key_Spacebar, OSM(RightControl), Key_skip), ) -// *INDENT-ON* +// clang-format on // OneShot is included to illustrate the different colors highlighting sticky // and one-shot keys. LEDOff is included because we need an LED mode active to diff --git a/examples/LEDs/LED-AlphaSquare/LED-AlphaSquare.ino b/examples/LEDs/LED-AlphaSquare/LED-AlphaSquare.ino index f3ef2d7a..2a46ba8e 100644 --- a/examples/LEDs/LED-AlphaSquare/LED-AlphaSquare.ino +++ b/examples/LEDs/LED-AlphaSquare/LED-AlphaSquare.ino @@ -20,7 +20,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -40,7 +40,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_skip), ) -// *INDENT-ON* +// clang-format on const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { if (!keyToggledOn(event.state)) @@ -57,12 +57,12 @@ const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { col = 10; for (uint8_t step = 0; step <= 0xf0; step += 8) { - AlphaSquare.color = { step, step, step }; + AlphaSquare.color = {step, step, step}; AlphaSquare.display({i, 0}, col); delay(10); } for (uint8_t step = 0xff; step >= 8; step -= 8) { - AlphaSquare.color = { step, step, step }; + AlphaSquare.color = {step, step, step}; AlphaSquare.display({i, 0}, col); delay(10); } @@ -74,14 +74,14 @@ const macro_t *macroAction(uint8_t macro_id, KeyEvent &event) { delay(100); for (uint8_t step = 0; step <= 0xf0; step += 8) { - AlphaSquare.color = { step, step, step }; + AlphaSquare.color = {step, step, step}; AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 2); AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 10); delay(10); } for (uint8_t step = 0xff; step >= 8; step -= 8) { - AlphaSquare.color = { step, step, step }; + AlphaSquare.color = {step, step, step}; AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 2); AlphaSquare.display(kaleidoscope::plugin::alpha_square::symbols::Lambda, 10); delay(10); @@ -102,7 +102,7 @@ KALEIDOSCOPE_INIT_PLUGINS(LEDControl, void setup() { Kaleidoscope.setup(); - AlphaSquare.color = { 0xcb, 0xc0, 0xff }; + AlphaSquare.color = {0xcb, 0xc0, 0xff}; } void loop() { diff --git a/examples/LEDs/LED-Brightness/LED-Brightness.ino b/examples/LEDs/LED-Brightness/LED-Brightness.ino index b17a354d..574e1205 100644 --- a/examples/LEDs/LED-Brightness/LED-Brightness.ino +++ b/examples/LEDs/LED-Brightness/LED-Brightness.ino @@ -20,7 +20,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -40,7 +40,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, M(1)), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, Macros, diff --git a/examples/LEDs/LED-Palette-Theme/LED-Palette-Theme.ino b/examples/LEDs/LED-Palette-Theme/LED-Palette-Theme.ino index e587ef3b..25e0e2ea 100644 --- a/examples/LEDs/LED-Palette-Theme/LED-Palette-Theme.ino +++ b/examples/LEDs/LED-Palette-Theme/LED-Palette-Theme.ino @@ -39,13 +39,11 @@ class TestLEDMode : public kaleidoscope::plugin::LEDMode { uint16_t TestLEDMode::map_base_; -void -TestLEDMode::setup() { +void TestLEDMode::setup() { map_base_ = LEDPaletteTheme.reserveThemes(1); } -void -TestLEDMode::update(void) { +void TestLEDMode::update(void) { LEDPaletteTheme.updateHandler(map_base_, 0); } @@ -54,11 +52,11 @@ TestLEDMode::onFocusEvent(const char *command) { return LEDPaletteTheme.themeFocusEvent(command, PSTR("testLedMode.map"), map_base_, 1); } -} +} // namespace example example::TestLEDMode TestLEDMode; -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -78,7 +76,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(Focus, LEDPaletteTheme, TestLEDMode, EEPROMSettings); diff --git a/examples/LEDs/LED-Stalker/LED-Stalker.ino b/examples/LEDs/LED-Stalker/LED-Stalker.ino index 9306513a..cf66f19c 100644 --- a/examples/LEDs/LED-Stalker/LED-Stalker.ino +++ b/examples/LEDs/LED-Stalker/LED-Stalker.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -39,7 +39,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, LEDOff, diff --git a/examples/LEDs/LED-Wavepool/LED-Wavepool.ino b/examples/LEDs/LED-Wavepool/LED-Wavepool.ino index 404eb295..3cd8486e 100644 --- a/examples/LEDs/LED-Wavepool/LED-Wavepool.ino +++ b/examples/LEDs/LED-Wavepool/LED-Wavepool.ino @@ -20,6 +20,7 @@ #include #include +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -46,12 +47,13 @@ KALEIDOSCOPE_INIT_PLUGINS( LEDOff, WavepoolEffect ); +// clang-format on void setup() { Kaleidoscope.setup(); WavepoolEffect.idle_timeout = 5000; // 5 seconds - WavepoolEffect.ripple_hue = WavepoolEffect.rainbow_hue; + WavepoolEffect.ripple_hue = WavepoolEffect.rainbow_hue; WavepoolEffect.activate(); } diff --git a/examples/LEDs/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino b/examples/LEDs/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino index c17fd55a..de152232 100644 --- a/examples/LEDs/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino +++ b/examples/LEDs/LEDEffect-BootGreeting/LEDEffect-BootGreeting.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -39,7 +39,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, BootGreetingEffect, diff --git a/examples/LEDs/LEDEffects/LEDEffects.ino b/examples/LEDs/LEDEffects/LEDEffects.ino index 02d79b15..6f5ad6c5 100644 --- a/examples/LEDs/LEDEffects/LEDEffects.ino +++ b/examples/LEDs/LEDEffects/LEDEffects.ino @@ -19,7 +19,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -39,7 +39,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, LEDOff, diff --git a/examples/LEDs/PersistentLEDMode/PersistentLEDMode.ino b/examples/LEDs/PersistentLEDMode/PersistentLEDMode.ino index b262047d..4d5fca73 100644 --- a/examples/LEDs/PersistentLEDMode/PersistentLEDMode.ino +++ b/examples/LEDs/PersistentLEDMode/PersistentLEDMode.ino @@ -24,7 +24,7 @@ #include #include -// *INDENT-OFF* +// clang-format off KEYMAPS( [0] = KEYMAP_STACKED ( @@ -44,7 +44,7 @@ KEYMAPS( Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_NoKey), ) -// *INDENT-ON* +// clang-format on KALEIDOSCOPE_INIT_PLUGINS(LEDControl, EEPROMSettings,