From 9a6c1b52ec250a2668c5ab76fc94b2777daded95 Mon Sep 17 00:00:00 2001 From: yc S Date: Mon, 30 Sep 2024 15:28:20 +0800 Subject: [PATCH] Initial --- .clang-format | 184 +++++++++++++++++++++++++++++++++++++++++++++++++ .clangd | 2 + .gitignore | 3 + CMakeLists.txt | 19 +++++ core.h | 2 + main.cpp | 29 ++++++++ 6 files changed, 239 insertions(+) create mode 100644 .clang-format create mode 100644 .clangd create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 core.h create mode 100644 main.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..daaa1e9 --- /dev/null +++ b/.clang-format @@ -0,0 +1,184 @@ + +BasedOnStyle: llvm +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +# https://www.cnblogs.com/PaulpauL/p/5929753.html + +# Comments Macros: +# WIN = Whatever. If Needed, you can change it as you like. +# WSO = Whatever. If needed, you can change, but keep same in One code block. +# BTW = Better This but you can change as you like, Whatever. +# +# 在标识后紧跟默认值,再后跟所有可能取值 + +Language: Cpp +DisableFormat: false # WIN false, true 如果为true,不应用整理 + +AccessModifierOffset: -4 # or 0 public, private, protected的缩进 +AlignAfterOpenBracket: false +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false # WIN false, true + AcrossEmptyLines: true # WIN true, false 跨过空行一并对齐 + AcrossComments: true # WIN true, false 跨过注释一并对齐 + AlignCompound: false # WIN false, true += -=诸如此类运算符是否对齐 + AlignFunctionPointers: true # WIN true, false 函数指针变量是否对齐 + PadOperators: false # WIN false, true <<= >>= +AlignConsecutiveBitFields: + Enabled: false # WIN false, true + AcrossEmptyLines: true # WIN true, false 跨过空行一并对齐 + AcrossComments: true # WIN true, false 跨过注释一并对齐 +AlignConsecutiveDeclarations: + Enabled: false # WIN false, true + AcrossEmptyLines: true # WIN true, false 跨过空行一并对齐 + AcrossComments: true # WIN true, false 跨过注释一并对齐 +AlignConsecutiveMacros: false # WIN false, true +AlignConsecutiveShortCaseStatements: + Enabled: false # WIN false, true + AcrossEmptyLines: true # WIN true, false 跨过空行一并对齐 + AcrossComments: true # WIN true, false 跨过注释一并对齐 + AlignCaseColons: false # WIN false, true 是否对齐case VAL冒号 +AlignEscapedNewlines: DontAlign # WIN false, true 是否对齐反斜杠\ +AlignOperands: DontAlign +AlignTrailingComments: + Kind: Leave # BTW: Leave, Always|Never + OverEmptyLines: 1 # BTW: 1, 最多跨过多少行一并对对齐 +AllowAllArgumentsOnNextLine: true # 如果false,强制把函数参数每个换行 +AllowAllParametersOfDeclarationOnNextLine: true # 如果false,强制把函数形参每个换行 +AllowBreakBeforeNoexceptSpecifier: Always # 是否允许复合noexcept换行 Never|OnlyWithParen +AllowShortBlocksOnASingleLine: Always # WIN Always, Empty|Never +AllowShortCaseLabelsOnASingleLine: true # WIN true, false +AllowShortCompoundRequirementOnASingleLine: true # BTW true, false +AllowShortEnumsOnASingleLine: true # WIN true, false +AllowShortFunctionsOnASingleLine: All # WIN All, None|InlineOnly|Empty|Inline +AllowShortIfStatementsOnASingleLine: AllIfsAndElse # WIN AllIfsAndElse, Never|WithoutElse|OnlyFirstIf +AllowShortLambdasOnASingleLine: All # BTW All, None|Empty|Inline +AllowShortLoopsOnASingleLine: true # WIN true, false +AlwaysBreakBeforeMultilineStrings: false # WIN false, true +AttributeMacros: [ + '__capability', + '__output', + '__unused' +] # WIN, i dont know what this is. +BinPackArguments: true # WIN true, false +BinPackParameters: true # WIN true, false +BraceWrapping: + # WIN false, true + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never # WIN Never, MultiLine|Always + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false # Objective-C用,Cpp应该不用 + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + # WIN true, false + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false # BTW false, true + BeforeWhile: true + # BTW false, true + IndentBraces: false # 仅当花括号换行时有效 + SplitEmptyFunction: false # 如果为true,空函数右花括号}强制换行 + SplitEmptyRecord: false # 如果为true,空类型class union union...右花括号}强制换行 + SplitEmptyNamespace: false # 如果为true,空namespace右花括号}强制换行 +BracedInitializerIndentWidth: 4 # 如果该项不存在,则使用ContinuationIndentWidth +BreakAdjacentStringLiterals: false # WIN false, true 是否给连续字面char[]""换行 +BreakAfterAttributes: Leave # WIN Leave, Always|Never 是否对[[]]后换行,尽可能不换行 +BreakAfterJavaFieldAnnotations: false +# BreakArrays: true 似乎非C++ +BreakBeforeBinaryOperators: All # BTW All, None|NonAssignment +# BTW Attach, +# Linux Break function, namespace, class +# |Mozilla Break enum, function, class, struct, union +# |Stroustrup Break function, catch, else(?) +# |Allman Break all +# |Whitesmiths Break and indent all +# |GNU Break all, extra indent control statements +# |WebKit Break function +# |Custom 根据BraceWrapping指定行为 +BreakBeforeBraces: Attach +BreakBeforeInlineASMColon: Never # WIN Never, OnlyMultiline|Always +BreakBeforeTernaryOperators: true # 如果为true,三元运算符需要换行时将运算符置于下一行开头而非上一行末尾 +# WIN AfterColon, 将冒号和逗号至于上一行行尾 +# BeforeColon 将冒号置于下一行开头,逗号置于上一行行尾 +# |BeforeComma 将冒号、逗号都置于下一行开头 +BreakConstructorInitializers: AfterColon +# BreakFunctionDefinitionParameters: false # 如果true,函数定义中的形参永远换行,好像不能用 +# WIN AfterColon, 将冒号和逗号至于上一行行尾 +# BeforeColon 将冒号置于下一行开头,逗号置于上一行行尾 +# |BeforeComma 将冒号、逗号都置于下一行开头 +# |AfterComma 第一行的冒号不换行,只在所有的逗号后面换行 +BreakInheritanceList: AfterColon +BreakStringLiterals: false # WIN false, true 如果为true,过长的字符串会被换行 +# BreakTemplateDeclarations: No # WIN No, Leave|MultiLine|Yes,好像不能用 +AlwaysBreakTemplateDeclarations: false +ColumnLimit: 0 # BTW 0 设置代码宽度,0为忽略。应该会用于判断是否要换行 +# 如果为true,可以在文件头标注 // CommentPragmas: '^ FOOBAR pragma:' +# 那么以后的诸如// FOOBAR pragma: 开头的注释不会被换行 +CommentPragmas: true +CompactNamespaces: false # BTW false, true 如果为true,连续的namespace声明会被放在同一行里,除非太长 +# 构造函数参数列表和继承列表的缩进 +ConstructorInitializerIndentWidth: 4 # 4 or 2,尽量与IndentWidth一致 +ContinuationIndentWidth: 4 # 4 or 2,尽量与IndentWidth一致 +Cpp11BracedListStyle: false # 如果为false,花括号里有东西的时候,会在左花括号右侧、右花括号左侧插入空格 +# BTW false, true +# 如果为true,会检查文件里最常出现的一种&和*的安排方式,然后统一; +# PointerAlignment指定的选项时备选 +DerivePointerAlignment: false +# WIN Leave, public protected private后是否要插入空行 +# Never|Always +# |(仅*After*)LogicalBlock 如果没有指定任何东西的访问权限,那么就不插入空行 +# 根据代码复杂度决定是否要留空行。可以不固定 +EmptyLineAfterAccessModifier: Leave +EmptyLineBeforeAccessModifier: Leave +# WIN false, true +# 在namespace的右花括号后加入注释。 +# 如果namespace短于ShortNamespaceLines规定的值,就不添加 +# 根据需要 +FixNamespaceComments: false +# BTW Preserve, 中间没有空行的include一起整理 +# Merge 无视空行,全部一起整理 +# |Regroup 按照<>和""重新分组整理 +IncludeBlocks: Preserve + + + + + +IndentCaseLabels: true +IndentExternBlock: Indent +IndentWidth: 4 +InsertNewlineAtEOF: true +KeepEmptyLinesAtEOF: true +LineEnding: CRLF +NamespaceIndentation: All # WIN +PackConstructorInitializers: NextLine +PenaltyBreakTemplateDeclaration: 4294967295 +PointerAlignment: Left +ReferenceAlignment: Left +ReflowComments: false +RemoveSemicolon: true # WIN +RequiresClausePosition: SingleLine +SeparateDefinitionBlocks: Always +SortIncludes: Never # BTW: Never,有时候includes必须要按照一定的顺序。 +SortUsingDeclarations: Lexicographic +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: false # WSO +SpaceAroundPointerQualifiers: Before # WSO +SpacesBeforeTrailingComments: 0 # Better 1; 0 ok, 2+ better not. +Standard: Latest +TabWidth: 4 # 4 or 2, WSO +# UseTab possible values: +# Never +# ForIndentation +# ForContinuationAndIndentation +# AlignWithSpaces +# Always +# 如果使用Tab缩进对齐,整理原理是: +# 使用Tab符替换空格,缩进一定是4,每TabWidth个空格替换为一个Tab。 +# 也就是说,如果TabWidth是2,那么每次缩进会使用2个Tab。 +# 使用Tab时,请一定把TabWidth设为4。 +UseTab: Always # WIN + diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..d7e6d48 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-DUNICODE, -D_UNICODE, -DCINTERFACE, -D__CARLBEKS_CMAKE_VSCODE__s] \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b33b9db --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/build +/out +/CMakePresets.json \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fe1a7f2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.5.0) +project(HighBloodPressure VERSION 0.1.0 LANGUAGES C CXX) + +#add_definitions(-DUNICODE) +#add_definitions(-D_UNICODE) +#add_definitions(-DCINTERFACE) +#add_definitions(-D__CARLBEKS_CMAKE_VSCODE__) +add_compile_definitions(DUNICODE) +add_compile_definitions(_UNICODE) +add_compile_definitions(CINTERFACE) +add_compile_definitions(__CARLBEKS_CMAKE_VSCODE__) +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_WIN32_EXECUTABLE true) + +include(CTest) +enable_testing() + +add_executable(HighBloodPressure main.cpp) +include(CPack) diff --git a/core.h b/core.h new file mode 100644 index 0000000..7813db6 --- /dev/null +++ b/core.h @@ -0,0 +1,2 @@ +#include "../CarlbeksLib/gxdef.h" + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..b348114 --- /dev/null +++ b/main.cpp @@ -0,0 +1,29 @@ +#include +#include + +#include "../CarlbeksLib/gxdef.h" + +__stdcall int wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { + // create window + WNDCLASSEX wc = { 0 }; + wc.cbSize = sizeof(WNDCLASSEX); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = DefWindowProc; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); + wc.lpszClassName = L"HighBloodPressure"; + RegisterClassEx(&wc); + + HWND hwnd = CreateWindowEx(0, L"HighBloodPressure", L"High Blood Pressure", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL); + ShowWindow(hwnd, nCmdShow); + + MSG msg = { 0 }; + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + return (int) msg.wParam; +}