This repository has been archived by the owner on Dec 10, 2023. It is now read-only.
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
15 changed files
with
441 additions
and
100 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -1,55 +1,43 @@ | ||
using AvalonEditB.CodeCompletion; | ||
using AvalonEditB.Document; | ||
using AvalonEditB.Editing; | ||
using SkEditorPlus.Windows.Generators; | ||
using HandyControl.Controls; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Windows; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Controls; | ||
|
||
namespace SkEditorPlus.Data | ||
{ | ||
public class CompletionData : ICompletionData | ||
public class CompletionData | ||
{ | ||
public CompletionData(string text, string description = "Brak opisu") | ||
{ | ||
Text = text; | ||
Description = description; | ||
} | ||
|
||
public System.Windows.Media.ImageSource Image | ||
public static List<CompletionDataElement> completionList = new() | ||
{ | ||
get { return null; } | ||
} | ||
|
||
public string Text { get; private set; } | ||
|
||
public object Content | ||
{ | ||
get { return this.Text; } | ||
} | ||
|
||
public object Description | ||
{ get; private set; } | ||
|
||
double ICompletionData.Priority => 1; | ||
|
||
public void Complete(TextArea textArea, ISegment completionSegment, | ||
EventArgs insertionRequestEventArgs) | ||
{ | ||
var caretOffset = textArea.Caret.Offset; | ||
var line = textArea.Document.GetLineByOffset(caretOffset); | ||
textArea.Document.Replace(line.Offset, caretOffset - line.Offset, ""); | ||
|
||
CommandGenerator commandGenerator = new(GetMainWindow().skEditor); | ||
commandGenerator.ShowDialog(); | ||
} | ||
public static MainWindow GetMainWindow() | ||
new CompletionDataElement("command", "command /{c}:\n\t"), | ||
new CompletionDataElement("commandgen"), | ||
new CompletionDataElement("options", "options:\n\t"), | ||
new CompletionDataElement("variables", "variables:\n\t"), | ||
new CompletionDataElement("trigger", "trigger:\n\t"), | ||
new CompletionDataElement("if", "if {c}:"), | ||
new CompletionDataElement("ifelse", "if {c}:\n\t\nelse:\n\t"), | ||
new CompletionDataElement("else"), | ||
new CompletionDataElement("send", "send \"{c}\""), | ||
new CompletionDataElement("sendallp", "send \"{c}\" to all players"), | ||
}; | ||
|
||
public static ListBoxItem[] GetCompletionData(string word) | ||
{ | ||
List<Window> windowList = new(); | ||
foreach (Window window in System.Windows.Application.Current.Windows) | ||
windowList.Add(window); | ||
return (MainWindow)windowList.Find(window => window.GetType() == typeof(MainWindow)); | ||
List<ListBoxItem> completions = new(); | ||
foreach (var item in completionList) | ||
{ | ||
if (item.Name.StartsWith(word)) | ||
{ | ||
//if (item.Name.Equals(word)) continue; | ||
completions.Add(new ListBoxItem { Content = item.Name }); | ||
} | ||
} | ||
return completions.ToArray(); | ||
} | ||
|
||
} | ||
} | ||
} |
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,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SkEditorPlus.Data | ||
{ | ||
public class CompletionDataElement | ||
{ | ||
public string Name { get; set; } | ||
public string Description { get; set; } | ||
|
||
public string Word { get; set; } | ||
|
||
public CompletionDataElement(string name, string word = "none", string description = "none") | ||
{ | ||
Name = name; | ||
|
||
if (!description.Equals("none")) | ||
{ | ||
Description = description; | ||
} | ||
|
||
if (!word.Equals("none")) | ||
{ | ||
Word = word; | ||
return; | ||
} | ||
Word = word; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.