forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTabbingManager.cs
More file actions
99 lines (91 loc) · 3.13 KB
/
TabbingManager.cs
File metadata and controls
99 lines (91 loc) · 3.13 KB
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
94
95
96
97
98
99
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using FlashDevelop.Docking;
using PluginCore;
namespace FlashDevelop.Managers
{
class TabbingManager
{
public static Timer TabTimer;
public static List<ITabbedDocument> TabHistory;
public static Int32 SequentialIndex;
static TabbingManager()
{
TabTimer = new Timer();
TabTimer.Interval = 100;
TabTimer.Tick += new EventHandler(OnTabTimer);
TabHistory = new List<ITabbedDocument>();
SequentialIndex = 0;
}
/// <summary>
/// Checks to see if the Control key has been released
/// </summary>
private static void OnTabTimer(Object sender, System.EventArgs e)
{
if ((Control.ModifierKeys & Keys.Control) == 0)
{
TabTimer.Enabled = false;
TabHistory.Remove(Globals.MainForm.CurrentDocument);
TabHistory.Insert(0, Globals.MainForm.CurrentDocument);
}
}
/// <summary>
/// Sets an index of the current document
/// </summary>
public static void UpdateSequentialIndex(ITabbedDocument document)
{
Int32 count = Globals.MainForm.Documents.Length;
for (Int32 i = 0; i < count; i++)
{
if (document == Globals.MainForm.Documents[i])
{
SequentialIndex = i;
return;
}
}
}
/// <summary>
/// Activates next document in tabs
/// </summary>
public static void NavigateTabsSequentially(Int32 direction)
{
ITabbedDocument current = Globals.CurrentDocument;
ITabbedDocument[] documents = Globals.MainForm.Documents;
Int32 count = documents.Length; if (count <= 1) return;
for (Int32 i = 0; i < count; i++)
{
if (documents[i] == current)
{
if (direction > 0)
{
if (i < count - 1) documents[i + 1].Activate();
else documents[0].Activate();
}
else if (direction < 0)
{
if (i > 0) documents[i - 1].Activate();
else documents[count - 1].Activate();
}
}
}
}
/// <summary>
/// Visual Studio style keyboard tab navigation: similar to Alt-Tab
/// </summary>
public static void NavigateTabHistory(Int32 direction)
{
Int32 currentIndex = 0;
if (TabHistory.Count < 1) return;
if (direction != 0)
{
currentIndex = TabHistory.IndexOf(Globals.MainForm.CurrentDocument);
currentIndex = (currentIndex + direction) % TabHistory.Count;
if (currentIndex == -1) currentIndex = TabHistory.Count - 1;
}
TabHistory[currentIndex].Activate();
}
}
}