Skip to content

Instantly share code, notes, and snippets.

NormalizedSnapshotSpanCollection SymmetricDifference(NormalizedSnapshotSpanCollection first, NormalizedSnapshotSpanCollection second)
{
return NormalizedSnapshotSpanCollection.Union(
NormalizedSnapshotSpanCollection.Difference(first, second),
NormalizedSnapshotSpanCollection.Difference(second, first));
}
void ReparseFile(object sender, EventArgs args)
{
ITextSnapshot snapshot = _buffer.CurrentSnapshot;
List<MarkdownSection> newSections = new List<MarkdownSection>(
MarkdownParser.ParseMarkdownSections(snapshot)
.Select(t => new MarkdownSection()
{
TokenType = t.TokenType,
Span = snapshot.CreateTrackingSpan(t.Span, SpanTrackingMode.EdgeExclusive)
void ReparseFile(object sender, EventArgs args)
{
ITextSnapshot snapshot = _buffer.CurrentSnapshot;
List<MarkdownSection> newSections = new List<MarkdownSection>(
MarkdownParser.ParseMarkdownSections(snapshot)
.Select(t => new MarkdownSection()
{
TokenType = t.TokenType,
Span = snapshot.CreateTrackingSpan(t.Span, SpanTrackingMode.EdgeExclusive)
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Utilities;
namespace MarkdownMode
{
static class ContentType
{
[Export]
[Name("markdown")]
[DisplayName("Markdown")]
// CtrlMouseWheelHandler - Handle Ctrl+mouse wheel events to scroll by pages instead of lines
using System;
using System.ComponentModel.Composition;
using System.Windows.Input;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
namespace CtrlMouseWheel
{
@NoahRic
NoahRic / MyMarkerDefinition.cs
Created October 30, 2009 06:14
A sample MarkerFormatDefinition (VS 2010 Beta 2)
[Export(typeof(EditorFormatDefinition))]
[Name("mymarker")]
internal sealed class MyMarkerDefinition : MarkerFormatDefinition
{
public MyMarkerDefinition()
{
this.ZOrder = 1;
this.Fill = Brushes.Blue;
this.Border = new Pen(Brushes.DarkGray, 0.5);
this.Fill.Freeze();
@NoahRic
NoahRic / SetGradientBrush.cs
Created October 28, 2009 06:56
Code for setting the active selection to use a gradient brush, like beta 1 (VS 2010 Beta 2).
void SetGradientBrush(IEditorFormatMap formatMap)
{
Color highlight = SystemColors.HighlightColor;
Color darkColor = Color.FromArgb(96, highlight.R, highlight.G, highlight.B);
Color lightColor = Color.FromArgb(48, highlight.R, highlight.G, highlight.B);
// Change the selected text properties to use a gradient brush and an outline pen
var properties = formatMap.GetProperties("Selected Text");
properties[EditorFormatDefinition.BackgroundBrushId] = new LinearGradientBrush(
new GradientStopCollection() { new GradientStop(darkColor, 0.0), new GradientStop(lightColor, 0.5), new GradientStop(darkColor, 1.0) }, 90.0);
// On a background thread, perform our typing work.
ThreadPool.QueueUserWorkItem((state) =>
{
Random random = new Random();
for (int i = 0; i < _textToType.Length; i++)
{
// Dispatch back to the UI thread to make the edit on the buffer
_dispatcher.Invoke(new Action(() =>
{
/* Modified version of Thomas Restrepo's KeywordClassifier.cs.
* The original can be found here:
* http://github.com/tomasr/KeywordClassifier/blob/b2472cc2bbdd823a4d8a2ff5fdbfc82c4da1423e/KeywordClassifier.cs
* This has been updated for Beta 2, and switched from using a classifier to a view-specific
* tagger, to avoid issues around self-consumption.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
/* TripleClickMouseProcessor.cs
* Copyright Noah Richards, licensed under the Ms-PL.
* Check out blogs.msdn.com/noahric for more information about the Visual Studio 2010 editor!
*/
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Input;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;