Skip to content

Commit 0d7f316

Browse files
authored
Merge pull request #349 from AvaloniaUI/update-to-avalonia11
Update to Avalonia 11
2 parents 870f53a + 9fce6f2 commit 0d7f316

File tree

5 files changed

+37
-64
lines changed

5 files changed

+37
-64
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<LangVersion>latest</LangVersion>
44
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
5-
<AvaloniaVersion>11.0.0-rc1.1</AvaloniaVersion>
5+
<AvaloniaVersion>11.0.0</AvaloniaVersion>
66
<TextMateSharpVersion>1.0.55</TextMateSharpVersion>
77
<VersionSuffix>beta</VersionSuffix>
88
</PropertyGroup>

src/AvaloniaEdit.Demo/AvaloniaEdit.Demo.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<ItemGroup>
3434
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
3535
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
36-
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)"/>
36+
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)"/>
3737
<ProjectReference Include="..\AvaloniaEdit\AvaloniaEdit.csproj" />
3838
<ProjectReference Include="..\AvaloniaEdit.TextMate\AvaloniaEdit.TextMate.csproj" />
3939
</ItemGroup>

src/AvaloniaEdit.TextMate/AvaloniaEdit.TextMate.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
15+
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
1616
<PackageReference Include="TextMateSharp" Version="$(TextMateSharpVersion)" />
1717
<PackageReference Include="TextMateSharp.Grammars" Version="$(TextMateSharpVersion)" />
1818
</ItemGroup>

src/AvaloniaEdit/Editing/TextArea.cs

+32-59
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static TextArea()
7373
if (!ta.IsReadOnly)
7474
{
7575
e.Client = ta._imClient;
76-
}
76+
}
7777
});
7878
}
7979

@@ -627,7 +627,7 @@ public IDisposable AllowCaretOutsideSelection()
627627
/// If the textview can be scrolled.
628628
/// </summary>
629629
/// <param name="line">The line to scroll to.</param>
630-
public void ScrollToLine (int line)
630+
public void ScrollToLine(int line)
631631
{
632632
var viewPortLines = (int)(this as IScrollable).Viewport.Height;
633633

@@ -1134,25 +1134,20 @@ public void RaiseScrollInvalidated(EventArgs e)
11341134
_logicalScrollable?.RaiseScrollInvalidated(e);
11351135
}
11361136

1137-
private class TextAreaTextInputMethodClient : ITextInputMethodClient
1137+
private class TextAreaTextInputMethodClient : TextInputMethodClient
11381138
{
1139-
private ITextEditable _textEditable;
11401139
private TextArea _textArea;
11411140

11421141
public TextAreaTextInputMethodClient()
11431142
{
11441143

11451144
}
11461145

1147-
public event EventHandler CursorRectangleChanged;
1148-
public event EventHandler TextViewVisualChanged;
1149-
public event EventHandler SurroundingTextChanged;
1150-
1151-
public Rect CursorRectangle
1146+
public override Rect CursorRectangle
11521147
{
11531148
get
1154-
{
1155-
if(_textArea == null)
1149+
{
1150+
if (_textArea == null)
11561151
{
11571152
return default;
11581153
}
@@ -1170,97 +1165,75 @@ public Rect CursorRectangle
11701165
}
11711166
}
11721167

1173-
public Visual TextViewVisual => _textArea;
1168+
public override Visual TextViewVisual => _textArea;
11741169

1175-
public bool SupportsPreedit => false;
1170+
public override bool SupportsPreedit => false;
11761171

1177-
public bool SupportsSurroundingText => true;
1172+
public override bool SupportsSurroundingText => true;
11781173

1179-
public TextInputMethodSurroundingText SurroundingText
1174+
public override string SurroundingText
11801175
{
11811176
get
11821177
{
1183-
if(_textArea == null)
1178+
if (_textArea == null)
11841179
{
11851180
return default;
11861181
}
11871182

11881183
var lineIndex = _textArea.Caret.Line;
11891184

1190-
var position = _textArea.Caret.Position;
1191-
11921185
var documentLine = _textArea.Document.GetLineByNumber(lineIndex);
11931186

11941187
var text = _textArea.Document.GetText(documentLine.Offset, documentLine.Length);
11951188

1196-
return new TextInputMethodSurroundingText
1197-
{
1198-
AnchorOffset = 0,
1199-
CursorOffset = position.Column,
1200-
Text = text
1201-
};
1189+
return text;
12021190
}
12031191
}
12041192

1205-
public ITextEditable TextEditable
1193+
public override TextSelection Selection
12061194
{
1207-
get => _textEditable;
1208-
set => _textEditable = value;
1195+
get => new TextSelection(_textArea.Caret.Position.Column, _textArea.Caret.Position.Column + _textArea.Selection.Length);
1196+
set
1197+
{
1198+
var selection = _textArea.Selection;
1199+
1200+
_textArea.Selection = selection.StartSelectionOrSetEndpoint(
1201+
new TextViewPosition(selection.StartPosition.Line, value.Start),
1202+
new TextViewPosition(selection.StartPosition.Line, value.End));
1203+
}
12091204
}
12101205

12111206
public void SetTextArea(TextArea textArea)
12121207
{
1213-
if(_textArea != null)
1208+
if (_textArea != null)
12141209
{
12151210
_textArea.Caret.PositionChanged -= Caret_PositionChanged;
1216-
_textArea.SelectionChanged -= TextArea_SelectionChanged;
12171211
}
12181212

12191213
_textArea = textArea;
12201214

1221-
if(_textArea != null)
1215+
if (_textArea != null)
12221216
{
12231217
_textArea.Caret.PositionChanged += Caret_PositionChanged;
1224-
_textArea.SelectionChanged += TextArea_SelectionChanged;
12251218
}
12261219

1227-
TextViewVisualChanged?.Invoke(this, EventArgs.Empty);
1220+
RaiseTextViewVisualChanged();
12281221

1229-
CursorRectangleChanged?.Invoke(this, EventArgs.Empty);
1230-
}
1231-
1232-
private void Caret_PositionChanged(object sender, EventArgs e)
1233-
{
1234-
CursorRectangleChanged?.Invoke(this, e);
1235-
}
1222+
RaiseCursorRectangleChanged();
12361223

1237-
private void TextArea_SelectionChanged(object sender, EventArgs e)
1238-
{
1239-
SurroundingTextChanged?.Invoke(this, e);
1224+
RaiseSurroundingTextChanged();
12401225
}
12411226

1242-
public void SelectInSurroundingText(int start, int end)
1227+
private void Caret_PositionChanged(object sender, EventArgs e)
12431228
{
1244-
if(_textArea == null)
1245-
{
1246-
return;
1247-
}
1248-
1249-
var selection = _textArea.Selection;
1250-
1251-
_textArea.Selection = _textArea.Selection.StartSelectionOrSetEndpoint(
1252-
new TextViewPosition(selection.StartPosition.Line, start),
1253-
new TextViewPosition(selection.StartPosition.Line, end));
1229+
RaiseCursorRectangleChanged();
1230+
RaiseSurroundingTextChanged();
1231+
RaiseSelectionChanged();
12541232
}
12551233

1256-
public void SetPreeditText(string text)
1234+
public override void SetPreeditText(string text)
12571235
{
1258-
1259-
}
12601236

1261-
public void SetComposingRegion(TextRange? region)
1262-
{
1263-
//ToDo
12641237
}
12651238
}
12661239
}

test/AvaloniaEdit.Tests/AvaloniaEdit.Tests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
<ItemGroup>
88
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
9-
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
10-
<PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
9+
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
10+
<PackageReference Include="Avalonia.Themes.Simple" Version="$(AvaloniaVersion)" />
1111
<PackageReference Include="Avalonia.Headless.NUnit" Version="$(AvaloniaVersion)" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
1313
<PackageReference Include="Moq" Version="4.18.4" />

0 commit comments

Comments
 (0)