├── .clang-format ├── LICENSE ├── logos-format.py └── README.md /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Chromium 2 | Language: ObjC 3 | IndentWidth: 4 4 | TabWidth: 4 5 | UseTab: Never 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Hearse 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /logos-format.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | from subprocess import Popen, PIPE, STDOUT 4 | 5 | # block level 6 | # hook -> replace with @logosformathook with ; at the end 7 | # end -> replace with @logosformatend with ; at the end 8 | # property -> replace with @logosformatproperty with NO ; at the end. Special case for block level 9 | # new -> replce with @logosformatnew with ; at the end 10 | # group -> replace with @logosformatgroup with ; at the end 11 | # subclass -> replace with @logosformatsubclass with ; at the end 12 | # top level 13 | # config -> replace with @logosformatconfig 14 | # hookf -> replace with @logosformathookf 15 | # ctor -> replace with @logosformatctor 16 | # dtor -> replace with @logosformatdtor 17 | 18 | # function level 19 | # init -> replace with @logosformatinit 20 | # c -> replace with @logosformatc 21 | # orig -> replace with @logosformatorig 22 | # log -> replace with @logosformatlog 23 | 24 | specialFilterList = ["%hook", "%end", "%new", "%group", "%subclass"] 25 | filterList = [ 26 | "%property", 27 | "%config", 28 | "%hookf", 29 | "%ctor", 30 | "%dtor", 31 | "%init", 32 | "%c", 33 | "%orig", 34 | "%log", 35 | ] 36 | 37 | 38 | fileContentsList = sys.stdin.read().splitlines() 39 | newList = [] 40 | 41 | for line in fileContentsList: 42 | for token in filterList: 43 | if token in line: 44 | line = re.sub(rf"%({token[1:]})\b", r"@logosformat\1", line) 45 | for token in specialFilterList: 46 | if token in line: 47 | line = re.sub(rf"%({token[1:]})\b", r"@logosformat\1", line) + ";" 48 | newList.append(line) 49 | 50 | command = ["clang-format"] + sys.argv[1:] 51 | process = Popen(command, stdout=PIPE, stderr=None, stdin=PIPE) 52 | stdoutData = process.communicate(input="\n".join(newList).encode())[0] 53 | refinedList = stdoutData.decode().splitlines() 54 | 55 | 56 | for line in refinedList: 57 | if "@logosformat" in line: 58 | fix = line.replace("@logosformat", "%") 59 | if any(token in fix for token in specialFilterList): 60 | print(fix.replace(";","")) 61 | else: 62 | print(fix) 63 | else: 64 | print(line) 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # logos-format 2 |
logos-format is a project that allows for logos to be formatted with the help of clang-format
3 | 4 | Before: 5 | 6 |  7 | 8 | 9 | After(BasedOnStyle: Chromium): 10 | 11 |  12 | 13 | 14 | 15 |