forked from fdorg/flashdevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarkerManager.cs
More file actions
98 lines (91 loc) · 3.06 KB
/
Copy pathMarkerManager.cs
File metadata and controls
98 lines (91 loc) · 3.06 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
using System;
using System.Text;
using ScintillaNet;
using PluginCore.Managers;
using PluginCore.Controls;
using PluginCore;
namespace FlashDevelop.Managers
{
class MarkerManager
{
/// <summary>
/// Mask value for all availables markers
/// </summary>
public static Int32 MARKERS = 1 << 0;
/// <summary>
/// Gets the mask of the marker
/// </summary>
public static Int32 GetMarkerMask(Int32 marker)
{
return 1 << marker;
}
/// <summary>
/// Adds or removes a marker
/// </summary>
public static void ToggleMarker(ScintillaControl sci, Int32 marker, Int32 line)
{
Int32 lineMask = sci.MarkerGet(line);
if ((lineMask & GetMarkerMask(marker)) == 0) sci.MarkerAdd(line, marker);
else sci.MarkerDelete(line, marker);
UITools.Manager.MarkerChanged(sci, line);
}
/// <summary>
/// Moves the cursor to the next marker
/// </summary>
public static void NextMarker(ScintillaControl sci, Int32 marker, Int32 line)
{
Int32 next = 0;
Int32 lineMask = sci.MarkerGet(line);
if ((lineMask & GetMarkerMask(marker)) != 0)
{
next = sci.MarkerNext(line + 1, GetMarkerMask(marker));
if (next != -1) sci.GotoLine(next);
else
{
next = sci.MarkerNext(0, GetMarkerMask(marker));
if (next != -1) sci.GotoLine(next);
}
}
else
{
next = sci.MarkerNext(line, GetMarkerMask(marker));
if (next != -1) sci.GotoLine(next);
else
{
next = sci.MarkerNext(0, GetMarkerMask(marker));
if (next != -1) sci.GotoLine(next);
}
}
}
/// <summary>
/// Moves the cursor to the previous marker
/// </summary>
public static void PreviousMarker(ScintillaControl sci, Int32 marker, Int32 line)
{
Int32 prev = 0; Int32 count = 0;
Int32 lineMask = sci.MarkerGet(line);
if ((lineMask & GetMarkerMask(marker)) != 0)
{
prev = sci.MarkerPrevious(line - 1, GetMarkerMask(marker));
if (prev != -1) sci.GotoLine(prev);
else
{
count = sci.LineCount;
prev = sci.MarkerPrevious(count, GetMarkerMask(marker));
if (prev != -1) sci.GotoLine(prev);
}
}
else
{
prev = sci.MarkerPrevious(line, GetMarkerMask(marker));
if (prev != -1) sci.GotoLine(prev);
else
{
count = sci.LineCount;
prev = sci.MarkerPrevious(count, GetMarkerMask(marker));
if (prev != -1) sci.GotoLine(prev);
}
}
}
}
}