Skip to content

Commit

Permalink
Adding the source code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey-Barkar committed Jul 16, 2023
1 parent 3454e51 commit 8dda1a9
Show file tree
Hide file tree
Showing 37 changed files with 794 additions and 39 deletions.
63 changes: 63 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
41 changes: 3 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.rsuser
Expand Down Expand Up @@ -29,6 +29,7 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/

Expand Down Expand Up @@ -90,7 +91,6 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
Expand Down Expand Up @@ -294,17 +294,6 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw

# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp

# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp

# Visual Studio 6 technical files
*.ncb
*.aps

# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
Expand Down Expand Up @@ -361,9 +350,6 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/

# Visual Studio History (VSHistory) files
.vshistory/

# BeatPulse healthcheck temp database
healthchecksdb

Expand All @@ -374,25 +360,4 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp

# JetBrains Rider
*.sln.iml
FodyWeavers.xsd
25 changes: 25 additions & 0 deletions AxBraceGuideLineExtension.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AxBraceGuideLineExtension", "AxBraceGuideLineExtension\AxBraceGuideLineExtension.csproj", "{5E0D8C41-14CD-4076-BF73-E3E975799629}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5E0D8C41-14CD-4076-BF73-E3E975799629}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E0D8C41-14CD-4076-BF73-E3E975799629}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E0D8C41-14CD-4076-BF73-E3E975799629}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E0D8C41-14CD-4076-BF73-E3E975799629}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D2E12FDD-AEAF-4D7E-BDE4-2B62B8F80EB3}
EndGlobalSection
EndGlobal
81 changes: 81 additions & 0 deletions AxBraceGuideLineExtension/AxBraceGuideLineExtension.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5E0D8C41-14CD-4076-BF73-E3E975799629}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AxBraceGuideLineExtension</RootNamespace>
<AssemblyName>AxBraceGuideLineExtension</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.CoreUtility">
<HintPath>.\Microsoft.VisualStudio.CoreUtility.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Data">
<HintPath>.\Microsoft.VisualStudio.Text.Data.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Logic">
<HintPath>.\Microsoft.VisualStudio.Text.Logic.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI">
<HintPath>.\Microsoft.VisualStudio.Text.UI.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf">
<HintPath>.\Microsoft.VisualStudio.Text.UI.Wpf.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AxBraceGuideLineStructure.cs" />
<Compile Include="AxBraceGuideLineProvider.cs" />
<Compile Include="BlockBraceParser.cs" />
<Compile Include="BlockSpan.cs" />
<Compile Include="BlockSpanViewIntersecting.cs" />
<Compile Include="Extensions\IAdornmentLayerExtension.cs" />
<Compile Include="Extensions\Int32Extension.cs" />
<Compile Include="Extensions\LineExtension.cs" />
<Compile Include="Extensions\ListExtension.cs" />
<Compile Include="Extensions\StackExtension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
42 changes: 42 additions & 0 deletions AxBraceGuideLineExtension/AxBraceGuideLineProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright (C) 2023 Sergey Barkar / [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;

namespace AxBraceGuideLineExtension
{
[TagType(typeof(TextMarkerTag))]
[Export(typeof(IViewTaggerProvider))]
[ContentType("text")]
internal class AxBraceGuideLineExtensionProvider : IViewTaggerProvider
{
public ITagger<T> CreateTagger<T>(ITextView _textView, ITextBuffer _buffer) where T : ITag
{
ITagger<T> ret = null;

if (_textView?.TextBuffer == _buffer)
{
ret = new AxBraceGuideLineExtension(_textView as IWpfTextView) as ITagger<T>;
}

return ret;
}
}
}

97 changes: 97 additions & 0 deletions AxBraceGuideLineExtension/AxBraceGuideLineStructure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Copyright (C) 2023 Sergey Barkar / [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Tagging;
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Utilities;
using System.ComponentModel.Composition;

namespace AxBraceGuideLineExtension
{
public class AxBraceGuideLineExtension : ITagger<TextMarkerTag>
{
readonly IWpfTextView IView;
readonly IAdornmentLayer layer;

[Export(typeof(AdornmentLayerDefinition))]
[Name(blockStructureLayerName)]
static AdornmentLayerDefinition adornmentLayer;

int drawnViewHash = 0;

const string blockStructureLayerName = "BlockStructure";

public AxBraceGuideLineExtension(IWpfTextView _IView)
{
IView = _IView;
layer = IView.GetAdornmentLayer(blockStructureLayerName);

IView.LayoutChanged += IView_LayoutChanged;
}

private bool isDrawRequired(int _currentViewHash)
{
return drawnViewHash != _currentViewHash && IView.TextViewLines != null;
}

void IView_LayoutChanged(object sender, TextViewLayoutChangedEventArgs e)
{
int currentHash = IView.TextSnapshot.GetHashCode() ^ IView.FormattedLineSource.GetHashCode();

if (this.isDrawRequired(currentHash))
{
this.drawNormalizedSnapshotSpans(new NormalizedSnapshotSpanCollection(IView.TextViewLines.FormattedSpan));
drawnViewHash = currentHash;
}
}

private void drawNormalizedSnapshotSpans(NormalizedSnapshotSpanCollection _normalizedSnapshotSpans)
{
layer.RemoveAllAdornments();

if (_normalizedSnapshotSpans.Count.isPositive())
{
HashSet<Span> updated = new HashSet<Span>();

foreach (var snapshotSpan in _normalizedSnapshotSpans)
{
var textSnapshot = snapshotSpan.Snapshot;

foreach (var spanToDraw in BlockBraceParser.Instance.Parse(textSnapshot))
{
if (!updated.Contains(spanToDraw))
{
if (layer.drawSpan(IView, spanToDraw))
{
updated.Add(spanToDraw);
}
}
}
}
}
}

public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
public IEnumerable<ITagSpan<TextMarkerTag>> GetTags(NormalizedSnapshotSpanCollection spans)
{
yield break;
}
}
}


Loading

0 comments on commit 8dda1a9

Please sign in to comment.