-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
293 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Arma.Studio.Data.TextEditor | ||
{ | ||
public interface ICodeCompletable | ||
{ | ||
IEnumerable<ICodeCompletionInfo> GetAutoCompleteInfos(string text, int caretOffset); | ||
bool IsSeparatorCharacter(char c); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
| ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Media; | ||
|
||
namespace Arma.Studio.Data.TextEditor | ||
{ | ||
public interface ICodeCompletionInfo | ||
{ | ||
ImageSource ImageSource { get; } | ||
|
||
string Text { get; } | ||
|
||
object Content { get; } | ||
|
||
object Description { get; } | ||
|
||
double Priority { get; } | ||
|
||
abstract string Complete(string input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Media; | ||
|
||
namespace Arma.Studio.Data.TextEditor | ||
{ | ||
public class WordCompletionInfo : ICodeCompletionInfo | ||
{ | ||
|
||
public ImageSource ImageSource => null; | ||
public string Text { get; private set; } | ||
public object Content { get; private set; } | ||
public object Description { get; private set; } | ||
public double Priority => 0; | ||
|
||
public WordCompletionInfo(string word) | ||
{ | ||
this.Text = word; | ||
this.Content = new System.Windows.Controls.TextBlock { Text = word }; | ||
} | ||
public WordCompletionInfo(string word, string description) | ||
{ | ||
this.Text = word; | ||
this.Description = description; | ||
this.Content = new System.Windows.Controls.TextBlock { Text = word }; | ||
} | ||
|
||
public WordCompletionInfo(string ltype, string @operator, string rtype, string description) | ||
{ | ||
this.Text = @operator; | ||
this.Description = description; | ||
var panel = new System.Windows.Controls.StackPanel { Orientation = System.Windows.Controls.Orientation.Horizontal }; | ||
if (!String.IsNullOrWhiteSpace(ltype) ) | ||
{ | ||
var textblock_ltype = new System.Windows.Controls.TextBlock { Text = ltype, FontStyle = System.Windows.FontStyles.Italic, Margin = new System.Windows.Thickness(0, 0, 6, 0) }; | ||
panel.Children.Add(textblock_ltype); | ||
} | ||
var textblock_operator = new System.Windows.Controls.TextBlock { Text = @operator, FontWeight = System.Windows.FontWeights.Bold }; | ||
panel.Children.Add(textblock_operator); | ||
if (!String.IsNullOrWhiteSpace(rtype)) | ||
{ | ||
var textblock_rtype = new System.Windows.Controls.TextBlock { Text = rtype, FontStyle = System.Windows.FontStyles.Italic, Margin = new System.Windows.Thickness(6, 0, 0, 0) }; | ||
panel.Children.Add(textblock_rtype); | ||
} | ||
this.Content = panel; | ||
} | ||
public string Complete(string input) | ||
{ | ||
return this.Text; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="AvalonEdit" version="6.0.1" targetFramework="net461" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Arma.Studio.Data.TextEditor; | ||
using ICSharpCode.AvalonEdit.CodeCompletion; | ||
using ICSharpCode.AvalonEdit.Document; | ||
using ICSharpCode.AvalonEdit.Editing; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Media; | ||
|
||
namespace Arma.Studio.UI | ||
{ | ||
public class CompletionData : ICompletionData | ||
{ | ||
private readonly ICodeCompletionInfo InnerCompletionInfo; | ||
public ImageSource Image => this.InnerCompletionInfo.ImageSource; | ||
|
||
public string Text => this.InnerCompletionInfo.Text; | ||
|
||
public object Content => this.InnerCompletionInfo.Content; | ||
|
||
public object Description => this.InnerCompletionInfo.Description; | ||
|
||
public double Priority => this.InnerCompletionInfo.Priority; | ||
|
||
public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs) | ||
{ | ||
var textSegment = textArea.Document.GetText(completionSegment); | ||
var text = this.InnerCompletionInfo.Complete(textSegment); | ||
textArea.Document.Replace(completionSegment, text); | ||
} | ||
|
||
public CompletionData(ICodeCompletionInfo codeCompletionInfo) | ||
{ | ||
this.InnerCompletionInfo = codeCompletionInfo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters