Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

Commit 9931c91

Browse files
Merge pull request #5 from Microsoft/dev/venkatesh/VSOperations
VSoperations inheriting from IEnvironmentOperations
2 parents 22457e7 + f02839f commit 9931c91

7 files changed

Lines changed: 107 additions & 14 deletions

File tree

src/VisualStudio/CodeTalk/CodeTalk.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<WarningLevel>4</WarningLevel>
6969
</PropertyGroup>
7070
<ItemGroup>
71+
<Compile Include="IEnvironmentOperations.cs" />
7172
<Compile Include="Properties\Resources.Designer.cs">
7273
<AutoGen>True</AutoGen>
7374
<DesignTime>True</DesignTime>

src/VisualStudio/CodeTalk/Commands/Commands.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public override void Execute()
119119
{
120120
int currentLineNumber = 0;
121121

122-
currentLineNumber = TalkCodePackage.vsOperations.GetCursorLineNumber();
122+
currentLineNumber = TalkCodePackage.vsOperations.GetCurrentCursorPosition().lineNumber;
123123
contextHierarchy = codeFile.GetContextAtLine(currentLineNumber) as IList<ISyntaxEntity>;
124124

125125
if (0 == contextHierarchy.Count)
@@ -276,7 +276,7 @@ public override void Execute()
276276
{
277277
rm = new ResourceManager(typeof(Resources));
278278

279-
if (TalkCodePackage.vsOperations.RemoveBreakpointIfExists()) { return; }
279+
if (TalkCodePackage.vsOperations.RemoveBreakpointInCurrentPosition()) { return; }
280280

281281
ToolWindowPane talkpointWindow = TalkCodePackage.currentPackage.FindToolWindow(typeof(TalkpointToolWindow), 0, true);
282282

src/VisualStudio/CodeTalk/Commands/MoveToContextCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override void Execute()
5757
int currentLineNumber = 0;
5858
int destinationLineNumber = 0;
5959

60-
currentLineNumber = TalkCodePackage.vsOperations.GetCursorLineNumber();
60+
currentLineNumber = TalkCodePackage.vsOperations.GetCurrentCursorPosition().lineNumber;
6161
contextHierarchy = codeFile.GetContextAtLine(currentLineNumber) as IList<ISyntaxEntity>;
6262

6363
if (0 == contextHierarchy.Count)

src/VisualStudio/CodeTalk/Commands/SkipCommentCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override void Execute()
5454
MessageBox.Show(rm.GetString("CompilationErrorString", CultureInfo.CurrentCulture), rm.GetString("CodeTalkText", CultureInfo.CurrentCulture), MessageBoxButtons.OK, MessageBoxIcon.Error);
5555
return;
5656
}
57-
lineNumber = TalkCodePackage.vsOperations.GetCursorLineNumber();
57+
lineNumber = TalkCodePackage.vsOperations.GetCurrentCursorPosition().lineNumber;
5858
commentAtLine = codeFile.GetCommentAtLine(lineNumber);
5959
if (commentAtLine != null)
6060
{
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using static Microsoft.CodeTalk.Constants;
7+
8+
namespace Microsoft.CodeTalk
9+
{
10+
public interface IEnvironmentOperations
11+
{
12+
/// <summary>
13+
/// Method to Evaluate Expression in Debugging context
14+
/// </summary>
15+
/// <param name="expression"></param>
16+
/// <returns></returns>
17+
string RunExpressionInDebugger(string expression);
18+
19+
/// <summary>
20+
/// Method to add a tone Talkpoint with existing tones
21+
/// </summary>
22+
/// <param name="tone"></param>
23+
/// <param name="doesContinue"></param>
24+
void AddTonalTalkPointToCurrentLine(Tones tone, bool doesContinue);
25+
26+
/// <summary>
27+
/// Method to add tone Talkpoint with Custom tones
28+
/// </summary>
29+
/// <param name="customTone"></param>
30+
/// <param name="doesContinue"></param>
31+
void AddTonalTalkPointToCurrentLine(CustomTone customTone, bool doesContinue);
32+
33+
/// <summary>
34+
/// Method to add text Talkpoint
35+
/// </summary>
36+
/// <param name="statement"></param>
37+
/// <param name="doesContinue"></param>
38+
void AddTextualTalkpointToCurrentLine(string statement, bool doesContinue);
39+
40+
/// <summary>
41+
/// Method to add expression Talkpoint
42+
/// </summary>
43+
/// <param name="expression"></param>
44+
/// <param name="doesContinue"></param>
45+
void AddExpressionTalkpointToCurrentLine(string expression, bool doesContinue);
46+
47+
/// <summary>
48+
/// Method to remove exixting breakpoints in current line
49+
/// </summary>
50+
/// <returns></returns>
51+
bool RemoveBreakpointInCurrentPosition();
52+
53+
/// <summary>
54+
/// Method to get the file path of the active document
55+
/// </summary>
56+
/// <returns></returns>
57+
string GetActiveDocumentPath();
58+
59+
/// <summary>
60+
/// Method to get the code text of the actuve document
61+
/// </summary>
62+
/// <returns></returns>
63+
string GetActiveDocumentCode();
64+
65+
/// <summary>
66+
/// Method to go to the given location in the active document
67+
/// </summary>
68+
/// <param name="lineNumber"></param>
69+
/// <param name="columnNumber"></param>
70+
void GoToLocationInActiveDocument(int lineNumber, int columnNumber);
71+
72+
/// <summary>
73+
/// Method to get the current cursor position
74+
/// </summary>
75+
/// <returns></returns>
76+
CursorPos GetCurrentCursorPosition();
77+
78+
/// <summary>
79+
/// Method to check if active document is in focus
80+
/// </summary>
81+
/// <returns></returns>
82+
bool IsActiveDocumentFocussed();
83+
84+
/// <summary>
85+
/// Method to play error tone if there is an error.
86+
/// </summary>
87+
void PlaySoundIfError();
88+
89+
}
90+
}

src/VisualStudio/CodeTalk/TalkCodePackage.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@ protected override void Initialize()
174174
currentPackage = this;
175175
vsOperations = new VSOperations();
176176

177-
//Setting Handlers
178-
vsOperations.SetBreakModeHandler();
179-
vsOperations.SetExceptionHandler();
180-
//VS Document focussed changed event
181-
vsOperations.OnDocumentFocusChanged();
182-
183177
TextToSpeech.IsTextToSpeechEnabled = true;
184178
AboutCommand.Initialize(this);
185179
CodeTalkOptionsCommand.Initialize(this);

src/VisualStudio/CodeTalk/VSOperations.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
namespace Microsoft.CodeTalk
2828
{
29-
public class VSOperations : IDisposable
29+
public class VSOperations : IEnvironmentOperations, IDisposable
3030
{
3131
DTE dte;
3232
IVsTextManager textManager;
@@ -50,7 +50,13 @@ public VSOperations()
5050
textManager = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));
5151
debugEvents = dte.Events.DebuggerEvents;
5252
mTalkPoints = new List<Talkpoint>();
53-
}
53+
54+
//Setting Handlers
55+
SetBreakModeHandler();
56+
SetExceptionHandler();
57+
//VS Document focussed changed event
58+
OnDocumentFocusChanged();
59+
}
5460

5561
public void SetBreakModeHandler()
5662
{
@@ -226,7 +232,7 @@ public void AddExpressionTalkpointToCurrentLine(string expression, bool doesCont
226232
}
227233
}
228234

229-
public bool RemoveBreakpointIfExists()
235+
public bool RemoveBreakpointInCurrentPosition()
230236
{
231237
var cursorPos = GetCurrentCursorPosition();
232238
var filePath = GetActiveDocumentPath();
@@ -311,19 +317,21 @@ public string GetDocumentCode(Document document)
311317
return codeText;
312318
}
313319

314-
public void GoToLocationInActiveDocument(int lineNumber)
320+
public void GoToLocationInActiveDocument(int lineNumber, int columnNumber = 0)
315321
{
316322
if (null == dte.ActiveDocument) { return; }
317323
TextDocument activeDocument = dte.ActiveDocument.Object() as TextDocument;
318324
dte.ActiveDocument.Activate();
319325
activeDocument.Selection.GotoLine(lineNumber);
320326
}
327+
321328
public bool IsActiveDocumentPresent()
322329
{
323330
if (null == dte) { return false; }
324331
if (null == dte.ActiveDocument) { return false; }
325332
return true;
326333
}
334+
327335
public int GetCursorLineNumber()
328336
{
329337
return GetCurrentCursorPosition().lineNumber;

0 commit comments

Comments
 (0)