-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add snippet blocks to autocomplete menu
- Loading branch information
1 parent
94a3b5b
commit 42cd6a8
Showing
17 changed files
with
350 additions
and
130 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
.../interpreter/parser/TemplateCodeOutput.cs → ...erpreter/csharpcode/TemplateCodeOutput.cs
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,4 +1,4 @@ | ||
// | ||
// | ||
// THIS FILE IS NOT COMPILED AS C# CODE. | ||
// IT IS AN EMBEDDED RESSOURCE. | ||
// | ||
|
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
50 changes: 50 additions & 0 deletions
50
pseudocodeIde/interpreter/pseudocode/PseudocodeAutocompleteItem.cs
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,50 @@ | ||
// Pseudocode IDE - Execute Pseudocode for the German (BW) 2024 Abitur | ||
// Copyright (C) 2024 PocketMiner82 | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY | ||
|
||
using AutocompleteMenuNS; | ||
using pseudocodeIde; | ||
using ScintillaNET; | ||
|
||
namespace pseudocode_ide.interpreter.pseudocode | ||
{ | ||
/// <summary> | ||
/// Represents an autocomplete item for pseudocode with custom behavior for replacing text. | ||
/// </summary> | ||
public class PseudocodeAutocompleteItem : SnippetAutocompleteItem | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="PseudocodeAutocompleteItem"/> class with the specified snippet and optional menu text. | ||
/// </summary> | ||
/// <param name="snippet">The snippet to be used for autocomplete.</param> | ||
/// <param name="menuText">The text to be displayed in the autocomplete menu. If null, the snippet is used.</param> | ||
public PseudocodeAutocompleteItem(string snippet, string menuText = null) : base(snippet) | ||
{ | ||
if (menuText != null) | ||
{ | ||
MenuText = menuText; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the text to replace the current fragment with, adjusting for indentation based on the current line. | ||
/// </summary> | ||
/// <returns>The adjusted text for replacement.</returns> | ||
public override string GetTextForReplace() | ||
{ | ||
Scintilla scintilla = (Scintilla)Parent.TargetControlWrapper.TargetControl; | ||
|
||
string line = scintilla.Lines[scintilla.LineFromPosition(Parent.Fragment.Start)].Text; | ||
string indents = new string('\t', line.GetIndentationLevel()); | ||
|
||
return Text.Replace("\n", $"\n{indents}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.