-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtasklist.csx
93 lines (82 loc) · 2.17 KB
/
tasklist.csx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#load "util.csx"
#load "WindowUtil.csx"
using EnvDTE;
using Microsoft.VisualStudio.Text;
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Reflection;
using Vim;
using Vim.Extensions;
const string vsWindowKindTaskList = "{4A9B7E51-AA16-11D0-A8C5-00A0C921A4D2}";
var DTE = Util.GetDTE2();
Window taskListWindow = DTE.Windows.Item(vsWindowKindTaskList);
bool autoHides = true;
VimBuffer.KeyInputStart += OnKeyInputStart;
VimBuffer.Closed += OnBufferClosed;
autoHides = taskListWindow.AutoHides;
taskListWindow.AutoHides = false;
taskListWindow.Activate();
if (0 < taskListWindow.GetItemsCount())
{
int index = taskListWindow.GetSelectedIndex();
index = Math.Max(index, 0);
taskListWindow.SetSelectedIndex(index);
}
DTE.ActiveDocument.Activate();
public void OnKeyInputStart(object sender, KeyInputStartEventArgs e)
{
e.Handled = true;
int index;
if (e.KeyInput.Char == 'j')
{
int count = taskListWindow.GetItemsCount();
if (0 < count)
{
index = taskListWindow.GetSelectedIndex();
if (index < count)
{
index++;
taskListWindow.SetSelectedIndex(index);
}
}
}
else if (e.KeyInput.Char == 'k')
{
if (0 < taskListWindow.GetItemsCount())
{
index = taskListWindow.GetSelectedIndex();
if (0 < index)
{
index--;
taskListWindow.SetSelectedIndex(index);
}
}
}
else if (e.KeyInput.Key == VimKey.Enter)
{
EndIntercept();
//taskListWindow.Activate();
taskListWindow.NavigateToSelectedEntry();
}
else if (e.KeyInput.Key == VimKey.Escape)
{
EndIntercept();
}
//messageAction?.Invoke();
}
public void OnBufferClosed(object sender, EventArgs e)
{
EndIntercept();
}
public void EndIntercept()
{
VimBuffer.KeyInputStart -= OnKeyInputStart;
VimBuffer.Closed -= OnBufferClosed;
//messageAction = null;
VimBuffer.DisplayStatus(string.Empty);
taskListWindow.AutoHides = autoHides;
}