Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #38 from kamilskoracki/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Kraviecc authored May 27, 2019
2 parents 42b996d + a496f13 commit a94f9fb
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 66 deletions.
1 change: 1 addition & 0 deletions CocoJumper.Base/CocoJumper.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<Compile Include="EventModels\SearchEvent.cs" />
<Compile Include="EventModels\SearchResultEvent.cs" />
<Compile Include="EventModels\StartNewSearchEvent.cs" />
<Compile Include="Exception\InvalidStateException.cs" />
<Compile Include="Logic\ICocoJumperLogic.cs" />
<Compile Include="Logic\TaggerCommon.cs" />
<Compile Include="Model\LineData.cs" />
Expand Down
11 changes: 6 additions & 5 deletions CocoJumper.Base/EventModels/SearchResultEvent.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System.Collections.Generic;
using System.Linq;
using CocoJumper.Base.Events;
using System.Collections.Generic;

namespace CocoJumper.Base.Events
namespace CocoJumper.Base.EventModels
{
public class SearchResultEvent
{
public List<SearchEvent> SearchEvents;

public SearchResultEvent()
{
SearchEvents = new List<SearchEvent>();
}

public bool IsHighlightDisabled { get; set; }
public List<SearchEvent> SearchEvents { get; set; }
}
}
9 changes: 9 additions & 0 deletions CocoJumper.Base/Exception/InvalidStateException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace CocoJumper.Base.Exception
{
public class InvalidStateException : System.Exception
{
public InvalidStateException(string message) : base(message)
{
}
}
}
4 changes: 2 additions & 2 deletions CocoJumper.Base/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyVersion("1.0.3.0")]
[assembly: AssemblyFileVersion("1.0.3.0")]
3 changes: 2 additions & 1 deletion CocoJumper/CodeHighlighterTag/CodeHighlighterTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.VisualStudio.Text.Tagging;
using System;
using System.Collections.Generic;
using CocoJumper.Base.EventModels;

namespace CocoJumper.CodeHighlighterTag
{
Expand Down Expand Up @@ -50,7 +51,7 @@ private void OnSearch(SearchResultEvent e)
{
if (!_textView.HasAggregateFocus || _textView.IsClosed)
return;
_searchEvents = e.SearchEvents;
_searchEvents = e.IsHighlightDisabled ? null : e.SearchEvents;
this.InvokeTagsChanged(TagsChanged, _buffer);
}
}
Expand Down
27 changes: 27 additions & 0 deletions CocoJumper/Commands/CocoJumperCommandPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,32 @@ public int AutomaticallyExitInterval
return page.AutomaticallyExitInterval;
}
}

public bool DisableHighlightForMultiSearch
{
get
{
CocoJumperOptions page = (CocoJumperOptions)GetDialogPage(typeof(CocoJumperOptions));
return page.DisableHighlightForMultiSearch;
}
}

public bool DisableHighlightForSingleHighlight
{
get
{
CocoJumperOptions page = (CocoJumperOptions)GetDialogPage(typeof(CocoJumperOptions));
return page.DisableHighlightForSingleHighlight;
}
}

public bool DisableHighlightForSingleSearch
{
get
{
CocoJumperOptions page = (CocoJumperOptions)GetDialogPage(typeof(CocoJumperOptions));
return page.DisableHighlightForSingleSearch;
}
}
}
}
12 changes: 5 additions & 7 deletions CocoJumper/Commands/CocoJumperMultiSearchCommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using CocoJumper.Base.Enum;
using CocoJumper.Base.Events;
using CocoJumper.Base.Logic;
using CocoJumper.Events;
using CocoJumper.Extensions;
using CocoJumper.Listeners;
using CocoJumper.Logic;
Expand All @@ -12,8 +14,6 @@
using Microsoft.VisualStudio.TextManager.Interop;
using System;
using System.ComponentModel.Design;
using CocoJumper.Base.Events;
using CocoJumper.Events;
using Task = System.Threading.Tasks.Task;

namespace CocoJumper.Commands
Expand Down Expand Up @@ -47,6 +47,7 @@ public static CocoJumperMultiSearchCommand Instance
get;
private set;
}

private IAsyncServiceProvider ServiceProvider => _package;

public static async Task InitializeAsync(AsyncPackage package)
Expand Down Expand Up @@ -79,11 +80,7 @@ private void Execute(object sender, EventArgs e)

CleanupLogicAndInputListener();
WpfViewProvider renderer = new WpfViewProvider(wpfTextView);
_logic = new CocoJumperLogic(renderer,
cocoJumperCommandPackage.LimitResults,
cocoJumperCommandPackage.TimerInterval,
cocoJumperCommandPackage.AutomaticallyExitInterval,
cocoJumperCommandPackage.JumpAfterChoosedElement);
_logic = new CocoJumperLogic(renderer, cocoJumperCommandPackage);

_inputListener = new InputListener(textView);
_inputListener.KeyPressEvent += OnKeyboardAction;
Expand All @@ -94,6 +91,7 @@ private void OnExit(ExitEvent e)
{
CleanupLogicAndInputListener();
}

private void OnKeyboardAction(object oSender, char? key, KeyEventType eventType)
{
_logic = _logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperMultiSearchCommand)}, {nameof(_logic)} is null");
Expand Down
51 changes: 32 additions & 19 deletions CocoJumper/Commands/CocoJumperOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,50 @@ namespace CocoJumper.Commands
public class CocoJumperOptions : DialogPage
{
private const string GeneralCategory = "General";
private int _timerInterval = 250;
private int _limitResults = 50;
private int _automaticallyExitInterval = 5000;
private bool _jumpAfterChoosedElement = false;

[Category(GeneralCategory)]
[DisplayName("Limit results")]
[Description("Limts results that are rendered on one page.")]
[DefaultValue(50)]
public int LimitResults { get => _limitResults; set => _limitResults = value; }

[Category(GeneralCategory)]
[DisplayName("Timer interval(ms)")]
[Description("Determines how much ms must pass before rendering components, counting from last key press.")]
[DefaultValue(250)]
public int TimerInterval { get => _timerInterval; set => _timerInterval = value; }
public event EventHandler Saved;

[Category(GeneralCategory)]
[DisplayName("Automatically exit after(ms)")]
[Description("Determines how much ms must pass before logic will automaticly exit.")]
[DefaultValue(5000)]
public int AutomaticallyExitInterval { get => _automaticallyExitInterval; set => _automaticallyExitInterval = value; }
public int AutomaticallyExitInterval { get; set; } = 5000;

[Category(GeneralCategory)]
[DisplayName("Disable highlight for multisearch")]
[Description("If set to True, logic will not render any highlighting components with may slowdown VisualStudio.")]
[DefaultValue(false)]
public bool DisableHighlightForMultiSearch { get; set; } = false;

[Category(GeneralCategory)]
[DisplayName("Disable highlight for single search with select")]
[Description("If set to True, logic will not render any highlighting components with may slowdown VisualStudio.")]
[DefaultValue(false)]
public bool DisableHighlightForSingleHighlight { get; set; } = false;

[Category(GeneralCategory)]
[DisplayName("Disable highlight for single search")]
[Description("If set to True, logic will not render any highlighting components with may slowdown VisualStudio.")]
[DefaultValue(false)]
public bool DisableHighlightForSingleSearch { get; set; } = false;

[Category(GeneralCategory)]
[DisplayName("Jump after choosed element")]
[Description("If set to True, logic will move caret to the end of choosed element.")]
[DefaultValue(false)]
public bool JumpAfterChoosedElement { get => _jumpAfterChoosedElement; set => _jumpAfterChoosedElement = value; }
public bool JumpAfterChoosedElement { get; set; } = false;

[Category(GeneralCategory)]
[DisplayName("Limit results")]
[Description("Limts results that are rendered on one page.")]
[DefaultValue(50)]
public int LimitResults { get; set; } = 50;

[Category(GeneralCategory)]
[DisplayName("Timer interval(ms)")]
[Description("Determines how much ms must pass before rendering components, counting from last key press.")]
[DefaultValue(250)]
public int TimerInterval { get; set; } = 250;

public override void SaveSettingsToStorage()
{
Expand All @@ -49,7 +64,5 @@ public override void SaveSettingsToStorage()

Saved?.Invoke(this, EventArgs.Empty);
}

public event EventHandler Saved;
}
}
7 changes: 2 additions & 5 deletions CocoJumper/Commands/CocoJumperSingleSearchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ private void Execute(object sender, EventArgs e)
CleanupLogicAndInputListener();
WpfViewProvider renderer = new WpfViewProvider(wpfTextView);

_logic = new CocoJumperLogic(renderer,
cocoJumperCommandPackage.LimitResults,
cocoJumperCommandPackage.TimerInterval,
cocoJumperCommandPackage.AutomaticallyExitInterval,
cocoJumperCommandPackage.JumpAfterChoosedElement);
_logic = new CocoJumperLogic(renderer, cocoJumperCommandPackage);
_inputListener = new InputListener(textView);
_inputListener.KeyPressEvent += OnKeyboardAction;
_logic.ActivateSearching(true, false);
Expand All @@ -102,6 +98,7 @@ private void OnExit(ExitEvent e)
{
CleanupLogicAndInputListener();
}

private void OnKeyboardAction(object oSender, char? key, KeyEventType eventType)
{
_logic = _logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperMultiSearchCommand)}, {nameof(_logic)} is null");
Expand Down
15 changes: 3 additions & 12 deletions CocoJumper/Commands/CocoJumperSingleSearchHighlightCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ public static CocoJumperSingleSearchHighlightCommand Instance
private set;
}

private IAsyncServiceProvider ServiceProvider
{
get
{
return _package;
}
}
private IAsyncServiceProvider ServiceProvider => _package;

public static async Task InitializeAsync(AsyncPackage package)
{
Expand Down Expand Up @@ -87,11 +81,7 @@ private void Execute(object sender, EventArgs e)
CleanupLogicAndInputListener();
WpfViewProvider renderer = new WpfViewProvider(wpfTextView);

_logic = new CocoJumperLogic(renderer,
cocoJumperCommandPackage.LimitResults,
cocoJumperCommandPackage.TimerInterval,
cocoJumperCommandPackage.AutomaticallyExitInterval,
cocoJumperCommandPackage.JumpAfterChoosedElement);
_logic = new CocoJumperLogic(renderer, cocoJumperCommandPackage);
_inputListener = new InputListener(textView);
_inputListener.KeyPressEvent += OnKeyboardAction;
_logic.ActivateSearching(true, true);
Expand All @@ -101,6 +91,7 @@ private void OnExit(ExitEvent e)
{
CleanupLogicAndInputListener();
}

private void OnKeyboardAction(object oSender, char? key, KeyEventType eventType)
{
_logic = _logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperMultiSearchCommand)}, {nameof(_logic)} is null");
Expand Down
Loading

0 comments on commit a94f9fb

Please sign in to comment.