├── .clang-format ├── .github └── workflows │ ├── clean_workflow.yml │ ├── farcolorer-ci.yml │ ├── farcolorer-release.yml │ └── prebuild.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CMakePresets.json ├── LICENSE ├── README.md ├── ci └── clean_packages │ ├── main.py │ └── requirements.txt ├── docs ├── enc │ ├── base.html │ ├── colorer.hhc │ ├── colorer.hhp │ ├── img │ │ ├── back_color.PNG │ │ ├── first_run.png │ │ ├── install_dir.png │ │ ├── logo-colorer.png │ │ ├── schemes_settings.PNG │ │ ├── settings.png │ │ └── truemod.PNG │ ├── index.html │ ├── install.html │ ├── modes.html │ ├── scheme_params.html │ ├── settings.html │ ├── shemes_settings.html │ ├── structure.html │ └── styles.css └── history.ru.txt ├── external └── far3sdk │ ├── DlgBuilder.hpp │ ├── farcolor.hpp │ ├── plugin.hpp │ ├── vc_crt_fix.asm │ ├── vc_crt_fix_impl.cpp │ └── yy_thunks_impl.h ├── misc ├── Plugin.Colorer.lua ├── colorere.hlf ├── colorere.lng ├── colorerpol.hlf ├── colorerpol.lng ├── colorerr.hlf ├── colorerr.lng └── hrcsettings.xml ├── scripts └── nmake_build.cmd ├── src ├── CMakeLists.txt ├── ChooseTypeMenu.cpp ├── ChooseTypeMenu.h ├── FarEditor.cpp ├── FarEditor.h ├── FarEditorSet.cpp ├── FarEditorSet.h ├── FarHrcSettings.cpp ├── FarHrcSettings.h ├── HrcSettingsForm.cpp ├── HrcSettingsForm.h ├── SettingsControl.cpp ├── SettingsControl.h ├── SimpleLogger.h ├── const_strings.h ├── pcolorer.cpp ├── pcolorer.h ├── pcolorer3.def ├── pcolorer3.rc ├── tools.cpp ├── tools.h └── version.h ├── vcpkg └── manifest │ ├── full │ ├── vcpkg-configuration.json │ └── vcpkg.json │ └── legacy │ ├── vcpkg-configuration.json │ └── vcpkg.json └── version4far.txt /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: Google 4 | AccessModifierOffset: -1 5 | AlignAfterOpenBracket: Align 6 | AlignArrayOfStructures: Right 7 | AlignConsecutiveMacros: None 8 | AlignConsecutiveAssignments: None 9 | AlignConsecutiveBitFields: None 10 | AlignConsecutiveDeclarations: None 11 | AlignEscapedNewlines: Left 12 | AlignOperands: DontAlign 13 | AlignTrailingComments: true 14 | AllowAllArgumentsOnNextLine: true 15 | AllowAllConstructorInitializersOnNextLine: true 16 | AllowAllParametersOfDeclarationOnNextLine: true 17 | AllowShortEnumsOnASingleLine: true 18 | AllowShortBlocksOnASingleLine: Never 19 | AllowShortCaseLabelsOnASingleLine: false 20 | AllowShortFunctionsOnASingleLine: Inline 21 | AllowShortLambdasOnASingleLine: All 22 | AllowShortIfStatementsOnASingleLine: Never 23 | AllowShortLoopsOnASingleLine: true 24 | AlwaysBreakAfterDefinitionReturnType: None 25 | AlwaysBreakAfterReturnType: None 26 | AlwaysBreakBeforeMultilineStrings: true 27 | AlwaysBreakTemplateDeclarations: Yes 28 | AttributeMacros: 29 | - __capability 30 | BinPackArguments: true 31 | BinPackParameters: true 32 | BraceWrapping: 33 | AfterCaseLabel: false 34 | AfterClass: true 35 | AfterControlStatement: MultiLine 36 | AfterEnum: false 37 | AfterFunction: true 38 | AfterNamespace: false 39 | AfterObjCDeclaration: false 40 | AfterStruct: true 41 | AfterUnion: false 42 | AfterExternBlock: false 43 | BeforeCatch: false 44 | BeforeElse: true 45 | BeforeLambdaBody: false 46 | BeforeWhile: false 47 | IndentBraces: false 48 | SplitEmptyFunction: true 49 | SplitEmptyRecord: true 50 | SplitEmptyNamespace: true 51 | BreakAfterAttributes: Always 52 | BreakBeforeBinaryOperators: None 53 | BreakBeforeConceptDeclarations: true 54 | BreakBeforeBraces: Custom 55 | BreakBeforeInheritanceComma: false 56 | BreakInheritanceList: BeforeColon 57 | BreakBeforeTernaryOperators: true 58 | BreakConstructorInitializersBeforeComma: false 59 | BreakConstructorInitializers: BeforeColon 60 | BreakAfterJavaFieldAnnotations: false 61 | BreakStringLiterals: true 62 | ColumnLimit: 120 63 | CommentPragmas: '^ IWYU pragma:' 64 | CompactNamespaces: false 65 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 66 | ConstructorInitializerIndentWidth: 4 67 | ContinuationIndentWidth: 4 68 | Cpp11BracedListStyle: true 69 | DeriveLineEnding: true 70 | DerivePointerAlignment: false 71 | DisableFormat: false 72 | EmptyLineAfterAccessModifier: Never 73 | EmptyLineBeforeAccessModifier: LogicalBlock 74 | ExperimentalAutoDetectBinPacking: false 75 | FixNamespaceComments: true 76 | ForEachMacros: 77 | - foreach 78 | - Q_FOREACH 79 | - BOOST_FOREACH 80 | IfMacros: 81 | - KJ_IF_MAYBE 82 | IncludeBlocks: Merge 83 | IncludeCategories: 84 | - Regex: '^' 85 | Priority: 2 86 | SortPriority: 0 87 | CaseSensitive: false 88 | - Regex: '^<.*\.h>' 89 | Priority: 1 90 | SortPriority: 0 91 | CaseSensitive: false 92 | - Regex: '^<.*' 93 | Priority: 2 94 | SortPriority: 0 95 | CaseSensitive: false 96 | - Regex: '.*' 97 | Priority: 3 98 | SortPriority: 0 99 | CaseSensitive: false 100 | IncludeIsMainRegex: '([-_](test|unittest))?$' 101 | IncludeIsMainSourceRegex: '' 102 | IndentAccessModifiers: false 103 | IndentCaseLabels: true 104 | IndentCaseBlocks: false 105 | IndentGotoLabels: true 106 | IndentPPDirectives: None 107 | IndentExternBlock: AfterExternBlock 108 | IndentWidth: 2 109 | IndentWrappedFunctionNames: false 110 | InsertTrailingCommas: None 111 | JavaScriptQuotes: Leave 112 | JavaScriptWrapImports: true 113 | KeepEmptyLinesAtTheStartOfBlocks: false 114 | LambdaBodyIndentation: Signature 115 | MacroBlockBegin: '' 116 | MacroBlockEnd: '' 117 | MaxEmptyLinesToKeep: 1 118 | NamespaceIndentation: None 119 | ObjCBinPackProtocolList: Never 120 | ObjCBlockIndentWidth: 2 121 | ObjCBreakBeforeNestedBlockParam: true 122 | ObjCSpaceAfterProperty: false 123 | ObjCSpaceBeforeProtocolList: true 124 | PenaltyBreakAssignment: 2 125 | PenaltyBreakBeforeFirstCallParameter: 1 126 | PenaltyBreakComment: 300 127 | PenaltyBreakFirstLessLess: 120 128 | PenaltyBreakString: 1000 129 | PenaltyBreakTemplateDeclaration: 10 130 | PenaltyExcessCharacter: 1000000 131 | PenaltyReturnTypeOnItsOwnLine: 200 132 | PenaltyIndentedWhitespace: 0 133 | PointerAlignment: Left 134 | PPIndentWidth: -1 135 | PackConstructorInitializers: NextLine 136 | RawStringFormats: 137 | - Language: Cpp 138 | Delimiters: 139 | - cc 140 | - CC 141 | - cpp 142 | - Cpp 143 | - CPP 144 | - 'c++' 145 | - 'C++' 146 | CanonicalDelimiter: '' 147 | BasedOnStyle: google 148 | - Language: TextProto 149 | Delimiters: 150 | - pb 151 | - PB 152 | - proto 153 | - PROTO 154 | EnclosingFunctions: 155 | - EqualsProto 156 | - EquivToProto 157 | - PARSE_PARTIAL_TEXT_PROTO 158 | - PARSE_TEST_PROTO 159 | - PARSE_TEXT_PROTO 160 | - ParseTextOrDie 161 | - ParseTextProtoOrDie 162 | - ParseTestProto 163 | - ParsePartialTestProto 164 | CanonicalDelimiter: '' 165 | BasedOnStyle: google 166 | ReferenceAlignment: Pointer 167 | ReflowComments: true 168 | ShortNamespaceLines: 1 169 | SortIncludes: CaseSensitive 170 | SortJavaStaticImport: Before 171 | SortUsingDeclarations: true 172 | SpaceAfterCStyleCast: true 173 | SpaceAfterLogicalNot: false 174 | SpaceAfterTemplateKeyword: true 175 | SpaceBeforeAssignmentOperators: true 176 | SpaceBeforeCaseColon: false 177 | SpaceBeforeCpp11BracedList: true 178 | SpaceBeforeCtorInitializerColon: true 179 | SpaceBeforeInheritanceColon: true 180 | SpaceBeforeParens: ControlStatements 181 | SpaceAroundPointerQualifiers: Default 182 | SpaceBeforeRangeBasedForLoopColon: true 183 | SpaceInEmptyBlock: false 184 | SpaceInEmptyParentheses: false 185 | SpacesBeforeTrailingComments: 2 186 | SpacesInAngles: Never 187 | SpacesInConditionalStatement: false 188 | SpacesInContainerLiterals: true 189 | SpacesInCStyleCastParentheses: false 190 | SpacesInLineCommentPrefix: 191 | Minimum: 1 192 | Maximum: -1 193 | SpacesInParentheses: false 194 | SpacesInSquareBrackets: false 195 | SpaceBeforeSquareBrackets: false 196 | BitFieldColonSpacing: Both 197 | Standard: Auto 198 | StatementAttributeLikeMacros: 199 | - Q_EMIT 200 | StatementMacros: 201 | - Q_UNUSED 202 | - QT_REQUIRE_VERSION 203 | TabWidth: 4 204 | UseCRLF: false 205 | UseTab: Never 206 | WhitespaceSensitiveMacros: 207 | - STRINGIZE 208 | - PP_STRINGIZE 209 | - BOOST_PP_STRINGIZE 210 | - NS_SWIFT_NAME 211 | - CF_SWIFT_NAME 212 | ... 213 | -------------------------------------------------------------------------------- /.github/workflows/clean_workflow.yml: -------------------------------------------------------------------------------- 1 | name: Delete old artifacts 2 | on: 3 | workflow_dispatch: 4 | schedule: 5 | - cron: '0 0 1 * *' 6 | # Run monthly, at 00:00 on the 1st day of month. 7 | 8 | jobs: 9 | clean_wf_runs: 10 | runs-on: ubuntu-latest 11 | permissions: 12 | actions: write 13 | contents: read 14 | steps: 15 | - name: Delete workflow runs 16 | uses: Mattraks/delete-workflow-runs@v2 17 | with: 18 | token: ${{ github.token }} 19 | repository: ${{ github.repository }} 20 | retain_days: 30 21 | keep_minimum_runs: 6 22 | check_pullrequest_exist: true 23 | 24 | clean_packages: 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: checkout repo content 28 | uses: actions/checkout@v4 29 | 30 | - name: setup python 31 | uses: actions/setup-python@v5 32 | 33 | - name: install python packages 34 | working-directory: ./ci/clean_packages 35 | run: | 36 | python -m pip install --upgrade pip 37 | pip install -r requirements.txt 38 | 39 | - name: execute clean script 40 | working-directory: ./ci/clean_packages 41 | env: 42 | ORG_NAME: colorer 43 | PACKAGE_MASK: ^farcolorer_.* 44 | PACKAGE_TYPE: nuget 45 | GITHUB_TOKEN: ${{ secrets.PACKAGES_GITHUB_TOKEN }} 46 | run: python main.py 47 | -------------------------------------------------------------------------------- /.github/workflows/farcolorer-ci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | branches: 7 | - master 8 | paths-ignore: 9 | - '.github/workflows/clean_workflow.yml' 10 | - '.github/workflows/prebuild.yml' 11 | - '.github/workflows/farcolorer-release.yml' 12 | - 'ci/**' 13 | - 'docs/**' 14 | - 'scripts/**' 15 | - '.clang-format' 16 | - '.gitignore' 17 | - 'CMakePresets.json' 18 | - 'LICENSE' 19 | - 'README.md' 20 | - 'version4far.txt' 21 | pull_request: 22 | branches: 23 | - master 24 | 25 | env: 26 | BUILD_TYPE: Release 27 | X_VCPKG_NUGET_ID_PREFIX: 'farcolorer' 28 | VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' 29 | 30 | jobs: 31 | build: 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | build: [ x64, x86, arm64 ] 36 | legacy: [ON, OFF] 37 | include: 38 | - { build: x64, arch: amd64, triplet: x64-win-static-rel} 39 | - { build: x86, arch: amd64_x86, triplet: x86-win-static-rel} 40 | - { build: arm64, arch: amd64_arm64, triplet: arm64-win-static-rel} 41 | 42 | runs-on: windows-2022 43 | 44 | steps: 45 | - name: Checkout source 46 | uses: actions/checkout@v4 47 | with: 48 | submodules: recursive 49 | fetch-depth: 0 50 | 51 | - name: Setup vcpkg 52 | run: | 53 | bootstrap-vcpkg.bat 54 | 55 | - name: Add C++ build tools to PATH 56 | uses: ilammy/msvc-dev-cmd@v1 57 | with: 58 | arch: ${{ matrix.arch }} 59 | 60 | - name: Setup NuGet Credentials for cache 61 | shell: bash 62 | run: > 63 | `vcpkg fetch nuget | tail -n 1` 64 | sources add 65 | -source "https://nuget.pkg.github.com/colorer/index.json" 66 | -storepasswordincleartext 67 | -name "GitHub" 68 | -username "${{ secrets.PACKAGES_GITHUB_USER }}" 69 | -password "${{ secrets.PACKAGES_GITHUB_TOKEN }}" 70 | 71 | - name: Create Build folder 72 | run: mkdir -p _build 73 | 74 | - name: Get number of CPU cores 75 | uses: SimenB/github-actions-cpu-cores@v2 76 | id: cpu-cores 77 | 78 | - name: Configure CMake 79 | shell: bash 80 | run: > 81 | cmake -S . -B _build -G "Ninja" 82 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE 83 | -DCOLORER_BUILD_ARCH=${{ matrix.build }} 84 | -DFARCOLORER_LEGACY=${{ matrix.legacy }} 85 | -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake 86 | -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} 87 | 88 | - name: Build 89 | shell: bash 90 | run: cmake --build _build --config $BUILD_TYPE -j ${{ steps.cpu-cores.outputs.count }} 91 | -------------------------------------------------------------------------------- /.github/workflows/farcolorer-release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | jobs: 9 | 10 | build-artifacts: 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | build: [ x64, x86, arm64 ] 15 | legacy: [ON, OFF] 16 | include: 17 | - { build: x64, arch: amd64, triplet: x64-win-static-rel} 18 | - { build: x86, arch: amd64_x86, triplet: x86-win-static-rel} 19 | - { build: arm64, arch: amd64_arm64, triplet: arm64-win-static-rel} 20 | 21 | env: 22 | BUILD_TYPE: Release 23 | X_VCPKG_NUGET_ID_PREFIX: 'farcolorer' 24 | VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' 25 | 26 | runs-on: windows-2022 27 | steps: 28 | - name: Checkout source 29 | uses: actions/checkout@v4 30 | with: 31 | submodules: recursive 32 | fetch-depth: 0 33 | 34 | - name: Add C++ build tools to PATH 35 | uses: ilammy/msvc-dev-cmd@v1 36 | with: 37 | arch: ${{ matrix.arch }} 38 | 39 | - name: Setup vcpkg 40 | run: | 41 | bootstrap-vcpkg.bat 42 | 43 | - name: Setup NuGet Credentials for vpckg cache 44 | shell: bash 45 | run: > 46 | `vcpkg fetch nuget | tail -n 1` 47 | sources add 48 | -source "https://nuget.pkg.github.com/colorer/index.json" 49 | -storepasswordincleartext 50 | -name "GitHub" 51 | -username "${{ secrets.PACKAGES_GITHUB_USER }}" 52 | -password "${{ secrets.PACKAGES_GITHUB_TOKEN }}" 53 | 54 | - name: Create Build forlder 55 | run: cmake -E make_directory build 56 | 57 | - name: Configure CMake 58 | shell: bash 59 | working-directory: build 60 | run: > 61 | cmake $GITHUB_WORKSPACE -G "Ninja" 62 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE 63 | -DCOLORER_BUILD_ARCH=${{ matrix.build }} 64 | -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake 65 | -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} 66 | -DFARCOLORER_LEGACY=${{ matrix.legacy }} 67 | -DCMAKE_INSTALL_PREFIX=./install/FarColorer 68 | 69 | - name: Build 70 | working-directory: build 71 | shell: bash 72 | run: cmake --build . --config $BUILD_TYPE 73 | 74 | - name: Install 75 | working-directory: build 76 | shell: bash 77 | run: cmake --install . --config $BUILD_TYPE 78 | 79 | - name: Download scheme 80 | working-directory: build 81 | shell: bash 82 | run: | 83 | curl -s https://api.github.com/repos/colorer/Colorer-schemes/releases/latest | grep -o "https://.*colorer-base\.allpacked.*.zip" | xargs curl -fsLJO 84 | zipfilename="$(find . -name "colorer-base*.zip")" 85 | 7z x $zipfilename -o./install/FarColorer/base 86 | 87 | - name: Set suffix 88 | if: matrix.legacy == 'ON' 89 | shell: bash 90 | run: | 91 | echo "suffix=" >> $GITHUB_ENV 92 | 93 | - name: Set suffix 94 | if: matrix.legacy == 'OFF' 95 | shell: bash 96 | run: | 97 | echo "suffix=.icu" >> $GITHUB_ENV 98 | 99 | - name: Set the pack file name 100 | shell: bash 101 | run: | 102 | echo "farcolorer_name=FarColorer.${{ matrix.build }}${{env.suffix}}.${{ github.ref_name }}.7z" >> $GITHUB_ENV 103 | echo "farcolorer_pdb_name=FarColorer.${{ matrix.build }}${{env.suffix}}.${{ github.ref_name }}.pdb.7z" >> $GITHUB_ENV 104 | echo "farcolorer_withoutbase_name=FarColorer.${{ matrix.build }}${{env.suffix}}.${{ github.ref_name }}.wobase.7z" >> $GITHUB_ENV 105 | 106 | - name: pack plugin 107 | working-directory: build 108 | shell: bash 109 | run: | 110 | 7z a -m0=LZMA -mf=BCJ2 -mx9 ${{ env.farcolorer_name }} ./install/FarColorer/* 111 | 7z a -m0=LZMA -mf=BCJ2 -mx9 ${{ env.farcolorer_withoutbase_name }} ./install/FarColorer/* -x!./install/FarColorer/base 112 | 7z a -m0=LZMA -mf=off -mx9 ${{ env.farcolorer_pdb_name }} ./src/colorer.pdb 113 | 114 | - name: Upload result to cache 115 | uses: actions/upload-artifact@v4 116 | with: 117 | name: result-${{ matrix.arch }}-${{ matrix.legacy }} 118 | path: ./build/*.7z 119 | retention-days: 1 120 | 121 | publish-release: 122 | needs: [ build-artifacts ] 123 | runs-on: windows-2022 124 | 125 | steps: 126 | - name: Checkout source 127 | uses: actions/checkout@v4 128 | with: 129 | submodules: recursive 130 | fetch-depth: 0 131 | 132 | - name: Download result 133 | uses: actions/download-artifact@v4 134 | with: 135 | path: result 136 | pattern: result-* 137 | merge-multiple: true 138 | 139 | - name: Create release 140 | shell: bash 141 | run: gh release create ${{ github.ref_name }} -t "FarColorer ${{ github.ref_name }}" -n "New version" result/*.7z 142 | env: 143 | GITHUB_TOKEN: ${{secrets.PACKAGES_GITHUB_TOKEN}} -------------------------------------------------------------------------------- /.github/workflows/prebuild.yml: -------------------------------------------------------------------------------- 1 | name: "Prebuild vcpkg" 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | - cron: '0 1 * * 1,3,5' 7 | 8 | env: 9 | BUILD_TYPE: Release 10 | X_VCPKG_NUGET_ID_PREFIX: 'farcolorer' 11 | VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite' 12 | 13 | jobs: 14 | windows-vc: 15 | runs-on: windows-2022 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | build: [ x64, x86, arm64 ] 21 | include: 22 | - { build: x64, arch: amd64, triplet: x64-win-static-rel} 23 | - { build: x86, arch: amd64_x86, triplet: x86-win-static-rel} 24 | - { build: arm64, arch: amd64_arm64, triplet: arm64-win-static-rel} 25 | 26 | name: windows-${{ matrix.arch }} 27 | 28 | steps: 29 | - name: Checkout source 30 | uses: actions/checkout@v4 31 | with: 32 | submodules: recursive 33 | fetch-depth: 0 34 | 35 | - name: Setup vcpkg 36 | run: | 37 | bootstrap-vcpkg.bat 38 | 39 | - name: Add C++ build tools to PATH 40 | uses: ilammy/msvc-dev-cmd@v1 41 | with: 42 | arch: ${{ matrix.arch }} 43 | 44 | - name: Setup NuGet Credentials for vpckg cache 45 | shell: bash 46 | run: > 47 | `vcpkg fetch nuget | tail -n 1` 48 | sources add 49 | -source "https://nuget.pkg.github.com/colorer/index.json" 50 | -storepasswordincleartext 51 | -name "GitHub" 52 | -username "${{ secrets.PACKAGES_GITHUB_USER }}" 53 | -password "${{ secrets.PACKAGES_GITHUB_TOKEN }}" 54 | 55 | - name: Create Build folder 56 | run: mkdir -p _build 57 | 58 | - name: Configure CMake 59 | shell: bash 60 | # add -DVCPKG_INSTALL_OPTIONS="--debug" for debug output 61 | run: > 62 | cmake -S . -B _build -G "Ninja" 63 | -DCMAKE_BUILD_TYPE=$BUILD_TYPE 64 | -DCOLORER_BUILD_ARCH=${{ matrix.build }} 65 | -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake 66 | -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} 67 | -DFARCOLORER_LEGACY=OFF 68 | 69 | # dependencies are being built at the configuration stage -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Clion project files 2 | /.idea 3 | /cmake-build* 4 | /.PVS-Studio 5 | 6 | # build 7 | /bin 8 | /build 9 | /out 10 | 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/colorer"] 2 | path = external/colorer 3 | url = https://github.com/colorer/Colorer-library 4 | branch = master 5 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | #==================================================== 4 | # Enable policy 5 | #==================================================== 6 | # enable CMAKE_MSVC_RUNTIME_LIBRARY 7 | cmake_policy(SET CMP0091 NEW) 8 | 9 | #==================================================== 10 | # vcpkg settings 11 | #==================================================== 12 | # set before declare project(...) 13 | set(COLORER_BUILD_ARCH x64 CACHE STRING "Build architecture") 14 | if(NOT VCPKG_TARGET_TRIPLET) 15 | set(VCPKG_TARGET_TRIPLET "${COLORER_BUILD_ARCH}-win-static" CACHE STRING "vcpkg triplet") 16 | endif() 17 | message(STATUS "Using vcpkg triplet: ${VCPKG_TARGET_TRIPLET}") 18 | 19 | option(FARCOLORER_LEGACY "Build to work on older platforms" OFF) 20 | if(FARCOLORER_LEGACY) 21 | set(MY_VCPKG_MANIFEST_DIR "${CMAKE_HOME_DIRECTORY}/vcpkg/manifest/legacy") 22 | else() 23 | set(MY_VCPKG_MANIFEST_DIR "${CMAKE_HOME_DIRECTORY}/vcpkg/manifest/full") 24 | endif() 25 | set(VCPKG_MANIFEST_DIR ${MY_VCPKG_MANIFEST_DIR} CACHE STRING "Set the path to the manifest folder") 26 | message(STATUS "Using vcpkg manifest: ${VCPKG_MANIFEST_DIR}/vcpkg.json") 27 | 28 | #==================================================== 29 | project(farcolorer CXX) 30 | 31 | #==================================================== 32 | # Set default build to release 33 | #==================================================== 34 | if(NOT CMAKE_BUILD_TYPE) 35 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type, one of: Release, Debug" FORCE) 36 | endif() 37 | message("Build type for FarColorer: ${CMAKE_BUILD_TYPE}") 38 | 39 | #==================================================== 40 | # Set configuration types 41 | #==================================================== 42 | if(NOT MSVC_IDE) 43 | set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) 44 | else() 45 | #target_compile_options cannot set parameters for all configurations 46 | set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE STRING "" FORCE) 47 | endif() 48 | message("FarColorer configurations for IDE: ${CMAKE_CONFIGURATION_TYPES}") 49 | 50 | #==================================================== 51 | # global settings 52 | #==================================================== 53 | 54 | if(FARCOLORER_LEGACY) 55 | set(COLORER_BUILD_OLD_COMPILERS ON CACHE STRING "Use own implementation for standard library") 56 | set(COLORER_USE_ICU_STRINGS OFF CACHE STRING "Use ICU library for strings") 57 | endif() 58 | 59 | if(MSVC) 60 | # set global Visual C++ runtime 61 | if(CMAKE_BUILD_TYPE MATCHES Debug) 62 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") 63 | else() 64 | set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded") 65 | endif() 66 | 67 | if(FARCOLORER_LEGACY) 68 | # support old AMD on winxp 69 | if("${COLORER_BUILD_ARCH}" STREQUAL "x86") 70 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:IA32") 71 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /arch:IA32") 72 | endif() 73 | 74 | # for vc_crt_fix_impl.cpp 75 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:threadSafeInit-") 76 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zc:threadSafeInit-") 77 | endif() 78 | 79 | endif() 80 | 81 | #==================================================== 82 | # find dependences 83 | #==================================================== 84 | # core library 85 | if(NOT FARCOLORER_LEGACY) 86 | find_package(ICU COMPONENTS uc data REQUIRED) 87 | endif() 88 | 89 | find_package(LibXml2 REQUIRED) 90 | if(COLORER_USE_ZIPINPUTSOURCE) 91 | find_package(ZLIB REQUIRED) 92 | find_package(unofficial-minizip REQUIRED) 93 | endif() 94 | 95 | #==================================================== 96 | # colorer 97 | #==================================================== 98 | set(COLORER_BUILD_TOOLS OFF CACHE BOOL "Build colorer tools") 99 | set(COLORER_BUILD_INSTALL OFF CACHE BOOL "Make targets for install") 100 | add_subdirectory(./external/colorer) 101 | 102 | #==================================================== 103 | # farcolorer 104 | #==================================================== 105 | add_subdirectory(./src) 106 | 107 | #==================================================== 108 | # install 109 | #==================================================== 110 | install(TARGETS farcolorer RUNTIME DESTINATION bin) 111 | install(DIRECTORY ${PROJECT_SOURCE_DIR}/misc/ DESTINATION bin) 112 | install(FILES 113 | ${CMAKE_CURRENT_BINARY_DIR}/src/colorer.map 114 | DESTINATION bin) 115 | install(FILES 116 | ${PROJECT_SOURCE_DIR}/LICENSE 117 | ${PROJECT_SOURCE_DIR}/README.md 118 | ${PROJECT_SOURCE_DIR}/docs/history.ru.txt 119 | DESTINATION .) 120 | 121 | -------------------------------------------------------------------------------- /CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "cmakeMinimumRequired": { 4 | "major": 3, 5 | "minor": 22, 6 | "patch": 0 7 | }, 8 | "configurePresets": [ 9 | { 10 | "name": "base", 11 | "description": "Sets generator, build and install directory, vcpkg", 12 | "hidden": true, 13 | "generator": "Ninja", 14 | "binaryDir": "${sourceDir}/out/build/${presetName}", 15 | "cacheVariables": { 16 | "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", 17 | "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}/far/plugins/FarColorer" 18 | } 19 | }, 20 | { 21 | "name": "x64", 22 | "architecture": { 23 | "value": "x64", 24 | "strategy": "external" 25 | }, 26 | "cacheVariables": { 27 | "COLORER_BUILD_ARCH": "x64" 28 | }, 29 | "hidden": true 30 | }, 31 | { 32 | "name": "x86", 33 | "architecture": { 34 | "value": "x86", 35 | "strategy": "external" 36 | }, 37 | "cacheVariables": { 38 | "COLORER_BUILD_ARCH": "x86" 39 | }, 40 | "hidden": true 41 | }, 42 | { 43 | "name": "arm64", 44 | "architecture": { 45 | "value": "arm64", 46 | "strategy": "external" 47 | }, 48 | "cacheVariables": { 49 | "COLORER_BUILD_ARCH": "arm64" 50 | }, 51 | "hidden": true 52 | }, 53 | { 54 | "name": "Debug", 55 | "cacheVariables": { 56 | "CMAKE_BUILD_TYPE": "Debug" 57 | }, 58 | "hidden": true 59 | }, 60 | { 61 | "name": "Release", 62 | "cacheVariables": { 63 | "CMAKE_BUILD_TYPE": "Release" 64 | }, 65 | "hidden": true 66 | }, 67 | { 68 | "name": "RelWithDebInfo", 69 | "cacheVariables": { 70 | "CMAKE_BUILD_TYPE": "RelWithDebInfo" 71 | }, 72 | "hidden": true 73 | }, 74 | { 75 | "name": "ICU", 76 | "cacheVariables": { 77 | "FARCOLORER_LEGACY": "OFF" 78 | }, 79 | "hidden": true 80 | }, 81 | { 82 | "name": "MSVC", 83 | "hidden": true, 84 | "cacheVariables": { 85 | "CMAKE_CXX_COMPILER": "cl.exe" 86 | }, 87 | "toolset": { 88 | "value": "host=x64", 89 | "strategy": "external" 90 | } 91 | }, 92 | { 93 | "name": "Clang-win", 94 | "hidden": true, 95 | "cacheVariables": { 96 | "CMAKE_CXX_COMPILER": "clang-cl.exe" 97 | }, 98 | "toolset": { 99 | "value": "host=x64", 100 | "strategy": "external" 101 | } 102 | }, 103 | { "name": "msvc-x64-Debug", "description": "MSVC for x64 (Debug, Legacy)", "inherits": [ "base", "x64", "Debug", "MSVC"] }, 104 | { "name": "msvc-x64-Release", "description": "MSVC for x64 (Release, Legacy)", "inherits": [ "base", "x64", "Release", "MSVC" ] }, 105 | { "name": "msvc-x64-Debug-ICU", "description": "MSVC for x64 (Debug, ICU)", "inherits": [ "base", "x64", "Debug", "MSVC", "ICU" ] }, 106 | { "name": "msvc-x64-Release-ICU", "description": "MSVC for x64 (Release, ICU)", "inherits": [ "base", "x64", "Release", "MSVC", "ICU" ] }, 107 | { "name": "msvc-x86-Debug", "description": "MSVC for x86 (Debug, Legacy)", "inherits": [ "base", "x86", "Debug", "MSVC" ] }, 108 | { "name": "msvc-x86-Release", "description": "MSVC for x86 (Release, Legacy)", "inherits": [ "base", "x86", "Release", "MSVC"] }, 109 | { "name": "msvc-x86-Debug-ICU", "description": "MSVC for x86 (Debug, ICU)", "inherits": [ "base", "x86", "Debug", "MSVC", "ICU" ] }, 110 | { "name": "msvc-x86-Release-ICU", "description": "MSVC for x86 (Release, ICU)", "inherits": [ "base", "x86", "Release", "MSVC", "ICU" ] }, 111 | { "name": "msvc-arm64-Debug", "description": "MSVC for ARM64 (Debug, Legacy)", "inherits": [ "base", "arm64", "Debug", "MSVC" ] }, 112 | { "name": "msvc-arm64-Release", "description": "MSVC for ARM64 (Release, Legacy)", "inherits": [ "base", "arm64", "Release", "MSVC" ] }, 113 | { "name": "msvc-arm64-Debug-ICU", "description": "MSVC for ARM64 (Debug, ICU)", "inherits": [ "base", "arm64", "Debug", "MSVC", "ICU" ] }, 114 | { "name": "msvc-arm64-Release-ICU", "description": "MSVC for ARM64 (Release, ICU)", "inherits": [ "base", "arm64", "Release", "MSVC", "ICU" ] } 115 | ] 116 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2009 Igor Russkih 4 | Copyright (c) 2009 and present Aleksey Dobrunov 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | FarColorer 2 | ========== 3 | FarColorer is a syntax highlighting plugin for Far Manager. 4 | [![Build](https://github.com/colorer/FarColorer/actions/workflows/farcolorer-ci.yml/badge.svg)](https://github.com/colorer/FarColorer/actions/workflows/farcolorer-ci.yml) 5 | 6 | It only works for (F4)Edit file. (F3)View is not supported, as there is no API. 7 | But you can type in the console `clr:name_of_file`. This launches the built-in viewer colorer. 8 | 9 | Downloads 10 | ========= 11 | FarColorer is included in Far Manager since 2013 year (about Far build 3.0.3200). So just update [Far Manager](http://www.farmanager.com/download.php?l=en) to get latest stable release of plugin. 12 | 13 | Other version you must find in [Releases](https://github.com/colorer/FarColorer/releases) on github. New release is auto-created after create tag in git. 14 | 15 | FarColorer has two main versions - legacy and modern. On [release page](https://github.com/colorer/FarColorer/releases) files of the modern version has suffix `icu`. 16 | For example, FarColorer.x64.icu.v1.6.1.7z - modern , FarColorer.x64.v1.6.1.7z - legacy. 17 | 18 | ### Legacy version 19 | 20 | * Installed manually 21 | * Support Windows XP (broken between 1.4.x and 1.5.x) 22 | * Used legacy Unicode string which the library was originally built on 23 | * Used ghc::filesystem instead of std::filesystem 24 | 25 | ### Modern version 26 | 27 | * Included in the Far Manager distribution 28 | * Do not support older platform, like as Windows XP 29 | * Used ICU Unicode string 30 | * Used std::filesystem 31 | 32 | For checking installed version press F9 - Options - Plugins configuration, select FarColorer and press F3. 33 | 34 | How to build from source 35 | ========== 36 | To build plugin from source, you will need: 37 | 38 | * Visual Studio 2019 or higher 39 | * git 40 | * cmake 3.15 or higher 41 | * vcpkg 42 | 43 | Download the source from git repository: 44 | 45 | ```bash 46 | git clone https://github.com/colorer/FarColorer.git --recursive 47 | ``` 48 | 49 | Setup vcpkg, or use the preset (set env VCPKG_ROOT) 50 | 51 | ```bash 52 | git clone https://github.com/microsoft/vcpkg.git 53 | set VCPKG_ROOT= 54 | %VCPKG_ROOT%\bootstrap-vcpkg.bat -disableMetrics 55 | ``` 56 | 57 | #### IDE 58 | 59 | Open folder with Colorer-library from IDE like as Clion, VSCode, VisualStudio. 60 | In the CMakePresets file.json configurations have been created for standard builds. 61 | 62 | #### Console 63 | 64 | Setup Visual Studio environment (x64 or x86/arm64 for platforms) 65 | 66 | ```bash 67 | "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 68 | ``` 69 | 70 | Build colorer and dependency, if they are not in the local cache: 71 | 72 | ```bash 73 | 74 | mkdir build 75 | cd build 76 | cmake -S .. -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DCOLORER_BUILD_ARCH=x64 77 | cmake --build . 78 | ``` 79 | 80 | For x86 platform use `-DCOLORER_BUILD_ARCH=x86`, arm64 - `-DCOLORER_BUILD_ARCH=arm64`. 81 | 82 | Once built, the dependencies will be cached in the local cache. 83 | 84 | Links 85 | ======================== 86 | 87 | * Project main page: [http://colorer.sourceforge.net/](http://colorer.sourceforge.net/) 88 | * Far Manager forum: [http://forum.farmanager.com/](http://forum.farmanager.com/) 89 | * FarColorer discussions (in Russian): [http://forum.farmanager.com/viewtopic.php?f=5&t=1573](http://forum.farmanager.com/viewtopic.php?f=5&t=1573) 90 | * FarColorer discussions (in English): [http://forum.farmanager.com/viewtopic.php?f=39&t=4319](http://forum.farmanager.com/viewtopic.php?f=39&t=4319) 91 | -------------------------------------------------------------------------------- /ci/clean_packages/main.py: -------------------------------------------------------------------------------- 1 | # Script for cleaning old versions of packages in GitHub Packages 2 | # Author: https://github.com/ctapmex 3 | 4 | from ghapi.all import GhApi 5 | from ghapi.page import paged 6 | import os 7 | import re 8 | 9 | 10 | def get_version_for_remove(package_versions): 11 | sorted_version = sorted(package_versions, key=lambda d: d['created_at'], reverse=True) 12 | # remove from list actual version 13 | del sorted_version[0] 14 | return sorted_version 15 | 16 | 17 | org_name = os.getenv('ORG_NAME', None) 18 | package_mask = os.getenv('PACKAGE_MASK', None) 19 | package_type = os.getenv('PACKAGE_TYPE', None) 20 | github_token = os.getenv('GITHUB_TOKEN', None) 21 | 22 | if not org_name or not package_type or not package_mask or not github_token: 23 | raise BaseException("not all significant parameters are set") 24 | 25 | api = GhApi(token=github_token) 26 | 27 | package_pages = paged(api.packages.list_packages_for_organization, org=org_name, 28 | package_type=package_type, visibility=None, per_page=100) 29 | 30 | print("search packages") 31 | for package_page in package_pages: 32 | for package in package_page: 33 | if re.search(package_mask, package['name']): 34 | print("found package - ", package['name']) 35 | package_version = [] 36 | version_pages = paged(api.packages.get_all_package_versions_for_package_owned_by_org, org=org_name, 37 | package_name=package['name'], package_type=package['package_type'], state='active', 38 | per_page=100) 39 | for version_page in version_pages: 40 | for version in version_page: 41 | vp = {'version_id': version['id'], 'created_at': version['created_at']} 42 | package_version.append(vp) 43 | 44 | version_for_del = get_version_for_remove(package_version) 45 | print("count of versions of the package to delete - ", len(version_for_del)) 46 | for version in version_for_del: 47 | print("delete id=", version['version_id']) 48 | api.packages.delete_package_version_for_org(org=org_name, package_name=package['name'], 49 | package_type=package['package_type'], 50 | package_version_id=version['version_id']) 51 | 52 | print("finish") 53 | -------------------------------------------------------------------------------- /ci/clean_packages/requirements.txt: -------------------------------------------------------------------------------- 1 | fastcore==1.6.3 2 | ghapi==1.0.5 3 | packaging==24.1 4 | -------------------------------------------------------------------------------- /docs/enc/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Библиотека схем 7 | 8 | 9 | 10 | 11 | 12 |

Библиотека схем
13 |

14 | 15 | главная
16 |
17 |
18 |

Библиотека схем - это базовый набор описаний синтаксисов и стилей раскраски, используемый библиотекой Colorer take5.

19 | Папка hrc содержит набор 20 | hrc-файлов (далее схема языка). hrc - это формат хранения описаний синтаксиса языков 21 | программирования, скриптов и другой структурированной текстовой 22 | информации. Он используется в библиотеке Colorer для синтаксического 23 | разбора и расцветки целевого текста. В общем-то, это довольно сложный 24 | скриптовый язык с мощными возможностями описания синтаксиса. hrc 25 | основан на метаязыке xml, и все его описания хранятся именно в этом 26 | формате.
27 |

Папка hrd содержит набор hrd-файлов (далее цветовой стиль). hrd используются для сопоставление реальных цветов синтаксическим регионам, созданным библиотекой Colorer по схеме языка. 28 | Каждый файл определяет целевую информацию для всех регионов. Эти цвета 29 | могут иметь свободный числовой или символьный формат - их интерпретация 30 | зависит от целевой программы, использующей библиотеку.

31 |

Центральным файлом для бибилиотеки схем является catalog.xml. В нем прописаны пути до hrc и hrd файлов и некоторые настройки.
32 |

33 | -------------------------------------------------------------------------------- /docs/enc/colorer.hhc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 50 | 51 | -------------------------------------------------------------------------------- /docs/enc/colorer.hhp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/colorer.hhp -------------------------------------------------------------------------------- /docs/enc/img/back_color.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/img/back_color.PNG -------------------------------------------------------------------------------- /docs/enc/img/first_run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/img/first_run.png -------------------------------------------------------------------------------- /docs/enc/img/install_dir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/img/install_dir.png -------------------------------------------------------------------------------- /docs/enc/img/logo-colorer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/img/logo-colorer.png -------------------------------------------------------------------------------- /docs/enc/img/schemes_settings.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/img/schemes_settings.PNG -------------------------------------------------------------------------------- /docs/enc/img/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/img/settings.png -------------------------------------------------------------------------------- /docs/enc/img/truemod.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/img/truemod.PNG -------------------------------------------------------------------------------- /docs/enc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Руководство по FarColorer 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 |

17 |
18 |

19 | 20 |

Руководство по FarColorer

21 | 22 |

FarColorer - плагин 23 | файлового менеджера Far2, предназначенный для подсветки синтаксиса 24 | файлов в редакторе.

25 | 26 |

Плагин построен на библиотеке Colorer take5.
27 |

28 | 29 |

В данном руководстве описаны моменты по настройке плагина, начиная 30 | от установки и заканчивая написанием своих типов подсветки синтаксиса.

31 | 32 |

Оглавление

33 | 34 |
    35 | 36 |
  1. Установка FarColorer
  2. 37 |
  3. Состав FarColorer
  4. 38 | 39 | 40 |
  5. Режимы работы. TrueMod.
    41 |
  6. 42 | 43 |
  7. Настройки FarColorer
    44 |
    45 | 48 |
  8. 49 |
  9. Библиотека схем
  10. 50 |
      51 |
    1. Параметры схем
      52 |
    2. 53 |
    54 |
55 |
    56 | 57 | 58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /docs/enc/install.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Установка FarColorer 6 | 7 | 8 | 9 | 10 | 11 |

Установка FarColorer

12 | главная
13 | 14 |
    15 |
  1. Скачиваем последнюю версию FarColorer с оффициального сайта.
  2. 16 |
  3. Распаковываем содержимое архива в подпапку Plugins папки с утановленным Far2.
    17 | install dir
  4. 18 |
  5. Запустить 19 | Far ( либо перезапустить, если установка шла в нем ). Теперь, если 20 | открыть файл, например, файл LICENSE, то вы увидете раскрашенный текстfirst run
    21 |
  6. 22 |
23 | 24 | -------------------------------------------------------------------------------- /docs/enc/modes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Режимы работы 6 | 7 | 8 | 9 | 10 |

Режимы работы
11 |

12 | 13 | главная
14 |
15 |
16 |

Основным режимом работы FarColorer является консольный. Подсветка синтаксиса производится с помощью стандартных средств консоли. Цвета ограничены возможностью консоли.

17 | console mode
18 |

В FarColorer 1.0.2.10 появился новый режим - TrueMod. В этом режиме текст отображается в RGB режиме, и используются разные стили (bold/italic/underlined и т.п.).
19 | truemod

20 | Для работы TrueMod, кроме включения опции в настройках, требуется ConEmu 21 | (в его настройках так же нужно включить режим отображения TrueMod) и 22 | модифицированная версия Far2 (Far-truemod). Far-truemod можно скачать 23 | на сайте плагина.
24 |

Внимание. Поддержкой Far-truemod разработчики Far не занимаются.

25 |


26 |

27 | -------------------------------------------------------------------------------- /docs/enc/scheme_params.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Параметры схем 5 | 6 | 7 |

Параметры схем
8 |

9 | главная
10 |

Параметры схем можно условно разделить на два типа - параметры 11 | библиотеки Сolorer и параметры FarColorer.

12 |

Параметры библиотеки Colorer 13 |

14 |

Это параметры, влияющие на парсинг файлов и подсветку 15 | синтаксиса библиотекой. Т.е. обрабатываются во всех программах, 16 | использующих бибилиотеку Colorer take5.
17 | Существует два фиксированных параметра. Это
18 |

19 | 28 |

Так же авторы схем могут создать свои параметры. Эти параметры 29 | могут принимать два значения true 30 | и false. Они используются 31 | для включения/выключения дополнительных возможностей при парсинге 32 | файла. Например, выделять или нет экранированные символы.

33 |

Параметры FarColorer

34 | Это параметры, влияющие на парсинг файлов и подсветку синтаксиса 35 | плагином FarColorer.
36 | Существуют следующие параметры:
37 |

Установка и наследование параметров


Параметры могут быть установлены в трех местах.
Чтение параметров схемы идет из описания(prototype)/настроек этой 77 | схемы, либо если параметры не установлены берутся значения от схемы с 78 | именем default. Поиск параметра для схемы идет в следующем порядке:
79 | 88 | 89 | 91 | -------------------------------------------------------------------------------- /docs/enc/settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Настройки FarColorer 6 | 7 | 8 | 9 | 10 | 11 |

Настройки FarColorer
12 |

13 | 14 | главная
15 |
16 |
17 | 18 |

Диалог настроек FarColorer вызывается в главном меню Far2  Параметры - Параметры внешних модулей - Colorer или в редакторе Команды внешних модулей - Colorer - Настройка .
19 |

20 | settings 21 | Настройки TrueMod
72 |
73 | 85 | Кнопки
86 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /docs/enc/shemes_settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Настройки схем 6 | 7 | 8 | 9 | 10 |

Настройки схем
11 |

12 | 13 | главная
14 |
15 |
16 | 17 |

Диалог настроек схем вызывается из окна настроек FarColorer кнопкой Настройки схем.

schemes settings
18 |

В данном окне настраиваются пользовательские значения параметров для каждой схемы индивидуально. 19 | Настройки сохраняются в реестре с остальными настройками плагина. Типы 20 | параметров и их значения, а так же порядок наследования приведены в 21 | разделе Параметры схем.
22 |

23 |

Большинство параметров принимает фиксированные значения. Все эти значения доступны для выбора в поле Значение параметра. Для 24 | остальных параметров, например backparse, значение нужно вводить 25 | вручную. Так же можно указать, чтобы для параметра устанавливалось 26 | значение по умолчанию, выбрав в поле <default-знач>.

27 | Если для параметра пользователем не установлено значение, то в поле ввода значения отображается текст <default-знач>. Данный текст показывает, что для параметра по умолчанию будет выставлено значение знач. Данное значение получено путем наследования. 28 |

Сохранение всех изменений происходит после нажатия кнопки OK. Кнопка Отмена не сохраняет никаких изменений.
29 |

30 | -------------------------------------------------------------------------------- /docs/enc/structure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Состав FarColorer 7 | 8 | 9 | 10 | 11 | 12 |

Состав FarColorer
13 |

14 | 15 | главная
16 | 17 |
18 |

FarColorer состоит из двух основных частей - 19 | непосредственно сам плагин, и базовый набор описаний синтаксисов и 20 | стилей раскраски (далее библиотека схем).

21 |

Папка bin содержит

22 | 36 | Папка base содержит библиотеку схем.
37 |
38 | -------------------------------------------------------------------------------- /docs/enc/styles.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/colorer/FarColorer/2de9ee04bae79090ff7c00e067d2abaf2b832841/docs/enc/styles.css -------------------------------------------------------------------------------- /external/far3sdk/farcolor.hpp: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLOR_HPP_57151931_4591_44A5_92CF_8E51D1FBC57E 2 | #define FARCOLOR_HPP_57151931_4591_44A5_92CF_8E51D1FBC57E 3 | #pragma once 4 | 5 | /* 6 | farcolor.hpp 7 | 8 | Colors Index for FAR Manager 3.0.6250.0 9 | */ 10 | /* 11 | Copyright © 1996 Eugene Roshal 12 | Copyright © 2000 Far Group 13 | All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions 17 | are met: 18 | 1. Redistributions of source code must retain the above copyright 19 | notice, this list of conditions and the following disclaimer. 20 | 2. Redistributions in binary form must reproduce the above copyright 21 | notice, this list of conditions and the following disclaimer in the 22 | documentation and/or other materials provided with the distribution. 23 | 3. The name of the authors may not be used to endorse or promote products 24 | derived from this software without specific prior written permission. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 27 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 29 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 30 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 31 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 35 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | 37 | EXCEPTION: 38 | Far Manager plugins that use this header file can be distributed under any 39 | other possible license with no implications from the above license on them. 40 | */ 41 | 42 | 43 | enum PaletteColors 44 | { 45 | COL_MENUTEXT, 46 | COL_MENUSELECTEDTEXT, 47 | COL_MENUHIGHLIGHT, 48 | COL_MENUSELECTEDHIGHLIGHT, 49 | COL_MENUBOX, 50 | COL_MENUTITLE, 51 | 52 | COL_HMENUTEXT, 53 | COL_HMENUSELECTEDTEXT, 54 | COL_HMENUHIGHLIGHT, 55 | COL_HMENUSELECTEDHIGHLIGHT, 56 | 57 | COL_PANELTEXT, 58 | COL_PANELSELECTEDTEXT, 59 | COL_PANELHIGHLIGHTTEXT, 60 | COL_PANELINFOTEXT, 61 | COL_PANELCURSOR, 62 | COL_PANELSELECTEDCURSOR, 63 | COL_PANELTITLE, 64 | COL_PANELSELECTEDTITLE, 65 | COL_PANELCOLUMNTITLE, 66 | COL_PANELTOTALINFO, 67 | COL_PANELSELECTEDINFO, 68 | 69 | COL_DIALOGTEXT, 70 | COL_DIALOGHIGHLIGHTTEXT, 71 | COL_DIALOGBOX, 72 | COL_DIALOGBOXTITLE, 73 | COL_DIALOGHIGHLIGHTBOXTITLE, 74 | COL_DIALOGEDIT, 75 | COL_DIALOGBUTTON, 76 | COL_DIALOGSELECTEDBUTTON, 77 | COL_DIALOGHIGHLIGHTBUTTON, 78 | COL_DIALOGHIGHLIGHTSELECTEDBUTTON, 79 | 80 | COL_DIALOGLISTTEXT, 81 | COL_DIALOGLISTSELECTEDTEXT, 82 | COL_DIALOGLISTHIGHLIGHT, 83 | COL_DIALOGLISTSELECTEDHIGHLIGHT, 84 | 85 | COL_WARNDIALOGTEXT, 86 | COL_WARNDIALOGHIGHLIGHTTEXT, 87 | COL_WARNDIALOGBOX, 88 | COL_WARNDIALOGBOXTITLE, 89 | COL_WARNDIALOGHIGHLIGHTBOXTITLE, 90 | COL_WARNDIALOGEDIT, 91 | COL_WARNDIALOGBUTTON, 92 | COL_WARNDIALOGSELECTEDBUTTON, 93 | COL_WARNDIALOGHIGHLIGHTBUTTON, 94 | COL_WARNDIALOGHIGHLIGHTSELECTEDBUTTON, 95 | 96 | COL_KEYBARNUM, 97 | COL_KEYBARTEXT, 98 | COL_KEYBARBACKGROUND, 99 | 100 | COL_COMMANDLINE, 101 | 102 | COL_CLOCK, 103 | 104 | COL_VIEWERTEXT, 105 | COL_VIEWERSELECTEDTEXT, 106 | COL_VIEWERSTATUS, 107 | 108 | COL_EDITORTEXT, 109 | COL_EDITORSELECTEDTEXT, 110 | COL_EDITORSTATUS, 111 | 112 | COL_HELPTEXT, 113 | COL_HELPHIGHLIGHTTEXT, 114 | COL_HELPTOPIC, 115 | COL_HELPSELECTEDTOPIC, 116 | COL_HELPBOX, 117 | COL_HELPBOXTITLE, 118 | 119 | COL_PANELDRAGTEXT, 120 | COL_DIALOGEDITUNCHANGED, 121 | COL_PANELSCROLLBAR, 122 | COL_HELPSCROLLBAR, 123 | COL_PANELBOX, 124 | COL_PANELSCREENSNUMBER, 125 | COL_DIALOGEDITSELECTED, 126 | COL_COMMANDLINESELECTED, 127 | COL_VIEWERARROWS, 128 | 129 | COL_DIALOGLISTSCROLLBAR, 130 | COL_MENUSCROLLBAR, 131 | COL_VIEWERSCROLLBAR, 132 | COL_COMMANDLINEPREFIX, 133 | COL_DIALOGDISABLED, 134 | COL_DIALOGEDITDISABLED, 135 | COL_DIALOGLISTDISABLED, 136 | COL_WARNDIALOGDISABLED, 137 | COL_WARNDIALOGEDITDISABLED, 138 | COL_WARNDIALOGLISTDISABLED, 139 | 140 | COL_MENUDISABLEDTEXT, 141 | 142 | COL_EDITORCLOCK, 143 | COL_VIEWERCLOCK, 144 | 145 | COL_DIALOGLISTTITLE, 146 | COL_DIALOGLISTBOX, 147 | 148 | COL_WARNDIALOGEDITSELECTED, 149 | COL_WARNDIALOGEDITUNCHANGED, 150 | 151 | COL_DIALOGCOMBOTEXT, 152 | COL_DIALOGCOMBOSELECTEDTEXT, 153 | COL_DIALOGCOMBOHIGHLIGHT, 154 | COL_DIALOGCOMBOSELECTEDHIGHLIGHT, 155 | COL_DIALOGCOMBOBOX, 156 | COL_DIALOGCOMBOTITLE, 157 | COL_DIALOGCOMBODISABLED, 158 | COL_DIALOGCOMBOSCROLLBAR, 159 | 160 | COL_WARNDIALOGLISTTEXT, 161 | COL_WARNDIALOGLISTSELECTEDTEXT, 162 | COL_WARNDIALOGLISTHIGHLIGHT, 163 | COL_WARNDIALOGLISTSELECTEDHIGHLIGHT, 164 | COL_WARNDIALOGLISTBOX, 165 | COL_WARNDIALOGLISTTITLE, 166 | COL_WARNDIALOGLISTSCROLLBAR, 167 | 168 | COL_WARNDIALOGCOMBOTEXT, 169 | COL_WARNDIALOGCOMBOSELECTEDTEXT, 170 | COL_WARNDIALOGCOMBOHIGHLIGHT, 171 | COL_WARNDIALOGCOMBOSELECTEDHIGHLIGHT, 172 | COL_WARNDIALOGCOMBOBOX, 173 | COL_WARNDIALOGCOMBOTITLE, 174 | COL_WARNDIALOGCOMBODISABLED, 175 | COL_WARNDIALOGCOMBOSCROLLBAR, 176 | 177 | COL_DIALOGLISTARROWS, 178 | COL_DIALOGLISTARROWSDISABLED, 179 | COL_DIALOGLISTARROWSSELECTED, 180 | COL_DIALOGCOMBOARROWS, 181 | COL_DIALOGCOMBOARROWSDISABLED, 182 | COL_DIALOGCOMBOARROWSSELECTED, 183 | COL_WARNDIALOGLISTARROWS, 184 | COL_WARNDIALOGLISTARROWSDISABLED, 185 | COL_WARNDIALOGLISTARROWSSELECTED, 186 | COL_WARNDIALOGCOMBOARROWS, 187 | COL_WARNDIALOGCOMBOARROWSDISABLED, 188 | COL_WARNDIALOGCOMBOARROWSSELECTED, 189 | COL_MENUARROWS, 190 | COL_MENUARROWSDISABLED, 191 | COL_MENUARROWSSELECTED, 192 | COL_COMMANDLINEUSERSCREEN, 193 | COL_EDITORSCROLLBAR, 194 | 195 | COL_MENUGRAYTEXT, 196 | COL_MENUSELECTEDGRAYTEXT, 197 | COL_DIALOGCOMBOGRAY, 198 | COL_DIALOGCOMBOSELECTEDGRAYTEXT, 199 | COL_DIALOGLISTGRAY, 200 | COL_DIALOGLISTSELECTEDGRAYTEXT, 201 | COL_WARNDIALOGCOMBOGRAY, 202 | COL_WARNDIALOGCOMBOSELECTEDGRAYTEXT, 203 | COL_WARNDIALOGLISTGRAY, 204 | COL_WARNDIALOGLISTSELECTEDGRAYTEXT, 205 | 206 | COL_DIALOGDEFAULTBUTTON, 207 | COL_DIALOGSELECTEDDEFAULTBUTTON, 208 | COL_DIALOGHIGHLIGHTDEFAULTBUTTON, 209 | COL_DIALOGHIGHLIGHTSELECTEDDEFAULTBUTTON, 210 | COL_WARNDIALOGDEFAULTBUTTON, 211 | COL_WARNDIALOGSELECTEDDEFAULTBUTTON, 212 | COL_WARNDIALOGHIGHLIGHTDEFAULTBUTTON, 213 | COL_WARNDIALOGHIGHLIGHTSELECTEDDEFAULTBUTTON, 214 | 215 | COL_LASTPALETTECOLOR 216 | }; 217 | 218 | #endif // FARCOLOR_HPP_57151931_4591_44A5_92CF_8E51D1FBC57E 219 | -------------------------------------------------------------------------------- /external/far3sdk/vc_crt_fix.asm: -------------------------------------------------------------------------------- 1 | ;vc_crt_fix.asm 2 | 3 | ;Workaround for Visual C++ CRT incompatibility with old Windows versions 4 | 5 | ;Copyright © 2010 Far Group 6 | ;All rights reserved. 7 | ; 8 | ;Redistribution and use in source and binary forms, with or without 9 | ;modification, are permitted provided that the following conditions 10 | ;are met: 11 | ;1. Redistributions of source code must retain the above copyright 12 | ; notice, this list of conditions and the following disclaimer. 13 | ;2. Redistributions in binary form must reproduce the above copyright 14 | ; notice, this list of conditions and the following disclaimer in the 15 | ; documentation and/or other materials provided with the distribution. 16 | ;3. The name of the authors may not be used to endorse or promote products 17 | ; derived from this software without specific prior written permission. 18 | ; 19 | ;THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | ;IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | ;OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | ;IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | ;INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | ;NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | ;DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | ;THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | ;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | ;THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | ifndef X64 31 | .model flat 32 | endif 33 | 34 | .const 35 | 36 | HOOK MACRO name, size, args:VARARG 37 | WRAPPER EQU @CatStr(Wrapper_, name) 38 | ifdef X64 39 | DARGS EQU 40 | IMP EQU @CatStr(__imp_, name) 41 | else 42 | DARGS EQU args 43 | IMP EQU @CatStr(__imp__, name, @, size) 44 | endif 45 | 46 | WRAPPER proto stdcall DARGS 47 | IMP dq WRAPPER 48 | public IMP 49 | ENDM 50 | 51 | ifndef X64 52 | HOOK EncodePointer , 4, :dword 53 | HOOK DecodePointer , 4, :dword 54 | HOOK GetModuleHandleExW , 12, :dword, :dword, :dword 55 | HOOK InitializeSListHead , 4, :dword 56 | HOOK InterlockedFlushSList , 4, :dword 57 | HOOK InterlockedPushEntrySList , 8, :dword, :dword 58 | HOOK GetNumaHighestNodeNumber , 4, :dword 59 | HOOK GetLogicalProcessorInformation , 8, :dword, :dword 60 | HOOK SetThreadStackGuarantee , 4, :dword 61 | HOOK FlsAlloc , 4, :dword 62 | HOOK FlsGetValue , 4, :dword 63 | HOOK FlsSetValue , 8, :dword, :dword 64 | HOOK FlsFree , 4, :dword 65 | endif 66 | HOOK InitializeCriticalSectionEx , 12, :dword, :dword, :dword 67 | HOOK CompareStringEx , 36, :dword, :dword, :dword, :dword, :dword, :dword, :dword, :dword, :dword 68 | HOOK LCMapStringEx , 36, :dword, :dword, :dword, :dword, :dword, :dword, :dword, :dword, :dword 69 | HOOK AcquireSRWLockExclusive , 4, :dword 70 | HOOK ReleaseSRWLockExclusive , 4, :dword 71 | HOOK SleepConditionVariableSRW , 16, :dword, :dword, :dword, :dword 72 | HOOK WakeAllConditionVariable , 4, :dword 73 | HOOK TryAcquireSRWLockExclusive , 4, :dword 74 | HOOK InitializeSRWLock , 4, :dword 75 | 76 | ; added to original file for FarColorer 77 | HOOK GetLocaleInfoEx , 16, :dword, :dword, :dword, :dword 78 | HOOK LocaleNameToLCID , 8, :dword, :dword 79 | 80 | end 81 | -------------------------------------------------------------------------------- /external/far3sdk/vc_crt_fix_impl.cpp: -------------------------------------------------------------------------------- 1 | // validator: no-self-include 2 | /* 3 | vc_crt_fix_impl.cpp 4 | 5 | Workaround for Visual C++ CRT incompatibility with old Windows versions 6 | */ 7 | /* 8 | Copyright © 2011 Far Group 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions 13 | are met: 14 | 1. Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | 2. Redistributions in binary form must reproduce the above copyright 17 | notice, this list of conditions and the following disclaimer in the 18 | documentation and/or other materials provided with the distribution. 19 | 3. The name of the authors may not be used to endorse or promote products 20 | derived from this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | #ifdef __clang__ 41 | #pragma clang diagnostic ignored "-Wmissing-prototypes" 42 | #endif 43 | 44 | 45 | template 46 | static T GetFunctionPointer(const wchar_t* ModuleName, const char* FunctionName, T Replacement) 47 | { 48 | const auto Module = GetModuleHandleW(ModuleName); 49 | const auto Address = Module? GetProcAddress(Module, FunctionName) : nullptr; 50 | return Address? reinterpret_cast(reinterpret_cast(Address)) : Replacement; 51 | } 52 | 53 | #define WRAPPER(name) Wrapper_ ## name 54 | #define CREATE_AND_RETURN(ModuleName, ...) \ 55 | static const auto FunctionPointer = GetFunctionPointer(ModuleName, __func__ + sizeof("Wrapper_") - 1, &implementation::impl); \ 56 | return FunctionPointer(__VA_ARGS__) 57 | 58 | namespace modules 59 | { 60 | static const wchar_t kernel32[] = L"kernel32"; 61 | } 62 | 63 | static void* XorPointer(void* Ptr) 64 | { 65 | static const auto Cookie = [] 66 | { 67 | static void* Ptr; 68 | auto Result = reinterpret_cast(&Ptr); 69 | 70 | FILETIME CreationTime, NotUsed; 71 | if (GetThreadTimes(GetCurrentThread(), &CreationTime, &NotUsed, &NotUsed, &NotUsed)) 72 | { 73 | Result ^= CreationTime.dwLowDateTime; 74 | Result ^= CreationTime.dwHighDateTime; 75 | } 76 | return Result; 77 | }(); 78 | return reinterpret_cast(reinterpret_cast(Ptr) ^ Cookie); 79 | } 80 | 81 | // EncodePointer (VC2010) 82 | extern "C" PVOID WINAPI WRAPPER(EncodePointer)(PVOID Ptr) 83 | { 84 | struct implementation 85 | { 86 | static PVOID WINAPI impl(PVOID Ptr) 87 | { 88 | return XorPointer(Ptr); 89 | } 90 | }; 91 | 92 | CREATE_AND_RETURN(modules::kernel32, Ptr); 93 | } 94 | 95 | // DecodePointer(VC2010) 96 | extern "C" PVOID WINAPI WRAPPER(DecodePointer)(PVOID Ptr) 97 | { 98 | struct implementation 99 | { 100 | static PVOID WINAPI impl(PVOID Ptr) 101 | { 102 | return XorPointer(Ptr); 103 | } 104 | }; 105 | 106 | CREATE_AND_RETURN(modules::kernel32, Ptr); 107 | } 108 | 109 | // GetModuleHandleExW (VC2012) 110 | extern "C" BOOL WINAPI WRAPPER(GetModuleHandleExW)(DWORD Flags, LPCWSTR ModuleName, HMODULE *Module) 111 | { 112 | struct implementation 113 | { 114 | static BOOL WINAPI impl(DWORD Flags, LPCWSTR ModuleName, HMODULE *Module) 115 | { 116 | if (Flags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS) 117 | { 118 | MEMORY_BASIC_INFORMATION mbi; 119 | if (!VirtualQuery(ModuleName, &mbi, sizeof(mbi))) 120 | return FALSE; 121 | 122 | const auto ModuleValue = static_cast(mbi.AllocationBase); 123 | 124 | if (!(Flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT)) 125 | { 126 | wchar_t Buffer[MAX_PATH]; 127 | if (!GetModuleFileNameW(ModuleValue, Buffer, ARRAYSIZE(Buffer))) 128 | return FALSE; 129 | // It's the same so not really necessary, but analysers report handle leak otherwise. 130 | *Module = LoadLibraryW(Buffer); 131 | } 132 | else 133 | { 134 | *Module = ModuleValue; 135 | } 136 | return TRUE; 137 | } 138 | 139 | // GET_MODULE_HANDLE_EX_FLAG_PIN not implemented 140 | 141 | if (const auto ModuleValue = (Flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT? GetModuleHandleW : LoadLibraryW)(ModuleName)) 142 | { 143 | *Module = ModuleValue; 144 | return TRUE; 145 | } 146 | return FALSE; 147 | } 148 | }; 149 | 150 | CREATE_AND_RETURN(modules::kernel32, Flags, ModuleName, Module); 151 | } 152 | 153 | // VC2015 154 | extern "C" void WINAPI WRAPPER(InitializeSListHead)(PSLIST_HEADER ListHead) 155 | { 156 | struct implementation 157 | { 158 | static void WINAPI impl(PSLIST_HEADER ListHead) 159 | { 160 | *ListHead = {}; 161 | } 162 | }; 163 | 164 | CREATE_AND_RETURN(modules::kernel32, ListHead); 165 | } 166 | 167 | #ifndef _WIN64 168 | static bool atomic_assign(PSLIST_HEADER To, SLIST_HEADER const& New, SLIST_HEADER const& Old) 169 | { 170 | return InterlockedCompareExchange64( 171 | static_cast(static_cast(&To->Alignment)), 172 | New.Alignment, 173 | Old.Alignment 174 | ) == static_cast(Old.Alignment); 175 | } 176 | #endif 177 | 178 | extern "C" PSLIST_ENTRY WINAPI WRAPPER(InterlockedFlushSList)(PSLIST_HEADER ListHead) 179 | { 180 | struct implementation 181 | { 182 | static PSLIST_ENTRY WINAPI impl(PSLIST_HEADER ListHead) 183 | { 184 | #ifdef _WIN64 185 | // The oldest x64 OS (XP) already has SList, so this shall never be called. 186 | DebugBreak(); 187 | return {}; 188 | #else 189 | if (!ListHead->Next.Next) 190 | return {}; 191 | 192 | SLIST_HEADER OldHeader, NewHeader{}; 193 | 194 | do 195 | { 196 | OldHeader = *ListHead; 197 | NewHeader.CpuId = OldHeader.CpuId; 198 | } 199 | while (!atomic_assign(ListHead, NewHeader, OldHeader)); 200 | 201 | return OldHeader.Next.Next; 202 | #endif 203 | } 204 | }; 205 | 206 | CREATE_AND_RETURN(modules::kernel32, ListHead); 207 | } 208 | 209 | extern "C" PSLIST_ENTRY WINAPI WRAPPER(InterlockedPushEntrySList)(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry) 210 | { 211 | struct implementation 212 | { 213 | static PSLIST_ENTRY WINAPI impl(PSLIST_HEADER ListHead, PSLIST_ENTRY ListEntry) 214 | { 215 | #ifdef _WIN64 216 | // The oldest x64 OS (XP) already has SList, so this shall never be called. 217 | DebugBreak(); 218 | return {}; 219 | #else 220 | SLIST_HEADER OldHeader, NewHeader; 221 | NewHeader.Next.Next = ListEntry; 222 | 223 | do 224 | { 225 | OldHeader = *ListHead; 226 | ListEntry->Next = OldHeader.Next.Next; 227 | NewHeader.Depth = OldHeader.Depth + 1; 228 | NewHeader.CpuId = OldHeader.CpuId; 229 | } 230 | while (!atomic_assign(ListHead, NewHeader, OldHeader)); 231 | 232 | return OldHeader.Next.Next; 233 | #endif 234 | } 235 | }; 236 | 237 | CREATE_AND_RETURN(modules::kernel32, ListHead, ListEntry); 238 | } 239 | 240 | // VC2017 241 | extern "C" BOOL WINAPI WRAPPER(GetNumaHighestNodeNumber)(PULONG HighestNodeNumber) 242 | { 243 | struct implementation 244 | { 245 | static BOOL WINAPI impl(PULONG HighestNodeNumber) 246 | { 247 | *HighestNodeNumber = 0; 248 | return TRUE; 249 | } 250 | }; 251 | 252 | CREATE_AND_RETURN(modules::kernel32, HighestNodeNumber); 253 | } 254 | 255 | // VC2017 256 | extern "C" BOOL WINAPI WRAPPER(GetLogicalProcessorInformation)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer, PDWORD ReturnLength) 257 | { 258 | struct implementation 259 | { 260 | static BOOL WINAPI impl(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD) 261 | { 262 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 263 | return FALSE; 264 | } 265 | }; 266 | 267 | CREATE_AND_RETURN(modules::kernel32, Buffer, ReturnLength); 268 | } 269 | 270 | // VC2019 271 | extern "C" BOOL WINAPI WRAPPER(SetThreadStackGuarantee)(PULONG StackSizeInBytes) 272 | { 273 | struct implementation 274 | { 275 | static BOOL WINAPI impl(PULONG) 276 | { 277 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 278 | return FALSE; 279 | } 280 | }; 281 | 282 | CREATE_AND_RETURN(modules::kernel32, StackSizeInBytes); 283 | } 284 | 285 | // VC2019 286 | extern "C" BOOL WINAPI WRAPPER(InitializeCriticalSectionEx)(LPCRITICAL_SECTION CriticalSection, DWORD SpinCount, DWORD Flags) 287 | { 288 | struct implementation 289 | { 290 | static int WINAPI impl(LPCRITICAL_SECTION CriticalSection, DWORD SpinCount, DWORD Flags) 291 | { 292 | InitializeCriticalSection(CriticalSection); 293 | CriticalSection->SpinCount = Flags | SpinCount; 294 | return TRUE; 295 | } 296 | }; 297 | 298 | CREATE_AND_RETURN(modules::kernel32, CriticalSection, SpinCount, Flags); 299 | } 300 | 301 | static LCID locale_name_to_lcid(const wchar_t* LocaleName) 302 | { 303 | if (!LocaleName) 304 | return LOCALE_USER_DEFAULT; 305 | 306 | if (!*LocaleName) 307 | return LOCALE_INVARIANT; 308 | 309 | if (!lstrcmp(LocaleName, LOCALE_NAME_SYSTEM_DEFAULT)) 310 | return LOCALE_SYSTEM_DEFAULT; 311 | 312 | return LOCALE_USER_DEFAULT; 313 | } 314 | 315 | // VC2019 316 | extern "C" int WINAPI WRAPPER(CompareStringEx)(LPCWSTR LocaleName, DWORD CmpFlags, LPCWCH String1, int Count1, LPCWCH String2, int Count2, LPNLSVERSIONINFO VersionInformation, LPVOID Reserved, LPARAM Param) 317 | { 318 | struct implementation 319 | { 320 | static int WINAPI impl(LPCWSTR LocaleName, DWORD CmpFlags, LPCWCH String1, int Count1, LPCWCH String2, int Count2, LPNLSVERSIONINFO, LPVOID, LPARAM) 321 | { 322 | return CompareStringW(locale_name_to_lcid(LocaleName), CmpFlags, String1, Count1, String2, Count2); 323 | } 324 | }; 325 | 326 | CREATE_AND_RETURN(modules::kernel32, LocaleName, CmpFlags, String1, Count1, String2, Count2, VersionInformation, Reserved, Param); 327 | } 328 | 329 | // VC2019 330 | extern "C" int WINAPI WRAPPER(LCMapStringEx)(LPCWSTR LocaleName, DWORD MapFlags, LPCWSTR SrcStr, int SrcCount, LPWSTR DestStr, int DestCount, LPNLSVERSIONINFO VersionInformation, LPVOID Reserved, LPARAM SortHandle) 331 | { 332 | struct implementation 333 | { 334 | static int WINAPI impl(LPCWSTR LocaleName, DWORD MapFlags, LPCWSTR SrcStr, int SrcCount, LPWSTR DestStr, int DestCount, LPNLSVERSIONINFO, LPVOID, LPARAM) 335 | { 336 | return LCMapStringW(locale_name_to_lcid(LocaleName), MapFlags, SrcStr, SrcCount, DestStr, DestCount); 337 | } 338 | }; 339 | 340 | CREATE_AND_RETURN(modules::kernel32, LocaleName, MapFlags, SrcStr, SrcCount, DestStr, DestCount, VersionInformation, Reserved, SortHandle); 341 | } 342 | 343 | // VC2022 344 | extern "C" BOOL WINAPI WRAPPER(SleepConditionVariableSRW)(PCONDITION_VARIABLE ConditionVariable, PSRWLOCK SRWLock, DWORD Milliseconds, ULONG Flags) 345 | { 346 | struct implementation 347 | { 348 | static BOOL WINAPI impl(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG) 349 | { 350 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 351 | return FALSE; 352 | } 353 | }; 354 | 355 | CREATE_AND_RETURN(modules::kernel32, ConditionVariable, SRWLock, Milliseconds, Flags); 356 | } 357 | 358 | // VC2022 359 | extern "C" void WINAPI WRAPPER(WakeAllConditionVariable)(PCONDITION_VARIABLE ConditionVariable) 360 | { 361 | struct implementation 362 | { 363 | static void WINAPI impl(PCONDITION_VARIABLE) 364 | { 365 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 366 | } 367 | }; 368 | 369 | CREATE_AND_RETURN(modules::kernel32, ConditionVariable); 370 | } 371 | 372 | // VC2022 373 | extern "C" void WINAPI WRAPPER(AcquireSRWLockExclusive)(PSRWLOCK SRWLock) 374 | { 375 | struct implementation 376 | { 377 | static void WINAPI impl(PSRWLOCK) 378 | { 379 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 380 | } 381 | }; 382 | 383 | CREATE_AND_RETURN(modules::kernel32, SRWLock); 384 | } 385 | 386 | // VC2022 387 | extern "C" void WINAPI WRAPPER(ReleaseSRWLockExclusive)(PSRWLOCK SRWLock) 388 | { 389 | struct implementation 390 | { 391 | static void WINAPI impl(PSRWLOCK) 392 | { 393 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 394 | } 395 | }; 396 | 397 | CREATE_AND_RETURN(modules::kernel32, SRWLock); 398 | } 399 | 400 | // VC2022 401 | extern "C" BOOLEAN WINAPI WRAPPER(TryAcquireSRWLockExclusive)(PSRWLOCK SRWLock) 402 | { 403 | struct implementation 404 | { 405 | static BOOLEAN WINAPI impl(PSRWLOCK) 406 | { 407 | SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 408 | return FALSE; 409 | } 410 | }; 411 | 412 | CREATE_AND_RETURN(modules::kernel32, SRWLock); 413 | } 414 | 415 | // VC2019 416 | extern "C" void WINAPI WRAPPER(InitializeSRWLock)(PSRWLOCK SRWLock) 417 | { 418 | struct implementation 419 | { 420 | static void WINAPI impl(PSRWLOCK SRWLock) 421 | { 422 | *SRWLock = SRWLOCK_INIT; 423 | } 424 | }; 425 | 426 | CREATE_AND_RETURN(modules::kernel32, SRWLock); 427 | } 428 | 429 | extern "C" DWORD WINAPI WRAPPER(FlsAlloc)(PFLS_CALLBACK_FUNCTION Callback) 430 | { 431 | struct implementation 432 | { 433 | static DWORD WINAPI impl(PFLS_CALLBACK_FUNCTION) 434 | { 435 | return TlsAlloc(); 436 | } 437 | }; 438 | 439 | CREATE_AND_RETURN(modules::kernel32, Callback); 440 | } 441 | 442 | extern "C" PVOID WINAPI WRAPPER(FlsGetValue)(DWORD FlsIndex) 443 | { 444 | struct implementation 445 | { 446 | static PVOID WINAPI impl(DWORD FlsIndex) 447 | { 448 | return TlsGetValue(FlsIndex); 449 | } 450 | }; 451 | 452 | CREATE_AND_RETURN(modules::kernel32, FlsIndex); 453 | } 454 | 455 | extern "C" BOOL WINAPI WRAPPER(FlsSetValue)(DWORD FlsIndex, PVOID FlsData) 456 | { 457 | struct implementation 458 | { 459 | static BOOL WINAPI impl(DWORD FlsIndex, PVOID FlsData) 460 | { 461 | return TlsSetValue(FlsIndex, FlsData); 462 | } 463 | }; 464 | 465 | CREATE_AND_RETURN(modules::kernel32, FlsIndex, FlsData); 466 | } 467 | 468 | extern "C" BOOL WINAPI WRAPPER(FlsFree)(DWORD FlsIndex) 469 | { 470 | struct implementation 471 | { 472 | static BOOL WINAPI impl(DWORD FlsIndex) 473 | { 474 | return TlsFree(FlsIndex); 475 | } 476 | }; 477 | 478 | CREATE_AND_RETURN(modules::kernel32, FlsIndex); 479 | } 480 | 481 | // added to original file for FarColorer 482 | #include "yy_thunks_impl.h" 483 | 484 | extern "C" int WINAPI WRAPPER(GetLocaleInfoEx)(LPCWSTR lpLocaleName, LCTYPE LCType, LPWSTR lpLCData, int cchData) 485 | { 486 | struct implementation 487 | { 488 | static int WINAPI impl(LPCWSTR lpLocaleName, LCTYPE LCType, LPWSTR lpLCData, int cchData) 489 | { 490 | auto Locale = LocaleNameToLCID(lpLocaleName, 0); 491 | 492 | if (Locale == 0) 493 | { 494 | SetLastError(ERROR_INVALID_PARAMETER); 495 | return 0; 496 | } 497 | return GetLocaleInfoW(Locale, LCType, lpLCData, cchData); 498 | } 499 | }; 500 | 501 | CREATE_AND_RETURN(modules::kernel32, lpLocaleName, LCType, lpLCData, cchData); 502 | } 503 | 504 | extern "C" LCID WINAPI WRAPPER(LocaleNameToLCID)(LPCWSTR lpName, DWORD dwFlags) 505 | { 506 | struct implementation 507 | { 508 | static LCID WINAPI impl(LPCWSTR lpName, DWORD dwFlags) 509 | { 510 | return local_LocaleNameToLCID(lpName, dwFlags); 511 | } 512 | }; 513 | 514 | CREATE_AND_RETURN(modules::kernel32, lpName, dwFlags); 515 | } 516 | 517 | // end FarColorer 518 | 519 | #undef CREATE_AND_RETURN 520 | #undef WRAPPER 521 | 522 | // disable VS2015 telemetry 523 | extern "C" 524 | { 525 | void __vcrt_initialize_telemetry_provider() {} 526 | void __telemetry_main_invoke_trigger() {} 527 | void __telemetry_main_return_trigger() {} 528 | void __vcrt_uninitialize_telemetry_provider() {} 529 | } 530 | -------------------------------------------------------------------------------- /misc/Plugin.Colorer.lua: -------------------------------------------------------------------------------- 1 | local ColorerGUID = "D2F36B62-A470-418D-83A3-ED7A3710E5B5"; 2 | 3 | Macro { 4 | area = "Editor"; 5 | description = "Colorer: Find Errors"; 6 | key = "/.Alt'/"; 7 | condition = function() 8 | return Plugin.Exist(ColorerGUID) 9 | end; 10 | action = function() 11 | Plugin.Call(ColorerGUID, "Errors", "Show") 12 | end; 13 | } 14 | 15 | Macro { 16 | area = "Editor"; 17 | description = "Colorer: List Functions"; 18 | key = "/.Alt;/"; 19 | condition = function() 20 | return Plugin.Exist(ColorerGUID) 21 | end; 22 | action = function() 23 | Plugin.Call(ColorerGUID, "Functions", "Show") 24 | end; 25 | } 26 | 27 | Macro { 28 | area = "Editor"; 29 | description = "Colorer: List Functions"; 30 | key = "F5"; 31 | condition = function() 32 | return Plugin.Exist(ColorerGUID) 33 | end; 34 | action = function() 35 | Plugin.Call(ColorerGUID, "Functions", "Show") 36 | end; 37 | } 38 | 39 | Macro { 40 | area = "Editor"; 41 | description = "Colorer: Select Region"; 42 | key = "/.AltK/"; 43 | condition = function() 44 | return Plugin.Exist(ColorerGUID) 45 | end; 46 | action = function() 47 | Plugin.Call(ColorerGUID, "Region", "Select") 48 | end; 49 | } 50 | 51 | Macro { 52 | area = "Editor"; 53 | description = "Colorer: List Types"; 54 | key = "/.AltL/"; 55 | condition = function() 56 | return Plugin.Exist(ColorerGUID) 57 | end; 58 | action = function() 59 | Plugin.Call(ColorerGUID, "Types", "Menu") 60 | end; 61 | } 62 | 63 | Macro { 64 | area = "Editor"; 65 | description = "Colorer: Find Function"; 66 | key = "/.AltO/"; 67 | condition = function() 68 | return Plugin.Exist(ColorerGUID) 69 | end; 70 | action = function() 71 | Plugin.Call(ColorerGUID, "Functions", "Find") 72 | end; 73 | } 74 | 75 | Macro { 76 | area = "Editor"; 77 | description = "Colorer: Select Pair"; 78 | key = "/.AltP/"; 79 | condition = function() 80 | return Plugin.Exist(ColorerGUID) 81 | end; 82 | action = function() 83 | Plugin.Call(ColorerGUID, "Brackets", "SelectAll") 84 | end; 85 | } 86 | 87 | Macro { 88 | area = "Editor"; 89 | description = "Colorer: Reload Colorer"; 90 | key = "/.AltR/"; 91 | condition = function() 92 | return Plugin.Exist(ColorerGUID) 93 | end; 94 | action = function() 95 | Plugin.Call(ColorerGUID, "Settings", "Reload") 96 | end; 97 | } 98 | 99 | Macro { 100 | area = "Editor"; 101 | description = "Colorer: Match Pair"; 102 | key = "/.Alt\\[/"; 103 | condition = function() 104 | return Plugin.Exist(ColorerGUID) 105 | end; 106 | action = function() 107 | Plugin.Call(ColorerGUID, "Brackets", "Match") 108 | end; 109 | } 110 | 111 | Macro { 112 | area = "Editor"; 113 | description = "Colorer: Select Block"; 114 | key = "/.Alt]/"; 115 | condition = function() 116 | return Plugin.Exist(ColorerGUID) 117 | end; 118 | action = function() 119 | Plugin.Call(ColorerGUID, "Brackets", "SelectIn") 120 | end; 121 | } 122 | 123 | Macro { 124 | area = "Editor"; 125 | description = "Colorer: Cross in current editor on/off"; 126 | key = "/.CtrlShiftC/"; 127 | condition = function() 128 | return Plugin.Exist(ColorerGUID) 129 | end; 130 | action = function() 131 | visible, style = Plugin.Call(ColorerGUID, "Editor", "CrossVisible") 132 | if (visible == 1) then 133 | visible = 0 134 | else 135 | visible = 1 136 | end 137 | Plugin.Call(ColorerGUID, "Editor", "CrossVisible", visible) 138 | end; 139 | } -------------------------------------------------------------------------------- /misc/colorere.hlf: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | .PluginContents=FarColorer 3 | 4 | @contents 5 | $# FarColorer 6 | 7 | ~Settings menu.~@settingsmenu@ 8 | ~Plugin setup.~@config@ 9 | ~Schemes settings.~@confighrc@ 10 | ~Logging settings.~@configlog@ 11 | ~Command line support.~@cmdline@ 12 | ~Plugin's menus.~@menu@ 13 | 14 | ~Using a plugin in macros:~@MacroCallPlugin@ 15 | ~Macro functions.~@MacroCall@ 16 | ~Plugin Guids.~@PluginGuids 17 | 18 | ~About authors.~@author@ 19 | 20 | @settingsmenu 21 | $# Settings 22 | 23 | #Main settings# 24 | Open dialog for main settings. 25 | 26 | #Schemes settings# 27 | Open dialog for shemes settings. The dialog does not work if the plugin is disabled. 28 | 29 | #Logging settings# 30 | Open dialog for log settings. 31 | 32 | #Test schema library# 33 | Tests ability to load all the language of schemes, taking the path to catalog.xml from the settings window. 34 | 35 | @config 36 | $# FarColorer's settings 37 | 38 | #Enabled# 39 | Enable/Disable FarColorer. 40 | 41 | #catalog.xml file:# 42 | Full file path sets default catalog file for FarColorer. If this field is empty FarColorer trying to find the file automatically in a subfolder of "base" parent directory plugin. 43 | 44 | #Users file of schemes# 45 | Full file path in this field specifies a file analogous to proto.hrc, or a directory with files containing with user schemes. If a directory is specified, only * .hrc files are processed. 46 | 47 | #Users file of color styles# 48 | Full file path sets the users file of color styles. 49 | 50 | #Color style:# 51 | Choose a color style, which will be used for coloring text. The choice does not work if the plugin is disabled. 52 | 53 | #TrueMod Enabled# 54 | Enable/Disable TrueMod in plugin. 55 | 56 | #TrueMod color style:# 57 | Choose a color style, which will be used for coloring text in TrueMod. The choice does not work if the plugin is disabled. 58 | 59 | #Pairs# 60 | Allocate or not paired language elements (brackets, quotes). 61 | 62 | #Syntax# 63 | Turns on display of syntax 64 | 65 | #Classic outline style# 66 | In classic style displays only the name of the function. Otherwise show the beginning of the line number, then the first letter in the function and the function name itself. 67 | 68 | #Change background editor# 69 | In the set condition, FarColorer set in System Preferences color of "Plain Text" color group "editor" such as and the default color for the color scheme FarColorer. The effect is visible on the files, the number of rows in less than window height editor. 70 | 71 | #Cross# 72 | [ ] Do not show ever 73 | [?] Show if included in the scheme. 74 | [x] Always Show. 75 | 76 | #Cross style# 77 | Cross style shown when "[x] Cross". 78 | 79 | #Period for build# 80 | The frequency, in milliseconds, at which Far call "background" parsing of the file in Colorer. The lower value - the faster large file is drawn, but the responsiveness of the screen drops. 81 | 82 | #{ Ok }# 83 | Closes dialog and save settings. 84 | 85 | @confighrc 86 | $# Schemes settings 87 | For each of the selected schemes, a list of parameters that affect the mapping coloring. Parameter value - the value set for this parameter. Values of the form shows that the parameter is "znach." It is set in the system (non-user) settings of the scheme or scheme is taken from default. Save all the changes occurs after clicking "OK" button. 88 | 89 | @configlog 90 | $# Logging settings 91 | 92 | #Enable logging# 93 | Enable/Disable logging. 94 | 95 | #Logging level# 96 | Log level from list. 97 | 98 | #Log path# 99 | Path to folder where log files will be stored. 100 | 101 | @cmdline 102 | $# Command line support 103 | You can use the plugin from FAR's command line with prefix 'clr:' to view files with syntax highlighting in FarColorer's internal viewer. To view file you have to specify file name after the 'clr:' prefix in FAR's command line. 104 | This function is equal to #colorer.exe# program features, but doesn't load HRC database each time, so it works faster. 105 | 106 | @add 107 | $# Outliner 108 | Here you can see a list of all functions or syntax errors found. Choose any item to go to corresponding line in text. 109 | 110 | You can use keyboard filter to quickly search for required items: 111 | 112 | #Ctrl-Left/Right# 113 | Expand-Collapse level of Outliner. 114 | 115 | #Ctrl-Up/Down# 116 | Move to next/previous item both in outliner and in source code. 117 | 118 | #Ctrl-Enter# 119 | Close the outliner and insert current item into the cursor position. 120 | 121 | #Enter# 122 | Close the outliner and jump to the selected item. 123 | 124 | #Tab# 125 | Complementing filter symbols, written after '?' in the field of display filter. 126 | 127 | #Symbol keys [0-9a-z;:-_]# 128 | Filter out the outliner items against entered filter. 129 | 130 | @menu 131 | $# FarColorer operation 132 | 133 | #1 List types# 134 | Lists all supported file types. You can choose any of them to use with current editor. 135 | 136 | #2 Match pair# 137 | Searches paired bracket (or any other pair structure) of the current region under cursor and jumps there. 138 | 139 | #3 Select block# 140 | Moves cursor to start of block and selects it all. You can call this function as on block limits as inside it. In second case FarColorer will find start and end of nearest block automatically. 141 | 142 | #4 Select pair# 143 | Selects pair block - but don't selects pair structures at start and end. 144 | 145 | #5 Outliner List# 146 | Shows all outlined regions in current file. There you can choose and jump into any of them, also you can use there any alphabetic symbols to create filters. 147 | 148 | #6 Errors List# 149 | As previous - but shows all errors in the text. 150 | 151 | #*# All these features are depend on the content of language scheme. All information is taken from syntax regions analysis. 152 | 153 | #7 Select region# 154 | Selects region under cursor. 155 | 156 | #Region info# 157 | Displays the name of the region and the scheme under the cursor. 158 | 159 | #8 Find function# 160 | Searches function name under cursor in outliner view, and jumps there. 161 | 162 | #9 Update highlight# 163 | Updates syntax highlighting in current editor. Use it, ifsome problems occurs in current syntax. 164 | 165 | #R Reload schema library# 166 | Reload the configuration plugin and library schemes. 167 | 168 | #C Configuration# 169 | Calls FarColorer ~configuration menu~@settingsmenu@. 170 | 171 | @PluginGuids 172 | $# Plugin Guids 173 | Plugin Guid - {D2F36B62-A470-418d-83A3-ED7A3710E5B5} 174 | 175 | #Dialog# 176 | Main settings - {87C92249-430D-4334-AC33-05E7423286E9} 177 | Scheme settings - {0497F43A-A8B9-4af1-A3A4-FA568F455707} 178 | Logging settings - {3D1031EA-B67A-451C-9FC6-081320D3A139} 179 | Define hot key - {C6BE56D8-A80A-4f7d-A331-A711435F2665} 180 | 181 | #Menu# 182 | Main menu in editor - {45453CAC-499D-4b37-82B8-0A77F7BD087C} 183 | Settings - {63E396BA-8E7F-4E38-A7A8-CBB7E9AC1E6D} 184 | Syntax choose - {46921647-DB52-44CA-8D8B-F34EA8B02E5D} 185 | Color styles - {18A6F7DF-375D-4d3d-8137-DC50AC52B71E} 186 | Outliner/error list - {A8A298BA-AD5A-4094-8E24-F65BF38E6C1F} 187 | 188 | #Message# 189 | Error - {0C954AC8-2B69-4c74-94C8-7AB10324A005} 190 | Reload base - {DEE3B49D-4A55-48a8-9DC8-D11DA04CBF37} 191 | Nothing found - {AB214DCE-450B-4389-9E3B-533C7A6D786C} 192 | Region name - {70656884-B7BD-4440-A8FF-6CE781C7DC6A} 193 | 194 | @MacroCallPlugin 195 | $# Using a plugin in macros 196 | The plugin can be called from a macro using the macro function Plugin.Call(GUID,[param]). 197 | Call format: 198 | 199 | #Plugin.Call("D2F36B62-A470-418d-83A3-ED7A3710E5B5",)# 200 | 201 | Here: 202 | #D2F36B62-A470-418d-83A3-ED7A3710E5B5# 203 | ~Guid of the plugin~@PluginGuids@ 204 | 205 | ## 206 | different parameters 207 | 208 | ~Macro functions.~@MacroCall@ 209 | 210 | @MacroCall 211 | $# Macro Functions 212 | 213 | #Работа с макросами.# 214 | Формат вызова функций #Plugin.Call("D2F36B62-A470-418d-83A3-ED7A3710E5B5",... )#, либо #Plugin.SyncCall#. 215 | Вызов всех функций регистро-независимый. 216 | Возвращаемое значение, если не указано отдельно, "true" - успешно, "false" - ошибка. 217 | 218 | #Работа с глобальными настройками# 219 | Ограничений на макрорегионы не установлено. 220 | 221 | #...,"Settings",, )# 222 | 223 | - принимает следующие значения: 224 | 225 | "Menu" - Открывает меню настроек. Значение по умолчанию если пустой. 226 | "Main" - Открывает окно главных настроек 227 | "Log" - Открывает окно настроек логирования 228 | "Hrc" - Открывает окно настроек параметров схем 229 | "Reload" - Перезагружает все настройки плагина и открытых редакторов. Включая библиотеку схему. 230 | "Status" - статус активности плагина. 231 | - number: 232 | 0 - disable; 233 | 1 - enable; 234 | Либо boolean: "false" -disable, "true" - enable. 235 | Если задан то применяется новый статус с перезагрузкой всех настроек. Возвращает предыдущее значение. Если не задан возвращает текущее значение. 236 | "SaveSettings" - Сохраняет настройки плагина. 237 | 238 | #Работа с меню# 239 | Работает только в MACROAREA_EDITOR. 240 | 241 | #...,"Menu")# 242 | Открывает меню плагина в редакторе. 243 | 244 | #Работа с типами файлов# 245 | Работает только в MACROAREA_EDITOR. 246 | 247 | #...,"Types",, )# 248 | 249 | - принимает следующие значения: 250 | 251 | "Menu" - Открывает меню выбора типа файлов. 252 | "List" - Возвращает массив названий всех доступных типов файлов. 253 | "Get" - Возвращает текущий тип (первый параметр) и группу файла (второй параметр). 254 | "Set" - Устанавливает для файла открытого в редакторе указанный тип. 255 | - строка, тип файла 256 | 257 | #Работа с параметрами типов файлов# 258 | Ограничений на макрорегионы не установлено. Все изменения применяются только для текущего сеанса плагина. Для сохранения изменений необходимо вызывать "SaveSettings", для сброса "Reload". 259 | 260 | #...,"ParamsOfType",, ,...)# 261 | 262 | "List" - Список параметров типа 263 | - название типа. Строка. Регистро-зависимо. 264 | Возвращает 265 | - массив названий параметров. 266 | - массив значений этих параметров. В случае отсутствия значения у параметра возвращается "nil". 267 | "Get" - Возвращает значение параметра. Тип - всегда строка. 268 | - название типа. Строка. Регистро-зависимо. 269 | - название параметра. Строка. Регистро-зависимо. В случае отсутствия значения возвращается "nil". 270 | "Set" - Устанавливает значение для параметра или удаляет его. 271 | - название типа. Строка. Регистро-зависимо. 272 | - название параметра. Строка. Регистро-зависимо. 273 | - значение параметра. Строка. Если не передан то удаляется пользовательское значение параметра. Если передана пустая строка то это значение присваивается параметру. 274 | 275 | #Работа с скобками# 276 | Работает только в MACROAREA_EDITOR. 277 | 278 | #...,"Brackets",)# 279 | 280 | - принимает следующие значения: 281 | 282 | "Match" - Найти парную скобку. 283 | "SelectAll" - Выделить блок со скобками. 284 | "SelectIn" - Выделить блок между скобок. 285 | 286 | #Работа с регионами# 287 | Работает только в MACROAREA_EDITOR. 288 | 289 | #...,"Region",)# 290 | 291 | - принимает следующие значения: 292 | 293 | "Select" - Выбрать текущий регион. 294 | "Show" - Показать окно с данными региона. 295 | "List" - Возвращает описание региона. Первый параметр регион, второй схема. 296 | 297 | #Работа с функциями# 298 | Работает только в MACROAREA_EDITOR. 299 | 300 | #...,"Functions",)# 301 | 302 | - принимает следующие значения: 303 | 304 | "Show" - Показать окно со списком функций. 305 | "Find" - Найти функцию, на которой стоит курсор. 306 | "List" - Возвращает массив всех найденных функций и массив номеров строк в которых они объявлены. 307 | 308 | #Работа с ошибками# 309 | Работает только в MACROAREA_EDITOR. 310 | 311 | #...,"Errors",)# 312 | 313 | - принимает следующие значения: 314 | 315 | "Show" - Показать окно со списком ошибок 316 | "List" - Возвращает массив всех найденных ошибок и массив номеров строк в которых они найдены. 317 | 318 | #Работа с параметрами текущего редактора# 319 | При закрытии редактора данные параметры не сохраняются. 320 | Работает только в MACROAREA_EDITOR. 321 | 322 | #...,"Editor",,,...)# 323 | 324 | - принимает следующие значения: 325 | 326 | "Refresh" - обновляет раскраску. 327 | "Status" - Статус активности плагина для текущего редактора: 328 | - number: 329 | 0 - disable; 330 | 1 - enable; 331 | Если задан то изменяется текущее и возвращает предыдущее значение. 332 | Если не задан, возвращает текущее значение для данного редактора 333 | "CrossVisible" - Видимость и тип креста в редакторе: 334 | Возвращает текущий стиль креста и правила отображения для данного редактора. 335 | - number: 336 | 0 - disable; 337 | 1 - enable; 338 | 2 - согласно параметрам схемы. 339 | - number: 340 | 0 - not displayed; 341 | 1 - vertical; 342 | 2 - horizontal; 343 | 3 - полный крест. 344 | Если указаны дополнительные параметры то изменяет стиль и правила отображения. 345 | - number: 346 | 0 - disable; 347 | 1 - enable; 348 | 2 - согласно параметрам схемы 349 | - необязательный, number: 350 | 1 - vertical; 351 | 2 - horizontal; 352 | 3 - полный крест. 353 | "Pair" - Статус отображения парных элементов: 354 | - number: 355 | 0 - disable; 356 | 1 - enable; 357 | Если задан то изменяется текущее и возвращает предыдущее значение. 358 | Если не задан, возвращает текущее значение для данного редактора. 359 | "Syntax" - статус отображения синтаксиса: 360 | - number: 361 | 0 - disable; 362 | 1 - enable; 363 | Если задан то изменяется текущее и возвращает предыдущее значение. 364 | Если не задан, то возвращает текущее значение для данного редактора. 365 | "Progress" - возвращает процент парсинга текущего файла в редакторе. Целочисленное значение. 366 | 367 | @hrd 368 | $# Color style selection 369 | List of all available color schemes. You can choose what you need. 370 | 371 | @exception 372 | $# Exception occured 373 | Exception happened while FarColorer work. All further processing would be disabled. You can re-enable FarColorer from it's settings menu after locating and removing exception cause. All extended information in FarColorer logging file (colorer.log by default) 374 | 375 | @filetypechoose 376 | $# List types 377 | The list contains all of the supported file types. By choosing any, you force the type of coloring the current file. 378 | 379 | #Automatic detection# - select the type of file produced plugin built rules. 380 | #Favorites# - The list of chosen types. Add to "Favorites" is produced by pressing the Ins, delete - Delete. 381 | #Hot keys# - to assign a hot key to the file type you need to press F4, and in the dialog box to specify the key. 382 | 383 | Hot keys and being in the group "Favorites" can also be customized through the ~Schemes settings.~@confighrc@ These are the parameters 'hotkey' and 'favorite' for any of the schemes. 384 | 385 | @keyassign 386 | $# Define key 387 | Keys 0-9, A-Z 388 | 389 | @author 390 | $# FarColorer is a syntax highlighting plugin for FAR Manager. 391 | #Plugin home site# 392 | http://colorer.sf.net/ 393 | 394 | #Igor Ruskih# (Cail Lomecb) Copyright (c) 1999-2009 395 | email : irusskih at gmail dot com 396 | web : http://cail.nm.ru 397 | 398 | #Eugene Efremov# 399 | email : 4mirror at mail dot ru 400 | 401 | #ctapmex# (Aleksey Dobrunov) Copyright (c) 2009-2021 402 | email : ctapmex at gmail dot com 403 | web : http://dobrunov.ru 404 | -------------------------------------------------------------------------------- /misc/colorere.lng: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | 3 | "FarColorer" 4 | 5 | "FarColorer's settings" 6 | 7 | "&Enabled" 8 | "TrueMod E&nabled" 9 | "&Pairs" 10 | "S&yntax" 11 | 12 | "Class&ic outline style" 13 | 14 | "&OK" 15 | "&Test schema library" 16 | "&Cancel" 17 | 18 | "c&atalog.xml file:" 19 | "Colo&r style:" 20 | "TrueMod color s&tyle:" 21 | 22 | "&1 List types" 23 | "&2 Match pair" 24 | "&3 Select block" 25 | "&4 Select pair" 26 | "&5 Outliner list" 27 | "&6 Errors list" 28 | "&7 Select region" 29 | "&A Region info" 30 | "&8 Find Function" 31 | "&9 Update highlighting" 32 | "&R Reload schema library" 33 | "&C Configure" 34 | 35 | "Total %d types" 36 | "Select syntax" 37 | "Outliner [%s]" 38 | "Nothing found" 39 | "Gotcha" 40 | "[Ctrl]Enter, Tab, Ctrl-Cursor, [0-9a-z;:-_]" 41 | 42 | "Reloading schema library..." 43 | "Ok" 44 | "Change Editor &background" 45 | "&Users file of color styles" 46 | "Users &file of schemes" 47 | "&Scheme settings" 48 | "Scheme settings" 49 | "&Scheme" 50 | "&Parameters" 51 | "Parameter &value" 52 | "&A Automatic detection" 53 | "Favorites" 54 | "&D Disable" 55 | "Define key" 56 | "Press the desired key" 57 | "Region name" 58 | "&Logging settings" 59 | "Logging settings" 60 | "&Enable logging" 61 | "Logging &level" 62 | "Log &directory" 63 | "&Main settings" 64 | "Settings" 65 | "Style configuration" 66 | "Cross sty&le:" 67 | "both" 68 | "vertical" 69 | "horizontal" 70 | "Cro&ss" 71 | 72 | "Performance" 73 | "Build perio&d" -------------------------------------------------------------------------------- /misc/colorerpol.lng: -------------------------------------------------------------------------------- 1 | .Language=Polish,Polish (Polski) 2 | 3 | "FarColorer" 4 | 5 | "Ustawienia" 6 | 7 | "&Włącz" 8 | "Włącz True&Mod" 9 | "&Pary" 10 | "&Składnia" 11 | 12 | "Klasyczny styl obramowa&nia" 13 | 14 | "&OK" 15 | "Sprawdź &bibliotekę schematów" 16 | "&Anuluj" 17 | 18 | "Plik catalog.&xml:" 19 | "S&tyl koloru:" 20 | "Sty&l koloru:" 21 | 22 | "&1 Lista typów" 23 | "&2 Znajdź parę" 24 | "&3 Zaznacz blok" 25 | "&4 Zaznacz parę" 26 | "&5 Lista rozdziałów" 27 | "&6 Lista błędów" 28 | "&7 Wybierz zakres" 29 | "&A Info o zakresie" 30 | "&8 Znajdź funkcję" 31 | "&9 Uaktualnij kolorowanie" 32 | "&S Przeładuj bibliotekę schematów" 33 | "&K Konfiguruj" 34 | 35 | "Razem %d typów" 36 | "Wybierz składnię" 37 | "Rozdział [%s]" 38 | "Nie znaleziono" 39 | "Gotowe" 40 | "[Ctrl]Enter, Tab, Ctrl-Cursor, [0-9a-z;:-_]" 41 | 42 | "Odświeżanie biblioteki schematów..." 43 | "OK" 44 | "Zmień tło &edytora" 45 | "Pliki stylów kolorów &użytkownika" 46 | "Pliki schematów uż&ytkownika" 47 | "Ustawienia &schematów" 48 | "Ustawienia schematu" 49 | "Schem.:" 50 | "Parametry" 51 | "Wartość parametru" 52 | "&A Automatyczne wykrywanie" 53 | "Ulubione" 54 | "Zdefiniuj skrót" 55 | "&W Wyłącz" 56 | "Wciśnij żądany klawisz" 57 | "Nazwa zakresu" 58 | "Ustawienia &logowania" 59 | "Ustawienia logowania" 60 | "&Włącz logowanie" 61 | "Poziom &logowania" 62 | "Ścieżka &dziennika" 63 | "Ustawienia &główne" 64 | "Ustawienia" 65 | "Konfiguracja stylu" 66 | "Styl &ramek:" 67 | "obie" 68 | "pionowa" 69 | "pozioma" 70 | "&Krzyż" 71 | 72 | "Wydajność" 73 | "C&zas odświeżania" 74 | -------------------------------------------------------------------------------- /misc/colorerr.hlf: -------------------------------------------------------------------------------- 1 | .Language=Russian,Russian (Русский) 2 | .PluginContents=FarColorer 3 | 4 | @contents 5 | $# FarColorer 6 | 7 | ~Меню настроек.~@settingsmenu@ 8 | ~Настройка плагина.~@config@ 9 | ~Настройка схем.~@confighrc@ 10 | ~Настройка логирования.~@configlog@ 11 | ~Командная строка.~@cmdline@ 12 | ~Меню плагина в редакторе.~@menu@ 13 | 14 | ~Использование плагина в макросах:~@MacroCallPlugin@ 15 | ~Макрофункции.~@MacroCall@ 16 | ~Идентификаторы плагина.~@PluginGuids 17 | 18 | ~Об авторах.~@author@ 19 | 20 | Всю информацию по инсталляции и работе с FarColorer ищите текстовых файлах в архивах плагина и в документации по библиотеке. 21 | 22 | @settingsmenu 23 | $# Settings 24 | 25 | #Основные настройки# 26 | Вызывает диалог с главными настройками плагина 27 | 28 | #Настройки схем# 29 | Вызывает диалог настройки параметров схем. Диалог не работает если плагин отключен. 30 | 31 | #Настройки логирования# 32 | Вызывает диалог настройки логирования. 33 | 34 | #Тест библиотеки схем# 35 | Тестирует возможность загрузки всех языковых схем беря путь до catalog.xml из окна настроек. 36 | 37 | @config 38 | $# Настройки плагина. 39 | 40 | Диалог настройки (#Параметры# - #Параметры внешних модулей# - #FarColorer#) позволяет настроить некоторые параметры плагина: 41 | 42 | #Включить# 43 | Включает/Отключает плагин в редакторе. 44 | 45 | #Файл catalog.xml# 46 | Полный путь в этом поле задает базовый файл настроек catalog.xml. При обычной установке плагина FarColorer ищет этот файл в подпапке base папки плагина. 47 | 48 | #Файл списка схем пользователя# 49 | Полный путь в этом поле задает файл аналог proto.hrc, или директорию с файлами, содержащими пользовательскиe схемы. В случае указания директории обрабатываются только *.hrc файлы. 50 | 51 | #Файл цветовых стилей пользователя# 52 | Полный путь в этом поле задает файл со списком цветовых стилей. 53 | 54 | #Цветовой стиль# 55 | Выбор цветового стиля который будет использоваться при раскраске текста. Выбор не работает если плагин отключен. 56 | 57 | #TrueMod Включить# 58 | Включает/Отключает TrueMod режим работы плагина. 59 | 60 | #TrueMod Цветовой стиль# 61 | Выбор цветового стиля который будет использоваться при раскраске текста в режиме TrueMod. Выбор не работает если плагин отключен или недоступен режим TrueMod. 62 | 63 | #Выделять парные элементы# 64 | Выделять или нет парные элементы языка (скобки, кавычки). 65 | 66 | #Показывать синтаксис# 67 | Включает/Отключает показ синтаксиса. 68 | 69 | #Классический стиль списка функций# 70 | В классическом стиле отображается только имя функции. Иначе показывается c начала номер строки, потом первая буква в функции и само имя функции. 71 | 72 | #Изменять цвет фона редактора# 73 | Во включенном состоянии FarColorer устанавливает в системных настройках цвет элемента "Обычный текст" цветовой группы "Редактор" таким же как и цвет по умолчанию для цветовой схемы FarColorer. Эффект виден на файлах количество строк в которых меньше высоты окна редактора. 74 | 75 | #Показать крест# 76 | [ ] Не показывать никогда. 77 | [?] Показывать если включено в схеме. 78 | [x] Показывать всегда. 79 | 80 | #Вид креста# 81 | Вид креста показываемый при "[x] Показать крест". 82 | 83 | #Период построения# 84 | Периодичность в миллисекундах с которой Far вызывает "фоновый" разбор файла в Colorer. Чем меньше это значение тем быстрее раскрашивается большой файл, но отзывчивость экрана падает. 85 | 86 | #{ Ok }# 87 | Закрытие диалога и сохранение параметров. 88 | 89 | @confighrc 90 | $# Настройки схем 91 | Для каждой из выбранных схем выводится список параметров влияющих на отображение раскраски. 92 | Значение параметра - значение установленное для этого параметра. 93 | Значения вида показывает, что параметр равен "значение" которое установлено либо в системных (не пользовательских) настройках схемы, либо взято у схемы default. Сохранение всех изменений происходит после нажатия кнопки "ОК". 94 | 95 | @configlog 96 | $# Настройки логирования 97 | 98 | #Включить# 99 | Включает/Отключает логирование в плагине. 100 | 101 | #Уровень логирования# 102 | Один из возможных уровней логирования. 103 | 104 | #Папка логов# 105 | Путь до папки в которой будут создаваться логи. Без указания имени файла. 106 | 107 | @cmdline 108 | $# Командная строка 109 | Вы можете вызывать внутренний консольный просмотрщик FarColorer`а через префикс плагина в командной строке. Используя префикс "clr:" после которого следует имя нужного файла вы можете открывать файл на просмотр с подсветкой синтаксиса. В пути могут быть использованы переменные окружения. При наличии пробелов в имени путь надо указывать в кавычках. 110 | Эта функциональность аналогична программе #colorer.exe# за тем исключением, что плагину не нужно каждый раз загружать базу HRC которая уже загружена и используется в редакторе. 111 | 112 | @add 113 | $# Списки 114 | 115 | В этих меню показывается список найденных функций в тексте или же найденные FarColorer`ом синтаксические ошибки. 116 | 117 | Можно пользоваться фильтром набирая прямо в меню искомую последовательность текста. 118 | 119 | #Ctrl-Left/Right# 120 | Раскрыть/закрыть иерархический уровень в списке. 121 | 122 | #Ctrl-Up/Down# 123 | Переместиться к следующему-предыдущему элементу в списке и по тексту. 124 | 125 | #Ctrl-Enter# 126 | Закрыть список и вставить текущий элемент в позицию под курсором. 127 | 128 | #Enter# 129 | Закрыть список и переместиться к выбранному элементу. 130 | 131 | #Tab# 132 | Дополняет фильтр символами, идущими после '?' в поле отображения фильтра. 133 | 134 | #Клавиши [0-9a-z;:-_]# 135 | Фильтровать список по вводимому шаблону. 136 | 137 | @menu 138 | $# Меню операций 139 | 140 | #1 Список типов# 141 | Выводит меню всех поддерживаемых типов файлов. Выбрав любой вы принудительно установите тип раскраски текущего файла. 142 | 143 | #2 Найти парную скобку# 144 | Находит парную скобку (или любую парную структуру) к текущей и переходит на нее. 145 | 146 | #3 Выделить блок со скобками# 147 | Переходит на начало парного блока и выделяет его весь. Эту функцию не обязательно вызывать установив курсор на парной конструкции. Если он находится внутри блока то FarColorer сам найдет начало и конец ближайшего блока и выделит его. 148 | 149 | #4 Выделить блок между скобок# 150 | Выделяется блок как и в предыдущем случае, но сами парные конструкции в выделение не попадают - выделяется только внутренность блока. 151 | 152 | #5 Список функций# 153 | Находит все функциональные регионы в текущем файле и выводит их в меню. В этом меню можно использовать любые буквенные клавиши для задания фильтров. 154 | 155 | #6 Список ошибок# 156 | Аналогично предыдущему - но показываются все найденные ошибки в файле. 157 | 158 | #*# Функционирование этих возможностей плагина зависит от соответствующих языковых схем. Вся выводимая информация берется из анализа регионов соответствующих типов файлов. 159 | 160 | #7 Выбрать текущий регион# 161 | Выделяет текущий цветовой регион под курсором. 162 | 163 | #A Данные региона# 164 | Выводит имя региона и схемы под курсором. 165 | 166 | #8 Найти функцию# 167 | Ищет функцию под курсором в списке функций и переходит на нее. 168 | 169 | #9 Обновить раскраску# 170 | Обновляет текущее состояние расцветки и заново перекрашивает файл. 171 | 172 | #R Перезагрузить библиотеку схем# 173 | Перечитывает настройки плагина и библиотеку схем. 174 | 175 | #C Настройка# 176 | Вызывает ~меню настроек~@config@ FarColorer. 177 | 178 | @PluginGuids 179 | $# Идентификаторы плагина 180 | GUID плагина - {D2F36B62-A470-418d-83A3-ED7A3710E5B5} 181 | 182 | #Диалоги# 183 | Диалог настроек - {87C92249-430D-4334-AC33-05E7423286E9} 184 | Диалог настроек параметров схем - {0497F43A-A8B9-4af1-A3A4-FA568F455707} 185 | Диалог настроек логирования - {3D1031EA-B67A-451C-9FC6-081320D3A139} 186 | Диалог назначения горячей клавиши - {C6BE56D8-A80A-4f7d-A331-A711435F2665} 187 | 188 | #Меню# 189 | Главное меню плагина в редакторе - {45453CAC-499D-4b37-82B8-0A77F7BD087C} 190 | Меню настроек - {63E396BA-8E7F-4E38-A7A8-CBB7E9AC1E6D} 191 | Меню выбора типа файлов - {46921647-DB52-44CA-8D8B-F34EA8B02E5D} 192 | Меню списка цветовых стилей - {18A6F7DF-375D-4d3d-8137-DC50AC52B71E} 193 | Меню списка функций/ошибок - {A8A298BA-AD5A-4094-8E24-F65BF38E6C1F} 194 | 195 | #Сообщения# 196 | Ошибка - {0C954AC8-2B69-4c74-94C8-7AB10324A005} 197 | Загрузка баз - {DEE3B49D-4A55-48a8-9DC8-D11DA04CBF37} 198 | Ничего не найдено - {AB214DCE-450B-4389-9E3B-533C7A6D786C} 199 | Название региона - {70656884-B7BD-4440-A8FF-6CE781C7DC6A} 200 | 201 | @MacroCallPlugin 202 | $# Использование плагина в макросах 203 | Плагин можно вызывать из макросов используя макрофункцию Plugin.Call(GUID,[param]). 204 | 205 | Формат вызова: 206 | 207 | #Plugin.Call("D2F36B62-A470-418d-83A3-ED7A3710E5B5",<Параметры>,...)# 208 | 209 | здесь: 210 | #D2F36B62-A470-418d-83A3-ED7A3710E5B5# 211 | ~идентификатор плагина~@PluginGuids@ 212 | 213 | #<Параметры># 214 | различные параметры согласно описанию ниже. 215 | 216 | ~Макрофункции.~@MacroCall@ 217 | 218 | @MacroCall 219 | $# Макрофункции 220 | 221 | #Работа с макросами# 222 | Формат вызова функций #Plugin.Call("D2F36B62-A470-418d-83A3-ED7A3710E5B5",... )#, либо #Plugin.SyncCall#. 223 | Вызов всех функций регистро-независимый. 224 | Возвращаемое значение, если не указано отдельно, "true" - успешно, "false" - ошибка. 225 | 226 | #Работа с глобальными настройками# 227 | Ограничений на макрорегионы не установлено. 228 | 229 | #...,"Settings",, )# 230 | 231 | - принимает следующие значения: 232 | 233 | "Menu" - Открывает меню настроек. Значение по умолчанию если пустой. 234 | "Main" - Открывает окно главных настроек 235 | "Log" - Открывает окно настроек логирования 236 | "Hrc" - Открывает окно настроек параметров схем 237 | "Reload" - Перезагружает все настройки плагина и открытых редакторов. Включая библиотеку схему. 238 | "Status" - статус активности плагина. 239 | - число: 240 | 0 - выключен; 241 | 1 - включен; 242 | Либо boolean: "false" -выключен, "true" - включён. 243 | Если задан то применяется новый статус с перезагрузкой всех настроек. Возвращает предыдущее значение. Если не задан возвращает текущее значение. 244 | "SaveSettings" - Сохраняет настройки плагина. 245 | 246 | #Работа с меню# 247 | Работает только в MACROAREA_EDITOR. 248 | 249 | #...,"Menu")# 250 | Открывает меню плагина в редакторе. 251 | 252 | #Работа с типами файлов# 253 | Работает только в MACROAREA_EDITOR. 254 | 255 | #...,"Types",, )# 256 | 257 | - принимает следующие значения: 258 | 259 | "Menu" - Открывает меню выбора типа файлов. 260 | "List" - Возвращает массив названий всех доступных типов файлов. 261 | "Get" - Возвращает текущий тип (первый параметр) и группу файла (второй параметр). 262 | "Set" - Устанавливает для файла открытого в редакторе указанный тип. 263 | - строка, тип файла 264 | 265 | #Работа с параметрами типов файлов# 266 | Ограничений на макрорегионы не установлено. Все изменения применяются только для текущего сеанса плагина. Для сохранения изменений необходимо вызывать "SaveSettings", для сброса "Reload". 267 | 268 | #...,"ParamsOfType",, ,...)# 269 | 270 | "List" - Список параметров типа 271 | - название типа. Строка. Регистро-зависимо. 272 | Возвращает 273 | - массив названий параметров. 274 | - массив значений этих параметров. В случае отсутствия значения у параметра возвращается "nil". 275 | "Get" - Возвращает значение параметра. Тип - всегда строка. 276 | - название типа. Строка. Регистро-зависимо. 277 | - название параметра. Строка. Регистро-зависимо. В случае отсутствия значения возвращается "nil". 278 | "Set" - Устанавливает значение для параметра или удаляет его. 279 | - название типа. Строка. Регистро-зависимо. 280 | - название параметра. Строка. Регистро-зависимо. 281 | - значение параметра. Строка. Если не передан то удаляется пользовательское значение параметра. Если передана пустая строка то это значение присваивается параметру. 282 | 283 | #Работа с скобками# 284 | Работает только в MACROAREA_EDITOR. 285 | 286 | #...,"Brackets",)# 287 | 288 | - принимает следующие значения: 289 | 290 | "Match" - Найти парную скобку. 291 | "SelectAll" - Выделить блок со скобками. 292 | "SelectIn" - Выделить блок между скобок. 293 | 294 | #Работа с регионами# 295 | Работает только в MACROAREA_EDITOR. 296 | 297 | #...,"Region",)# 298 | 299 | - принимает следующие значения: 300 | 301 | "Select" - Выбрать текущий регион. 302 | "Show" - Показать окно с данными региона. 303 | "List" - Возвращает описание региона. Первый параметр регион, второй схема. 304 | 305 | #Работа с функциями# 306 | Работает только в MACROAREA_EDITOR. 307 | 308 | #...,"Functions",)# 309 | 310 | - принимает следующие значения: 311 | 312 | "Show" - Показать окно со списком функций. 313 | "Find" - Найти функцию, на которой стоит курсор. 314 | "List" - Возвращает массив всех найденных функций и массив номеров строк в которых они объявлены. 315 | 316 | #Работа с ошибками# 317 | Работает только в MACROAREA_EDITOR. 318 | 319 | #...,"Errors",)# 320 | 321 | - принимает следующие значения: 322 | 323 | "Show" - Показать окно со списком ошибок 324 | "List" - Возвращает массив всех найденных ошибок и массив номеров строк в которых они найдены. 325 | 326 | #Работа с параметрами текущего редактора# 327 | При закрытии редактора данные параметры не сохраняются. 328 | Работает только в MACROAREA_EDITOR. 329 | 330 | #...,"Editor",,,...)# 331 | 332 | - принимает следующие значения: 333 | 334 | "Refresh" - обновляет раскраску. 335 | "Status" - Статус активности плагина для текущего редактора: 336 | - число: 337 | 0 - выключен; 338 | 1 - включен; 339 | Если задан то изменяется текущее и возвращает предыдущее значение. 340 | Если не задан, возвращает текущее значение для данного редактора 341 | "CrossVisible" - Видимость и тип креста в редакторе: 342 | Возвращает текущий стиль креста и правила отображения для данного редактора. 343 | - число: 344 | 0 - выключен; 345 | 1 - включен; 346 | 2 - согласно параметрам схемы. 347 | - число: 348 | 0 - не отображается; 349 | 1 - вертикальный; 350 | 2 - горизонтальный; 351 | 3 - полный крест. 352 | Если указаны дополнительные параметры то изменяет стиль и правила отображения. 353 | - число: 354 | 0 - выключен; 355 | 1 - включен; 356 | 2 - согласно параметрам схемы 357 | - необязательный, число: 358 | 1 - вертикальный; 359 | 2 - горизонтальный; 360 | 3 - полный крест. 361 | "Pair" - Статус отображения парных элементов: 362 | - число: 363 | 0 - выключен; 364 | 1 - включен; 365 | Если задан то изменяется текущее и возвращает предыдущее значение. 366 | Если не задан, возвращает текущее значение для данного редактора. 367 | "Syntax" - статус отображения синтаксиса: 368 | - число: 369 | 0 - выключен; 370 | 1 - включен; 371 | Если задан то изменяется текущее и возвращает предыдущее значение. 372 | Если не задан, то возвращает текущее значение для данного редактора. 373 | "Progress" - возвращает процент парсинга текущего файла в редакторе. Целочисленное значение. 374 | 375 | @hrd 376 | $# Выбор цветового стиля 377 | Список всех доступных цветовых стилей. Можно выбрать любой для работы. 378 | 379 | @exception 380 | $# Произошло исключение 381 | Во время работы FarColorer произошло исключение. Вся дальнейшая работа плагина будет приостановлена. Вы можете включить FarColorer через его меню настроек как только будете уверены в том, что причина исключения устранена. Вся дополнительная информация об ошибке находится в файле лога ошибок (по умолчанию colorer.log). 382 | 383 | @filetypechoose 384 | $# Список типов 385 | Список содержит все поддерживаемые типы файлов. Выбрав любой вы принудительно установите тип раскраски текущего файла. 386 | 387 | #Автоматическое определение# - выбор типа файла производит плагин по встроенным правилам. 388 | #Избранные# - список избранных типов. Добавление в "Избранные" производится по нажатию клавиши Ins, удаление - Delete. 389 | #Горячие клавиши# - для назначения горячей клавиши типу файла нужно нажать F4 и в открывшемся окне задать клавишу. 390 | 391 | Горячие клавиши и нахождение в группе "Избранные" так же можно настраивать через ~Настройки схем.~@confighrc@ Это параметры "hotkey" и "favorite" для любой из схем. 392 | 393 | @keyassign 394 | $# Назначение клавиши 395 | Клавиши 0-9, A-Z 396 | 397 | @author 398 | $# FarColorer плагин подсветки синтаксиса для FAR Manager. 399 | #Сайт плагина# 400 | http://colorer.sf.net 401 | 402 | #Cail Lomecb# (Игорь Русских). Copyright (c) 1999-2009 403 | email : irusskih at gmail dot com 404 | web : http://cail.nm.ru 405 | 406 | #Eugene Efremov# 407 | email : 4mirror at mail dot ru 408 | 409 | #ctapmex# (Алексей Добрунов). Copyright (c) 2009-2021 410 | email : ctapmex at gmail dot com 411 | web : http://dobrunov.ru 412 | -------------------------------------------------------------------------------- /misc/colorerr.lng: -------------------------------------------------------------------------------- 1 | .Language=Russian,Russian (Русский) 2 | 3 | "FarColorer" 4 | 5 | "Настройки FarColorer" 6 | 7 | "&Включить" 8 | "TrueMod В&ключить" 9 | "Выделять парные &элементы" 10 | "Показывать синт&аксис" 11 | 12 | "Классический стиль с&писка функций" 13 | 14 | "&ОК" 15 | "Тест &библиотеки схем" 16 | "О&тмена" 17 | 18 | "Файл &catalog.xml:" 19 | "&Цветовой стиль:" 20 | "TrueMod цветовой стил&ь:" 21 | 22 | "&1 Список типов" 23 | "&2 Найти парную скобку" 24 | "&3 Выделить блок со скобками" 25 | "&4 Выделить блок между скобок" 26 | "&5 Список функций" 27 | "&6 Список ошибок" 28 | "&7 Выбрать текущий регион" 29 | "&A Данные региона" 30 | "&8 Найти функцию" 31 | "&9 Обновить раскраску" 32 | "&R Перезагрузить библиотеку схем" 33 | "&C Настройка" 34 | 35 | "Всего типов: %d" 36 | "Выберите синтаксис" 37 | "Outliner [%s]" 38 | "Ничего не найдено" 39 | "Ок" 40 | "[Ctrl]Enter, Tab, Ctrl-Cursor, [0-9a-z;:-_]" 41 | 42 | "Перезагрузка библиотеки схем..." 43 | "Ок" 44 | "И&зменять цвет фона редактора" 45 | "&Файл цветовых стилей пользователя" 46 | "Фай&л списка схем пользователя" 47 | "&Настройки схем" 48 | "Настройка параметров схем" 49 | "Схема" 50 | "Параметры" 51 | "Значение параметра" 52 | "&A Автоматическое определение" 53 | "Избранные" 54 | "&D Отключено" 55 | "Задание клавиши" 56 | "Нажмите желаемую клавишу" 57 | "Название региона" 58 | "Настройки &логирования" 59 | "Настройки логирования" 60 | "&Включить" 61 | "Уровень логирования" 62 | "Папка логов" 63 | "&Основные настройки" 64 | "Настройки" 65 | "Настройки стиля" 66 | "Вид креста:" 67 | "целый" 68 | "вертикальный" 69 | "горизонтальный" 70 | "Показывать к&рест" 71 | 72 | "Производительность" 73 | "Период построения" -------------------------------------------------------------------------------- /misc/hrcsettings.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /scripts/nmake_build.cmd: -------------------------------------------------------------------------------- 1 | rem Example script for build FarColorer 2 | @echo off 3 | set PROJECT_ROOT=%~dp0.. 4 | set PROJECT_CONFIG=Release 5 | set LEGACY=ON 6 | 7 | set PROJECT_ARCH=x64 8 | 9 | :build 10 | set PROJECT_BUIILDDIR=%PROJECT_ROOT%\build\%PROJECT_CONFIG%\%PROJECT_ARCH% 11 | set INSTALL_DIR=%PROJECT_ROOT%\build\FarColorer\%PROJECT_ARCH% 12 | 13 | if exist %PROJECT_BUIILDDIR% rmdir /S /Q %PROJECT_BUIILDDIR% 14 | if exist %INSTALL_DIR% rmdir /S /Q %INSTALL_DIR% 15 | mkdir %PROJECT_BUIILDDIR% > NUL 16 | mkdir %INSTALL_DIR% > NUL 17 | 18 | pushd %PROJECT_BUIILDDIR% 19 | @call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" %PROJECT_ARCH% 20 | cmake.exe %PROJECT_ROOT% -G "NMake Makefiles" -DCOLORER_BUILD_ARCH=%PROJECT_ARCH% -DCMAKE_BUILD_TYPE=%PROJECT_CONFIG% -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DFARCOLORER_LEGACY=%LEGACY% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% 21 | cmake --build . --config %PROJECT_CONFIG% 22 | cmake --install . --config %PROJECT_CONFIG% 23 | echo See result in directory %INSTALL_DIR% 24 | popd 25 | 26 | if "%PROJECT_ARCH%" == "x64" goto x86 27 | goto exit 28 | 29 | :x86 30 | set PROJECT_ARCH=x86 31 | goto build 32 | 33 | :exit 34 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #==================================================== 2 | # farcolorer 3 | #==================================================== 4 | 5 | set(SRC_CPP 6 | ChooseTypeMenu.cpp 7 | ChooseTypeMenu.h 8 | FarEditor.cpp 9 | FarEditor.h 10 | FarEditorSet.cpp 11 | FarEditorSet.h 12 | FarHrcSettings.cpp 13 | FarHrcSettings.h 14 | HrcSettingsForm.cpp 15 | HrcSettingsForm.h 16 | SettingsControl.cpp 17 | SettingsControl.h 18 | SimpleLogger.h 19 | const_strings.h 20 | pcolorer.cpp 21 | pcolorer.h 22 | pcolorer3.rc 23 | tools.cpp 24 | tools.h 25 | version.h) 26 | 27 | set(SRC_DEF pcolorer3.def) 28 | 29 | #==================================================== 30 | # support win2k, winxp 31 | #==================================================== 32 | if(FARCOLORER_LEGACY AND MSVC AND NOT "${COLORER_BUILD_ARCH}" STREQUAL "arm64") 33 | set(ASM_SOURCE ${PROJECT_SOURCE_DIR}/external/far3sdk/vc_crt_fix.asm) 34 | set(ASM_OBJECT ${CMAKE_CURRENT_BINARY_DIR}/vc_crt_fix.obj) 35 | set(ASM_OBJECTS ${ASM_OBJECTS} ${ASM_OBJECT}) 36 | set(MASM_DEFINES "") 37 | if(${CMAKE_CL_64} STREQUAL "0") 38 | find_program(MASM_EXECUTABLE ml) 39 | else() 40 | find_program(MASM_EXECUTABLE ml64) 41 | set(MASM_DEFINES "/DX64") 42 | endif() 43 | 44 | add_custom_command( 45 | OUTPUT ${ASM_OBJECT} 46 | COMMAND ${MASM_EXECUTABLE} 47 | ARGS /c ${MASM_DEFINES} /Fo ${ASM_OBJECT} ${ASM_SOURCE} 48 | DEPENDS ${ASM_SOURCE} 49 | ) 50 | 51 | set(SRC_CPP ${SRC_CPP} 52 | ${PROJECT_SOURCE_DIR}/external/far3sdk/vc_crt_fix_impl.cpp 53 | ${ASM_OBJECTS} 54 | ) 55 | endif() 56 | 57 | #==================================================== 58 | # common flags 59 | #==================================================== 60 | 61 | if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") 62 | # defaut for msvc 63 | # CMAKE_CXX_FLAGS= /DWIN32 /D_WINDOWS /GR /EHsc 64 | # CMAKE_CXX_FLAGS_DEBUG= /MDd /Zi /Ob0 /Od /RTC1 65 | # CMAKE_CXX_FLAGS_RELEASE= /MD /O2 /Ob2 /DNDEBUG 66 | 67 | set(FLAGS_CXX_DEFAULT /Zi) 68 | set(FLAGS_CXX_RELEASE /W3 /Oi /Ot /GL /GS-) 69 | set(FLAGS_CXX_DEBUG /W4 /GS) 70 | 71 | set(LINK_FLAGS "/MAP /MANIFEST:NO") 72 | 73 | # build with debug info in pdb 74 | if(CMAKE_BUILD_TYPE MATCHES "Release") 75 | set(LINK_FLAGS "${LINK_FLAGS} /incremental:no /OPT:REF /OPT:ICF /debug /ltcg") 76 | endif() 77 | 78 | add_definitions(-DUNICODE) 79 | 80 | if("${COLORER_BUILD_ARCH}" STREQUAL "x64") 81 | set(CMAKE_RC_FLAGS -D_WIN64) 82 | endif() 83 | 84 | # old functions 85 | add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 86 | endif() 87 | 88 | # set options for target 89 | set(MAIN_FLAGS_CXX_DEBUG ${FLAGS_CXX_DEBUG} ${FLAGS_CXX_DEFAULT}) 90 | set(MAIN_FLAGS_CXX_RELEASE ${FLAGS_CXX_RELEASE} ${FLAGS_CXX_DEFAULT}) 91 | #==================================================== 92 | # build 93 | #==================================================== 94 | 95 | set(SRC_FILES ${SRC_CPP} ${SRC_DEF}) 96 | add_library(farcolorer SHARED ${SRC_FILES}) 97 | target_link_libraries(farcolorer colorer_lib) 98 | target_include_directories(farcolorer 99 | PRIVATE ${PROJECT_SOURCE_DIR}/external/far3sdk/ 100 | ) 101 | 102 | set_target_properties(farcolorer PROPERTIES OUTPUT_NAME "colorer") 103 | set_target_properties(farcolorer PROPERTIES 104 | CXX_STANDARD 17 105 | CXX_STANDARD_REQUIRED YES 106 | CXX_EXTENSIONS NO 107 | ) 108 | 109 | if(${CMAKE_BUILD_TYPE} MATCHES Debug) 110 | target_compile_options(farcolorer PRIVATE $<$:${MAIN_FLAGS_CXX_DEBUG}>) 111 | else() 112 | target_compile_options(farcolorer PRIVATE $<$:${MAIN_FLAGS_CXX_RELEASE}>) 113 | endif() 114 | 115 | set_target_properties(farcolorer PROPERTIES LINK_FLAGS "${LINK_FLAGS}") 116 | -------------------------------------------------------------------------------- /src/ChooseTypeMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "ChooseTypeMenu.h" 2 | #include "FarEditor.h" 3 | 4 | ChooseTypeMenu::ChooseTypeMenu(const wchar_t* AutoDetect, const wchar_t* Favorites, const wchar_t* Disable) 5 | { 6 | ItemCount = 0; 7 | Item = nullptr; 8 | ItemSelected = 0; 9 | 10 | AddItem(AutoDetect, 0, nullptr, 0); 11 | AddItem(Disable, 0, nullptr, 1); 12 | AddItem(Favorites, MIF_SEPARATOR, nullptr, 2); 13 | } 14 | 15 | ChooseTypeMenu::~ChooseTypeMenu() 16 | { 17 | for (size_t idx = 0; idx < ItemCount; idx++) { 18 | if (Item[idx].Text) { 19 | free((void*) Item[idx].Text); 20 | } 21 | } 22 | free(Item); 23 | } 24 | 25 | void ChooseTypeMenu::DeleteItem(size_t index) 26 | { 27 | if (Item[index].Text) { 28 | free((void*) Item[index].Text); 29 | } 30 | memmove(Item + index, Item + index + 1, sizeof(FarMenuItem) * (ItemCount - (index + 1))); 31 | ItemCount--; 32 | if (ItemSelected >= index) { 33 | ItemSelected--; 34 | } 35 | } 36 | 37 | FarMenuItem* ChooseTypeMenu::getItems() const 38 | { 39 | return Item; 40 | } 41 | 42 | size_t ChooseTypeMenu::AddItem(const wchar_t* Text, const MENUITEMFLAGS Flags, const FileType* UserData, size_t PosAdd) 43 | { 44 | if (PosAdd > ItemCount) { 45 | PosAdd = ItemCount; 46 | } 47 | 48 | if (!(ItemCount & 255)) { 49 | auto* NewPtr = static_cast(realloc(Item, sizeof(FarMenuItem) * (ItemCount + 256 + 1))); 50 | if (!NewPtr) { 51 | throw Exception("ChooseTypeMenu: not enough available memory."); 52 | } 53 | 54 | Item = NewPtr; 55 | } 56 | 57 | if (PosAdd < ItemCount) { 58 | memmove(Item + PosAdd + 1, Item + PosAdd, sizeof(FarMenuItem) * (ItemCount - PosAdd)); 59 | } 60 | 61 | ItemCount++; 62 | 63 | Item[PosAdd].Flags = Flags; 64 | Item[PosAdd].Text = _wcsdup(Text); 65 | Item[PosAdd].UserData = (intptr_t) UserData; 66 | ZeroMemory(Item[PosAdd].Reserved, sizeof(Item[PosAdd].Reserved)); 67 | Item[PosAdd].AccelKey.ControlKeyState = 0; 68 | Item[PosAdd].AccelKey.VirtualKeyCode = 0; 69 | 70 | return PosAdd; 71 | } 72 | 73 | size_t ChooseTypeMenu::AddGroup(const wchar_t* Text) 74 | { 75 | return AddItem(Text, MIF_SEPARATOR, nullptr); 76 | } 77 | 78 | size_t ChooseTypeMenu::AddItem(const FileType* fType, size_t PosAdd) 79 | { 80 | UnicodeString* s = GenerateName(fType); 81 | size_t k = AddItem(UStr::to_stdwstr(s).c_str(), 0, fType, PosAdd); 82 | delete s; 83 | return k; 84 | } 85 | 86 | void ChooseTypeMenu::SetSelected(size_t index) 87 | { 88 | if (index < ItemCount) { 89 | Item[ItemSelected].Flags &= ~MIF_SELECTED; 90 | Item[index].Flags |= MIF_SELECTED; 91 | ItemSelected = index; 92 | } 93 | } 94 | 95 | size_t ChooseTypeMenu::GetNext(size_t index) const 96 | { 97 | size_t p; 98 | for (p = index + 1; p < ItemCount; p++) { 99 | if (!(Item[p].Flags & MIF_SEPARATOR)) { 100 | break; 101 | } 102 | } 103 | if (p < ItemCount) { 104 | return p; 105 | } 106 | else { 107 | for (p = favorite_idx; p < ItemCount && !(Item[p].Flags & MIF_SEPARATOR); p++) 108 | ; 109 | return p + 1; 110 | } 111 | } 112 | 113 | FileType* ChooseTypeMenu::GetFileType(size_t index) const 114 | { 115 | return (FileType*) Item[index].UserData; 116 | } 117 | 118 | void ChooseTypeMenu::MoveToFavorites(size_t index) 119 | { 120 | auto* f = GetFileType(index); 121 | DeleteItem(index); 122 | size_t k = AddFavorite(f); 123 | SetSelected(k); 124 | HideEmptyGroup(); 125 | } 126 | 127 | size_t ChooseTypeMenu::AddFavorite(const FileType* fType) 128 | { 129 | size_t i; 130 | for (i = favorite_idx; i < ItemCount && !(Item[i].Flags & MIF_SEPARATOR); i++) 131 | ; 132 | size_t p = AddItem(fType, i); 133 | if (ItemSelected >= p) { 134 | ItemSelected++; 135 | } 136 | return p; 137 | } 138 | 139 | void ChooseTypeMenu::HideEmptyGroup() const 140 | { 141 | for (size_t i = favorite_idx; i < ItemCount - 1; i++) { 142 | if ((Item[i].Flags & MIF_SEPARATOR) && (Item[i + 1].Flags & MIF_SEPARATOR)) { 143 | Item[i].Flags |= MIF_HIDDEN; 144 | } 145 | } 146 | } 147 | 148 | void ChooseTypeMenu::DelFromFavorites(size_t index) 149 | { 150 | auto* f = (FileType*) Item[index].UserData; 151 | DeleteItem(index); 152 | AddItemInGroup(f); 153 | if (Item[index].Flags & MIF_SEPARATOR) { 154 | SetSelected(GetNext(index)); 155 | } 156 | else { 157 | SetSelected(index); 158 | } 159 | f->setParamValue(UnicodeString(param_Favorite), UnicodeString(value_False)); 160 | } 161 | 162 | size_t ChooseTypeMenu::AddItemInGroup(FileType* fType) 163 | { 164 | size_t i; 165 | auto group = fType->getGroup(); 166 | for (i = favorite_idx; i < ItemCount && !((Item[i].Flags & MIF_SEPARATOR) && (group.compare(UnicodeString(Item[i].Text)) == 0)); i++) 167 | ; 168 | if (Item[i].Flags & MIF_HIDDEN) { 169 | Item[i].Flags &= ~MIF_HIDDEN; 170 | } 171 | size_t k = AddItem(fType, i + 1); 172 | if (ItemSelected >= k) { 173 | ItemSelected++; 174 | } 175 | return k; 176 | } 177 | 178 | bool ChooseTypeMenu::IsFavorite(size_t index) const 179 | { 180 | size_t i; 181 | for (i = favorite_idx; i < ItemCount && !(Item[i].Flags & MIF_SEPARATOR); i++) 182 | ; 183 | i = ItemCount ? i : i + 1; 184 | return i > index; 185 | } 186 | 187 | void ChooseTypeMenu::RefreshItemCaption(size_t index) 188 | { 189 | if (Item[index].Text) { 190 | free((void*) Item[index].Text); 191 | } 192 | 193 | UnicodeString* s = GenerateName(GetFileType(index)); 194 | Item[index].Text = _wcsdup(UStr::to_stdwstr(s).c_str()); 195 | delete s; 196 | } 197 | 198 | UnicodeString* ChooseTypeMenu::GenerateName(const FileType* fType) 199 | { 200 | const UnicodeString* v; 201 | v = ((FileType*) fType)->getParamValue(UnicodeString(param_HotKey)); 202 | auto* s = new UnicodeString; 203 | if (v != nullptr && v->length()) { 204 | s->append("&").append(*v); 205 | } 206 | else { 207 | s->append(" "); 208 | } 209 | s->append(" ").append(fType->getName()).append(": ").append(fType->getDescription()); 210 | 211 | return s; 212 | } -------------------------------------------------------------------------------- /src/ChooseTypeMenu.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_CHOOSE_TYPE_MENU_H 2 | #define FARCOLORER_CHOOSE_TYPE_MENU_H 3 | 4 | #include 5 | #include "pcolorer.h" 6 | 7 | class ChooseTypeMenu 8 | { 9 | public: 10 | ChooseTypeMenu(const wchar_t* AutoDetect, const wchar_t* Favorites, const wchar_t* Disable); 11 | ~ChooseTypeMenu(); 12 | [[nodiscard]] FarMenuItem* getItems() const; 13 | [[nodiscard]] size_t getItemsCount() const 14 | { 15 | return ItemCount; 16 | } 17 | 18 | size_t AddItem(const FileType* fType, size_t PosAdd = 0x7FFFFFFF); 19 | size_t AddItemInGroup(FileType* fType); 20 | size_t AddGroup(const wchar_t* Text); 21 | void SetSelected(size_t index); 22 | [[nodiscard]] size_t GetNext(size_t index) const; 23 | [[nodiscard]] FileType* GetFileType(size_t index) const; 24 | void MoveToFavorites(size_t index); 25 | size_t AddFavorite(const FileType* fType); 26 | void DeleteItem(size_t index); 27 | 28 | void HideEmptyGroup() const; 29 | void DelFromFavorites(size_t index); 30 | [[nodiscard]] bool IsFavorite(size_t index) const; 31 | void RefreshItemCaption(size_t index); 32 | static UnicodeString* GenerateName(const FileType* fType); 33 | 34 | private: 35 | size_t ItemCount; 36 | FarMenuItem* Item; 37 | 38 | size_t ItemSelected; // Index of selected item 39 | 40 | size_t AddItem(const wchar_t* Text, MENUITEMFLAGS Flags, const FileType* UserData = nullptr, size_t PosAdd = 0x7FFFFFFF); 41 | 42 | static const size_t favorite_idx = 3; 43 | }; 44 | 45 | #endif //FARCOLORER_CHOOSE_TYPE_MENU_H -------------------------------------------------------------------------------- /src/FarEditor.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_FAREDITOR_H 2 | #define FARCOLORER_FAREDITOR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "const_strings.h" 8 | #include "pcolorer.h" 9 | 10 | const intptr_t CurrentEditor = -1; 11 | 12 | #define revertRGB(x) ((BYTE) ((x) >> 16 & 0xff) | ((BYTE) ((x) >> 8 & 0xff) << 8) | ((BYTE) ((x) &0xff) << 16)) 13 | 14 | /** FAR Editor internal plugin structures. 15 | Implements text parsing and different 16 | editor extended functions. 17 | @ingroup far_plugin 18 | */ 19 | class FarEditor : public LineSource 20 | { 21 | public: 22 | enum class CROSS_STATUS { CROSS_OFF = 0, CROSS_ON = 1, CROSS_INSCHEME = 2 }; 23 | enum class CROSS_STYLE { CSTYLE_NONE = 0, CSTYLE_VERT = 1, CSTYLE_HOR = 2, CSTYLE_BOTH = 3 }; 24 | 25 | /** Creates FAR editor instance. 26 | */ 27 | FarEditor(PluginStartupInfo* info, ParserFactory* pf, const UnicodeString* file_name); 28 | /** Drops this editor */ 29 | ~FarEditor() override; 30 | 31 | void endJob(size_t lno) override; 32 | /** 33 | Returns line number "lno" from FAR interface. Line is only valid until next call of this function, 34 | it also should not be disposed, this function takes care of this. 35 | */ 36 | UnicodeString* getLine(size_t lno) override; 37 | 38 | /** Changes current assigned file type. 39 | */ 40 | void setFileType(FileType* ftype); 41 | /** Returns currently selected file type. 42 | */ 43 | [[nodiscard]] FileType* getFileType() const; 44 | 45 | /** Selects file type with it's extension and first lines 46 | */ 47 | void chooseFileType(const UnicodeString* fname); 48 | 49 | /** Installs specified RegionMapper implementation. 50 | This class serves to request mapping of regions into 51 | real colors. 52 | */ 53 | void setRegionMapper(RegionMapper* rs); 54 | 55 | /** 56 | * Change editor properties. These overwrites default HRC settings 57 | */ 58 | void setCrossState(int status, int style); 59 | void setCrossStatus(int status); 60 | void setCrossStyle(int style); 61 | void setDrawPairs(bool drawPairs); 62 | void setDrawSyntax(bool drawSyntax); 63 | void setOutlineStyle(bool oldStyle); 64 | void setTrueMod(bool TrueMod_); 65 | 66 | /** Editor action: pair matching. 67 | */ 68 | void matchPair(); 69 | /** Editor action: pair selection. 70 | */ 71 | void selectPair(); 72 | /** Editor action: pair selection with current block. 73 | */ 74 | void selectBlock(); 75 | /** Editor action: Selection of current region under cursor. 76 | */ 77 | void selectRegion(); 78 | /** Editor action: Lists functional region. 79 | */ 80 | void listFunctions(); 81 | /** Editor action: Lists syntax errors in text. 82 | */ 83 | void listErrors(); 84 | /** 85 | * Locates a function under cursor and tries to jump to it using outliner information 86 | */ 87 | void locateFunction(); 88 | 89 | /** Invalidates current syntax highlighting 90 | */ 91 | void updateHighlighting(); 92 | 93 | /** Handle passed FAR editor event */ 94 | int editorEvent(intptr_t event, void* param); 95 | /** Dispatch editor input event */ 96 | int editorInput(const INPUT_RECORD& Rec); 97 | 98 | void cleanEditor(); 99 | 100 | void getNameCurrentScheme(); 101 | void getCurrentRegionInfo(UnicodeString& region, UnicodeString& scheme); 102 | 103 | void changeCrossStyle(CROSS_STYLE newStyle); 104 | [[nodiscard]] CROSS_STYLE getVisibleCrossState() const; 105 | [[nodiscard]] int getCrossStatus() const; 106 | [[nodiscard]] int getCrossStyle() const; 107 | [[nodiscard]] bool isDrawPairs() const; 108 | [[nodiscard]] bool isDrawSyntax() const; 109 | 110 | Outliner* getFunctionOutliner(); 111 | Outliner* getErrorOutliner(); 112 | 113 | int getParseProgress(); 114 | [[nodiscard]] bool isColorerEnable() const; 115 | boolean hasWork(); 116 | 117 | private: 118 | PluginStartupInfo* info; 119 | ParserFactory* parserFactory; 120 | 121 | void init(); 122 | void destroy(); 123 | 124 | std::unique_ptr baseEditor; 125 | 126 | int maxLineLength = 0; 127 | bool fullBackground = true; 128 | 129 | int crossStatus = 0; // 0 - off, 1 - always, 2 - if included in the scheme 130 | int crossStyle = 0; 131 | // 3 - both; 1 - vertical; 2 - horizontal 132 | bool showVerticalCross = false; 133 | bool showHorizontalCross = false; 134 | int crossZOrder = 0; 135 | FarColor horzCrossColor{}; 136 | FarColor vertCrossColor{}; 137 | 138 | bool drawPairs = true; 139 | bool drawSyntax = true; 140 | bool oldOutline = false; 141 | bool TrueMod = true; 142 | 143 | bool inRedraw = false; 144 | int idleCount = 0; 145 | 146 | std::unique_ptr ret_str; 147 | 148 | int newfore = -1; 149 | int newback = -1; 150 | const StyledRegion* rdBackground = nullptr; 151 | std::unique_ptr cursorRegion; 152 | 153 | size_t visibleLevel = 100; 154 | std::unique_ptr structOutliner; 155 | std::unique_ptr errorOutliner; 156 | intptr_t editor_id = -1; 157 | 158 | void reloadTypeSettings(); 159 | EditorInfo getEditorInfo(); 160 | FarColor convert(const StyledRegion* rd) const; 161 | void showOutliner(Outliner* outliner); 162 | void addFARColor(intptr_t lno, intptr_t s, intptr_t e, const FarColor& col, EDITORCOLORFLAGS TabMarkStyle = 0) const; 163 | void deleteFarColor(intptr_t lno, intptr_t s = -1) const; 164 | [[nodiscard]] const wchar_t* GetMsg(int msg) const; 165 | static COLORREF getSuitableColor(COLORREF base_color, COLORREF blend_color); 166 | void drawCross(const EditorInfo& ei, intptr_t lno, intptr_t ecp_cl) const; 167 | }; 168 | #endif // FARCOLORER_FAREDITOR_H 169 | -------------------------------------------------------------------------------- /src/FarEditorSet.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_FAREDITORSET_H 2 | #define FARCOLORER_FAREDITORSET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "ChooseTypeMenu.h" 8 | #include "FarEditor.h" 9 | #include "pcolorer.h" 10 | 11 | // registry keys 12 | const wchar_t cRegEnabled[] = L"Enabled"; 13 | const wchar_t cRegHrdName[] = L"HrdName"; 14 | const wchar_t cRegHrdNameTm[] = L"HrdNameTm"; 15 | const wchar_t cRegCatalog[] = L"Catalog"; 16 | const wchar_t cRegPairsDraw[] = L"PairsDraw"; 17 | const wchar_t cRegSyntaxDraw[] = L"SyntaxDraw"; 18 | const wchar_t cRegOldOutLine[] = L"OldOutlineView"; 19 | const wchar_t cRegTrueMod[] = L"TrueMod"; 20 | const wchar_t cRegChangeBgEditor[] = L"ChangeBgEditor"; 21 | const wchar_t cRegUserHrdPath[] = L"UserHrdPath"; 22 | const wchar_t cRegUserHrcPath[] = L"UserHrcPath"; 23 | const wchar_t cRegLogPath[] = L"LogPath"; 24 | const wchar_t cRegLogLevel[] = L"LogLevel"; 25 | const wchar_t cRegLogEnabled[] = L"LogEnabled"; 26 | const wchar_t cRegCrossDraw[] = L"CrossDraw"; 27 | const wchar_t cRegCrossStyle[] = L"CrossStyle"; 28 | const wchar_t cThreadBuildPeriod[] = L"ThreadBuildPeriod"; 29 | 30 | // values of registry keys by default 31 | const bool cEnabledDefault = true; 32 | const wchar_t cHrdNameDefault[] = L"default"; 33 | const wchar_t cHrdNameTmDefault[] = L"default"; 34 | const wchar_t cCatalogDefault[] = L""; 35 | const bool cPairsDrawDefault = true; 36 | const bool cSyntaxDrawDefault = true; 37 | const bool cOldOutLineDefault = true; 38 | const bool cTrueMod = false; 39 | const bool cChangeBgEditor = false; 40 | const wchar_t cUserHrdPathDefault[] = L""; 41 | const wchar_t cUserHrcPathDefault[] = L""; 42 | const wchar_t cLogPathDefault[] = L""; 43 | const wchar_t cLogLevelDefault[] = L"INFO"; 44 | const bool cLogEnabledDefault = false; 45 | const int cCrossDrawDefault = 2; 46 | const int cCrossStyleDefault = 3; 47 | const int cThreadBuildPeriodDefault = 200; 48 | 49 | const UnicodeString DConsole = UnicodeString("console"); 50 | const UnicodeString DRgb = UnicodeString("rgb"); 51 | const UnicodeString DAutodetect = UnicodeString("autodetect"); 52 | 53 | enum { 54 | IDX_CH_BOX, 55 | IDX_CH_CAPTIONLIST, 56 | IDX_CH_SCHEMAS, 57 | IDX_CH_PARAM_LIST, 58 | IDX_CH_PARAM_VALUE_CAPTION, 59 | IDX_CH_PARAM_VALUE_LIST, 60 | IDX_CH_DESCRIPTION, 61 | IDX_CH_OK, 62 | IDX_CH_CANCEL 63 | }; 64 | 65 | enum ERROR_TYPE { ERR_NO_ERROR = 0, ERR_BASE_LOAD = 1, ERR_FARSETTINGS_ERROR = 2 }; 66 | 67 | INT_PTR WINAPI SettingDialogProc(HANDLE hDlg, intptr_t Msg, intptr_t Param1, void* Param2); 68 | 69 | struct Options 70 | { 71 | int rEnabled; 72 | int drawPairs; 73 | int drawSyntax; 74 | int oldOutline; 75 | int TrueModOn; 76 | int ChangeBgEditor; 77 | int drawCross; 78 | int CrossStyle; 79 | int LogEnabled; 80 | int ThreadBuildPeriod; 81 | wchar_t HrdName[20]; 82 | wchar_t HrdNameTm[20]; 83 | wchar_t CatalogPath[MAX_PATH]; 84 | wchar_t UserHrdPath[MAX_PATH]; 85 | wchar_t UserHrcPath[MAX_PATH]; 86 | wchar_t LogPath[MAX_PATH]; 87 | wchar_t logLevel[10]; 88 | }; 89 | 90 | struct SettingWindow 91 | { 92 | int turnOff; 93 | int okButtonConfig; 94 | int catalogEdit; 95 | int hrcEdit; 96 | int hrdEdit; 97 | int hrdCons; 98 | int hrdTM; 99 | }; 100 | 101 | class HrcSettingsForm; 102 | class FarHrcSettings; 103 | /** 104 | * FAR Editors container. 105 | * Manages all library resources and creates FarEditor class instances. 106 | * @ingroup far_plugin 107 | */ 108 | class FarEditorSet 109 | { 110 | friend HrcSettingsForm; 111 | friend FarHrcSettings; 112 | 113 | public: 114 | /** Creates set and initialises it with PluginStartupInfo structure */ 115 | FarEditorSet(); 116 | /** Standard destructor */ 117 | ~FarEditorSet(); 118 | 119 | /** Shows editor actions menu */ 120 | void openMenu(); 121 | 122 | void menuConfigure(); 123 | /** Shows plugin's configuration dialog */ 124 | bool configure(); 125 | /** Views current file with internal viewer */ 126 | void viewFile(const UnicodeString& path); 127 | HANDLE openFromMacro(const struct OpenInfo* oInfo); 128 | HANDLE openFromCommandLine(const struct OpenInfo* oInfo); 129 | void* execMacro(FARMACROAREA area, OpenMacroInfo* params); 130 | 131 | /** Dispatch editor event in the opened editor */ 132 | int editorEvent(const struct ProcessEditorEventInfo* pInfo); 133 | /** Dispatch editor input event in the opened editor */ 134 | int editorInput(const INPUT_RECORD& Rec); 135 | 136 | /** Get the description of HRD, or parameter name if description=null */ 137 | [[nodiscard]] const UnicodeString* getHRDescription(const UnicodeString& name, const UnicodeString& _hrdClass) const; 138 | 139 | /** Reads all registry settings into variables */ 140 | void ReadSettings(); 141 | /** 142 | * trying to load the database on the specified path 143 | */ 144 | enum class HRC_MODE { HRCM_CONSOLE, HRCM_RGB, HRCM_BOTH }; 145 | bool TestLoadBase(const wchar_t* catalogPath, const wchar_t* userHrdPath, const wchar_t* userHrcPath, const wchar_t* hrdCons, const wchar_t* hrdTm, 146 | bool full, HRC_MODE hrc_mode); 147 | 148 | [[nodiscard]] bool isEnable() const 149 | { 150 | return Opt.rEnabled; 151 | } 152 | 153 | /** Disables all plugin processing*/ 154 | void disableColorer(); 155 | void enableColorer(); 156 | 157 | bool SetBgEditor() const; 158 | 159 | /** Shows hrc configuration dialog */ 160 | bool configureHrc(bool call_from_editor); 161 | 162 | /** Show logging configuration dialog*/ 163 | bool configureLogging(); 164 | 165 | static void showExceptionMessage(const UnicodeString* message); 166 | void applyLogSetting(); 167 | [[nodiscard]] size_t getEditorCount() const; 168 | 169 | SettingWindow settingWindow {0}; 170 | 171 | std::vector hrd_con_instances; 172 | std::vector hrd_rgb_instances; 173 | 174 | private: 175 | /** add current active editor and return him. */ 176 | FarEditor* addCurrentEditor(); 177 | /** Returns currently active editor. */ 178 | FarEditor* getCurrentEditor(); 179 | /** 180 | * Reloads HRC database. 181 | * Drops all currently opened editors and their 182 | * internal structures. Prepares to work with newly 183 | * loaded database. Read settings from registry 184 | */ 185 | void ReloadBase(); 186 | 187 | /** Shows dialog of file type selection */ 188 | bool chooseType(); 189 | /** FAR localized messages */ 190 | static const wchar_t* GetMsg(int msg); 191 | /** Applies the current settings for editor*/ 192 | void applySettingsToEditor(FarEditor* editor) const; 193 | /** writes settings in the registry*/ 194 | void SaveSettings() const; 195 | void SaveLogSettings() const; 196 | 197 | /** Kills all currently opened editors*/ 198 | void dropAllEditors(bool clean); 199 | /** kill the current editor*/ 200 | void dropCurrentEditor(bool clean); 201 | 202 | void setEmptyLogger(); 203 | 204 | void addEventTimer(); 205 | void removeEventTimer(); 206 | 207 | enum class MENU_ACTION { 208 | NO_ACTION = -1, 209 | LIST_TYPE = 0, 210 | MATCH_PAIR, 211 | SELECT_BLOCK, 212 | SELECT_PAIR, 213 | LIST_FUNCTION, 214 | FIND_ERROR, 215 | SELECT_REGION, 216 | CURRENT_REGION_NAME, 217 | LOCATE_FUNCTION, 218 | UPDATE_HIGHLIGHT = LOCATE_FUNCTION + 2, 219 | RELOAD_BASE, 220 | CONFIGURE 221 | }; 222 | 223 | static FarEditorSet::MENU_ACTION showMenu(bool plugin_enabled, bool editor_enabled); 224 | void execMenuAction(MENU_ACTION action, FarEditor* editor); 225 | 226 | void* macroSettings(FARMACROAREA area, const OpenMacroInfo* params); 227 | void* macroMenu(FARMACROAREA area, const OpenMacroInfo* params); 228 | void* macroTypes(FARMACROAREA area, const OpenMacroInfo* params); 229 | void* macroBrackets(FARMACROAREA area, const OpenMacroInfo* params); 230 | void* macroRegion(FARMACROAREA area, const OpenMacroInfo* params); 231 | void* macroFunctions(FARMACROAREA area, const OpenMacroInfo* params); 232 | void* macroErrors(FARMACROAREA area, const OpenMacroInfo* params); 233 | void* macroEditor(FARMACROAREA area, const OpenMacroInfo* params); 234 | void* macroParams(FARMACROAREA area, OpenMacroInfo* params); 235 | 236 | void disableColorerInEditor(); 237 | void enableColorerInEditor(); 238 | void FillTypeMenu(ChooseTypeMenu* Menu, const FileType* CurFileType) const; 239 | static UnicodeString* getCurrentFileName(); 240 | 241 | static int getHrdArrayWithCurrent(const wchar_t* current, std::vector* hrd_instances, std::vector* out_array); 242 | // filetype "default" 243 | FileType* defaultType = nullptr; 244 | void addParamAndValue(FileType* filetype, const UnicodeString& name, const UnicodeString& value, const FileType* def_filetype = nullptr) const; 245 | 246 | std::unordered_map farEditorInstances; 247 | std::unique_ptr parserFactory; 248 | std::unique_ptr regionMapper; 249 | 250 | /** registry settings */ 251 | Options Opt {0}; 252 | 253 | /** UNC path */ 254 | std::unique_ptr sCatalogPathExp; 255 | std::unique_ptr sUserHrdPathExp; 256 | std::unique_ptr sUserHrcPathExp; 257 | 258 | std::unique_ptr pluginPath; 259 | 260 | unsigned int err_status = ERR_NO_ERROR; 261 | 262 | 263 | HANDLE hTimer = nullptr; 264 | HANDLE hTimerQueue = nullptr; 265 | 266 | bool ignore_event = false; 267 | }; 268 | 269 | #endif // FARCOLORER_FAREDITORSET_H 270 | -------------------------------------------------------------------------------- /src/FarHrcSettings.cpp: -------------------------------------------------------------------------------- 1 | #include "FarHrcSettings.h" 2 | #include 3 | #include 4 | #include "SettingsControl.h" 5 | #include "colorer/parsers/CatalogParser.h" 6 | 7 | void FarHrcSettings::loadUserHrc(const UnicodeString* filename) 8 | { 9 | if (filename && !filename->isEmpty()) { 10 | parserFactory->loadHrcPath(*filename); 11 | } 12 | } 13 | 14 | void FarHrcSettings::loadUserHrd(const UnicodeString* filename) 15 | { 16 | if (!filename || filename->isEmpty()) { 17 | return; 18 | } 19 | 20 | XmlInputSource config(*filename); 21 | XmlReader xml_parser(config); 22 | if (!xml_parser.parse()) { 23 | throw ParserFactoryException(UnicodeString("Error reading ").append(*filename)); 24 | } 25 | std::list nodes; 26 | xml_parser.getNodes(nodes); 27 | 28 | if (nodes.begin()->name != catTagHrdSets) { 29 | throw Exception("main '' block not found"); 30 | } 31 | for (const auto& node : nodes.begin()->children) { 32 | if (node.name == catTagHrd) { 33 | auto hrd = CatalogParser::parseHRDSetsChild(node); 34 | if (hrd) 35 | parserFactory->addHrd(std::move(hrd)); 36 | } 37 | } 38 | } 39 | 40 | void FarHrcSettings::readPluginHrcSettings(const UnicodeString* plugin_path) 41 | { 42 | auto path = UnicodeString(*plugin_path); 43 | path.append(UnicodeString(FarProfileXml)); 44 | readXML(&path); 45 | } 46 | 47 | void FarHrcSettings::readXML(const UnicodeString* file) 48 | { 49 | XmlInputSource config(*file); 50 | XmlReader xml_parser(config); 51 | if (!xml_parser.parse()) { 52 | throw ParserFactoryException("Error reading hrcsettings.xml."); 53 | } 54 | std::list nodes; 55 | xml_parser.getNodes(nodes); 56 | 57 | if (nodes.begin()->name != u"hrc-settings") { 58 | throw FarHrcSettingsException("main '' block not found"); 59 | } 60 | for (const auto& node : nodes.begin()->children) { 61 | if (node.name == hrcTagPrototype) { 62 | UpdatePrototype(node); 63 | } 64 | } 65 | } 66 | 67 | void FarHrcSettings::UpdatePrototype(const XMLNode& elem) 68 | { 69 | const auto& typeName = elem.getAttrValue(hrcPrototypeAttrName); 70 | if (typeName.isEmpty()) { 71 | return; 72 | } 73 | auto& hrcLibrary = parserFactory->getHrcLibrary(); 74 | auto* type = hrcLibrary.getFileType(typeName); 75 | if (type == nullptr) { 76 | return; 77 | } 78 | 79 | for (const auto& node : elem.children) { 80 | if (node.name == hrcTagParam) { 81 | const auto& name = node.getAttrValue(hrcParamAttrName); 82 | const auto& value = node.getAttrValue(hrcParamAttrValue); 83 | const auto& descr = node.getAttrValue(hrcParamAttrDescription); 84 | 85 | if (name.isEmpty()) { 86 | continue; 87 | } 88 | 89 | if (type->getParamValue(name) == nullptr) { 90 | type->addParam(name, value); 91 | } 92 | else { 93 | type->setParamDefaultValue(name, &value); 94 | } 95 | if (descr != nullptr) { 96 | type->setParamDescription(name, &descr); 97 | } 98 | } 99 | } 100 | } 101 | 102 | void FarHrcSettings::readUserProfile(const FileType* def_filetype) 103 | { 104 | auto& hrcLibrary = parserFactory->getHrcLibrary(); 105 | 106 | SettingsControl ColorerSettings; 107 | auto hrc_subkey = ColorerSettings.rGetSubKey(0, HrcSettings); 108 | FarSettingsEnum fse {sizeof(FarSettingsEnum)}; 109 | 110 | // enum all the sections in HrcSettings 111 | if (ColorerSettings.rEnum(hrc_subkey, &fse)) { 112 | for (size_t i = 0; i < fse.Count; i++) { 113 | if (fse.Items[i].Type == FST_SUBKEY) { 114 | // check whether we have such a scheme 115 | UnicodeString named = UnicodeString(fse.Items[i].Name); 116 | auto* type = hrcLibrary.getFileType(&named); 117 | if (type) { 118 | // enum all params in the section 119 | auto type_subkey = ColorerSettings.rGetSubKey(hrc_subkey, fse.Items[i].Name); 120 | FarSettingsEnum type_fse {sizeof(FarSettingsEnum)}; 121 | if (ColorerSettings.rEnum(type_subkey, &type_fse)) { 122 | for (size_t j = 0; j < type_fse.Count; j++) { 123 | if (type_fse.Items[j].Type == FST_STRING) { 124 | const wchar_t* p = ColorerSettings.Get(type_subkey, type_fse.Items[j].Name, static_cast(nullptr)); 125 | if (p) { 126 | UnicodeString name_fse = UnicodeString(type_fse.Items[j].Name); 127 | UnicodeString dp = UnicodeString(p); 128 | farEditorSet->addParamAndValue(type, name_fse, dp, def_filetype); 129 | } 130 | } 131 | } 132 | } 133 | } 134 | } 135 | } 136 | } 137 | } 138 | 139 | void FarHrcSettings::writeUserProfile() 140 | { 141 | auto& hrcLibrary = parserFactory->getHrcLibrary(); 142 | 143 | SettingsControl ColorerSettings; 144 | auto hrc_subkey = ColorerSettings.rGetSubKey(0, HrcSettings); 145 | 146 | // enum all FileTypes 147 | for (int idx = 0;; idx++) { 148 | auto type = hrcLibrary.enumerateFileTypes(idx); 149 | 150 | if (!type) { 151 | break; 152 | } 153 | 154 | if (type->getParamCount()) { // params>0 155 | auto type_subkey = ColorerSettings.rGetSubKey(hrc_subkey, UStr::to_stdwstr(type->getName()).c_str()); 156 | // enum all params 157 | std::vector type_params = type->enumParams(); 158 | for (auto& type_param : type_params) { 159 | const UnicodeString* v = type->getParamUserValue(type_param); 160 | if (v != nullptr) { 161 | ColorerSettings.Set(type_subkey, UStr::to_stdwstr(&type_param).c_str(), UStr::to_stdwstr(v).c_str()); 162 | } 163 | else { 164 | ColorerSettings.rDeleteSubKey(type_subkey, UStr::to_stdwstr(&type_param).c_str()); 165 | } 166 | } 167 | } 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /src/FarHrcSettings.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_FARHRCSETTINGS_H 2 | #define FARCOLORER_FARHRCSETTINGS_H 3 | 4 | #include 5 | #include "colorer/xml/XMLNode.h" 6 | #include "FarEditorSet.h" 7 | 8 | const wchar_t FarCatalogXml[] = L"\\base\\catalog.xml"; 9 | const wchar_t FarProfileXml[] = L"\\bin\\hrcsettings.xml"; 10 | const wchar_t HrcSettings[] = L"HrcSettings"; 11 | 12 | class FarHrcSettingsException : public Exception 13 | { 14 | public: 15 | explicit FarHrcSettingsException(const UnicodeString& msg) noexcept : Exception("[FarHrcSettingsException] " + msg) {} 16 | }; 17 | 18 | class FarHrcSettings 19 | { 20 | public: 21 | explicit FarHrcSettings(FarEditorSet* _farEditorSet, ParserFactory* _parserFactory) 22 | { 23 | parserFactory = _parserFactory; 24 | farEditorSet = _farEditorSet; 25 | } 26 | void readXML(const UnicodeString* file); 27 | void readPluginHrcSettings(const UnicodeString* plugin_path); 28 | void readUserProfile(const FileType* def_filetype = nullptr); 29 | void writeUserProfile(); 30 | void loadUserHrc(const UnicodeString* filename); 31 | void loadUserHrd(const UnicodeString* filename); 32 | 33 | private: 34 | void UpdatePrototype(const XMLNode& elem); 35 | 36 | ParserFactory* parserFactory; 37 | FarEditorSet* farEditorSet; 38 | }; 39 | 40 | #endif // FARCOLORER_FARHRCSETTINGS_H -------------------------------------------------------------------------------- /src/HrcSettingsForm.cpp: -------------------------------------------------------------------------------- 1 | #include "HrcSettingsForm.h" 2 | #include 3 | #include "FarHrcSettings.h" 4 | #include "tools.h" 5 | 6 | HrcSettingsForm::HrcSettingsForm(FarEditorSet* _farEditorSet, FileType* filetype) 7 | { 8 | menuid = 0; 9 | farEditorSet = _farEditorSet; 10 | current_filetype = nullptr; 11 | filetype_in_editor = filetype; 12 | } 13 | 14 | bool HrcSettingsForm::Show() 15 | { 16 | return showForm(); 17 | } 18 | 19 | INT_PTR WINAPI SettingHrcDialogProc(HANDLE hDlg, intptr_t Msg, intptr_t Param1, void* Param2) 20 | { 21 | auto* fes = reinterpret_cast(Info.SendDlgMessage(hDlg, DM_GETDLGDATA, 0, nullptr)); 22 | 23 | switch (Msg) { 24 | case DN_INITDIALOG: { 25 | fes->menuid = -1; 26 | fes->OnChangeHrc(); 27 | return false; 28 | } 29 | case DN_BTNCLICK: 30 | if (IDX_CH_OK == Param1) { 31 | fes->OnSaveHrcParams(); 32 | return false; 33 | } 34 | break; 35 | case DN_EDITCHANGE: 36 | if (IDX_CH_SCHEMAS == Param1) { 37 | fes->menuid = -1; 38 | fes->OnChangeHrc(); 39 | return true; 40 | } 41 | 42 | break; 43 | case DN_LISTCHANGE: 44 | if (IDX_CH_PARAM_LIST == Param1) { 45 | fes->OnChangeParam(reinterpret_cast(Param2)); 46 | return true; 47 | } 48 | break; 49 | default: 50 | break; 51 | } 52 | return Info.DefDlgProc(hDlg, Msg, Param1, Param2); 53 | } 54 | 55 | bool HrcSettingsForm::showForm() 56 | { 57 | if (!farEditorSet->Opt.rEnabled) { 58 | return false; 59 | } 60 | 61 | FarDialogItem fdi[] = { 62 | // type, x1, y1, x2, y2, param, history, mask, flags, userdata, ptrdata, maxlen 63 | {DI_DOUBLEBOX, 2, 1, 56, 21, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_BOX, 64 | {DI_TEXT, 3, 3, 0, 3, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_CAPTIONLIST, 65 | {DI_COMBOBOX, 10, 3, 54, 2, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_SCHEMAS, 66 | {DI_LISTBOX, 3, 4, 30, 17, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_PARAM_LIST, 67 | {DI_TEXT, 32, 5, 0, 5, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_PARAM_VALUE_CAPTION 68 | {DI_COMBOBOX, 32, 6, 54, 6, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_PARAM_VALUE_LIST 69 | {DI_EDIT, 4, 18, 54, 18, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_DESCRIPTION, 70 | {DI_BUTTON, 37, 20, 0, 0, 0, nullptr, nullptr, DIF_DEFAULTBUTTON, nullptr, 0, 0}, // IDX_CH_OK, 71 | {DI_BUTTON, 45, 20, 0, 0, 0, nullptr, nullptr, 0, nullptr, 0, 0}, // IDX_CH_CANCEL, 72 | }; 73 | 74 | fdi[IDX_CH_BOX].Data = FarEditorSet::GetMsg(mUserHrcSettingDialog); 75 | fdi[IDX_CH_CAPTIONLIST].Data = FarEditorSet::GetMsg(mListSyntax); 76 | FarList* l = buildHrcList(); 77 | fdi[IDX_CH_SCHEMAS].ListItems = l; 78 | fdi[IDX_CH_SCHEMAS].Flags = DIF_LISTWRAPMODE | DIF_DROPDOWNLIST; 79 | fdi[IDX_CH_OK].Data = FarEditorSet::GetMsg(mOk); 80 | fdi[IDX_CH_CANCEL].Data = FarEditorSet::GetMsg(mCancel); 81 | fdi[IDX_CH_PARAM_LIST].Data = FarEditorSet::GetMsg(mParamList); 82 | fdi[IDX_CH_PARAM_VALUE_CAPTION].Data = FarEditorSet::GetMsg(mParamValue); 83 | fdi[IDX_CH_DESCRIPTION].Flags = DIF_READONLY; 84 | 85 | fdi[IDX_CH_PARAM_LIST].Flags = DIF_LISTWRAPMODE | DIF_LISTNOCLOSE; 86 | 87 | hDlg = Info.DialogInit(&MainGuid, &HrcPluginConfig, -1, -1, 59, 23, L"confighrc", fdi, std::size(fdi), 0, 0, SettingHrcDialogProc, this); 88 | if (IDX_CH_OK == Info.DialogRun(hDlg)) { 89 | SaveChangedValueParam(); 90 | } 91 | 92 | removeFarList(l); 93 | 94 | Info.DialogFree(hDlg); 95 | return true; 96 | } 97 | 98 | size_t HrcSettingsForm::getCountFileTypeAndGroup() const 99 | { 100 | size_t num = 0; 101 | UnicodeString group; 102 | FileType* type; 103 | 104 | for (int idx = 0;; idx++) { 105 | type = farEditorSet->parserFactory->getHrcLibrary().enumerateFileTypes(idx); 106 | 107 | if (type == nullptr) { 108 | break; 109 | } 110 | 111 | num++; 112 | if (group.compare(type->getGroup()) != 0) { 113 | num++; 114 | group = type->getGroup(); 115 | } 116 | } 117 | return num; 118 | } 119 | 120 | FarList* HrcSettingsForm::buildHrcList() const 121 | { 122 | size_t num = getCountFileTypeAndGroup(); 123 | UnicodeString group; 124 | FileType* type; 125 | 126 | auto* hrcList = new FarListItem[num] {}; 127 | 128 | HrcLibrary& hrcLibrary = farEditorSet->parserFactory->getHrcLibrary(); 129 | for (int idx = 0, i = 0;; idx++, i++) { 130 | type = hrcLibrary.enumerateFileTypes(idx); 131 | 132 | if (type == nullptr) { 133 | break; 134 | } 135 | 136 | if (type == filetype_in_editor) { 137 | hrcList[i].Flags = LIF_SELECTED; 138 | } 139 | 140 | if (group.compare(type->getGroup()) != 0) { 141 | hrcList[i].Flags = LIF_SEPARATOR; 142 | i++; 143 | } 144 | 145 | group = type->getGroup(); 146 | 147 | std::wstring groupChars; 148 | 149 | if (group != nullptr) { 150 | groupChars = UStr::to_stdwstr(group); 151 | } 152 | else { 153 | groupChars = std::wstring(L""); 154 | } 155 | 156 | hrcList[i].Text = new wchar_t[255]; 157 | _snwprintf(const_cast(hrcList[i].Text), 255, L"%s: %s", groupChars.c_str(), UStr::to_stdwstr(type->getDescription()).c_str()); 158 | hrcList[i].UserData = (intptr_t) type; 159 | } 160 | 161 | return buildFarList(hrcList, num); 162 | } 163 | 164 | void HrcSettingsForm::OnChangeParam(intptr_t idx) 165 | { 166 | if (menuid != idx && menuid != -1) { 167 | SaveChangedValueParam(); 168 | } 169 | FarListGetItem List {sizeof(FarListGetItem), idx}; 170 | bool res = Info.SendDlgMessage(hDlg, DM_LISTGETITEM, IDX_CH_PARAM_LIST, &List); 171 | if (!res) 172 | return; 173 | 174 | menuid = idx; 175 | UnicodeString p = UnicodeString(List.Item.Text); 176 | 177 | const UnicodeString* value; 178 | value = current_filetype->getParamDescription(p); 179 | if (value == nullptr) { 180 | value = farEditorSet->defaultType->getParamDescription(p); 181 | } 182 | if (value != nullptr) { 183 | Info.SendDlgMessage(hDlg, DM_SETTEXTPTR, IDX_CH_DESCRIPTION, (void*) UStr::to_stdwstr(value).c_str()); 184 | } 185 | 186 | // set visible begin of text 187 | COORD c {0, 0}; 188 | Info.SendDlgMessage(hDlg, DM_SETCURSORPOS, IDX_CH_DESCRIPTION, &c); 189 | 190 | if (UnicodeString(param_ShowCross).compare(p) == 0) { 191 | setCrossValueListToCombobox(); 192 | } 193 | else { 194 | if (UnicodeString(param_CrossZorder).compare(p) == 0) { 195 | setCrossPosValueListToCombobox(); 196 | } 197 | else if (UnicodeString(param_MaxLen).compare(p) == 0 || UnicodeString(param_Backparse).compare(p) == 0 || 198 | UnicodeString(param_DefFore).compare(p) == 0 || UnicodeString(param_DefBack).compare(p) == 0 || 199 | UnicodeString(param_Firstlines).compare(p) == 0 || UnicodeString(param_Firstlinebytes).compare(p) == 0 || 200 | UnicodeString(param_HotKey).compare(p) == 0 || UnicodeString(param_MaxBlockSize).compare(p) == 0) { 201 | setCustomListValueToCombobox(UnicodeString(List.Item.Text)); 202 | } 203 | else if (UnicodeString(param_Fullback).compare(p) == 0) { 204 | setYNListValueToCombobox(UnicodeString(List.Item.Text)); 205 | } 206 | else { 207 | setTFListValueToCombobox(UnicodeString(List.Item.Text)); 208 | } 209 | } 210 | } 211 | 212 | void HrcSettingsForm::OnSaveHrcParams() const 213 | { 214 | SaveChangedValueParam(); 215 | FarHrcSettings p(farEditorSet, farEditorSet->parserFactory.get()); 216 | p.writeUserProfile(); 217 | } 218 | 219 | void HrcSettingsForm::SaveChangedValueParam() const 220 | { 221 | FarListGetItem List = {sizeof(FarListGetItem), menuid}; 222 | bool res = Info.SendDlgMessage(hDlg, DM_LISTGETITEM, IDX_CH_PARAM_LIST, &List); 223 | 224 | if (!res) 225 | return; 226 | 227 | // param name 228 | UnicodeString p = UnicodeString(List.Item.Text); 229 | // param value 230 | UnicodeString v = UnicodeString(trim(reinterpret_cast(Info.SendDlgMessage(hDlg, DM_GETCONSTTEXTPTR, IDX_CH_PARAM_VALUE_LIST, nullptr)))); 231 | 232 | const UnicodeString* value = current_filetype->getParamUserValue(p); 233 | const UnicodeString* def_value = getParamDefValue(current_filetype, p); 234 | if (v.compare(*def_value) == 0) { 235 | if (value != nullptr) 236 | current_filetype->setParamValue(p, nullptr); 237 | } 238 | else if (value == nullptr || v.compare(*value) != 0) { // changed 239 | farEditorSet->addParamAndValue(current_filetype, p, v); 240 | } 241 | delete def_value; 242 | } 243 | 244 | void HrcSettingsForm::getCurrentTypeInDialog() 245 | { 246 | auto k = static_cast(Info.SendDlgMessage(hDlg, DM_LISTGETCURPOS, IDX_CH_SCHEMAS, nullptr)); 247 | FarListGetItem f {sizeof(FarListGetItem), k}; 248 | bool res = Info.SendDlgMessage(hDlg, DM_LISTGETITEM, IDX_CH_SCHEMAS, (void*) &f); 249 | if (res) 250 | current_filetype = (FileType*) f.Item.UserData; 251 | } 252 | 253 | void HrcSettingsForm::OnChangeHrc() 254 | { 255 | if (menuid != -1) { 256 | SaveChangedValueParam(); 257 | } 258 | getCurrentTypeInDialog(); 259 | FarList* List = buildParamsList(current_filetype); 260 | 261 | Info.SendDlgMessage(hDlg, DM_LISTSET, IDX_CH_PARAM_LIST, List); 262 | removeFarList(List); 263 | OnChangeParam(0); 264 | } 265 | 266 | void HrcSettingsForm::setYNListValueToCombobox(const UnicodeString& param) const 267 | { 268 | const UnicodeString* value = current_filetype->getParamUserValue(param); 269 | const UnicodeString* def_value = getParamDefValue(current_filetype, param); 270 | 271 | size_t count = 3; 272 | auto* fcross = new FarListItem[count] {}; 273 | fcross[0].Text = _wcsdup(value_No); 274 | fcross[1].Text = _wcsdup(value_Yes); 275 | fcross[2].Text = _wcsdup(UStr::to_stdwstr(def_value).c_str()); 276 | delete def_value; 277 | 278 | size_t ret; 279 | if (value == nullptr || !value->length()) { 280 | ret = 2; 281 | } 282 | else { 283 | if (value->compare(value_No) == 0) { 284 | ret = 0; 285 | } 286 | else if (value->compare(value_Yes) == 0) { 287 | ret = 1; 288 | } 289 | else { 290 | ret = 2; 291 | } 292 | } 293 | fcross[ret].Flags = LIF_SELECTED; 294 | auto* lcross = buildFarList(fcross, count); 295 | ChangeParamValueList(lcross, true); 296 | removeFarList(lcross); 297 | } 298 | 299 | void HrcSettingsForm::setTFListValueToCombobox(const UnicodeString& param) const 300 | { 301 | const UnicodeString* value = current_filetype->getParamUserValue(param); 302 | const UnicodeString* def_value = getParamDefValue(current_filetype, param); 303 | 304 | size_t count = 3; 305 | auto* fcross = new FarListItem[count] {}; 306 | fcross[0].Text = _wcsdup(value_False); 307 | fcross[1].Text = _wcsdup(value_True); 308 | fcross[2].Text = _wcsdup(UStr::to_stdwstr(def_value).c_str()); 309 | delete def_value; 310 | 311 | size_t ret; 312 | if (value == nullptr || !value->length()) { 313 | ret = 2; 314 | } 315 | else { 316 | if (value->compare(value_False) == 0) { 317 | ret = 0; 318 | } 319 | else if (value->compare(value_True) == 0) { 320 | ret = 1; 321 | } 322 | else { 323 | ret = 2; 324 | } 325 | } 326 | fcross[ret].Flags = LIF_SELECTED; 327 | auto* lcross = buildFarList(fcross, count); 328 | ChangeParamValueList(lcross, true); 329 | removeFarList(lcross); 330 | } 331 | 332 | void HrcSettingsForm::setCustomListValueToCombobox(const UnicodeString& param) const 333 | { 334 | const UnicodeString* value = current_filetype->getParamUserValue(param); 335 | const UnicodeString* def_value = getParamDefValue(current_filetype, param); 336 | 337 | size_t count = 1; 338 | auto* fcross = new FarListItem[count] {}; 339 | fcross[0].Text = _wcsdup(UStr::to_stdwstr(def_value).c_str()); 340 | delete def_value; 341 | 342 | fcross[0].Flags = LIF_SELECTED; 343 | auto* lcross = buildFarList(fcross, count); 344 | ChangeParamValueList(lcross, false); 345 | removeFarList(lcross); 346 | 347 | if (value != nullptr) { 348 | Info.SendDlgMessage(hDlg, DM_SETTEXTPTR, IDX_CH_PARAM_VALUE_LIST, (void*) UStr::to_stdwstr(value).c_str()); 349 | } 350 | } 351 | 352 | void HrcSettingsForm::setCrossValueListToCombobox() const 353 | { 354 | auto uparam = UnicodeString(param_ShowCross); 355 | const UnicodeString* value = current_filetype->getParamUserValue(uparam); 356 | const UnicodeString* def_value = getParamDefValue(current_filetype, uparam); 357 | 358 | size_t count = 5; 359 | auto* fcross = new FarListItem[count] {}; 360 | fcross[0].Text = _wcsdup(value_None); 361 | fcross[1].Text = _wcsdup(value_Vertical); 362 | fcross[2].Text = _wcsdup(value_Horizontal); 363 | fcross[3].Text = _wcsdup(value_Both); 364 | fcross[4].Text = _wcsdup(UStr::to_stdwstr(def_value).c_str()); 365 | delete def_value; 366 | 367 | size_t ret = 0; 368 | if (value == nullptr || !value->length()) { 369 | ret = 4; 370 | } 371 | else { 372 | if (value->compare(value_None) == 0) { 373 | ret = 0; 374 | } 375 | else if (value->compare(value_Vertical) == 0) { 376 | ret = 1; 377 | } 378 | else if (value->compare(value_Horizontal) == 0) { 379 | ret = 2; 380 | } 381 | else if (value->compare(value_Both) == 0) { 382 | ret = 3; 383 | } 384 | } 385 | fcross[ret].Flags = LIF_SELECTED; 386 | auto* lcross = buildFarList(fcross, count); 387 | ChangeParamValueList(lcross, true); 388 | removeFarList(lcross); 389 | } 390 | 391 | void HrcSettingsForm::setCrossPosValueListToCombobox() const 392 | { 393 | auto uparam = UnicodeString(param_CrossZorder); 394 | const UnicodeString* value = current_filetype->getParamUserValue(uparam); 395 | const UnicodeString* def_value = getParamDefValue(current_filetype, uparam); 396 | 397 | size_t count = 3; 398 | auto* fcross = new FarListItem[count] {}; 399 | fcross[0].Text = _wcsdup(value_Bottom); 400 | fcross[1].Text = _wcsdup(value_Top); 401 | fcross[2].Text = _wcsdup(UStr::to_stdwstr(def_value).c_str()); 402 | delete def_value; 403 | 404 | size_t ret; 405 | if (value == nullptr || !value->length()) { 406 | ret = 2; 407 | } 408 | else { 409 | if (value->compare(value_Bottom) == 0) { 410 | ret = 0; 411 | } 412 | else if (value->compare(value_Top) == 0) { 413 | ret = 1; 414 | } 415 | else { 416 | ret = 2; 417 | } 418 | } 419 | fcross[ret].Flags = LIF_SELECTED; 420 | auto* lcross = buildFarList(fcross, count); 421 | 422 | ChangeParamValueList(lcross, true); 423 | removeFarList(lcross); 424 | } 425 | 426 | const UnicodeString* HrcSettingsForm::getParamDefValue(FileType* type, const UnicodeString& param) const 427 | { 428 | const UnicodeString* value; 429 | value = type->getParamDefaultValue(param); 430 | if (value == nullptr) { 431 | value = farEditorSet->defaultType->getParamValue(param); 432 | } 433 | if (value == nullptr) { 434 | return new UnicodeString(""); 435 | } 436 | else { 437 | auto* p = new UnicodeString("append(*value); 439 | p->append(">"); 440 | return p; 441 | } 442 | } 443 | 444 | FarList* HrcSettingsForm::buildParamsList(FileType* type) const 445 | { 446 | auto type_params = type->enumParams(); 447 | auto default_params = farEditorSet->defaultType->enumParams(); 448 | type_params.insert(type_params.end(), default_params.begin(), default_params.end()); 449 | std::sort(type_params.begin(), type_params.end()); 450 | auto last = std::unique(type_params.begin(), type_params.end()); 451 | type_params.erase(last, type_params.end()); 452 | 453 | size_t count = 0; 454 | auto* fparam = new FarListItem[type_params.size()] {}; 455 | for (const auto& param : type_params) { 456 | fparam[count++].Text = _wcsdup(UStr::to_stdwstr(¶m).c_str()); 457 | } 458 | fparam[0].Flags = LIF_SELECTED; 459 | return buildFarList(fparam, type_params.size()); 460 | } 461 | 462 | void HrcSettingsForm::ChangeParamValueList(FarList* items, bool dropdownlist) const 463 | { 464 | FARDIALOGITEMFLAGS flags = DIF_LISTWRAPMODE; 465 | if (dropdownlist) { 466 | flags |= DIF_DROPDOWNLIST; 467 | } 468 | FarDialogItem fdi {DI_COMBOBOX, 32, 6, 54, 6, 0, nullptr, nullptr, flags, nullptr, 0, 0}; 469 | // так не работает 470 | // fdi.ListItems = items; 471 | 472 | Info.SendDlgMessage(hDlg, DM_SETDLGITEM, IDX_CH_PARAM_VALUE_LIST, &fdi); 473 | Info.SendDlgMessage(hDlg, DM_LISTSET, IDX_CH_PARAM_VALUE_LIST, items); 474 | } 475 | 476 | FarList* HrcSettingsForm::buildFarList(FarListItem* list, size_t count) 477 | { 478 | auto* lparam = new FarList; 479 | lparam->Items = list; 480 | lparam->ItemsNumber = count; 481 | lparam->StructSize = sizeof(FarList); 482 | return lparam; 483 | } 484 | 485 | void HrcSettingsForm::removeFarList(FarList* list) 486 | { 487 | for (size_t idx = 0; idx < list->ItemsNumber; idx++) { 488 | delete[] list->Items[idx].Text; 489 | } 490 | delete[] list->Items; 491 | delete list; 492 | } -------------------------------------------------------------------------------- /src/HrcSettingsForm.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_HRCSETTINGSFORM_H 2 | #define FARCOLORER_HRCSETTINGSFORM_H 3 | 4 | #include "FarEditorSet.h" 5 | 6 | class HrcSettingsForm 7 | { 8 | public: 9 | explicit HrcSettingsForm(FarEditorSet* _farEditorSet, FileType* filetype); 10 | ~HrcSettingsForm() = default; 11 | 12 | bool Show(); 13 | 14 | bool showForm(); 15 | [[nodiscard]] FarList* buildHrcList() const; 16 | void OnSaveHrcParams() const; 17 | void OnChangeParam(intptr_t idx); 18 | void SaveChangedValueParam() const; 19 | void getCurrentTypeInDialog(); 20 | void OnChangeHrc(); 21 | void setCustomListValueToCombobox(const UnicodeString& param) const; 22 | void setTFListValueToCombobox(const UnicodeString& param) const; 23 | void setYNListValueToCombobox(const UnicodeString& param) const; 24 | void setCrossPosValueListToCombobox() const; 25 | void setCrossValueListToCombobox() const; 26 | void ChangeParamValueList(FarList* items, bool dropdownlist) const; 27 | FarList* buildParamsList(FileType* type) const; 28 | const UnicodeString* getParamDefValue(FileType* type, const UnicodeString& param) const; 29 | [[nodiscard]] size_t getCountFileTypeAndGroup() const; 30 | 31 | static FarList* buildFarList(FarListItem* list, size_t count); 32 | static void removeFarList(FarList* list); 33 | 34 | FarEditorSet* farEditorSet; 35 | intptr_t menuid; 36 | FileType* current_filetype; 37 | FileType* filetype_in_editor; 38 | HANDLE hDlg {}; 39 | }; 40 | 41 | #endif // FARCOLORER_HRCSETTINGSFORM_H 42 | -------------------------------------------------------------------------------- /src/SettingsControl.cpp: -------------------------------------------------------------------------------- 1 | #include "SettingsControl.h" 2 | 3 | SettingsControl::SettingsControl() 4 | { 5 | FarSettingsCreate fsc {}; 6 | fsc.Guid = MainGuid; 7 | fsc.StructSize = sizeof(FarSettingsCreate); 8 | if (Info.SettingsControl(INVALID_HANDLE_VALUE, SCTL_CREATE, PSL_ROAMING, &fsc)) { 9 | farSettingHandle = fsc.Handle; 10 | } 11 | else { 12 | farSettingHandle = INVALID_HANDLE_VALUE; 13 | throw SettingsControlException("Access error to the FarSettings."); 14 | } 15 | } 16 | 17 | SettingsControl::~SettingsControl() 18 | { 19 | Info.SettingsControl(farSettingHandle, SCTL_FREE, 0, nullptr); 20 | } 21 | 22 | const wchar_t* SettingsControl::Get(size_t Root, const wchar_t* Name, const wchar_t* Default) 23 | { 24 | FarSettingsItem item = {sizeof(FarSettingsItem), Root, Name, FST_STRING}; 25 | if (Info.SettingsControl(farSettingHandle, SCTL_GET, 0, &item)) { 26 | return item.String; 27 | } 28 | return Default; 29 | } 30 | 31 | void SettingsControl::Get(size_t Root, const wchar_t* Name, wchar_t* Value, size_t Size, const wchar_t* Default) 32 | { 33 | lstrcpynW(Value, Get(Root, Name, Default), (int) Size); 34 | } 35 | 36 | unsigned __int64 SettingsControl::Get(size_t Root, const wchar_t* Name, unsigned __int64 Default) 37 | { 38 | FarSettingsItem item = {sizeof(FarSettingsItem), Root, Name, FST_QWORD}; 39 | if (Info.SettingsControl(farSettingHandle, SCTL_GET, 0, &item)) { 40 | return item.Number; 41 | } 42 | return Default; 43 | } 44 | 45 | bool SettingsControl::Set(size_t Root, const wchar_t* Name, const wchar_t* Value) 46 | { 47 | FarSettingsItem item = {sizeof(FarSettingsItem), Root, Name, FST_STRING}; 48 | item.String = Value; 49 | return Info.SettingsControl(farSettingHandle, SCTL_SET, 0, &item) != FALSE; 50 | } 51 | 52 | bool SettingsControl::Set(size_t Root, const wchar_t* Name, unsigned __int64 Value) 53 | { 54 | FarSettingsItem item = {sizeof(FarSettingsItem), Root, Name, FST_QWORD}; 55 | item.Number = Value; 56 | return Info.SettingsControl(farSettingHandle, SCTL_SET, 0, &item) != FALSE; 57 | } 58 | 59 | size_t SettingsControl::rGetSubKey(size_t Root, const wchar_t* Name) 60 | { 61 | FarSettingsValue fsv = {sizeof(FarSettingsValue), Root, Name}; 62 | return (size_t) Info.SettingsControl(farSettingHandle, SCTL_CREATESUBKEY, 0, &fsv); 63 | } 64 | 65 | bool SettingsControl::rEnum(size_t Root, FarSettingsEnum* fse) 66 | { 67 | fse->Root = Root; 68 | return Info.SettingsControl(farSettingHandle, SCTL_ENUM, 0, fse) != 0; 69 | } 70 | 71 | bool SettingsControl::rDeleteSubKey(size_t Root, const wchar_t* Name) 72 | { 73 | FarSettingsValue fsv = {sizeof(FarSettingsValue), Root, Name}; 74 | return Info.SettingsControl(farSettingHandle, SCTL_DELETE, 0, &fsv) != 0; 75 | } 76 | 77 | __int64 SettingsControl::Get(size_t Root, const wchar_t* Name, __int64 Default) 78 | { 79 | return (__int64) Get(Root, Name, (unsigned __int64) Default); 80 | } 81 | 82 | int SettingsControl::Get(size_t Root, const wchar_t* Name, int Default) 83 | { 84 | return (int) Get(Root, Name, (unsigned __int64) Default); 85 | } 86 | 87 | unsigned int SettingsControl::Get(size_t Root, const wchar_t* Name, unsigned int Default) 88 | { 89 | return (unsigned int) Get(Root, Name, (unsigned __int64) Default); 90 | } 91 | 92 | DWORD SettingsControl::Get(size_t Root, const wchar_t* Name, DWORD Default) 93 | { 94 | return (DWORD) Get(Root, Name, (unsigned __int64) Default); 95 | } 96 | 97 | bool SettingsControl::Get(size_t Root, const wchar_t* Name, bool Default) 98 | { 99 | return Get(Root, Name, Default ? 1ull : 0ull) != 0; 100 | } 101 | 102 | bool SettingsControl::Set(size_t Root, const wchar_t* Name, __int64 Value) 103 | { 104 | return Set(Root, Name, (unsigned __int64) Value); 105 | } 106 | 107 | bool SettingsControl::Set(size_t Root, const wchar_t* Name, int Value) 108 | { 109 | return Set(Root, Name, (unsigned __int64) Value); 110 | } 111 | 112 | bool SettingsControl::Set(size_t Root, const wchar_t* Name, unsigned int Value) 113 | { 114 | return Set(Root, Name, (unsigned __int64) Value); 115 | } 116 | 117 | bool SettingsControl::Set(size_t Root, const wchar_t* Name, DWORD Value) 118 | { 119 | return Set(Root, Name, (unsigned __int64) Value); 120 | } 121 | 122 | bool SettingsControl::Set(size_t Root, const wchar_t* Name, bool Value) 123 | { 124 | return Set(Root, Name, Value ? 1ull : 0ull); 125 | } -------------------------------------------------------------------------------- /src/SettingsControl.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_SETTINGSCONTROL_H 2 | #define FARCOLORER_SETTINGSCONTROL_H 3 | 4 | #include 5 | #include "pcolorer.h" 6 | 7 | class SettingsControl 8 | { 9 | public: 10 | SettingsControl(); 11 | ~SettingsControl(); 12 | 13 | const wchar_t* Get(size_t Root, const wchar_t* Name, const wchar_t* Default); 14 | void Get(size_t Root, const wchar_t* Name, wchar_t* Value, size_t Size, const wchar_t* Default); 15 | unsigned __int64 Get(size_t Root, const wchar_t* Name, unsigned __int64 Default); 16 | __int64 Get(size_t Root, const wchar_t* Name, __int64 Default); 17 | int Get(size_t Root, const wchar_t* Name, int Default); 18 | unsigned int Get(size_t Root, const wchar_t* Name, unsigned int Default); 19 | DWORD Get(size_t Root, const wchar_t* Name, DWORD Default); 20 | bool Get(size_t Root, const wchar_t* Name, bool Default); 21 | 22 | bool Set(size_t Root, const wchar_t* Name, unsigned __int64 Value); 23 | bool Set(size_t Root, const wchar_t* Name, const wchar_t* Value); 24 | bool Set(size_t Root, const wchar_t* Name, __int64 Value); 25 | bool Set(size_t Root, const wchar_t* Name, int Value); 26 | bool Set(size_t Root, const wchar_t* Name, unsigned int Value); 27 | bool Set(size_t Root, const wchar_t* Name, DWORD Value); 28 | bool Set(size_t Root, const wchar_t* Name, bool Value); 29 | 30 | size_t rGetSubKey(size_t Root, const wchar_t* Name); 31 | bool rEnum(size_t Root, FarSettingsEnum* fse); 32 | bool rDeleteSubKey(size_t Root, const wchar_t* Name); 33 | 34 | private: 35 | HANDLE farSettingHandle; 36 | }; 37 | 38 | class SettingsControlException : public Exception 39 | { 40 | public: 41 | explicit SettingsControlException(const UnicodeString& msg) noexcept : Exception("[SettingsControl] " + msg) {} 42 | }; 43 | 44 | #endif // FARCOLORER_SETTINGSCONTROL_H -------------------------------------------------------------------------------- /src/SimpleLogger.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMPLELOGGER_H 2 | #define SIMPLELOGGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "colorer/common/Logger.h" 8 | 9 | class SimpleLogger : public Logger 10 | { 11 | public: 12 | static constexpr std::string_view LogLevelStr[] {"off", "error", "warning", "info", "debug", "trace"}; 13 | 14 | SimpleLogger(const std::string& filename, const std::string& log_level) 15 | { 16 | current_level = getLogLevel(log_level); 17 | log_filename = filename; 18 | open_logfile(); 19 | } 20 | 21 | SimpleLogger(const std::string& filename, const Logger::LogLevel log_level) 22 | { 23 | current_level = log_level; 24 | log_filename = filename; 25 | open_logfile(); 26 | } 27 | 28 | ~SimpleLogger() override { ofs.close(); } 29 | 30 | void open_logfile() 31 | { 32 | if (current_level == LOG_OFF || ofs.is_open()) { 33 | return; 34 | } 35 | ofs.open(log_filename.c_str(), std::ofstream::out | std::ofstream::app); 36 | if (!ofs.is_open()) { 37 | throw std::runtime_error("Could not open file to write logs: " + log_filename); 38 | } 39 | } 40 | 41 | void log(Logger::LogLevel level, const char* /*filename_in*/, int /*line_in*/, const char* /*funcname_in*/, 42 | const char* message) 43 | { 44 | if (level > current_level) { 45 | return; 46 | } 47 | std::time_t const t = std::time(nullptr); 48 | char mbstr[30]; 49 | std::strftime(mbstr, sizeof(mbstr), "%FT%T", std::localtime(&t)); 50 | ofs << "[" << mbstr << "] " 51 | << "[" << LogLevelStr[level] << "] "; 52 | ofs << message << '\n'; 53 | } 54 | 55 | static Logger::LogLevel getLogLevel(const std::string& log_level) 56 | { 57 | int i = 0; 58 | for (auto it : LogLevelStr) { 59 | if (log_level == it) { 60 | return static_cast(i); 61 | } 62 | i++; 63 | } 64 | if (log_level == "warn") { 65 | return Logger::LOG_WARN; 66 | } 67 | return Logger::LOG_OFF; 68 | } 69 | 70 | void setLogLevel(Logger::LogLevel level) 71 | { 72 | ofs.flush(); 73 | if (current_level == Logger::LOG_OFF) { 74 | current_level = level; 75 | open_logfile(); 76 | } 77 | current_level = level; 78 | } 79 | 80 | void flush() { ofs.flush(); } 81 | 82 | private: 83 | std::ofstream ofs; 84 | Logger::LogLevel current_level; 85 | std::string log_filename; 86 | }; 87 | 88 | #endif // SIMPLELOGGER_H -------------------------------------------------------------------------------- /src/const_strings.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_PARAMNAMES_H 2 | #define FARCOLORER_PARAMNAMES_H 3 | 4 | static const wchar_t name_DefaultScheme[] = L"default"; 5 | static const wchar_t param_ShowCross[] = L"show-cross"; 6 | static const wchar_t value_None[] = L"none"; 7 | static const wchar_t value_Vertical[] = L"vertical"; 8 | static const wchar_t value_Horizontal[] = L"horizontal"; 9 | static const wchar_t value_Both[] = L"both"; 10 | static const wchar_t param_CrossZorder[] = L"cross-zorder"; 11 | static const wchar_t value_Bottom[] = L"bottom"; 12 | static const wchar_t value_Top[] = L"top"; 13 | static const wchar_t value_Yes[] = L"yes"; 14 | static const wchar_t value_No[] = L"no"; 15 | static const wchar_t value_True[] = L"true"; 16 | static const wchar_t value_False[] = L"false"; 17 | static const wchar_t param_Backparse[] = L"backparse"; 18 | static const wchar_t param_MaxBlockSize[] = L"maxblocksize"; 19 | static const wchar_t param_MaxLen[] = L"maxlinelength"; 20 | static const wchar_t param_DefFore[] = L"default-fore"; 21 | static const wchar_t param_DefBack[] = L"default-back"; 22 | static const wchar_t param_Fullback[] = L"fullback"; 23 | static const wchar_t param_HotKey[] = L"hotkey"; 24 | static const wchar_t param_Favorite[] = L"favorite"; 25 | static const wchar_t param_Firstlines[] = L"firstlines"; 26 | static const wchar_t param_Firstlinebytes[] = L"firstlinebytes"; 27 | static const wchar_t region_DefOutlined[] = L"def:Outlined"; 28 | static const wchar_t region_DefError[] = L"def:Error"; 29 | static const wchar_t region_DefText[] = L"def:Text"; 30 | 31 | #endif // FARCOLORER_PARAMNAMES_H 32 | -------------------------------------------------------------------------------- /src/pcolorer.cpp: -------------------------------------------------------------------------------- 1 | #include "pcolorer.h" 2 | #include "FarEditorSet.h" 3 | #include "version.h" 4 | 5 | FarEditorSet* editorSet = nullptr; 6 | bool inEventProcess = false; 7 | PluginStartupInfo Info; 8 | FarStandardFunctions FSF; 9 | 10 | /** 11 | Returns message from FAR current language. 12 | */ 13 | const wchar_t* GetMsg(int msg) 14 | { 15 | return Info.GetMsg(&MainGuid, msg); 16 | } 17 | 18 | /** 19 | Global information about the plugin 20 | */ 21 | void WINAPI GetGlobalInfoW(struct GlobalInfo* gInfo) 22 | { 23 | gInfo->StructSize = sizeof(GlobalInfo); 24 | gInfo->MinFarVersion = MAKEFARVERSION(3, 0, 0, 3371, VS_RELEASE); 25 | gInfo->Version = MAKEFARVERSION(PLUGIN_VER_MAJOR, PLUGIN_VER_MINOR, PLUGIN_VER_PATCH, 0, VS_RELEASE); 26 | gInfo->Guid = MainGuid; 27 | gInfo->Title = PLUGIN_NAME; 28 | gInfo->Author = L"Igor Ruskih, Dobrunov Aleksey, Eugene Efremov"; 29 | 30 | #ifdef COLORER_FEATURE_ICU 31 | gInfo->Description = L"Syntax highlighting in Far editor (ICU)"; 32 | #else 33 | gInfo->Description = L"Syntax highlighting in Far editor"; 34 | #endif 35 | } 36 | 37 | /** 38 | Plugin initialization and creation of editor set support class. 39 | */ 40 | void WINAPI SetStartupInfoW(const struct PluginStartupInfo* fei) 41 | { 42 | Info = *fei; 43 | FSF = *fei->FSF; 44 | Info.FSF = &FSF; 45 | } 46 | 47 | /** 48 | Plugin strings in FAR interface. 49 | */ 50 | void WINAPI GetPluginInfoW(struct PluginInfo* pInfo) 51 | { 52 | static wchar_t* PluginMenuStrings; 53 | memset(pInfo, 0, sizeof(*pInfo)); 54 | pInfo->Flags = PF_EDITOR | PF_DISABLEPANELS; 55 | pInfo->StructSize = sizeof(*pInfo); 56 | pInfo->PluginConfig.Count = 1; 57 | pInfo->PluginMenu.Count = 1; 58 | PluginMenuStrings = (wchar_t*) GetMsg(mName); 59 | pInfo->PluginConfig.Strings = &PluginMenuStrings; 60 | pInfo->PluginMenu.Strings = &PluginMenuStrings; 61 | pInfo->PluginConfig.Guids = &PluginConfig; 62 | pInfo->PluginMenu.Guids = &PluginMenu; 63 | pInfo->CommandPrefix = L"clr"; 64 | } 65 | 66 | /** 67 | On FAR exit. Destroys all internal structures. 68 | */ 69 | void WINAPI ExitFARW(const struct ExitInfo* /*eInfo*/) 70 | { 71 | delete editorSet; 72 | } 73 | 74 | /** 75 | Open plugin configuration of actions dialog. 76 | */ 77 | HANDLE WINAPI OpenW(const struct OpenInfo* oInfo) 78 | { 79 | HANDLE result = nullptr; 80 | if (!editorSet) { 81 | editorSet = new FarEditorSet(); 82 | } 83 | 84 | switch (oInfo->OpenFrom) { 85 | case OPEN_EDITOR: 86 | editorSet->openMenu(); 87 | break; 88 | case OPEN_COMMANDLINE: 89 | editorSet->openFromCommandLine(oInfo); 90 | break; 91 | case OPEN_FROMMACRO: 92 | result = editorSet->openFromMacro(oInfo); 93 | case OPEN_LEFTDISKMENU: 94 | case OPEN_PLUGINSMENU: 95 | case OPEN_FINDLIST: 96 | case OPEN_SHORTCUT: 97 | case OPEN_VIEWER: 98 | case OPEN_FILEPANEL: 99 | case OPEN_DIALOG: 100 | case OPEN_ANALYSE: 101 | case OPEN_RIGHTDISKMENU: 102 | case OPEN_LUAMACRO: 103 | break; 104 | } 105 | 106 | Log::flush(); 107 | return result; 108 | } 109 | 110 | /** 111 | Configures plugin. 112 | */ 113 | intptr_t WINAPI ConfigureW(const struct ConfigureInfo* /*cInfo*/) 114 | { 115 | if (!editorSet) { 116 | editorSet = new FarEditorSet(); 117 | } 118 | editorSet->menuConfigure(); 119 | Log::flush(); 120 | return 1; 121 | } 122 | 123 | /** 124 | Processes FAR editor events and 125 | makes text colorizing here. 126 | */ 127 | intptr_t WINAPI ProcessEditorEventW(const struct ProcessEditorEventInfo* pInfo) 128 | { 129 | if (inEventProcess) { 130 | return 0; 131 | } 132 | 133 | inEventProcess = true; 134 | 135 | if (!editorSet) { 136 | editorSet = new FarEditorSet(); 137 | } 138 | 139 | int result = editorSet->editorEvent(pInfo); 140 | 141 | inEventProcess = false; 142 | Log::flush(); 143 | return result; 144 | } 145 | 146 | intptr_t WINAPI ProcessEditorInputW(const struct ProcessEditorInputInfo* pInfo) 147 | { 148 | if (inEventProcess) { 149 | return 0; 150 | } 151 | 152 | inEventProcess = true; 153 | if (!editorSet) { 154 | editorSet = new FarEditorSet(); 155 | } 156 | 157 | int result = editorSet->editorInput(pInfo->Rec); 158 | 159 | inEventProcess = false; 160 | Log::flush(); 161 | return result; 162 | } 163 | 164 | intptr_t WINAPI ProcessSynchroEventW(const ProcessSynchroEventInfo* pInfo) 165 | { 166 | if (pInfo->Event != SE_COMMONSYNCHRO) { 167 | return 0; 168 | } 169 | try { 170 | if (editorSet && editorSet->getEditorCount() > 0) { 171 | INPUT_RECORD ir; 172 | ir.EventType = KEY_EVENT; 173 | ir.Event.KeyEvent.wVirtualKeyCode = 0; 174 | int result = editorSet->editorInput(ir); 175 | Log::flush(); 176 | return result; 177 | } 178 | } catch (...) { 179 | } 180 | 181 | return 0; 182 | } 183 | -------------------------------------------------------------------------------- /src/pcolorer.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_PCOLORER_H 2 | #define FARCOLORER_PCOLORER_H 3 | 4 | #include 5 | #include 6 | // Dialog Guid 7 | // {D2F36B62-A470-418d-83A3-ED7A3710E5B5} 8 | DEFINE_GUID(MainGuid, 0xd2f36b62, 0xa470, 0x418d, 0x83, 0xa3, 0xed, 0x7a, 0x37, 0x10, 0xe5, 0xb5); 9 | // {87C92249-430D-4334-AC33-05E7423286E9} 10 | DEFINE_GUID(PluginConfig, 0x87c92249, 0x430d, 0x4334, 0xac, 0x33, 0x5, 0xe7, 0x42, 0x32, 0x86, 0xe9); 11 | // {0497F43A-A8B9-4af1-A3A4-FA568F455707} 12 | DEFINE_GUID(HrcPluginConfig, 0x497f43a, 0xa8b9, 0x4af1, 0xa3, 0xa4, 0xfa, 0x56, 0x8f, 0x45, 0x57, 0x7); 13 | // {C6BE56D8-A80A-4f7d-A331-A711435F2665} 14 | DEFINE_GUID(AssignKeyDlg, 0xc6be56d8, 0xa80a, 0x4f7d, 0xa3, 0x31, 0xa7, 0x11, 0x43, 0x5f, 0x26, 0x65); 15 | // {3D1031EA-B67A-451C-9FC6-081320D3A139} 16 | DEFINE_GUID(LoggingConfig, 0x3d1031ea, 0xb67a, 0x451c, 0x9f, 0xc6, 0x8, 0x13, 0x20, 0xd3, 0xa1, 0x39); 17 | 18 | // Menu Guid 19 | // {45453CAC-499D-4b37-82B8-0A77F7BD087C} 20 | DEFINE_GUID(PluginMenu, 0x45453cac, 0x499d, 0x4b37, 0x82, 0xb8, 0xa, 0x77, 0xf7, 0xbd, 0x8, 0x7c); 21 | // {46921647-DB52-44CA-8D8B-F34EA8B02E5D} 22 | DEFINE_GUID(FileChooseMenu, 0x46921647, 0xdb52, 0x44ca, 0x8d, 0x8b, 0xf3, 0x4e, 0xa8, 0xb0, 0x2e, 0x5d); 23 | // {18A6F7DF-375D-4d3d-8137-DC50AC52B71E} 24 | DEFINE_GUID(HrdMenu, 0x18a6f7df, 0x375d, 0x4d3d, 0x81, 0x37, 0xdc, 0x50, 0xac, 0x52, 0xb7, 0x1e); 25 | // {A8A298BA-AD5A-4094-8E24-F65BF38E6C1F} 26 | DEFINE_GUID(OutlinerMenu, 0xa8a298ba, 0xad5a, 0x4094, 0x8e, 0x24, 0xf6, 0x5b, 0xf3, 0x8e, 0x6c, 0x1f); 27 | // {63E396BA-8E7F-4E38-A7A8-CBB7E9AC1E6D} 28 | DEFINE_GUID(ConfigMenu, 0x63e396ba, 0x8e7f, 0x4e38, 0xa7, 0xa8, 0xcb, 0xb7, 0xe9, 0xac, 0x1e, 0x6d); 29 | 30 | // Message Guid 31 | // {0C954AC8-2B69-4c74-94C8-7AB10324A005} 32 | DEFINE_GUID(ErrorMessage, 0xc954ac8, 0x2b69, 0x4c74, 0x94, 0xc8, 0x7a, 0xb1, 0x3, 0x24, 0xa0, 0x5); 33 | // {DEE3B49D-4A55-48a8-9DC8-D11DA04CBF37} 34 | DEFINE_GUID(ReloadBaseMessage, 0xdee3b49d, 0x4a55, 0x48a8, 0x9d, 0xc8, 0xd1, 0x1d, 0xa0, 0x4c, 0xbf, 0x37); 35 | // {AB214DCE-450B-4389-9E3B-533C7A6D786C} 36 | DEFINE_GUID(NothingFoundMesage, 0xab214dce, 0x450b, 0x4389, 0x9e, 0x3b, 0x53, 0x3c, 0x7a, 0x6d, 0x78, 0x6c); 37 | // {70656884-B7BD-4440-A8FF-6CE781C7DC6A} 38 | DEFINE_GUID(RegionName, 0x70656884, 0xb7bd, 0x4440, 0xa8, 0xff, 0x6c, 0xe7, 0x81, 0xc7, 0xdc, 0x6a); 39 | 40 | extern PluginStartupInfo Info; 41 | extern FarStandardFunctions FSF; 42 | 43 | /** FAR .lng file identifiers. */ 44 | enum { 45 | mName, 46 | mSetup, 47 | mTurnOff, 48 | mTrueMod, 49 | mPairs, 50 | mSyntax, 51 | mOldOutline, 52 | mOk, 53 | mReloadAll, 54 | mCancel, 55 | mCatalogFile, 56 | mHRDName, 57 | mHRDNameTrueMod, 58 | mListTypes, 59 | mMatchPair, 60 | mSelectBlock, 61 | mSelectPair, 62 | mListFunctions, 63 | mFindErrors, 64 | mSelectRegion, 65 | mCurrentRegionName, 66 | mLocateFunction, 67 | mUpdateHighlight, 68 | mReloadBase, 69 | mConfigure, 70 | mTotalTypes, 71 | mSelectSyntax, 72 | mOutliner, 73 | mNothingFound, 74 | mGotcha, 75 | mChoose, 76 | mReloading, 77 | mDie, 78 | mChangeBackgroundEditor, 79 | mUserHrdFile, 80 | mUserHrcFile, 81 | mUserHrcSetting, 82 | mUserHrcSettingDialog, 83 | mListSyntax, 84 | mParamList, 85 | mParamValue, 86 | mAutoDetect, 87 | mFavorites, 88 | mDisable, 89 | mKeyAssignDialogTitle, 90 | mKeyAssignTextTitle, 91 | mRegionName, 92 | mLog, 93 | mLogging, 94 | mLogTurnOff, 95 | mLogLevel, 96 | mLogPath, 97 | mMainSettings, 98 | mSettings, 99 | mStyleConf, 100 | mCrossText, 101 | mCrossBoth, 102 | mCrossVert, 103 | mCrossHoriz, 104 | mCross, 105 | mPerfomance, 106 | mBuildPeriod 107 | }; 108 | 109 | #endif // FARCOLORER_PCOLORER_H 110 | -------------------------------------------------------------------------------- /src/pcolorer3.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | EXPORTS 3 | GetGlobalInfoW 4 | OpenW 5 | SetStartupInfoW 6 | GetPluginInfoW 7 | ConfigureW 8 | ProcessEditorInputW 9 | ProcessEditorEventW 10 | ExitFARW 11 | ProcessSynchroEventW -------------------------------------------------------------------------------- /src/pcolorer3.rc: -------------------------------------------------------------------------------- 1 | #pragma code_page(65001) 2 | #include 3 | #include "version.h" 4 | 5 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 6 | VS_VERSION_INFO VERSIONINFO 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | 10 | #ifdef _DEBUG 11 | | VS_FF_PRERELEASE | VS_FF_DEBUG 12 | #endif 13 | 14 | FILEOS VOS_NT_WINDOWS32 15 | FILETYPE VFT_APP 16 | 17 | FILEVERSION PLUGIN_VER_MAJOR,PLUGIN_VER_MINOR,PLUGIN_VER_PATCH,0 18 | PRODUCTVERSION PLUGIN_VER_MAJOR,PLUGIN_VER_MINOR,PLUGIN_VER_PATCH,0 19 | 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "040904B0" 24 | BEGIN 25 | VALUE "FileDescription", PLUGIN_DESC 26 | VALUE "FileVersion", PLUGIN_VERSION 27 | VALUE "LegalCopyright", PLUGIN_COPYRIGHT 28 | VALUE "OriginalFilename", PLUGIN_FILENAME 29 | VALUE "ProductName", PLUGIN_NAME 30 | VALUE "ProductVersion", PLUGIN_VERSION 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x0409, 1200 36 | END 37 | END -------------------------------------------------------------------------------- /src/tools.cpp: -------------------------------------------------------------------------------- 1 | #include "tools.h" 2 | 3 | wchar_t* rtrim(wchar_t* str) 4 | { 5 | wchar_t* ptr = str; 6 | str += wcslen(str); 7 | 8 | while (iswspace(*(--str))) { 9 | *str = 0; 10 | } 11 | 12 | return ptr; 13 | } 14 | 15 | wchar_t* ltrim(wchar_t* str) 16 | { 17 | while (iswspace(*(str++))) { 18 | } 19 | return str - 1; 20 | } 21 | 22 | wchar_t* trim(wchar_t* str) 23 | { 24 | return ltrim(rtrim(str)); 25 | } 26 | 27 | /** 28 | Function converts a path in the UNC path. 29 | Source path can be framed by quotes, be a relative, or contain environment variables 30 | */ 31 | wchar_t* PathToFull(const wchar_t* path, bool unc) 32 | { 33 | size_t len = wcslen(path); 34 | if (!len) { 35 | return nullptr; 36 | } 37 | 38 | wchar_t* new_path; 39 | // we remove quotes, if they are present, focusing on the first character 40 | // if he quote it away and the first and last character. 41 | // If the first character quote, but the latter does not - well, it's not our 42 | // problem, and so and so error 43 | if (*path == L'"') { 44 | len--; 45 | new_path = new wchar_t[len]; 46 | wcsncpy(new_path, &path[1], len - 1); 47 | new_path[len - 1] = '\0'; 48 | } 49 | else { 50 | len++; 51 | new_path = new wchar_t[len]; 52 | wcscpy(new_path, path); 53 | } 54 | 55 | // replace the environment variables to their values 56 | size_t i = ExpandEnvironmentStringsW(new_path, nullptr, 0); 57 | if (i > len) { 58 | len = i; 59 | } 60 | auto* temp = new wchar_t[len]; 61 | ExpandEnvironmentStringsW(new_path, temp, static_cast(i)); 62 | delete[] new_path; 63 | new_path = temp; 64 | 65 | CONVERTPATHMODES mode; 66 | if (unc) { 67 | mode = CPM_NATIVE; 68 | } 69 | else { 70 | mode = CPM_FULL; 71 | } 72 | 73 | // take the full path to the file, converting all kinds of ../ ./ etc 74 | size_t p = FSF.ConvertPath(mode, new_path, nullptr, 0); 75 | if (p > len) { 76 | len = p; 77 | auto* temp2 = new wchar_t[len]; 78 | wcscpy(temp2, new_path); 79 | delete[] new_path; 80 | new_path = temp2; 81 | } 82 | FSF.ConvertPath(mode, new_path, new_path, len); 83 | 84 | return trim(new_path); 85 | } 86 | 87 | UnicodeString* PathToFullS(const wchar_t* path, bool unc) 88 | { 89 | UnicodeString* spath = nullptr; 90 | wchar_t* t = PathToFull(path, unc); 91 | if (t) { 92 | spath = new UnicodeString(t); 93 | } 94 | delete[] t; 95 | return spath; 96 | } 97 | 98 | intptr_t macroGetValue(FarMacroValue* value, intptr_t def) 99 | { 100 | intptr_t result = def; 101 | if (FMVT_BOOLEAN == value->Type) 102 | result = value->Boolean; 103 | else if (FMVT_INTEGER == value->Type) 104 | result = value->Integer; 105 | else if (FMVT_DOUBLE == value->Type) 106 | result = static_cast(value->Double); 107 | return result; 108 | } 109 | 110 | // free memory after far save values 111 | void WINAPI MacroCallback(void* CallbackData, FarMacroValue* Values, size_t Count) 112 | { 113 | for (auto i = 0; i < Count; i++) { 114 | if (FMVT_STRING == Values[i].Type) { 115 | free((void*) Values[i].String); 116 | } 117 | else if (FMVT_ARRAY == Values[i].Type) { 118 | for (auto k = 0; k < Values[i].Array.Count; k++) { 119 | if (FMVT_STRING == Values[i].Array.Values[k].Type) { 120 | free((void*) Values[i].Array.Values[k].String); 121 | } 122 | } 123 | delete[] Values[i].Array.Values; 124 | } 125 | } 126 | delete[] Values; 127 | delete (FarMacroCall*) CallbackData; 128 | } 129 | 130 | FarMacroCall* macroReturnInt(long long int value) 131 | { 132 | auto* out_params = new FarMacroValue[1]; 133 | out_params[0].Type = FMVT_INTEGER; 134 | out_params[0].Integer = value; 135 | 136 | auto* out_result = new FarMacroCall; 137 | out_result->StructSize = sizeof(FarMacroCall); 138 | out_result->Count = 1; 139 | out_result->Values = out_params; 140 | out_result->Callback = MacroCallback; 141 | out_result->CallbackData = out_result; 142 | 143 | return out_result; 144 | } 145 | 146 | FarMacroCall* macroReturnValues(FarMacroValue* values, int count) 147 | { 148 | auto* out_result = new FarMacroCall; 149 | out_result->StructSize = sizeof(FarMacroCall); 150 | out_result->Count = count; 151 | out_result->Values = values; 152 | out_result->Callback = MacroCallback; 153 | out_result->CallbackData = out_result; 154 | 155 | return out_result; 156 | } 157 | 158 | wchar_t* Upper(wchar_t* Ch) 159 | { 160 | CharUpperBuffW(Ch, 1); 161 | return Ch; 162 | } -------------------------------------------------------------------------------- /src/tools.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_TOOLS_H 2 | #define FARCOLORER_TOOLS_H 3 | 4 | #include 5 | #include "pcolorer.h" 6 | 7 | wchar_t* rtrim(wchar_t* str); 8 | wchar_t* ltrim(wchar_t* str); 9 | wchar_t* trim(wchar_t* str); 10 | wchar_t* Upper(wchar_t* Ch); 11 | 12 | wchar_t* PathToFull(const wchar_t* path, bool unc); 13 | UnicodeString* PathToFullS(const wchar_t* path, bool unc); 14 | 15 | intptr_t macroGetValue(FarMacroValue* value, intptr_t def = 0); 16 | FarMacroCall* macroReturnInt(long long int value); 17 | FarMacroCall* macroReturnValues(FarMacroValue* values, int count); 18 | void WINAPI MacroCallback(void* CallbackData, FarMacroValue* Values, size_t Count); 19 | #endif //FARCOLORER_TOOLS_H 20 | -------------------------------------------------------------------------------- /src/version.h: -------------------------------------------------------------------------------- 1 | #ifndef FARCOLORER_VERSION_H_ 2 | #define FARCOLORER_VERSION_H_ 3 | 4 | #include 5 | 6 | #ifdef _WIN64 7 | #define PLATFORM L" x64" 8 | #elif defined _M_ARM64 9 | #define PLATFORM L" ARM64" 10 | #elif defined _WIN32 11 | #define PLATFORM L" x86" 12 | #else 13 | #define PLATFORM L"" 14 | #endif 15 | 16 | #ifdef COLORER_FEATURE_ICU 17 | #define USTRING L" ICU" 18 | #else 19 | #define USTRING L"" 20 | #endif 21 | 22 | #define PLUGIN_VER_MAJOR 1 23 | #define PLUGIN_VER_MINOR 6 24 | #define PLUGIN_VER_PATCH 9 25 | #define PLUGIN_DESC L"FarColorer - Syntax Highlighting for Far Manager 3" PLATFORM USTRING 26 | #define PLUGIN_NAME L"FarColorer" 27 | #define PLUGIN_FILENAME L"colorer.dll" 28 | #define PLUGIN_COPYRIGHT L"(c) 1999-2009 Igor Russkih, (c) Aleksey Dobrunov 2009-2025" 29 | 30 | #define STRINGIZE2(s) #s 31 | #define STRINGIZE(s) STRINGIZE2(s) 32 | 33 | #define PLUGIN_VERSION STRINGIZE(PLUGIN_VER_MAJOR) "." STRINGIZE(PLUGIN_VER_MINOR) "." STRINGIZE(PLUGIN_VER_PATCH) 34 | 35 | #endif // FARCOLORER_VERSION_H_ 36 | -------------------------------------------------------------------------------- /vcpkg/manifest/full/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json", 3 | "overlay-ports": [ 4 | ], 5 | "overlay-triplets": [ "../../../external/colorer/vcpkg/triplets" ] 6 | } -------------------------------------------------------------------------------- /vcpkg/manifest/full/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "farcolorer", 3 | "version": "1.6.9", 4 | "dependencies": [ 5 | "minizip", 6 | "icu", 7 | { 8 | "name": "libxml2", 9 | "default-features": false 10 | } 11 | ], 12 | "overrides": 13 | [ 14 | { 15 | "name": "icu", 16 | "version": "72.1#5" 17 | }, 18 | { 19 | "name": "libxml2", 20 | "version": "2.11.9#1" 21 | } 22 | ], 23 | "builtin-baseline": "3c5b9b4ea547898b1ae2d82edbeeda1333c212e9" 24 | } -------------------------------------------------------------------------------- /vcpkg/manifest/legacy/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json", 3 | "overlay-ports": [ 4 | ], 5 | "overlay-triplets": [ "../../../external/colorer/vcpkg/triplets" ] 6 | } -------------------------------------------------------------------------------- /vcpkg/manifest/legacy/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "farcolorer", 3 | "version": "1.6.9", 4 | "dependencies": [ 5 | "minizip", 6 | { 7 | "name": "libxml2", 8 | "default-features": false 9 | } 10 | ], 11 | "overrides": 12 | [ 13 | { 14 | "name": "libxml2", 15 | "version": "2.11.9#1" 16 | } 17 | ], 18 | "builtin-baseline": "3c5b9b4ea547898b1ae2d82edbeeda1333c212e9" 19 | } -------------------------------------------------------------------------------- /version4far.txt: -------------------------------------------------------------------------------- 1 | 1.6.9 --------------------------------------------------------------------------------