Skip to content

Commit a43e230

Browse files
authored
Merge pull request #5 from mcneel/sbaer/textchanged_event
Sbaer/textchanged event
2 parents 1759ed1 + 13eaf03 commit a43e230

File tree

7 files changed

+103
-65
lines changed

7 files changed

+103
-65
lines changed

src/Eto.CodeEditor.Wpf/CodeEditorHandler.cs

+12
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ public int LineNumberColumnWidth
139139
}
140140
}
141141

142+
public event EventHandler TextChanged
143+
{
144+
add
145+
{
146+
WinFormsControl.TextChanged += value;
147+
}
148+
remove
149+
{
150+
WinFormsControl.TextChanged -= value;
151+
}
152+
}
153+
142154
void SetupTheme()
143155
{
144156
// just style things enough that you can tell you're working in a code editor

src/Eto.CodeEditor.XamMac/CodeEditorHandler.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ public void SetColor(Section section, Eto.Drawing.Color foreground, Eto.Drawing.
158158
}
159159
}
160160

161-
161+
public event EventHandler TextChanged
162+
{
163+
add { }
164+
remove { }
165+
}
162166
}
163167
}

src/Eto.CodeEditor/CodeEditor.cs

+14
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ public void SetColor(Section section, Eto.Drawing.Color foreground, Eto.Drawing.
7575
Handler.SetColor(section, foreground, background);
7676
}
7777

78+
public event EventHandler TextChanged
79+
{
80+
add
81+
{
82+
Handler.TextChanged += value;
83+
}
84+
remove
85+
{
86+
Handler.TextChanged -= value;
87+
}
88+
}
89+
7890
public new interface IHandler : Control.IHandler
7991
{
8092
string Text { get; set; }
@@ -83,6 +95,8 @@ public void SetColor(Section section, Eto.Drawing.Color foreground, Eto.Drawing.
8395
int FontSize { get; set; }
8496
int LineNumberColumnWidth { get; set; }
8597
void SetColor(Section section, Eto.Drawing.Color foreground, Eto.Drawing.Color background);
98+
99+
event EventHandler TextChanged;
86100
}
87101
}
88102

src/Eto.Toolkit.sln

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Global
4848
{835EF387-1702-49FF-B1B1-41C3D0CDF8B9}.Release|Windows.ActiveCfg = Release|Any CPU
4949
{835EF387-1702-49FF-B1B1-41C3D0CDF8B9}.Release|Windows.Build.0 = Release|Any CPU
5050
{2BF83FDA-9BFF-4A1E-8C58-1EAC435DEED6}.Debug|Mac.ActiveCfg = Debug|Any CPU
51-
{2BF83FDA-9BFF-4A1E-8C58-1EAC435DEED6}.Debug|Mac.Build.0 = Debug|Any CPU
5251
{2BF83FDA-9BFF-4A1E-8C58-1EAC435DEED6}.Debug|Windows.ActiveCfg = Debug|Any CPU
5352
{2BF83FDA-9BFF-4A1E-8C58-1EAC435DEED6}.Debug|Windows.Build.0 = Debug|Any CPU
5453
{2BF83FDA-9BFF-4A1E-8C58-1EAC435DEED6}.Release|Mac.ActiveCfg = Release|Any CPU

src/Scintilla.XamMac2/ApiDefinition.cs

+57-51
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,76 @@
55
using ObjCRuntime;
66
//using Scintilla;
77

8-
namespace ScintillaNET
8+
// @protocol ScintillaNotificationProtocol
9+
[Protocol, Model]
10+
interface ScintillaNotificationProtocol
911
{
12+
// @required -(void)notification:(SCNotification *)notification;
13+
[Abstract]
14+
[Export("notification:")]
15+
void Notification(IntPtr notification);
16+
}
17+
18+
// @interface ScintillaView : NSView <InfoBarCommunicator, ScintillaNotificationProtocol>
19+
[BaseType(typeof(NSView))]
20+
interface ScintillaView
21+
{
22+
// @property (assign, nonatomic) id<ScintillaNotificationProtocol> delegate;
23+
[NullAllowed, Export("delegate", ArgumentSemantic.Assign)]
24+
NSObject WeakDelegate { get; set; }
1025

11-
// @interface ScintillaView : NSView <InfoBarCommunicator, ScintillaNotificationProtocol>
12-
[BaseType(typeof(NSView))]
13-
interface ScintillaView
14-
{
15-
// @property (assign, nonatomic) id<ScintillaNotificationProtocol> delegate;
16-
[NullAllowed, Export("delegate", ArgumentSemantic.Assign)]
17-
NSObject WeakDelegate { get; set; }
18-
19-
// @property (readonly, nonatomic) NSScrollView * scrollView;
20-
[Export("scrollView")]
21-
NSScrollView ScrollView { get; }
26+
// @property (readonly, nonatomic) NSScrollView * scrollView;
27+
[Export("scrollView")]
28+
NSScrollView ScrollView { get; }
2229

23-
// -(NSString *)string;
24-
// -(void)setString:(NSString *)aString;
25-
[Export("string")]
26-
string Text { get; set; }
30+
// -(NSString *)string;
31+
// -(void)setString:(NSString *)aString;
32+
[Export("string")]
33+
string Text { get; set; }
2734

2835

29-
// -(void)setGeneralProperty:(int)property parameter:(long)parameter value:(long)value;
30-
[Export("setGeneralProperty:parameter:value:")]
31-
void SetGeneralProperty(int property, nint parameter, nint value);
36+
// -(void)setGeneralProperty:(int)property parameter:(long)parameter value:(long)value;
37+
[Export("setGeneralProperty:parameter:value:")]
38+
void SetGeneralProperty(int property, nint parameter, nint value);
3239

33-
// -(void)setGeneralProperty:(int)property value:(long)value;
34-
[Export("setGeneralProperty:value:")]
35-
void SetGeneralProperty(int property, nint value);
40+
// -(void)setGeneralProperty:(int)property value:(long)value;
41+
[Export("setGeneralProperty:value:")]
42+
void SetGeneralProperty(int property, nint value);
3643

37-
// -(long)getGeneralProperty:(int)property;
38-
[Export("getGeneralProperty:")]
39-
nint GetGeneralProperty(int property);
44+
// -(long)getGeneralProperty:(int)property;
45+
[Export("getGeneralProperty:")]
46+
nint GetGeneralProperty(int property);
4047

41-
// -(long)getGeneralProperty:(int)property parameter:(long)parameter;
42-
[Export("getGeneralProperty:parameter:")]
43-
nint GetGeneralProperty(int property, nint parameter);
48+
// -(long)getGeneralProperty:(int)property parameter:(long)parameter;
49+
[Export("getGeneralProperty:parameter:")]
50+
nint GetGeneralProperty(int property, nint parameter);
4451

45-
// -(long)getGeneralProperty:(int)property parameter:(long)parameter extra:(long)extra;
46-
[Export("getGeneralProperty:parameter:extra:")]
47-
nint GetGeneralProperty(int property, nint parameter, nint extra);
52+
// -(long)getGeneralProperty:(int)property parameter:(long)parameter extra:(long)extra;
53+
[Export("getGeneralProperty:parameter:extra:")]
54+
nint GetGeneralProperty(int property, nint parameter, nint extra);
4855

49-
// -(void)setColorProperty:(int)property parameter:(long)parameter value:(NSColor *)value;
50-
[Export("setColorProperty:parameter:value:")]
51-
void SetColorProperty(int property, nint parameter, NSColor value);
56+
// -(void)setColorProperty:(int)property parameter:(long)parameter value:(NSColor *)value;
57+
[Export("setColorProperty:parameter:value:")]
58+
void SetColorProperty(int property, nint parameter, NSColor value);
5259

53-
// -(void)setColorProperty:(int)property parameter:(long)parameter fromHTML:(NSString *)fromHTML;
54-
[Export("setColorProperty:parameter:fromHTML:")]
55-
void SetColorProperty(int property, nint parameter, string fromHTML);
60+
// -(void)setColorProperty:(int)property parameter:(long)parameter fromHTML:(NSString *)fromHTML;
61+
[Export("setColorProperty:parameter:fromHTML:")]
62+
void SetColorProperty(int property, nint parameter, string fromHTML);
5663

57-
// -(NSColor *)getColorProperty:(int)property parameter:(long)parameter;
58-
[Export("getColorProperty:parameter:")]
59-
NSColor GetColorProperty(int property, nint parameter);
64+
// -(NSColor *)getColorProperty:(int)property parameter:(long)parameter;
65+
[Export("getColorProperty:parameter:")]
66+
NSColor GetColorProperty(int property, nint parameter);
6067

61-
// -(void)setReferenceProperty:(int)property parameter:(long)parameter value:(const void *)value;
62-
[Export("setReferenceProperty:parameter:value:")]
63-
void SetReferenceProperty(int property, nint parameter, IntPtr value);
68+
// -(void)setReferenceProperty:(int)property parameter:(long)parameter value:(const void *)value;
69+
[Export("setReferenceProperty:parameter:value:")]
70+
void SetReferenceProperty(int property, nint parameter, IntPtr value);
6471

65-
// -(void)setStringProperty:(int)property parameter:(long)parameter value:(NSString *)value;
66-
[Export("setStringProperty:parameter:value:")]
67-
void SetStringProperty(int property, nint parameter, string value);
72+
// -(void)setStringProperty:(int)property parameter:(long)parameter value:(NSString *)value;
73+
[Export("setStringProperty:parameter:value:")]
74+
void SetStringProperty(int property, nint parameter, string value);
6875

69-
// -(NSString *)getStringProperty:(int)property parameter:(long)parameter;
70-
[Export("getStringProperty:parameter:")]
71-
string GetStringProperty(int property, nint parameter);
72-
}
76+
// -(NSString *)getStringProperty:(int)property parameter:(long)parameter;
77+
[Export("getStringProperty:parameter:")]
78+
string GetStringProperty(int property, nint parameter);
79+
}
7380

74-
}

src/Scintilla.XamMac2/ScintillaView.cs

+9-12
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22
using System.Runtime.InteropServices;
33
using System.Text;
44

5-
namespace ScintillaNET
5+
public partial class ScintillaView
66
{
7-
public partial class ScintillaView
8-
{
97
public void SetKeywords(int set, string keywords)
108
{
11-
var bytes = ASCIIEncoding.ASCII.GetBytes(keywords.ToCharArray());
12-
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
9+
var bytes = ASCIIEncoding.ASCII.GetBytes(keywords.ToCharArray());
10+
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
1311

14-
// retrieve a raw pointer to pass to the native code:
15-
IntPtr ptr = handle.AddrOfPinnedObject();
12+
// retrieve a raw pointer to pass to the native code:
13+
IntPtr ptr = handle.AddrOfPinnedObject();
1614

17-
SetReferenceProperty(ScintillaNET.NativeMethods.SCI_SETKEYWORDS, set, ptr);
18-
// later, possibly in some other method:
19-
handle.Free();
15+
SetReferenceProperty(ScintillaNET.NativeMethods.SCI_SETKEYWORDS, set, ptr);
16+
// later, possibly in some other method:
17+
handle.Free();
2018
}
21-
}
22-
}
19+
}

test/Eto.CodeEditor.TestApp/MainForm.cs

+6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ public MainForm()
2121
print(i);
2222
}"
2323
};
24+
editor.TextInput += Editor_TextInput;
2425

2526
Content = editor;
2627
}
28+
29+
private void Editor_TextInput(object sender, TextInputEventArgs e)
30+
{
31+
int i = 0;
32+
}
2733
}
2834
}

0 commit comments

Comments
 (0)