-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextViewExtensions.cs
More file actions
81 lines (73 loc) · 3.34 KB
/
Copy pathTextViewExtensions.cs
File metadata and controls
81 lines (73 loc) · 3.34 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
using System.Drawing;
using Terminal.Gui.Drawing;
using Terminal.Gui.Views;
namespace TerminalGui.Extensions.Extensions.ViewExtensions;
/// <summary>
/// Extension methods for <see cref="TextView" />.
/// </summary>
public static class TextViewExtensions
{
extension(TextView textView)
{
/// <summary>
/// Subscribes to the <see cref="TextView.ContentsChanged" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="ContentsChangedEventArgs" />.</param>
/// <returns>The <see cref="TextView" /> instance.</returns>
public TextView OnContentsChanged(Action<ContentsChangedEventArgs> callback)
{
textView.ContentsChanged += (_, e) => callback(e);
return textView;
}
/// <summary>
/// Subscribes to the <see cref="TextView.DrawNormalColor" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CellEventArgs" />.</param>
/// <returns>The <see cref="TextView" /> instance.</returns>
public TextView OnDrawNormalColor(Action<CellEventArgs> callback)
{
textView.DrawNormalColor += (_, e) => callback(e);
return textView;
}
/// <summary>
/// Subscribes to the <see cref="TextView.DrawReadOnlyColor" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CellEventArgs" />.</param>
/// <returns>The <see cref="TextView" /> instance.</returns>
public TextView OnDrawReadOnlyColor(Action<CellEventArgs> callback)
{
textView.DrawReadOnlyColor += (_, e) => callback(e);
return textView;
}
/// <summary>
/// Subscribes to the <see cref="TextView.DrawSelectionColor" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CellEventArgs" />.</param>
/// <returns>The <see cref="TextView" /> instance.</returns>
public TextView OnDrawSelectionColor(Action<CellEventArgs> callback)
{
textView.DrawSelectionColor += (_, e) => callback(e);
return textView;
}
/// <summary>
/// Subscribes to the <see cref="TextView.DrawUsedColor" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CellEventArgs" />.</param>
/// <returns>The <see cref="TextView" /> instance.</returns>
public TextView OnDrawUsedColor(Action<CellEventArgs> callback)
{
textView.DrawUsedColor += (_, e) => callback(e);
return textView;
}
/// <summary>
/// Subscribes to the <see cref="TextView.UnwrappedCursorPositionChanged" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="Point" /> representing the unwrapped cursor position.</param>
/// <returns>The <see cref="TextView" /> instance.</returns>
public TextView OnUnwrappedCursorPositionChanged(Action<Point> callback)
{
textView.UnwrappedCursorPositionChanged += (_, e) => callback(e);
return textView;
}
}
}