├── .clang-format
├── .gitattributes
├── .github
└── workflows
│ └── msbuild.yml
├── .gitignore
├── .gitmodules
├── .nuget
├── NuGet.Config
├── NuGet.exe
└── NuGet.targets
├── .tgitconfig
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── azure-pipelines.yml
├── build.txt
├── choco
├── chocolateyInstall.ps1
└── grepwin.nuspec
├── default.build
├── default.build.user.tmpl
├── grepWin.sln
├── grepWin.sln.DotSettings
├── src
├── AboutDlg.cpp
├── AboutDlg.h
├── Bookmarks.cpp
├── Bookmarks.h
├── BookmarksDlg.cpp
├── BookmarksDlg.h
├── COMPtrs.h
├── ExplorerCommandVerb
│ ├── ExplorerCommandVerb.vcxproj
│ ├── ExplorerCommandVerb.vcxproj.filters
│ ├── compatibility.manifest
│ ├── dllmain.cpp
│ ├── framework.h
│ ├── packages.config
│ ├── pch.cpp
│ ├── pch.h
│ └── source.def
├── LineData.h
├── MultiLineEditDlg.cpp
├── MultiLineEditDlg.h
├── NameDlg.cpp
├── NameDlg.h
├── NewlinesDlg.cpp
├── NewlinesDlg.h
├── RegexReplaceFormatter.cpp
├── RegexReplaceFormatter.h
├── RegexTestDlg.cpp
├── RegexTestDlg.h
├── Resources
│ ├── GitHub-socialpreview.png
│ ├── grepWin.ico
│ ├── grepWin.rc
│ ├── grepWin.rc2
│ ├── grepWin_search-small.png
│ ├── grepWin_search.png
│ ├── grepwin.svg
│ ├── grepwin_128.png
│ ├── grepwin_16.png
│ ├── grepwin_24.png
│ ├── grepwin_256.png
│ ├── grepwin_32.png
│ ├── grepwin_48.png
│ ├── grepwin_64.png
│ ├── infodlg.rtf
│ ├── logo.png
│ ├── vs9-tools-grepwin-prj.png
│ └── vs9-tools-grepwin-sln.png
├── SK.ruleset
├── SearchDlg.cpp
├── SearchDlg.h
├── SearchInfo.cpp
├── SearchInfo.h
├── Settings.cpp
├── Settings.h
├── Setup
│ ├── AppXManifest.xml.in
│ ├── Banner.jpg
│ ├── CustomActions
│ │ ├── CustomActions.cpp
│ │ ├── CustomActions.def
│ │ ├── CustomActions.vcxproj
│ │ ├── CustomActions.vcxproj.filters
│ │ └── CustomActions.vcxproj.user
│ ├── Dialog.jpg
│ ├── License.rtf
│ ├── Setup.wxs
│ ├── StefansTools_setupdialog.pdn
│ ├── VersionNumberInclude.in.wxi
│ ├── setup.build
│ └── website.url
├── ShellContextMenu.cpp
├── ShellContextMenu.h
├── TextOffset.h
├── Theme.cpp
├── Theme.h
├── compatibility.manifest
├── grepWin.cpp
├── grepWin.vcxproj
├── grepWin.vcxproj.filters
├── last
│ └── version.h
├── packages.config
├── resource.h
├── stdafx.cpp
├── stdafx.h
└── version.in
├── tools
├── ResText.exe
├── checkyear.js
└── coverity.bat
├── translations
├── Afrikaans.lang
├── Belarusian.lang
├── Chinese Simplified.lang
├── Chinese Traditional.lang
├── Dutch.lang
├── English.lang
├── French.lang
├── German.lang
├── Greek.lang
├── Hindi.lang
├── Hungarian.lang
├── Italian.lang
├── Japanese.lang
├── Korean.lang
├── Polish.lang
├── Portuguese Brazilian.lang
├── Portuguese.lang
├── Russian.lang
├── Slovak.lang
├── Spanish Mexican.lang
├── Spanish.lang
├── Swedish.lang
├── Tamil.lang
└── Turkish.lang
├── version.build.in
├── version.txt
└── versioninfo.build
/.clang-format:
--------------------------------------------------------------------------------
1 | ---
2 | Language: Cpp
3 | AccessModifierOffset: -4
4 | AlignAfterOpenBracket: Align
5 | AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
6 | AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
7 | AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
8 | AlignConsecutiveMacros: AcrossEmptyLinesAndComments
9 | AlignEscapedNewlines: Right
10 | AlignOperands: true
11 | AlignTrailingComments: true
12 | AllowAllParametersOfDeclarationOnNextLine: true
13 | AllowShortBlocksOnASingleLine: false
14 | AllowShortCaseLabelsOnASingleLine: false
15 | AllowShortFunctionsOnASingleLine: All
16 | AllowShortIfStatementsOnASingleLine: false
17 | AllowShortLoopsOnASingleLine: false
18 | AlwaysBreakAfterDefinitionReturnType: None
19 | AlwaysBreakAfterReturnType: None
20 | AlwaysBreakBeforeMultilineStrings: false
21 | AlwaysBreakTemplateDeclarations: false
22 | BinPackArguments: true
23 | BinPackParameters: true
24 | BraceWrapping:
25 | AfterCaseLabel: true
26 | AfterClass: true
27 | AfterControlStatement: true
28 | AfterEnum: true
29 | AfterFunction: true
30 | AfterNamespace: true
31 | AfterObjCDeclaration: true
32 | AfterStruct: true
33 | AfterUnion: true
34 | BeforeCatch: true
35 | BeforeElse: true
36 | IndentBraces: false
37 | SplitEmptyFunction: true
38 | SplitEmptyRecord: true
39 | SplitEmptyNamespace: true
40 | BreakBeforeBinaryOperators: None
41 | BreakBeforeBraces: Custom
42 | BreakBeforeInheritanceComma: true
43 | BreakBeforeTernaryOperators: true
44 | BreakConstructorInitializersBeforeComma: true
45 | BreakConstructorInitializers: BeforeColon
46 | BreakAfterJavaFieldAnnotations: false
47 | BreakStringLiterals: true
48 | ColumnLimit: 0
49 | CommentPragmas: '^ IWYU pragma:'
50 | CompactNamespaces: false
51 | ConstructorInitializerAllOnOneLineOrOnePerLine: false
52 | ConstructorInitializerIndentWidth: 4
53 | ContinuationIndentWidth: 4
54 | Cpp11BracedListStyle: true
55 | DerivePointerAlignment: false
56 | DisableFormat: false
57 | ExperimentalAutoDetectBinPacking: false
58 | FixNamespaceComments: true
59 | ForEachMacros:
60 | - foreach
61 | - Q_FOREACH
62 | - BOOST_FOREACH
63 | IncludeCategories:
64 | - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
65 | Priority: 2
66 | - Regex: '^(<|"(gtest|gmock|isl|json)/)'
67 | Priority: 3
68 | - Regex: '.*'
69 | Priority: 1
70 | IncludeIsMainRegex: '(Test)?$'
71 | IndentCaseLabels: true
72 | IndentPPDirectives: AfterHash
73 | IndentWidth: 4
74 | IndentWrappedFunctionNames: true
75 | JavaScriptQuotes: Leave
76 | JavaScriptWrapImports: true
77 | KeepEmptyLinesAtTheStartOfBlocks: false
78 | MacroBlockBegin: "^\
79 | BEGIN_MSG_MAP|\
80 | BEGIN_MESSAGE_MAP|\
81 | BEGIN_MSG_MAP_EX|\
82 | BEGIN_MESSAGE_MAP_EX|\
83 | BEGIN_SAFE_MSG_MAP_EX|\
84 | CR_BEGIN_MSG_MAP_EX|\
85 | IPC_BEGIN_MESSAGE_MAP|\
86 | IPC_BEGIN_MESSAGE_MAP_WITH_PARAM|\
87 | IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN|\
88 | IPC_STRUCT_BEGIN|\
89 | IPC_STRUCT_BEGIN_WITH_PARENT|\
90 | IPC_STRUCT_TRAITS_BEGIN|\
91 | POLPARAMS_BEGIN|\
92 | PPAPI_BEGIN_MESSAGE_MAP$"
93 | MacroBlockEnd: "^\
94 | CR_END_MSG_MAP|\
95 | END_MSG_MAP|\
96 | END_MESSAGE_MAP|\
97 | IPC_END_MESSAGE_MAP|\
98 | IPC_PROTOBUF_MESSAGE_TRAITS_END|\
99 | IPC_STRUCT_END|\
100 | IPC_STRUCT_TRAITS_END|\
101 | POLPARAMS_END|\
102 | PPAPI_END_MESSAGE_MAP$"
103 | MaxEmptyLinesToKeep: 1
104 | NamespaceIndentation: None
105 | ObjCBlockIndentWidth: 2
106 | ObjCSpaceAfterProperty: false
107 | ObjCSpaceBeforeProtocolList: true
108 | PenaltyBreakAssignment: 2
109 | PenaltyBreakBeforeFirstCallParameter: 19
110 | PenaltyBreakComment: 300
111 | PenaltyBreakFirstLessLess: 120
112 | PenaltyBreakString: 1000
113 | PenaltyExcessCharacter: 1000000
114 | PenaltyReturnTypeOnItsOwnLine: 60
115 | PointerAlignment: Left
116 | ReflowComments: true
117 | SortIncludes: false
118 | SortUsingDeclarations: true
119 | SpaceAfterCStyleCast: false
120 | SpaceAfterTemplateKeyword: true
121 | SpaceBeforeAssignmentOperators: true
122 | SpaceBeforeParens: ControlStatements
123 | SpaceInEmptyParentheses: false
124 | SpacesBeforeTrailingComments: 1
125 | SpacesInAngles: false
126 | SpacesInContainerLiterals: false
127 | SpacesInCStyleCastParentheses: false
128 | SpacesInParentheses: false
129 | SpacesInSquareBrackets: false
130 | Standard: Cpp11
131 | TabWidth: 4
132 | UseTab: Never
133 | ...
134 |
135 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | /src/Resources/grepWin.rc text working-tree-encoding=UTF-8
2 | /src/Resources/grepWin.rc2 text working-tree-encoding=UTF-8
3 | /src/resource.h text working-tree-encoding=UTF-8
4 | /translations/*.lang text working-tree-encoding=UTF-8
5 |
--------------------------------------------------------------------------------
/.github/workflows/msbuild.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | paths-ignore:
6 | - "*.md"
7 | pull_request:
8 | paths-ignore:
9 | - "*.md"
10 |
11 | env:
12 | # Path to the solution file relative to the root of the project.
13 | SOLUTION_FILE_PATH: .
14 |
15 | # Configuration type to build.
16 | # You can convert this to a build matrix if you need coverage of multiple configuration types.
17 | # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
18 | BUILD_CONFIGURATION: Release
19 |
20 | jobs:
21 | build:
22 | runs-on: windows-latest
23 | strategy:
24 | matrix:
25 | include:
26 | - platform: Win32
27 | dir: Release
28 | - platform: x64
29 | dir: Release64
30 |
31 | steps:
32 | - uses: actions/checkout@v4
33 | with:
34 | fetch-depth: 0
35 | submodules: recursive
36 |
37 | - name: Add MSBuild to PATH
38 | uses: microsoft/setup-msbuild@v2
39 |
40 | - name: Restore NuGet packages
41 | working-directory: ${{env.GITHUB_WORKSPACE}}
42 | run: nuget restore ${{env.SOLUTION_FILE_PATH}}
43 |
44 | - name: Build ${{matrix.platform}}
45 | working-directory: ${{env.GITHUB_WORKSPACE}}
46 | run: |
47 | Select-Xml -Path ./version.build.in 'project/target/setenv/variable' | ForEach-Object { Set-Variable -Name $_.Node.name -Value $_.Node.value }
48 | $WCREV = git rev-list --count HEAD
49 | $WCDATE = "$($env:GITHUB_SHA.Substring(0,7))" # more specific
50 | $Version = "$MajorVersion.$MinorVersion.$MicroVersion.$WCREV"
51 | Copy-Item "./src/version.in" -Destination "./src/last/version.h"
52 | Copy-Item "./src/Setup/VersionNumberInclude.in.wxi" -Destination "./src/Setup/VersionNumberInclude.wxi"
53 | sed -i "s/\`$MajorVersion\`$/$MajorVersion/gm" ./src/last/version.h ./src/Setup/VersionNumberInclude.wxi
54 | sed -i "s/\`$MinorVersion\`$/$MinorVersion/gm" ./src/last/version.h ./src/Setup/VersionNumberInclude.wxi
55 | sed -i "s/\`$MicroVersion\`$/$MicroVersion/gm" ./src/last/version.h ./src/Setup/VersionNumberInclude.wxi
56 | sed -i "s/\`$WCREV\`$/$WCREV/gm" ./src/last/version.h ./src/Setup/VersionNumberInclude.wxi
57 | sed -i "s/\`$WCDATE\`$/$WCDATE/gm" ./src/last/version.h
58 | msbuild -m -p:Configuration=${{env.BUILD_CONFIGURATION}} -p:Platform=${{matrix.platform}} -warnAsError ${{env.SOLUTION_FILE_PATH}}
59 | Copy-Item "./bin/${{matrix.dir}}/grepWin.exe" -Destination "./bin/${{matrix.dir}}/grepWin-${{matrix.platform}}_portable.exe"
60 | Set-Location -Path "./src/Setup"
61 | if ("${{matrix.platform}}" -eq "x64") {
62 | New-Item -ItemType "directory" -Path . -Name "x64"
63 | sed "s/\`$Version\`$/$Version/gm" AppXManifest.xml.in > x64\AppxManifest.xml
64 | $MSVCRoot = vswhere -property installationPath
65 | & "${env:COMSPEC}" /s /c "`"$MSVCRoot\Common7\Tools\vsdevcmd.bat`" -no_logo -arch=amd64 && set" | ForEach-Object {
66 | $name, $value = $_ -split '=', 2
67 | set-content env:"$name" $value
68 | }
69 | MakeAppX pack /o /d x64 -p ..\..\bin\release64\package.msix /nv
70 | # unsigned
71 | }
72 | candle -nologo -dPlatform=${{matrix.platform}} -out ..\..\bin\Setup-${{matrix.platform}}.wixobj Setup.wxs
73 | light -nologo -sice:ICE57 -ext WixUIExtension -cultures:en-us -out ..\..\bin\grepWin-${{matrix.platform}}.msi ..\..\bin\Setup-${{matrix.platform}}.wixobj
74 |
75 | - name: Upload artifacts for ${{matrix.platform}}
76 | uses: actions/upload-artifact@v4
77 | with:
78 | name: grepWin-${{matrix.platform}}_portable
79 | path: bin/${{matrix.dir}}/grepWin-${{matrix.platform}}_portable.exe
80 | - name: Upload artifacts for ${{matrix.platform}} msi
81 | uses: actions/upload-artifact@v4
82 | with:
83 | name: grepWin-${{matrix.platform}}-msi
84 | path: bin/*.msi
85 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /default.build.user
2 | /obj
3 | /bin
4 | /.vs
5 | /packages
6 | /src/grepWin.vcxproj.user
7 | /src/version.h
8 | /version.build
9 | /signinfo.txt
10 | /src/Resources/grepWin.aps
11 | /src/Setup/VersionNumberInclude.wxi
12 | /test
13 | /choco/package
14 | /_ReSharper.Caches
15 | /src/ExplorerCommandVerb/ExplorerCommandVerb.vcxproj.user
16 | /src/Setup/x64
17 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "sktoolslib"]
2 | path = sktoolslib
3 | url = https://github.com/stefankueng/sktoolslib.git
4 | branch = main
5 |
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stefankueng/grepWin/25539ce753e1a0f7804691be2b03d9b9bb21ed4f/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config"))
32 |
33 |
34 |
35 |
36 | $(SolutionDir).nuget
37 | packages.config
38 |
39 |
40 |
41 |
42 | $(NuGetToolsPath)\NuGet.exe
43 | @(PackageSource)
44 |
45 | "$(NuGetExePath)"
46 | mono --runtime=v4.0.30319 $(NuGetExePath)
47 |
48 | $(TargetDir.Trim('\\'))
49 |
50 | -RequireConsent
51 | -NonInteractive
52 |
53 | "$(SolutionDir) "
54 | "$(SolutionDir)"
55 |
56 |
57 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
58 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
59 |
60 |
61 |
62 | RestorePackages;
63 | $(BuildDependsOn);
64 |
65 |
66 |
67 |
68 | $(BuildDependsOn);
69 | BuildPackage;
70 |
71 |
72 |
73 |
74 |
75 |
76 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
91 |
92 |
95 |
96 |
97 |
98 |
100 |
101 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
133 |
134 |
135 |
136 |
--------------------------------------------------------------------------------
/.tgitconfig:
--------------------------------------------------------------------------------
1 | [bugtraq]
2 | url = https://github.com/stefankueng/grepWin/issues/%BUGID%
3 | logregex = "([Cc]loses?)?:?(\\s*(,|and)?\\s*#\\d+)+\n(\\d+)"
4 | [hook "precommit"]
5 | cmdline = WScript %root%\\\\tools\\\\checkyear.js
6 | wait = true
7 | show = false
8 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Code of Conduct
2 |
3 | Don't have one. Don't want one.
4 |
5 | That's the short version.
6 |
7 | Now the _long version_:
8 |
9 | 1. Having a code of conduct means forcing rules on our community. We don't want that. We want to be free of restrictions and just get the project going.
10 | 2. We don't care about your political views, your race, gender, hair color, tatoos or whatever. We just don't. And we don't ask. Because it has nothing to do with this project.
11 | 3. We do care about the project, and the code. And nothing else.
12 |
13 | If we can't be civil among each other, then having a code of conduct won't help either.
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # grepWin
2 | Regular expression search and replace for Windows
3 |
4 | [](https://github.com/stefankueng/grepWin/actions/workflows/msbuild.yml)
5 |
6 | grepWin is a simple search and replace tool which can use [regular expressions](https://en.wikipedia.org/wiki/Regular_expression) to do its job. This allows to do much more powerful searches and replaces.
7 |
8 | In case you're not familiar with regular expressions, we have a very short [regular expression tutorial](https://tools.stefankueng.com/regexhelp.html) for you.
9 |
10 | [](https://github.com/stefankueng/grepWin/raw/main/src/Resources/grepWin_search.png)
11 |
12 | # Command line parameters
13 | The command line parameters are listed on a [separate page](https://tools.stefankueng.com/grepWin_cmd.html).
14 |
15 | Please visit the [homepage](https://tools.stefankueng.com/grepWin.html) of grepWin for more information.
16 |
--------------------------------------------------------------------------------
/azure-pipelines.yml:
--------------------------------------------------------------------------------
1 | # .NET Desktop
2 | # Build and run tests for .NET Desktop or Windows classic desktop solutions.
3 | # Add steps that publish symbols, save build artifacts, and more:
4 | # https://docs.microsoft.com/vsts/pipelines/apps/windows/dot-net
5 |
6 | pool:
7 | vmImage: 'windows-2019'
8 |
9 | variables:
10 | solution: '**/*.sln'
11 | buildPlatform: 'x64'
12 | buildConfiguration: 'Release'
13 |
14 | steps:
15 | - task: NuGetToolInstaller@1
16 |
17 | - task: NuGetCommand@2
18 | inputs:
19 | restoreSolution: '$(solution)'
20 |
21 | - task: VSBuild@1
22 | inputs:
23 | solution: '$(solution)'
24 | platform: '$(buildPlatform)'
25 | configuration: '$(buildConfiguration)'
26 |
27 | - task: VSTest@2
28 | inputs:
29 | platform: '$(buildPlatform)'
30 | configuration: '$(buildConfiguration)'
31 |
--------------------------------------------------------------------------------
/build.txt:
--------------------------------------------------------------------------------
1 | First make sure you've cloned the repository recursively to get the submodule
2 | as well!
3 |
4 | Then you need to install the compiler package.
5 |
6 | - You need VS2022.
7 | If you want to build the msi make sure the "Tools for Redistributing
8 | Applications" are installed.
9 |
10 | If you just want to build the exe without the installer and if you're comfortable
11 | with the exe having version 1.0.0.0 in the resources, you can just open the
12 | grepWin.sln file in Visual Studio and build the project.
13 |
14 | If you want to use the build script you have to do a little bit more work first:
15 |
16 | you need to install some utilities/programs:
17 | - TortoiseGit : http://tortoisegit.org
18 | - WiX 3.10(*) : http://wixtoolset.org/
19 | - NAnt 0.92(*) : http://nant.sourceforge.net
20 |
21 | (*) Add the paths of the binaries to the PATH environment variable.
22 | You may have to logoff/logon to make the new environment variables take effect!
23 |
24 | Now you're almost ready. Only a few more steps to do:
25 | - Clone the grepWin repository from GitHub and checkout the source
26 | Note: you have to clone recursively to also get the submodules
27 | - Make a copy of the file default.build.user.tmpl in the grepWin root folder and
28 | rename that copy to default.build.user. Then adjust the paths as mentioned
29 | in that file.
30 |
31 |
32 | Building packages
33 |
34 | Hint: before you can start building grepWin with the NAnt script, you need to
35 | call the vcvars32.bat or vcvars64.bat which are located in
36 | C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build
37 |
38 | > nant
39 | will compile grepWin
40 |
41 | > nant setup
42 | will compile grepWin and create the msi installer
43 |
44 | If you encounter any build errors, you can run nant again like this:
45 |
46 | > nant setup -l:buildlog.txt
47 |
48 | which will create a build log file which you can use to analyse where
49 | exactly the build failed.
50 |
51 |
52 | After the script finished, the packages can be found in .\bin.
53 |
54 | Once grepWin has been built with the NAnt script, you can build it again
55 | with VS2022 alone and get the correct version info in the resources.
56 |
--------------------------------------------------------------------------------
/choco/chocolateyInstall.ps1:
--------------------------------------------------------------------------------
1 | Install-ChocolateyPackage 'grepWin' 'msi' '/quiet' 'https://github.com/stefankueng/grepWin/releases/download/$MajorVersion$.$MinorVersion$.$MicroVersion$/grepWin-$MajorVersion$.$MinorVersion$.$MicroVersion$.msi' 'https://github.com/stefankueng/grepWin/releases/download/$MajorVersion$.$MinorVersion$.$MicroVersion$/grepWin-$MajorVersion$.$MinorVersion$.$MicroVersion$-x64.msi' -checksum '$checksum$' -checksum64 '$checksum64$' -checksumType 'sha256'
--------------------------------------------------------------------------------
/choco/grepwin.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | grepwin
5 | grepWin
6 | $MajorVersion$.$MinorVersion$.$MicroVersion$
7 | Stefan Kueng
8 | Stefan Kueng
9 | grepWin is a powerful and fast search tool using regular expressions.
10 | grepWin is a simple search and replace tool which can use regular expressions to do its job. This allows to do much more powerful searches and replaces.
11 | https://tools.stefankueng.com/grepWin.html
12 | grepwin grep search regex admin
13 | http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
14 | false
15 | https://github.com/stefankueng/grepWin/raw/main/src/Resources/grepwin_256.png
16 | https://github.com/stefankueng/grepWin
17 | https://github.com/stefankueng/grepWin/issues
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/default.build.user.tmpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | You must first call "%VS140COMNTOOLS%\vsvars32.bat"
24 |
25 |
26 |
27 |
28 |
34 |
35 |
36 |
37 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/grepWin.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio Version 17
3 | VisualStudioVersion = 17.0.31912.275
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grepWin", "src\grepWin.vcxproj", "{0049F8CF-1BEC-4E6E-B457-0187A33AD522}"
6 | EndProject
7 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D32CB10B-1891-471D-B780-5445BC67C1E2}"
8 | ProjectSection(SolutionItems) = preProject
9 | .nuget\NuGet.Config = .nuget\NuGet.Config
10 | .nuget\NuGet.exe = .nuget\NuGet.exe
11 | .nuget\NuGet.targets = .nuget\NuGet.targets
12 | EndProjectSection
13 | EndProject
14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExplorerCommandVerb", "src\ExplorerCommandVerb\ExplorerCommandVerb.vcxproj", "{585A1606-DC66-49BA-BFFB-E6F0B63A66BF}"
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{89723F04-E4BB-4E0E-917F-75B12FBCD5F0}"
17 | ProjectSection(SolutionItems) = preProject
18 | src\Setup\AppXManifest.xml.in = src\Setup\AppXManifest.xml.in
19 | src\Setup\setup.build = src\Setup\setup.build
20 | src\Setup\Setup.wxs = src\Setup\Setup.wxs
21 | EndProjectSection
22 | EndProject
23 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomActions", "src\Setup\CustomActions\CustomActions.vcxproj", "{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}"
24 | EndProject
25 | Global
26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
27 | Debug|Win32 = Debug|Win32
28 | Debug|x64 = Debug|x64
29 | Release|Win32 = Release|Win32
30 | Release|x64 = Release|x64
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Debug|Win32.ActiveCfg = Debug|Win32
34 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Debug|Win32.Build.0 = Debug|Win32
35 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Debug|x64.ActiveCfg = Debug|x64
36 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Debug|x64.Build.0 = Debug|x64
37 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Release|Win32.ActiveCfg = Release|Win32
38 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Release|Win32.Build.0 = Release|Win32
39 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Release|x64.ActiveCfg = Release|x64
40 | {0049F8CF-1BEC-4E6E-B457-0187A33AD522}.Release|x64.Build.0 = Release|x64
41 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Debug|Win32.ActiveCfg = Debug|Win32
42 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Debug|Win32.Build.0 = Debug|Win32
43 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Debug|x64.ActiveCfg = Debug|x64
44 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Debug|x64.Build.0 = Debug|x64
45 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Release|Win32.ActiveCfg = Release|Win32
46 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Release|Win32.Build.0 = Release|Win32
47 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Release|x64.ActiveCfg = Release|x64
48 | {585A1606-DC66-49BA-BFFB-E6F0B63A66BF}.Release|x64.Build.0 = Release|x64
49 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|Win32.ActiveCfg = Release|Win32
50 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|Win32.Build.0 = Release|Win32
51 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|x64.ActiveCfg = Release|x64
52 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Debug|x64.Build.0 = Release|x64
53 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|Win32.ActiveCfg = Release|Win32
54 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|Win32.Build.0 = Release|Win32
55 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|x64.ActiveCfg = Release|x64
56 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}.Release|x64.Build.0 = Release|x64
57 | EndGlobalSection
58 | GlobalSection(SolutionProperties) = preSolution
59 | HideSolutionNode = FALSE
60 | EndGlobalSection
61 | GlobalSection(NestedProjects) = preSolution
62 | {454D5FCC-E25A-4B45-9CA2-01ABB0FA5181} = {89723F04-E4BB-4E0E-917F-75B12FBCD5F0}
63 | EndGlobalSection
64 | GlobalSection(ExtensibilityGlobals) = postSolution
65 | SolutionGuid = {DD6F736F-53AC-4B02-8607-993275ABED73}
66 | EndGlobalSection
67 | EndGlobal
68 |
--------------------------------------------------------------------------------
/grepWin.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
3 |
4 | True
5 | MB
6 | <NamingElement Priority="24"><Descriptor Static="False" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="PUBLIC"><type Name="class field" /><type Name="union member" /></Descriptor><Policy Inspect="False" Prefix="" Suffix="" Style="AaBb"><ExtraRule Prefix="m_" Suffix="" Style="aaBb" /></Policy></NamingElement>
--------------------------------------------------------------------------------
/src/AboutDlg.cpp:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2013, 2018, 2020-2021 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #include "stdafx.h"
20 | #include "resource.h"
21 | #include "AboutDlg.h"
22 | #include "version.h"
23 | #include "Theme.h"
24 | #include
25 | #include
26 |
27 | CAboutDlg::CAboutDlg(HWND hParent)
28 | : m_hParent(hParent)
29 | , m_themeCallbackId(0)
30 | {
31 | }
32 |
33 | CAboutDlg::~CAboutDlg()
34 | {
35 | }
36 |
37 | LRESULT CAboutDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
38 | {
39 | UNREFERENCED_PARAMETER(lParam);
40 | switch (uMsg)
41 | {
42 | case WM_INITDIALOG:
43 | {
44 | m_themeCallbackId = CTheme::Instance().RegisterThemeChangeCallback(
45 | [this]() {
46 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
47 | });
48 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
49 | InitDialog(hwndDlg, IDI_GREPWIN);
50 | CLanguage::Instance().TranslateWindow(*this);
51 | wchar_t buf[MAX_PATH] = {0};
52 | swprintf_s(buf, _countof(buf), L"grepWin version %ld.%ld.%ld.%ld", GREPWIN_VERMAJOR, GREPWIN_VERMINOR, GREPWIN_VERMICRO, GREPWIN_VERBUILD);
53 | SetDlgItemText(*this, IDC_VERSIONINFO, buf);
54 | SetDlgItemText(*this, IDC_DATE, TEXT(GREPWIN_VERDATE));
55 | }
56 | return TRUE;
57 | case WM_COMMAND:
58 | return DoCommand(LOWORD(wParam), HIWORD(wParam));
59 | case WM_CLOSE:
60 | CTheme::Instance().RemoveRegisteredCallback(m_themeCallbackId);
61 | break;
62 | case WM_NOTIFY:
63 | {
64 | switch (wParam)
65 | {
66 | case IDC_WEBLINK:
67 | switch (reinterpret_cast(lParam)->code)
68 | {
69 | case NM_CLICK:
70 | case NM_RETURN:
71 | {
72 | PNMLINK pNMLink = reinterpret_cast(lParam);
73 | LITEM item = pNMLink->item;
74 | if (item.iLink == 0)
75 | {
76 | ShellExecute(*this, L"open", item.szUrl, nullptr, nullptr, SW_SHOW);
77 | }
78 | break;
79 | }
80 | }
81 | break;
82 | default:
83 | break;
84 | }
85 | }
86 | break;
87 | default:
88 | return FALSE;
89 | }
90 | return FALSE;
91 | }
92 |
93 | LRESULT CAboutDlg::DoCommand(int id, int /*msg*/)
94 | {
95 | switch (id)
96 | {
97 | case IDOK:
98 | // fall through
99 | case IDCANCEL:
100 | EndDialog(*this, id);
101 | break;
102 | default:
103 | break;
104 | }
105 | return 1;
106 | }
107 |
--------------------------------------------------------------------------------
/src/AboutDlg.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2008, 2012-2013, 2020-2021 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include "BaseDialog.h"
21 |
22 | /**
23 | * bookmarks dialog.
24 | */
25 | class CAboutDlg : public CDialog
26 | {
27 | public:
28 | CAboutDlg(HWND hParent);
29 | ~CAboutDlg() override;
30 |
31 | protected:
32 | LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
33 | LRESULT DoCommand(int id, int msg);
34 |
35 | private:
36 | HWND m_hParent;
37 | int m_themeCallbackId;
38 | };
39 |
--------------------------------------------------------------------------------
/src/Bookmarks.cpp:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2009, 2012-2013, 2017, 2020-2023 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #include "stdafx.h"
20 | #include "Bookmarks.h"
21 | #include "maxpath.h"
22 | #include
23 | #include
24 |
25 | CBookmarks::CBookmarks()
26 | {
27 | SetUnicode(true);
28 | }
29 |
30 | CBookmarks::~CBookmarks()
31 | {
32 | }
33 |
34 | void CBookmarks::Load()
35 | {
36 | auto path = std::make_unique(MAX_PATH_NEW);
37 | GetModuleFileName(nullptr, path.get(), MAX_PATH_NEW);
38 | if (bPortable)
39 | {
40 | m_iniPath = path.get();
41 | m_iniPath = m_iniPath.substr(0, m_iniPath.rfind('\\'));
42 | }
43 | else
44 | {
45 | SHGetFolderPath(nullptr, CSIDL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, path.get());
46 | m_iniPath = path.get();
47 | m_iniPath += L"\\grepWin";
48 | }
49 | CreateDirectory(m_iniPath.c_str(), nullptr);
50 | m_iniPath += L"\\bookmarks";
51 | SetUnicode();
52 | SetMultiLine(true); // multiline search
53 | LoadFile(m_iniPath.c_str());
54 | }
55 |
56 | void CBookmarks::Save() const
57 | {
58 | assert(!m_iniPath.empty());
59 | FILE* pFile = nullptr;
60 | _wfopen_s(&pFile, m_iniPath.c_str(), L"wb");
61 | SaveFile(pFile);
62 | fclose(pFile);
63 | }
64 |
65 | void CBookmarks::AddBookmark(const Bookmark& bm)
66 | {
67 | std::wstring val = L"\"";
68 | val += bm.Search;
69 | val += L"\"";
70 | SetValue(bm.Name.c_str(), L"searchString", val.c_str());
71 |
72 | val = L"\"";
73 | val += bm.Replace;
74 | val += L"\"";
75 | SetValue(bm.Name.c_str(), L"replaceString", val.c_str());
76 | SetValue(bm.Name.c_str(), L"useregex", bm.UseRegex ? L"true" : L"false");
77 | SetValue(bm.Name.c_str(), L"casesensitive", bm.CaseSensitive ? L"true" : L"false");
78 | SetValue(bm.Name.c_str(), L"dotmatchesnewline", bm.DotMatchesNewline ? L"true" : L"false");
79 | SetValue(bm.Name.c_str(), L"backup", bm.Backup ? L"true" : L"false");
80 | SetValue(bm.Name.c_str(), L"keepfiledate", bm.KeepFileDate ? L"true" : L"false");
81 | SetValue(bm.Name.c_str(), L"wholewords", bm.WholeWords ? L"true" : L"false");
82 | SetValue(bm.Name.c_str(), L"utf8", bm.Utf8 ? L"true" : L"false");
83 | SetValue(bm.Name.c_str(), L"includesystem", bm.IncludeSystem ? L"true" : L"false");
84 | SetValue(bm.Name.c_str(), L"includefolder", bm.IncludeFolder ? L"true" : L"false");
85 | SetValue(bm.Name.c_str(), L"includesymlinks", bm.IncludeSymLinks ? L"true" : L"false");
86 | SetValue(bm.Name.c_str(), L"includehidden", bm.IncludeHidden ? L"true" : L"false");
87 | SetValue(bm.Name.c_str(), L"includebinary", bm.IncludeBinary ? L"true" : L"false");
88 | val = L"\"";
89 | val += bm.ExcludeDirs;
90 | val += L"\"";
91 | SetValue(bm.Name.c_str(), L"excludedirs", val.c_str());
92 | val = L"\"";
93 | val += bm.FileMatch;
94 | val += L"\"";
95 | SetValue(bm.Name.c_str(), L"filematch", val.c_str());
96 | SetValue(bm.Name.c_str(), L"filematchregex", bm.FileMatchRegex ? L"true" : L"false");
97 | SetValue(bm.Name.c_str(), L"searchpath", bm.Path.c_str());
98 | }
99 |
100 | void CBookmarks::RemoveBookmark(const std::wstring& name)
101 | {
102 | Delete(name.c_str(), L"searchString", true);
103 | Delete(name.c_str(), L"replaceString", true);
104 | Delete(name.c_str(), L"useregex", true);
105 | Delete(name.c_str(), L"casesensitive", true);
106 | Delete(name.c_str(), L"dotmatchesnewline", true);
107 | Delete(name.c_str(), L"backup", true);
108 | Delete(name.c_str(), L"keepfiledate", true);
109 | Delete(name.c_str(), L"wholewords", true);
110 | Delete(name.c_str(), L"utf8", true);
111 | Delete(name.c_str(), L"includesystem", true);
112 | Delete(name.c_str(), L"includefolder", true);
113 | Delete(name.c_str(), L"includesymlinks", true);
114 | Delete(name.c_str(), L"includehidden", true);
115 | Delete(name.c_str(), L"includebinary", true);
116 | Delete(name.c_str(), L"excludedirs", true);
117 | Delete(name.c_str(), L"filematch", true);
118 | Delete(name.c_str(), L"filematchregex", true);
119 | Delete(name.c_str(), L"searchpath", true);
120 | }
121 |
122 | Bookmark CBookmarks::GetBookmark(const std::wstring& name) const
123 | {
124 | Bookmark bk;
125 | if (GetSectionSize(name.c_str()) >= 0)
126 | {
127 | bk.Name = name;
128 | bk.Search = GetValue(name.c_str(), L"searchString", L"");
129 | bk.Replace = GetValue(name.c_str(), L"replaceString", L"");
130 | bk.UseRegex = wcscmp(GetValue(name.c_str(), L"useregex", L"false"), L"true") == 0;
131 | bk.CaseSensitive = wcscmp(GetValue(name.c_str(), L"casesensitive", L"false"), L"true") == 0;
132 | bk.DotMatchesNewline = wcscmp(GetValue(name.c_str(), L"dotmatchesnewline", L"false"), L"true") == 0;
133 | bk.Backup = wcscmp(GetValue(name.c_str(), L"backup", L"false"), L"true") == 0;
134 | bk.KeepFileDate = wcscmp(GetValue(name.c_str(), L"keepfiledate", L"false"), L"true") == 0;
135 | bk.WholeWords = wcscmp(GetValue(name.c_str(), L"wholewords", L"false"), L"true") == 0;
136 | bk.Utf8 = wcscmp(GetValue(name.c_str(), L"utf8", L"false"), L"true") == 0;
137 | bk.IncludeSystem = wcscmp(GetValue(name.c_str(), L"includesystem", L"false"), L"true") == 0;
138 | bk.IncludeFolder = wcscmp(GetValue(name.c_str(), L"includefolder", L"false"), L"true") == 0;
139 | bk.IncludeSymLinks = wcscmp(GetValue(name.c_str(), L"includesymlinks", L"false"), L"true") == 0;
140 | bk.IncludeHidden = wcscmp(GetValue(name.c_str(), L"includehidden", L"false"), L"true") == 0;
141 | bk.IncludeBinary = wcscmp(GetValue(name.c_str(), L"includebinary", L"false"), L"true") == 0;
142 | bk.ExcludeDirs = GetValue(name.c_str(), L"excludedirs", L"");
143 | bk.FileMatch = GetValue(name.c_str(), L"filematch", L"");
144 | bk.FileMatchRegex = wcscmp(GetValue(name.c_str(), L"filematchregex", L"false"), L"true") == 0;
145 | bk.Path = GetValue(name.c_str(), L"searchpath", L"");
146 |
147 | RemoveQuotes(bk.Search);
148 | RemoveQuotes(bk.Replace);
149 | RemoveQuotes(bk.ExcludeDirs);
150 | RemoveQuotes(bk.FileMatch);
151 | }
152 |
153 | return bk;
154 | }
155 |
156 | void CBookmarks::RemoveQuotes(std::wstring& str)
157 | {
158 | if (!str.empty())
159 | {
160 | if (str[0] == '"')
161 | str = str.substr(1);
162 | if (!str.empty())
163 | {
164 | if (str[str.size() - 1] == '"')
165 | str = str.substr(0, str.size() - 1);
166 | }
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/src/Bookmarks.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2008, 2012-2013, 2020-2023 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include "SimpleIni.h"
21 | #include
22 | #include
23 |
24 | class Bookmark
25 | {
26 | public:
27 | Bookmark()
28 | : UseRegex(false)
29 | , CaseSensitive(false)
30 | , DotMatchesNewline(false)
31 | , Backup(false)
32 | , KeepFileDate(false)
33 | , WholeWords(false)
34 | , Utf8(false)
35 | , Binary(false)
36 | , IncludeSystem(false)
37 | , IncludeFolder(false)
38 | , IncludeSymLinks(false)
39 | , IncludeHidden(false)
40 | , IncludeBinary(false)
41 | , FileMatchRegex(false)
42 | {
43 | }
44 |
45 | ~Bookmark(){};
46 |
47 | std::wstring Name;
48 | std::wstring Search;
49 | std::wstring Replace;
50 | std::wstring Path;
51 | bool UseRegex;
52 | bool CaseSensitive;
53 | bool DotMatchesNewline;
54 | bool Backup;
55 | bool KeepFileDate;
56 | bool WholeWords;
57 | bool Utf8;
58 | bool Binary;
59 | bool IncludeSystem;
60 | bool IncludeFolder;
61 | bool IncludeSymLinks;
62 | bool IncludeHidden;
63 | bool IncludeBinary;
64 | std::wstring ExcludeDirs;
65 | std::wstring FileMatch;
66 | bool FileMatchRegex;
67 | };
68 |
69 | class CBookmarks : public CSimpleIni
70 | {
71 | public:
72 | CBookmarks();
73 | ~CBookmarks();
74 |
75 | void Load();
76 | void Save() const;
77 | void AddBookmark(const Bookmark& bm);
78 | void RemoveBookmark(const std::wstring& name);
79 | Bookmark GetBookmark(const std::wstring& name) const;
80 | static void RemoveQuotes(std::wstring& str);
81 |
82 | protected:
83 | std::wstring m_iniPath;
84 | TNamesDepend m_sections;
85 | };
86 |
--------------------------------------------------------------------------------
/src/BookmarksDlg.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2009, 2012-2013, 2016, 2019-2024 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include "BaseDialog.h"
21 | #include "DlgResizer.h"
22 | #include "Bookmarks.h"
23 | #include
24 |
25 | #define WM_BOOKMARK (WM_APP + 20)
26 |
27 | /**
28 | * bookmarks dialog.
29 | */
30 | class CBookmarksDlg : public CDialog
31 | {
32 | public:
33 | CBookmarksDlg(HWND hParent);
34 | ~CBookmarksDlg() override;
35 |
36 | void InitBookmarks();
37 | std::wstring GetName() const { return m_name; }
38 | std::wstring GetSelectedSearchString() const { return m_searchString; }
39 | std::wstring GetSelectedReplaceString() const { return m_replaceString; }
40 | std::wstring GetPath() const { return m_path; }
41 | bool GetSelectedUseRegex() const { return m_bUseRegex; }
42 | bool GetSelectedSearchCase() const { return m_bCaseSensitive; }
43 | bool GetSelectedDotMatchNewline() const { return m_bDotMatchesNewline; }
44 | bool GetSelectedBackup() const { return m_bBackup; }
45 | bool GetSelectedKeepFileDate() const { return m_bKeepFileDate; }
46 | bool GetSelectedWholeWords() const { return m_bWholeWords; }
47 | bool GetSelectedTreatAsUtf8() const { return m_bUtf8; }
48 | bool GetSelectedTreatAsBinary() const { return m_bForceBinary; }
49 | bool GetSelectedIncludeSystem() const { return m_bIncludeSystem; }
50 | bool GetSelectedIncludeFolder() const { return m_bIncludeFolder; }
51 | bool GetSelectedIncludeSymLinks() const { return m_bIncludeSymLinks; }
52 | bool GetSelectedIncludeHidden() const { return m_bIncludeHidden; }
53 | bool GetSelectedIncludeBinary() const { return m_bIncludeBinary; }
54 | std::wstring GetSelectedExcludeDirs() const { return m_sExcludeDirs; }
55 | std::wstring GetSelectedFileMatch() const { return m_sFileMatch; }
56 | bool GetSelectedFileMatchRegex() const { return m_bFileMatchRegex; }
57 |
58 | protected:
59 | LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
60 | LRESULT DoCommand(int id, int msg);
61 | void PrepareSelected();
62 |
63 | private:
64 | HWND m_hParent;
65 | std::wstring m_name;
66 | CBookmarks m_bookmarks;
67 |
68 | std::wstring m_searchString;
69 | std::wstring m_replaceString;
70 | std::wstring m_path;
71 | bool m_bUseRegex;
72 | bool m_bCaseSensitive;
73 | bool m_bDotMatchesNewline;
74 | bool m_bBackup;
75 | bool m_bKeepFileDate;
76 | bool m_bWholeWords;
77 | bool m_bUtf8;
78 | bool m_bForceBinary;
79 | bool m_bIncludeSystem;
80 | bool m_bIncludeFolder;
81 | bool m_bIncludeSymLinks;
82 | bool m_bIncludeHidden;
83 | bool m_bIncludeBinary;
84 | std::wstring m_sExcludeDirs;
85 | std::wstring m_sFileMatch;
86 | bool m_bFileMatchRegex;
87 |
88 | int m_themeCallbackId;
89 | CDlgResizer m_resizer;
90 | };
91 |
--------------------------------------------------------------------------------
/src/COMPtrs.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2009, 2012-2013, 2016, 2019-2021 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 |
26 | _COM_SMARTPTR_TYPEDEF(IFileOpenDialog, __uuidof(IFileOpenDialog));
27 | _COM_SMARTPTR_TYPEDEF(IShellItem, __uuidof(IShellItem));
28 | _COM_SMARTPTR_TYPEDEF(IShellItemArray, __uuidof(IShellItemArray));
29 | _COM_SMARTPTR_TYPEDEF(IFileOperation, __uuidof(IFileOperation));
30 | _COM_SMARTPTR_TYPEDEF(IStream, __uuidof(IStream));
31 | _COM_SMARTPTR_TYPEDEF(IFileSaveDialog, __uuidof(IFileSaveDialog));
32 | _COM_SMARTPTR_TYPEDEF(IShellItem, __uuidof(IShellItem));
33 | _COM_SMARTPTR_TYPEDEF(IFileDialogCustomize, __uuidof(IFileDialogCustomize));
34 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/ExplorerCommandVerb.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 16.0
23 | Win32Proj
24 | {585a1606-dc66-49ba-bffb-e6f0b63a66bf}
25 | ExplorerCommandVerb
26 |
27 |
28 |
29 | DynamicLibrary
30 | true
31 | v143
32 | Unicode
33 |
34 |
35 | DynamicLibrary
36 | false
37 | v143
38 | true
39 | Unicode
40 |
41 |
42 | DynamicLibrary
43 | true
44 | v143
45 | Unicode
46 |
47 |
48 | DynamicLibrary
49 | false
50 | v143
51 | true
52 | Unicode
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | true
74 | $(SolutionDir)bin\$(Configuration)\
75 | $(SolutionDir)obj\$(Configuration)\$(ProjectName)\
76 |
77 |
78 | false
79 | $(SolutionDir)bin\$(Configuration)\
80 | $(SolutionDir)obj\$(Configuration)\$(ProjectName)\
81 |
82 |
83 | true
84 | $(SolutionDir)bin\$(Configuration)64\
85 | $(SolutionDir)obj\$(Configuration)64\$(ProjectName)\
86 |
87 |
88 | false
89 | $(SolutionDir)bin\$(Configuration)64\
90 | $(SolutionDir)obj\$(Configuration)64\$(ProjectName)\
91 |
92 |
93 |
94 | Level3
95 | true
96 | WIN32;_DEBUG;EXPLORERCOMMANDVERB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
97 | true
98 | Use
99 | pch.h
100 | stdcpp20
101 | MultiThreadedDebug
102 |
103 |
104 | Windows
105 | true
106 | false
107 | runtimeobject.lib;%(AdditionalDependencies)
108 | source.def
109 |
110 |
111 |
112 |
113 | Level3
114 | true
115 | true
116 | true
117 | WIN32;NDEBUG;EXPLORERCOMMANDVERB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
118 | true
119 | Use
120 | pch.h
121 | stdcpp20
122 | MultiThreaded
123 |
124 |
125 | Windows
126 | true
127 | true
128 | true
129 | false
130 | runtimeobject.lib;%(AdditionalDependencies)
131 | source.def
132 |
133 |
134 |
135 |
136 | Level3
137 | true
138 | _DEBUG;EXPLORERCOMMANDVERB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
139 | true
140 | Use
141 | pch.h
142 | stdcpp20
143 | MultiThreadedDebug
144 |
145 |
146 | Windows
147 | true
148 | false
149 | runtimeobject.lib;%(AdditionalDependencies)
150 | source.def
151 |
152 |
153 |
154 |
155 | Level3
156 | true
157 | true
158 | true
159 | NDEBUG;EXPLORERCOMMANDVERB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
160 | true
161 | Use
162 | pch.h
163 | stdcpp20
164 | MultiThreaded
165 |
166 |
167 | Windows
168 | true
169 | true
170 | true
171 | false
172 | runtimeobject.lib;%(AdditionalDependencies)
173 | source.def
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 | Create
184 | Create
185 | Create
186 | Create
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
203 |
204 |
205 |
206 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/ExplorerCommandVerb.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 |
26 |
27 | Source Files
28 |
29 |
30 | Source Files
31 |
32 |
33 |
34 |
35 | Source Files
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/compatibility.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/framework.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
4 | // Windows Header Files
5 | #include
6 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: source file corresponding to the pre-compiled header
2 |
3 | #include "pch.h"
4 |
5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
6 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/pch.h:
--------------------------------------------------------------------------------
1 | // pch.h: This is a precompiled header file.
2 | // Files listed below are compiled only once, improving build performance for future builds.
3 | // This also affects IntelliSense performance, including code completion and many code browsing features.
4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds.
5 | // Do not add files here that you will be updating frequently as this negates the performance advantage.
6 |
7 | #ifndef PCH_H
8 | #define PCH_H
9 |
10 | // add headers that you want to pre-compile here
11 | #include "framework.h"
12 |
13 | #endif //PCH_H
14 |
--------------------------------------------------------------------------------
/src/ExplorerCommandVerb/source.def:
--------------------------------------------------------------------------------
1 | LIBRARY
2 | EXPORTS
3 | DllCanUnloadNow PRIVATE
4 | DllGetClassObject PRIVATE
5 | DllGetActivationFactory PRIVATE
6 |
--------------------------------------------------------------------------------
/src/LineData.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2012 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include
21 | #include
22 |
23 | struct LineDataLine
24 | {
25 | DWORD number;
26 | DWORD column;
27 | std::wstring text;
28 | };
29 |
30 | struct LineData
31 | {
32 | std::wstring path;
33 | std::vector lines;
34 | };
--------------------------------------------------------------------------------
/src/MultiLineEditDlg.cpp:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2011-2013, 2019-2021, 2024 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #include "stdafx.h"
20 | #include "resource.h"
21 | #include "MultiLineEditDlg.h"
22 |
23 | #include "NewlinesDlg.h"
24 | #include "Theme.h"
25 | #include "../sktoolslib/StringUtils.h"
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | CMultiLineEditDlg::CMultiLineEditDlg(HWND hParent)
32 | : m_hParent(hParent)
33 | , m_themeCallbackId(0)
34 | , m_forReplace(false)
35 | , m_forRegex(false)
36 | {
37 | }
38 |
39 | CMultiLineEditDlg::~CMultiLineEditDlg()
40 | {
41 | }
42 |
43 | void CMultiLineEditDlg::setForReplace()
44 | {
45 | m_forReplace = true;
46 | }
47 | void CMultiLineEditDlg::setForRegex()
48 | {
49 | m_forRegex = true;
50 | }
51 |
52 | LRESULT CMultiLineEditDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
53 | {
54 | UNREFERENCED_PARAMETER(lParam);
55 | switch (uMsg)
56 | {
57 | case WM_INITDIALOG:
58 | {
59 | m_themeCallbackId = CTheme::Instance().RegisterThemeChangeCallback(
60 | [this]() {
61 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
62 | });
63 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
64 |
65 | InitDialog(hwndDlg, IDI_GREPWIN);
66 | CLanguage::Instance().TranslateWindow(*this);
67 | // initialize the controls
68 | if (!m_forRegex)
69 | {
70 | ShowWindow(GetDlgItem(hwndDlg, IDC_CONVERTNEWLINES_BTN), SW_HIDE);
71 | ShowWindow(GetDlgItem(hwndDlg, IDC_INFOLABEL), SW_HIDE);
72 | }
73 | else
74 | {
75 | // does the string already contain newlines?
76 | if (m_regexText.find(L"\n") == std::wstring::npos)
77 | {
78 | // use boost regex to append all \\r\\n, \\r, \\n with newlines, but only if they're not already followed by newlines
79 | m_regexText = boost::regex_replace(m_regexText, boost::wregex(L"(\\\\r\\\\n)(?!\\r|\\n|\\||\\))"), L"\\\\r\\\\n\\r\\n");
80 | m_regexText = boost::regex_replace(m_regexText, boost::wregex(L"(\\\\r)(?!\\\\n|\\r|\\n|\\||\\))"), L"\\\\r\\r\\n");
81 | m_regexText = boost::regex_replace(m_regexText, boost::wregex(L"(\\\\n)(?!\\r|\\n|\\||\\))"), L"\\\\n\\r\\n");
82 | m_regexText = boost::regex_replace(m_regexText, boost::wregex(L"(\\(\\\\r\\\\n\\|\\\\r\\|\\\\n\\))(?!\\r|\\n|\\||\\))"), L"\\(\\\\r\\\\n\\|\\\\r\\|\\\\n\\)\\r\\n");
83 | }
84 | }
85 |
86 | SetDlgItemText(hwndDlg, IDC_TEXTCONTENT, m_regexText.c_str());
87 |
88 | SetFocus(GetDlgItem(hwndDlg, IDC_TEXTCONTENT));
89 |
90 | m_resizer.Init(hwndDlg);
91 | m_resizer.UseSizeGrip(!CTheme::Instance().IsDarkTheme());
92 | m_resizer.AddControl(hwndDlg, IDC_TEXTCONTENT, RESIZER_TOPLEFTBOTTOMRIGHT);
93 | m_resizer.AddControl(hwndDlg, IDC_INFOLABEL, RESIZER_BOTTOMLEFTRIGHT);
94 | m_resizer.AddControl(hwndDlg, IDC_CONVERTNEWLINES_BTN, RESIZER_BOTTOMLEFT);
95 | m_resizer.AddControl(hwndDlg, IDOK, RESIZER_BOTTOMRIGHT);
96 | m_resizer.AddControl(hwndDlg, IDCANCEL, RESIZER_BOTTOMRIGHT);
97 |
98 | SendMessage(GetDlgItem(*this, IDC_TEXTCONTENT), EM_SETEVENTMASK, 0, ENM_CHANGE);
99 | SendMessage(GetDlgItem(*this, IDC_TEXTCONTENT), EM_EXLIMITTEXT, 0, 200 * 1024);
100 | }
101 | return FALSE;
102 | case WM_COMMAND:
103 | return DoCommand(LOWORD(wParam), HIWORD(wParam));
104 | case WM_SIZE:
105 | {
106 | m_resizer.DoResize(LOWORD(lParam), HIWORD(lParam));
107 | }
108 | break;
109 | case WM_GETMINMAXINFO:
110 | {
111 | MINMAXINFO* mmi = reinterpret_cast(lParam);
112 | mmi->ptMinTrackSize.x = m_resizer.GetDlgRect()->right;
113 | mmi->ptMinTrackSize.y = m_resizer.GetDlgRect()->bottom;
114 | return 0;
115 | }
116 | case WM_CLOSE:
117 | CTheme::Instance().RemoveRegisteredCallback(m_themeCallbackId);
118 | break;
119 | default:
120 | return FALSE;
121 | }
122 | return FALSE;
123 | }
124 |
125 | LRESULT CMultiLineEditDlg::DoCommand(int id, int msg)
126 | {
127 | switch (id)
128 | {
129 | case IDOK:
130 | {
131 | auto buf = GetDlgItemText(IDC_TEXTCONTENT);
132 | m_regexText = std::wstring(buf.get());
133 | if (m_forRegex)
134 | {
135 | // remove formatting newlines
136 | SearchReplace(m_regexText, L"\n", L"");
137 | SearchReplace(m_regexText, L"\r", L"");
138 | }
139 | }
140 | [[fallthrough]];
141 | case IDCANCEL:
142 | EndDialog(*this, id);
143 | break;
144 | case IDC_TEXTCONTENT:
145 | {
146 | if (msg == EN_CHANGE)
147 | {
148 | auto buf = GetDlgItemText(IDC_TEXTCONTENT);
149 | m_regexText = std::wstring(buf.get());
150 | }
151 | }
152 | break;
153 | case IDC_CONVERTNEWLINES_BTN:
154 | CNewlinesDlg newLinesDlg(*this);
155 | newLinesDlg.setShowBoth(!m_forReplace);
156 | if (newLinesDlg.DoModal(hResource, IDD_NEWLINESDLG, *this) == IDOK)
157 | {
158 | auto buf = GetDlgItemText(IDC_TEXTCONTENT);
159 | m_regexText = std::wstring(buf.get());
160 | // normalize newlines
161 | SearchReplace(m_regexText, L"\r\n", L"\n");
162 | SearchReplace(m_regexText, L"\r", L"\n");
163 |
164 | switch (newLinesDlg.getNewLines())
165 | {
166 | case eNewlines::Linux:
167 | {
168 | // convert newlines to regex newlines
169 | SearchReplace(m_regexText, L"\n", L"\\n\r\n");
170 | }
171 | break;
172 | case eNewlines::Windows:
173 | {
174 | // convert newlines to regex newlines
175 | SearchReplace(m_regexText, L"\n", L"\\r\\n\r\n");
176 | }
177 | break;
178 | case eNewlines::Both:
179 | {
180 | // convert newlines to regex newlines
181 | SearchReplace(m_regexText, L"\n", L"(\\r\\n|\\r|\\n)\r\n");
182 | }
183 | break;
184 | default:
185 | break;
186 | }
187 | SetDlgItemText(*this, IDC_TEXTCONTENT, m_regexText.c_str());
188 | }
189 | break;
190 | }
191 | return 1;
192 | }
193 |
--------------------------------------------------------------------------------
/src/MultiLineEditDlg.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2011-2013, 2019-2021, 2024 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include "BaseDialog.h"
21 | #include "DlgResizer.h"
22 | #include
23 |
24 | #define ID_REGEXTIMER 100
25 |
26 | /**
27 | * regex test dialog.
28 | */
29 | class CMultiLineEditDlg : public CDialog
30 | {
31 | public:
32 | CMultiLineEditDlg(HWND hParent);
33 | ~CMultiLineEditDlg() override;
34 |
35 | void SetString(const std::wstring& search) { m_regexText = search; }
36 | std::wstring GetSearchString() const { return m_regexText; }
37 | void setForReplace();
38 | void setForRegex();
39 |
40 | protected:
41 | LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
42 | LRESULT DoCommand(int id, int msg);
43 |
44 | private:
45 | HWND m_hParent;
46 | std::wstring m_regexText;
47 | int m_themeCallbackId;
48 | CDlgResizer m_resizer;
49 | bool m_forReplace;
50 | bool m_forRegex;
51 | };
52 |
--------------------------------------------------------------------------------
/src/NameDlg.cpp:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2008, 2012-2013, 2019-2021, 2024 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #include "stdafx.h"
20 | #include "resource.h"
21 | #include "NameDlg.h"
22 | #include "Theme.h"
23 | #include
24 |
25 | #include
26 |
27 | CNameDlg::CNameDlg(HWND hParent)
28 | : m_hParent(hParent)
29 | , m_bIncludePath(false)
30 | , m_themeCallbackId(0)
31 | {
32 | }
33 |
34 | CNameDlg::~CNameDlg()
35 | {
36 | }
37 |
38 | LRESULT CNameDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
39 | {
40 | UNREFERENCED_PARAMETER(lParam);
41 | switch (uMsg)
42 | {
43 | case WM_INITDIALOG:
44 | {
45 | m_themeCallbackId = CTheme::Instance().RegisterThemeChangeCallback(
46 | [this]() {
47 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
48 | });
49 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
50 |
51 | InitDialog(hwndDlg, IDI_GREPWIN);
52 | CLanguage::Instance().TranslateWindow(*this);
53 | // initialize the controls
54 |
55 | SetDlgItemText(*this, IDC_NAME, m_name.c_str());
56 | SetFocus(GetDlgItem(hwndDlg, IDC_NAME));
57 | }
58 | return FALSE;
59 | case WM_COMMAND:
60 | return DoCommand(LOWORD(wParam), HIWORD(wParam));
61 | case WM_CLOSE:
62 | CTheme::Instance().RemoveRegisteredCallback(m_themeCallbackId);
63 | break;
64 | default:
65 | return FALSE;
66 | }
67 | return FALSE;
68 | }
69 |
70 | LRESULT CNameDlg::DoCommand(int id, int /*msg*/)
71 | {
72 | switch (id)
73 | {
74 | case IDOK:
75 | {
76 | auto buf = GetDlgItemText(IDC_NAME);
77 | m_name = buf.get();
78 | m_bIncludePath = IsDlgButtonChecked(*this, IDC_INCLUDEPATH);
79 | }
80 | [[fallthrough]];
81 | case IDCANCEL:
82 | EndDialog(*this, id);
83 | break;
84 | default:
85 | break;
86 | }
87 | return 1;
88 | }
89 |
--------------------------------------------------------------------------------
/src/NameDlg.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2007-2008, 2012-2013, 2019-2021 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include "BaseDialog.h"
21 | #include "DlgResizer.h"
22 | #include
23 |
24 | /**
25 | * name dialog.
26 | */
27 | class CNameDlg : public CDialog
28 | {
29 | public:
30 | CNameDlg(HWND hParent);
31 | ~CNameDlg() override;
32 |
33 | std::wstring GetName() const { return m_name; }
34 | void SetName(const std::wstring& n) { m_name = n; }
35 | bool IncludePath() const { return m_bIncludePath; }
36 |
37 | protected:
38 | LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
39 | LRESULT DoCommand(int id, int msg);
40 |
41 | private:
42 | HWND m_hParent;
43 | std::wstring m_name;
44 | bool m_bIncludePath;
45 | int m_themeCallbackId;
46 | };
47 |
--------------------------------------------------------------------------------
/src/NewlinesDlg.cpp:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2024 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #include "stdafx.h"
20 | #include "resource.h"
21 | #include "NewlinesDlg.h"
22 | #include "Theme.h"
23 | #include
24 |
25 | CNewlinesDlg::CNewlinesDlg(HWND hParent)
26 | : m_hParent(hParent)
27 | , m_themeCallbackId(0)
28 | , m_newLines(eNewlines::None)
29 | {
30 | }
31 |
32 | CNewlinesDlg::~CNewlinesDlg()
33 | {
34 | }
35 | void CNewlinesDlg::setNewLines(eNewlines nl)
36 | {
37 | m_newLines = nl;
38 | }
39 | eNewlines CNewlinesDlg::getNewLines() const
40 | {
41 | return m_newLines;
42 | }
43 | void CNewlinesDlg::setShowBoth(bool show)
44 | {
45 | m_showBoth = show;
46 | }
47 |
48 | LRESULT CNewlinesDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
49 | {
50 | UNREFERENCED_PARAMETER(lParam);
51 | switch (uMsg)
52 | {
53 | case WM_INITDIALOG:
54 | {
55 | m_themeCallbackId = CTheme::Instance().RegisterThemeChangeCallback(
56 | [this]() {
57 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
58 | });
59 | CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
60 |
61 | InitDialog(hwndDlg, IDI_GREPWIN);
62 | CLanguage::Instance().TranslateWindow(*this);
63 | // initialize the controls
64 | switch (m_newLines)
65 | {
66 | case eNewlines::None:
67 | CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_CRLF);
68 |
69 | break;
70 | case eNewlines::Linux:
71 | CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_LF);
72 | break;
73 | case eNewlines::Windows:
74 | CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_CRLF);
75 | break;
76 | case eNewlines::Both:
77 | CheckRadioButton(hwndDlg, IDC_CRLF, IDC_BOTH, IDC_BOTH);
78 | break;
79 | }
80 | if (!m_showBoth)
81 | {
82 | ShowWindow(GetDlgItem(hwndDlg, IDC_BOTH), SW_HIDE);
83 | }
84 | }
85 | return FALSE;
86 | case WM_COMMAND:
87 | return DoCommand(LOWORD(wParam), HIWORD(wParam));
88 | case WM_CLOSE:
89 | CTheme::Instance().RemoveRegisteredCallback(m_themeCallbackId);
90 | break;
91 | default:
92 | return FALSE;
93 | }
94 | return FALSE;
95 | }
96 |
97 | LRESULT CNewlinesDlg::DoCommand(int id, int /*msg*/)
98 | {
99 | switch (id)
100 | {
101 | case IDOK:
102 | if (IsDlgButtonChecked(*this, IDC_LF) == BST_CHECKED)
103 | {
104 | m_newLines = eNewlines::Linux;
105 | }
106 | else if (IsDlgButtonChecked(*this, IDC_CRLF) == BST_CHECKED)
107 | {
108 | m_newLines = eNewlines::Windows;
109 | }
110 | else if (IsDlgButtonChecked(*this, IDC_BOTH) == BST_CHECKED)
111 | {
112 | m_newLines = eNewlines::Both;
113 | }
114 | [[fallthrough]];
115 | case IDCANCEL:
116 | EndDialog(*this, id);
117 | break;
118 | }
119 | return 1;
120 | }
121 |
--------------------------------------------------------------------------------
/src/NewlinesDlg.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2024 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include "BaseDialog.h"
21 |
22 | enum class eNewlines
23 | {
24 | None,
25 | Linux,
26 | Windows,
27 | Both,
28 | };
29 |
30 | class CNewlinesDlg : public CDialog
31 | {
32 | public:
33 | CNewlinesDlg(HWND hParent);
34 | ~CNewlinesDlg() override;
35 |
36 | void setNewLines(eNewlines nl);
37 | eNewlines getNewLines() const;
38 | void setShowBoth(bool show);
39 |
40 | protected:
41 | LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
42 | LRESULT DoCommand(int id, int msg);
43 |
44 | private:
45 | HWND m_hParent;
46 | int m_themeCallbackId;
47 | eNewlines m_newLines;
48 | bool m_showBoth;
49 | };
50 |
--------------------------------------------------------------------------------
/src/RegexReplaceFormatter.cpp:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2011, 2015, 2024-2025 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #include "stdafx.h"
20 | #include "RegexReplaceFormatter.h"
21 | #include
22 |
23 | std::wstring ExpandString(const std::wstring& replaceString)
24 | {
25 | // ${now,formatString}
26 | wchar_t buf[4096] = {};
27 | GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, buf, _countof(buf));
28 | std::wstring dateStr = buf;
29 | GetTimeFormat(LOCALE_USER_DEFAULT, 0, nullptr, nullptr, buf, _countof(buf));
30 | dateStr += L" - ";
31 | dateStr += buf;
32 | std::time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
33 | UINT syntaxFlags = boost::regex::normal;
34 | boost::wregex expression = boost::wregex(L"\\$\\{now\\s*,?([^}]*)\\}", syntaxFlags);
35 | boost::match_results whatC;
36 | boost::match_flag_type matchFlags = boost::match_default | boost::format_all;
37 | auto resultString = replaceString;
38 | SearchReplace(resultString, L"${now}", dateStr);
39 |
40 | try
41 | {
42 | auto start = resultString.cbegin();
43 | auto end = resultString.cend();
44 | while (regex_search(start, end, whatC, expression, matchFlags))
45 | {
46 | if (whatC[0].matched)
47 | {
48 | auto fullMatch = whatC.str();
49 |
50 | std::wstring formatStr;
51 | if (whatC.size() > 1)
52 | {
53 | formatStr = whatC[1].str();
54 | if (!formatStr.empty())
55 | {
56 | std::wstring formattedDateStr(4096, '\0');
57 | struct tm locTime;
58 | _localtime64_s(&locTime, &now);
59 | try
60 | {
61 | std::wcsftime(&formattedDateStr[0], formattedDateStr.size(), formatStr.c_str(), &locTime);
62 | SearchReplace(resultString, fullMatch, formattedDateStr);
63 | }
64 | catch (const std::exception&)
65 | {
66 | }
67 | }
68 | }
69 | else
70 | {
71 | SearchReplace(resultString, fullMatch, dateStr);
72 | }
73 | }
74 | if (start == whatC[0].second)
75 | {
76 | if (start == end)
77 | break;
78 | ++start;
79 | }
80 | else
81 | start = whatC[0].second;
82 | }
83 | }
84 | catch (const std::exception&)
85 | {
86 | }
87 | return resultString;
88 | }
--------------------------------------------------------------------------------
/src/RegexReplaceFormatter.h:
--------------------------------------------------------------------------------
1 | // grepWin - regex search and replace for Windows
2 |
3 | // Copyright (C) 2011-2012, 2014-2015, 2021, 2023-2024 - Stefan Kueng
4 |
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program; if not, write to the Free Software Foundation,
17 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 | //
19 | #pragma once
20 | #include
21 | #include
22 | #include
23 | #include