Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EncodingTools/EncodingTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Threading;
using FindAndReplace;

namespace href.Utils
namespace FindAndReplace
{
public static class EncodingTools
{
Expand Down
4 changes: 2 additions & 2 deletions src/EncodingTools/EncodingTools.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EncodingTools</RootNamespace>
<AssemblyName>EncodingTools</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
Expand Down
21 changes: 12 additions & 9 deletions src/FindAndReplace.App/FindAndReplace.App.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
Expand All @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FindAndReplace.App</RootNamespace>
<AssemblyName>fnr</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -142,13 +142,6 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FindAndReplace\FindAndReplace.csproj">
<Project>{4E35E2C7-099B-4356-9215-0DC77D156CFA}</Project>
<Name>FindAndReplace</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\swap_icon.gif" />
</ItemGroup>
Expand All @@ -158,6 +151,16 @@
<ItemGroup>
<None Include="Resources\donate2.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EncodingTools\EncodingTools.csproj">
<Project>{ca19d4de-b232-491a-92bf-7bf3a2758694}</Project>
<Name>EncodingTools</Name>
</ProjectReference>
<ProjectReference Include="..\FindAndReplace\FindAndReplace.csproj">
<Project>{4e35e2c7-099b-4356-9215-0dc77d156cfa}</Project>
<Name>FindAndReplace</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
Expand Down
26 changes: 17 additions & 9 deletions src/FindAndReplace.App/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,27 @@ private void ShowFindResult(Finder.FindResultItem findResultItem, Stats stats, S

if (findResultItem.IsSuccess && findResultItem.NumMatches > 0) //Account for errors and IncludeFilesWithoutMatches
{
string fileContent = string.Empty;

using (var sr = new StreamReader(findResultItem.FilePath, findResultItem.FileEncoding))
if (Path.GetExtension(findResultItem.FilePath).Equals(".pdf", StringComparison.OrdinalIgnoreCase))
{
fileContent = sr.ReadToEnd();
string lineSeparator = ("\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n");
gvResults.Rows[currentRow].Cells[columnIndex].Value = string.Join(lineSeparator, findResultItem.Matches.Select(x => x.PreviewText));
}
else
{
string fileContent = string.Empty;

using (var sr = new StreamReader(findResultItem.FilePath, findResultItem.FileEncoding))
{
fileContent = sr.ReadToEnd();
}

List<MatchPreviewLineNumber> lineNumbers = Utils.GetLineNumbersForMatchesPreview(fileContent,
findResultItem.Matches);
gvResults.Rows[currentRow].Cells[columnIndex].Value = GenerateMatchesPreviewText(fileContent,
lineNumbers.Select(
ln => ln.LineNumber).ToList());

List<MatchPreviewLineNumber> lineNumbers = Utils.GetLineNumbersForMatchesPreview(fileContent,
findResultItem.Matches);
gvResults.Rows[currentRow].Cells[columnIndex].Value = GenerateMatchesPreviewText(fileContent,
lineNumbers.Select(
ln => ln.LineNumber).ToList());
}
}

//Grid likes to select the first row for some reason
Expand Down
32 changes: 16 additions & 16 deletions src/FindAndReplace.App/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/FindAndReplace.App/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/FindAndReplace.App/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<section name="FindAndReplace.App.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup><userSettings>
<FindAndReplace.App.Properties.Settings>
<setting name="Dir" serializeAs="String">
<value/>
Expand Down
2 changes: 1 addition & 1 deletion src/FindAndReplace.App/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="1.9.71" targetFramework="net40" />
<package id="CommandLineParser" version="1.9.71" targetFramework="net40" requireReinstallation="true" />
</packages>
6 changes: 3 additions & 3 deletions src/FindAndReplace.Tests.CommandLine/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand All @@ -9,12 +9,13 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FindAndReplace.Tests.CommandLine</RootNamespace>
<AssemblyName>FindAndReplace.Tests.CommandLine</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
1 change: 0 additions & 1 deletion src/FindAndReplace.Tests/DetectEncodingAccuracyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading;
using NUnit.Framework;
using System.Linq;
using href.Utils;

namespace FindAndReplace.Tests
{
Expand Down
4 changes: 2 additions & 2 deletions src/FindAndReplace.Tests/FindAndReplace.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FindAndReplace.Tests</RootNamespace>
<AssemblyName>FindAndReplace.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
Expand Down
40 changes: 25 additions & 15 deletions src/FindAndReplace.sln
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
# Visual Studio Version 17
VisualStudioVersion = 17.14.36221.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.App", "FindAndReplace.App\FindAndReplace.App.csproj", "{128F4172-1975-4ABA-A8D8-4B55DC9AB481}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.Tests", "FindAndReplace.Tests\FindAndReplace.Tests.csproj", "{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}"
ProjectSection(ProjectDependencies) = postProject
{4E35E2C7-099B-4356-9215-0DC77D156CFA} = {4E35E2C7-099B-4356-9215-0DC77D156CFA}
{CA19D4DE-B232-491A-92BF-7BF3A2758694} = {CA19D4DE-B232-491A-92BF-7BF3A2758694}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace", "FindAndReplace\FindAndReplace.csproj", "{4E35E2C7-099B-4356-9215-0DC77D156CFA}"
ProjectSection(ProjectDependencies) = postProject
{CA19D4DE-B232-491A-92BF-7BF3A2758694} = {CA19D4DE-B232-491A-92BF-7BF3A2758694}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EncodingTools", "EncodingTools\EncodingTools.csproj", "{CA19D4DE-B232-491A-92BF-7BF3A2758694}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.Tests", "FindAndReplace.Tests\FindAndReplace.Tests.csproj", "{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FindAndReplace.Tests.CommandLine", "FindAndReplace.Tests.CommandLine\FindAndReplace.Tests.CommandLine.csproj", "{72B4C6BB-E2C8-4162-AE69-23B588048689}"
EndProject
Global
Expand All @@ -33,17 +40,6 @@ Global
{128F4172-1975-4ABA-A8D8-4B55DC9AB481}.Release|Mixed Platforms.Build.0 = Release|x86
{128F4172-1975-4ABA-A8D8-4B55DC9AB481}.Release|x86.ActiveCfg = Release|x86
{128F4172-1975-4ABA-A8D8-4B55DC9AB481}.Release|x86.Build.0 = Release|x86
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.ActiveCfg = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.Build.0 = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.Build.0 = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|x86.ActiveCfg = Release|Any CPU
{4E35E2C7-099B-4356-9215-0DC77D156CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4E35E2C7-099B-4356-9215-0DC77D156CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E35E2C7-099B-4356-9215-0DC77D156CFA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
Expand All @@ -64,16 +60,30 @@ Global
{CA19D4DE-B232-491A-92BF-7BF3A2758694}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CA19D4DE-B232-491A-92BF-7BF3A2758694}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{CA19D4DE-B232-491A-92BF-7BF3A2758694}.Release|x86.ActiveCfg = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.ActiveCfg = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Debug|x86.Build.0 = Debug|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Any CPU.Build.0 = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|x86.ActiveCfg = Release|Any CPU
{2517D7CF-7BBD-4CEA-AA10-87FFB6C6A0DC}.Release|x86.Build.0 = Release|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|x86.ActiveCfg = Debug|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Debug|x86.Build.0 = Debug|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Any CPU.Build.0 = Release|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|x86.ActiveCfg = Release|Any CPU
{72B4C6BB-E2C8-4162-AE69-23B588048689}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading