@@ -64,31 +64,12 @@ public static int SelectionStart
64
64
{
65
65
get
66
66
{
67
- int curPos = ( int ) Win32 . SendMessage ( PluginBase . GetCurrentScintilla ( ) , SciMsg . SCI_GETSELECTIONSTART , 0 , 0 ) ;
68
- IScintillaGateway scintilla = new ScintillaGateway ( PluginBase . GetCurrentScintilla ( ) ) ;
69
- string beginingText = scintilla . GetText ( curPos ) ;
70
- string text = BEncoding . GetScintillaTextFromUtf8Text ( beginingText , out int length ) ;
71
- return length ;
67
+ return new ScintillaGateway ( PluginBase . GetCurrentScintilla ( ) ) . GetSelectionStart ( ) ;
72
68
}
73
69
74
70
set
75
71
{
76
- string allText = Text ;
77
- int startToUse = value ;
78
-
79
- if ( value < 0 )
80
- {
81
- startToUse = 0 ;
82
- }
83
- else if ( value > allText . Length )
84
- {
85
- startToUse = allText . Length ;
86
- }
87
-
88
- string beforeText = allText . Substring ( 0 , startToUse ) ;
89
- string beforeTextInDefaultEncoding = BEncoding . GetScintillaTextFromUtf8Text ( beforeText , out int defaultStart ) ;
90
-
91
- Win32 . SendMessage ( PluginBase . GetCurrentScintilla ( ) , SciMsg . SCI_SETSELECTIONSTART , defaultStart , 0 ) ;
72
+ new ScintillaGateway ( PluginBase . GetCurrentScintilla ( ) ) . SetSelectionStart ( new Position ( value ) ) ;
92
73
}
93
74
}
94
75
@@ -155,8 +136,9 @@ public static string SelectedText
155
136
{
156
137
get
157
138
{
158
- int start = SelectionStart ;
159
- int end = SelectionEnd ;
139
+ IScintillaGateway scintillaGateway = new ScintillaGateway ( PluginBase . GetCurrentScintilla ( ) ) ;
140
+ int start = scintillaGateway . GetSelectionStart ( ) . Value ;
141
+ int end = scintillaGateway . GetSelectionEnd ( ) . Value ;
160
142
161
143
return end - start == 0 ? "" : Text . Substring ( start , end - start ) ;
162
144
}
0 commit comments