diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 0b9d64c..db48ea1 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -2,7 +2,7 @@ name: Build app on PR on: workflow_dispatch: pull_request: - branches: [ main, dev ] + branches: [ dev ] jobs: diff --git a/.releaserc b/.releaserc index 19403ad..a45df7b 100644 --- a/.releaserc +++ b/.releaserc @@ -52,7 +52,7 @@ "pseudocodeIde/pseudocodeIde.csproj" ], "from": ".*", - "to": "${nextRelease.version.split('-')[0]}", + "to": "${nextRelease.version.replace('-dev', '')}", "countMatches": true } ] diff --git a/AutoUpdater.xml b/AutoUpdater.xml index 37b6441..ec145cd 100644 --- a/AutoUpdater.xml +++ b/AutoUpdater.xml @@ -1,7 +1,7 @@ - 1.2.7 + 1.3.0.4 https://github.com/PocketMiner82/pseudocode-ide/releases/latest/download/pseudocode-ide.zip - https://github.com/PocketMiner82/pseudocode-ide/releases + https://github.com/PocketMiner82/pseudocode-ide/blob/main/CHANGELOG.md false \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bec2179..da6fd48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,28 @@ +# [1.3.0-dev.4](https://github.com/PocketMiner82/pseudocode-ide/compare/1.3.0-dev.3...1.3.0-dev.4) (2024-04-09) + +# [1.3.0-dev.3](https://github.com/PocketMiner82/pseudocode-ide/compare/1.3.0-dev.2...1.3.0-dev.3) (2024-04-09) + + +### Features + +* add update to beta button ([a85f2f1](https://github.com/PocketMiner82/pseudocode-ide/commit/a85f2f18edcf1e6e592c42e560a539a28f39dc81)) + +# [1.3.0-dev.2](https://github.com/PocketMiner82/pseudocode-ide/compare/1.3.0-dev.1...1.3.0-dev.2) (2024-04-09) + + +### Bug Fixes + +* point changelog to actual changelog file ([df9c1ba](https://github.com/PocketMiner82/pseudocode-ide/commit/df9c1ba52b7e0a2b2fe7335d16d9f462b2f79c99)) + +# [1.3.0-dev.1](https://github.com/PocketMiner82/pseudocode-ide/compare/1.2.7...1.3.0-dev.1) (2024-04-09) + + +### Features + +* add autocomplete menu using AutoCompleteMenu-ScintillaNET library ([38b2909](https://github.com/PocketMiner82/pseudocode-ide/commit/38b2909a09149cc3e8c79002ee15a796b6dc7699)) +* add word highlighting on select + use Scintilla5.NET ([b9ec14c](https://github.com/PocketMiner82/pseudocode-ide/commit/b9ec14cb6f5ac1f5651b8cad25c3978bb70914f1)) +* use ScintillaNET-FindReplaceDialog for find/replace ([efac5dc](https://github.com/PocketMiner82/pseudocode-ide/commit/efac5dc811e7188fe2b5f07438a552dbb3529e40)) + ## [1.2.7](https://github.com/PocketMiner82/pseudocode-ide/compare/1.2.6...1.2.7) (2024-04-03) diff --git a/pseudocodeIde/PseudocodeIDEForm.Designer.cs b/pseudocodeIde/PseudocodeIDEForm.Designer.cs index 580c131..58a74a3 100644 --- a/pseudocodeIde/PseudocodeIDEForm.Designer.cs +++ b/pseudocodeIde/PseudocodeIDEForm.Designer.cs @@ -40,6 +40,8 @@ private void InitializeComponent() this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.findMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.replaceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.goToMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.wordWrapMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.runMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -50,8 +52,10 @@ private void InitializeComponent() this.helpMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.showHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.updatePseudocodeIDEMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.updateMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.updateBetaMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.codeTextBox = new ScintillaNET.Scintilla(); + this.autoCompleteMenu = new AutocompleteMenuNS.AutocompleteMenu(); this.menuStrip.SuspendLayout(); this.SuspendLayout(); // @@ -113,7 +117,9 @@ private void InitializeComponent() this.redoToolStripMenuItem, this.toolStripSeparator1, this.findMenuItem, - this.replaceMenuItem}); + this.replaceMenuItem, + this.toolStripSeparator4, + this.goToMenuItem}); this.editMenuItem.Name = "editMenuItem"; this.editMenuItem.Size = new System.Drawing.Size(111, 29); this.editMenuItem.Text = "Bearbeiten"; @@ -157,6 +163,19 @@ private void InitializeComponent() this.replaceMenuItem.Text = "Ersetzen"; this.replaceMenuItem.Click += new System.EventHandler(this.replaceMenuItem_Click); // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(308, 6); + // + // goToMenuItem + // + this.goToMenuItem.Name = "goToMenuItem"; + this.goToMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G))); + this.goToMenuItem.Size = new System.Drawing.Size(311, 34); + this.goToMenuItem.Text = "Gehe zu"; + this.goToMenuItem.Click += new System.EventHandler(this.goToMenuItem_Click); + // // viewMenuItem // this.viewMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -221,7 +240,8 @@ private void InitializeComponent() this.helpMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.showHelpMenuItem, this.toolStripSeparator3, - this.updatePseudocodeIDEMenuItem}); + this.updateMenuItem, + this.updateBetaMenuItem}); this.helpMenuItem.Name = "helpMenuItem"; this.helpMenuItem.Size = new System.Drawing.Size(64, 29); this.helpMenuItem.Text = "Hilfe"; @@ -230,39 +250,52 @@ private void InitializeComponent() // this.showHelpMenuItem.Name = "showHelpMenuItem"; this.showHelpMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F1; - this.showHelpMenuItem.Size = new System.Drawing.Size(346, 34); + this.showHelpMenuItem.Size = new System.Drawing.Size(415, 34); this.showHelpMenuItem.Text = "Hilfe anzeigen"; this.showHelpMenuItem.Click += new System.EventHandler(this.showHelpMenuItem_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(343, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(412, 6); // - // updatePseudocodeIDEMenuItem + // updateMenuItem // - this.updatePseudocodeIDEMenuItem.Name = "updatePseudocodeIDEMenuItem"; - this.updatePseudocodeIDEMenuItem.Size = new System.Drawing.Size(346, 34); - this.updatePseudocodeIDEMenuItem.Text = "Pseudocode IDE aktualisieren"; - this.updatePseudocodeIDEMenuItem.Click += new System.EventHandler(this.updatePseudocodeIDEMenuItem_Click); + this.updateMenuItem.Name = "updateMenuItem"; + this.updateMenuItem.Size = new System.Drawing.Size(415, 34); + this.updateMenuItem.Text = "Pseudocode IDE aktualisieren"; + this.updateMenuItem.Click += new System.EventHandler(this.updateMenuItem_Click); + // + // updateBetaMenuItem + // + this.updateBetaMenuItem.Name = "updateBetaMenuItem"; + this.updateBetaMenuItem.Size = new System.Drawing.Size(415, 34); + this.updateBetaMenuItem.Text = "Pseudocode IDE auf Beta aktualisieren"; + this.updateBetaMenuItem.Click += new System.EventHandler(this.updateBetaMenuItem_Click); // // codeTextBox // this.codeTextBox.AdditionalSelectionTyping = true; + this.codeTextBox.AutoCMaxHeight = 9; + this.codeTextBox.BiDirectionality = ScintillaNET.BiDirectionalDisplayType.Disabled; this.codeTextBox.CaretLineBackColor = System.Drawing.Color.WhiteSmoke; this.codeTextBox.CaretLineVisible = true; this.codeTextBox.Dock = System.Windows.Forms.DockStyle.Fill; this.codeTextBox.EolMode = ScintillaNET.Eol.Lf; this.codeTextBox.IndentationGuides = ScintillaNET.IndentView.Real; this.codeTextBox.IndentWidth = 4; + this.codeTextBox.LexerName = null; this.codeTextBox.Location = new System.Drawing.Point(0, 33); this.codeTextBox.MultiPaste = ScintillaNET.MultiPaste.Each; this.codeTextBox.MultipleSelection = true; this.codeTextBox.Name = "codeTextBox"; this.codeTextBox.ScrollWidth = 39; this.codeTextBox.Size = new System.Drawing.Size(1176, 676); + this.codeTextBox.TabIndents = true; this.codeTextBox.TabIndex = 1; + this.codeTextBox.UseRightToLeftReadingLayout = false; this.codeTextBox.UseTabs = true; + this.codeTextBox.WrapMode = ScintillaNET.WrapMode.None; this.codeTextBox.Zoom = 2; this.codeTextBox.CharAdded += new System.EventHandler(this.codeTextBox_CharAdded); this.codeTextBox.UpdateUI += new System.EventHandler(this.codeTextBox_UpdateUI); @@ -270,6 +303,16 @@ private void InitializeComponent() this.codeTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.codeTextBox_KeyDown); this.codeTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.codeTextBox_KeyPress); // + // autoCompleteMenu + // + this.autoCompleteMenu.AllowsTabKey = true; + this.autoCompleteMenu.AppearInterval = 50; + this.autoCompleteMenu.Colors = ((AutocompleteMenuNS.Colors)(resources.GetObject("autoCompleteMenu.Colors"))); + this.autoCompleteMenu.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.autoCompleteMenu.ImageList = null; + this.autoCompleteMenu.Items = new string[0]; + this.autoCompleteMenu.TargetControlWrapper = null; + // // PseudocodeIDEForm // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); @@ -318,8 +361,12 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem openOutputFormMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripMenuItem updatePseudocodeIDEMenuItem; + private System.Windows.Forms.ToolStripMenuItem updateMenuItem; private ScintillaNET.Scintilla codeTextBox; + private System.Windows.Forms.ToolStripMenuItem goToMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; + private AutocompleteMenuNS.AutocompleteMenu autoCompleteMenu; + private System.Windows.Forms.ToolStripMenuItem updateBetaMenuItem; } } diff --git a/pseudocodeIde/PseudocodeIDEForm.cs b/pseudocodeIde/PseudocodeIDEForm.cs index f7562a9..34b4000 100644 --- a/pseudocodeIde/PseudocodeIDEForm.cs +++ b/pseudocodeIde/PseudocodeIDEForm.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using pseudocodeIde.findReplace; using pseudocode_ide; using Newtonsoft.Json; using System.Diagnostics; @@ -14,6 +13,8 @@ using ScintillaNET; using pseudocode_ide.interpreter.scanner; using System.Drawing; +using ScintillaNET_FindReplaceDialog; +using AutocompleteMenuNS; namespace pseudocodeIde { @@ -72,7 +73,7 @@ public string code /// private bool isSaved = true; - private FindReplaceForm findReplaceForm; + private FindReplace findReplace; private OutputForm outputForm; @@ -81,10 +82,11 @@ public string code public PseudocodeIDEForm() { - this.findReplaceForm = new FindReplaceForm(this); + InitializeComponent(); this.outputForm = new OutputForm(this); + this.findReplace = new FindReplace(this.codeTextBox); + this.findReplace.KeyPressed += codeTextBox_KeyDown; - InitializeComponent(); this.resetUndoRedo(); // disable right click menu @@ -95,6 +97,20 @@ public PseudocodeIDEForm() this.setFileSaved(); } + private void buildAutocompleteMenu() + { + autoCompleteMenu.TargetControlWrapper = new ScintillaWrapper(codeTextBox); + + List items = new List(); + + foreach (string item in Scanner.KEYWORDS.Keys) + { + items.Add(new SnippetAutocompleteItem(item) { ImageIndex = 1 }); + } + + autoCompleteMenu.SetAutocompleteItems(items); + } + // --------------------------------------------- // COMMON EVENT LISTENERS // --------------------------------------------- @@ -108,9 +124,15 @@ private void PseudocodeIDEForm_Load(object sender, EventArgs e) FileSystem.CopyDirectory(Path.Combine(currentDir, "updater"), tempExeDir, true); // show remind later - this.checkForUpdate(true); + this.checkForUpdate(true, false); // set font + this.configureCodeTextBox(); + this.buildAutocompleteMenu(); + } + + private void configureCodeTextBox() + { codeTextBox.StyleResetDefault(); codeTextBox.Styles[Style.Default].Font = "Courier New"; codeTextBox.StyleClearAll(); @@ -131,8 +153,8 @@ private void PseudocodeIDEForm_Load(object sender, EventArgs e) codeTextBox.Styles[SyntaxHighlightingLexer.STYLE_COMMENT].ForeColor = Color.Green; + codeTextBox.LexerName = ""; codeTextBox.StyleNeeded += codeTextBox_StyleNeeded; - codeTextBox.Lexer = Lexer.Container; } private void codeTextBox_StyleNeeded(object sender, StyleNeededEventArgs e) @@ -158,12 +180,6 @@ private void singleEqualIsCompareOperatorMenuItem_Click(object sender, EventArgs private void PseudocodeIDE_FormClosing(object sender, FormClosingEventArgs e) { // main form won't close if child form is not disposed - if (!this.findReplaceForm.IsDisposed) - { - this.findReplaceForm.Close(); - this.Close(); - return; - } if (!this.outputForm.IsDisposed) { this.outputForm.Close(); @@ -229,6 +245,12 @@ private void codeTextBox_TextChanged(object sender, EventArgs e) private void codeTextBox_KeyDown(object sender, KeyEventArgs e) { + // hack to allow enter to autocomplete even if down wasnt pressed before + if ((e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab) && e.Modifiers == Keys.None && autoCompleteMenu.SelectedItemIndex < 0) + { + autoCompleteMenu.ProcessKey((char)Keys.Down, e.Modifiers); + } + // ignore CTRL[+SHIFT]+(Z/Y/L/R/E/S) if ((e.KeyCode == Keys.Z || e.KeyCode == Keys.Y || e.KeyCode == Keys.L || e.KeyCode == Keys.R || e.KeyCode == Keys.E || e.KeyCode == Keys.S) && (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == (Keys.Control | Keys.Shift))) @@ -245,6 +267,16 @@ private void codeTextBox_KeyDown(object sender, KeyEventArgs e) e.SuppressKeyPress = false; return; } + else if (e.Shift && e.KeyCode == Keys.F3) + { + this.findReplace.Window.FindPrevious(); + e.SuppressKeyPress = true; + } + else if (e.KeyCode == Keys.F3) + { + this.findReplace.Window.FindNext(); + e.SuppressKeyPress = true; + } } private void codeTextBox_KeyPress(object sender, KeyPressEventArgs e) @@ -372,6 +404,49 @@ private void userChangedSelection() this.updateUndoStack(true); } this.lastCursorPosition = codeTextBox.SelectionStart; + + this.highlightWord(codeTextBox.SelectedText); + } + + // adapted from https://github.com/desjarlais/Scintilla.NET/wiki/Find-and-Highlight-Words + private void highlightWord(string text) + { + // Indicators 0-7 could be in use by a lexer + // so we'll use indicator 8 to highlight words. + const int NUM = 8; + + // Remove all uses of our indicator + codeTextBox.IndicatorCurrent = NUM; + codeTextBox.IndicatorClearRange(0, codeTextBox.TextLength); + + if (string.IsNullOrEmpty(text)) + { + return; + } + + // Update indicator appearance + codeTextBox.Indicators[NUM].Style = IndicatorStyle.StraightBox; + codeTextBox.Indicators[NUM].Under = true; + codeTextBox.Indicators[NUM].ForeColor = Color.Lime; + codeTextBox.Indicators[NUM].OutlineAlpha = 127; + codeTextBox.Indicators[NUM].Alpha = 127; + + // Search the document + codeTextBox.TargetStart = 0; + codeTextBox.TargetEnd = codeTextBox.TextLength; + codeTextBox.SearchFlags = SearchFlags.None; + while (codeTextBox.SearchInTarget(text) != -1) + { + if (codeTextBox.TargetStart != codeTextBox.SelectionStart) + { + // Mark the search results with the current indicator + codeTextBox.IndicatorFillRange(codeTextBox.TargetStart, codeTextBox.TargetEnd - codeTextBox.TargetStart); + } + + // Search the remainder of the document + codeTextBox.TargetStart = codeTextBox.TargetEnd; + codeTextBox.TargetEnd = codeTextBox.TextLength; + } } // --------------------------------------------- @@ -673,70 +748,17 @@ private void redoToolStripMenuItem_Click(object sender, EventArgs e) private void findMenuItem_Click(object sender, EventArgs e) { - this.findReplaceForm.Show(FindReplaceTabs.FIND, codeTextBox.SelectedText); + this.findReplace.ShowFind(); } private void replaceMenuItem_Click(object sender, EventArgs e) { - this.findReplaceForm.Show(FindReplaceTabs.REPLACE, codeTextBox.SelectedText); + this.findReplace.ShowReplace(); } - /// - /// Get the start of the current selection in the code text box - /// - public int getSelectionStart() + private void goToMenuItem_Click(object sender, EventArgs e) { - return codeTextBox.SelectionStart; - } - - /// - /// Get the end of the current selection in the code text box - /// - public int getSelectionEnd() - { - return codeTextBox.SelectionEnd; - } - - /// - /// Get the selection length in the code text box - /// - public int getSelectionLength() - { - return codeTextBox.SelectionEnd - codeTextBox.SelectionStart; - } - - /// - /// Get the currently selected text. - /// - public string getSelection() - { - return codeTextBox.SelectedText; - } - - /// - /// Select text in the code text box. Will be invoked on the UI thread. - /// - /// start of the selection - /// length of the selection - public void selectText(int selectionStart, int selectionLength) - { - Invoke(new Action(() => - { - codeTextBox.SelectionStart = selectionStart; - codeTextBox.SelectionEnd = selectionStart + selectionLength; - })); - } - - /// - /// Replace the selected text. Will be invoked on the UI thread. - /// - /// The new text to replace - public void setSelectedText(string toReplace) - { - Invoke(new Action(() => - { - codeTextBox.ReplaceSelection(toReplace); - })); + new GoTo(codeTextBox).ShowGoToDialog(); } // --------------------------------------------- @@ -779,13 +801,13 @@ private void showHelpMenuItem_Click(object sender, EventArgs e) // (AUTO) UPDATE // --------------------------------------------- - private void updatePseudocodeIDEMenuItem_Click(object sender, EventArgs e) + private void updateMenuItem_Click(object sender, EventArgs e) { // dont show remind later - this.checkForUpdate(false); + this.checkForUpdate(false, false); } - private void checkForUpdate(bool firstRun) + private void checkForUpdate(bool firstRun, bool beta) { string currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string tempExeDir = Path.Combine(Path.GetTempPath(), "pseudocode-ide\\updater"); @@ -796,10 +818,15 @@ private void checkForUpdate(bool firstRun) { compiler.StartInfo.FileName = tempExePath; compiler.StartInfo.WorkingDirectory = tempExeDir; - compiler.StartInfo.Arguments = $"\"{currentDir}\" \"{firstRun}\""; + compiler.StartInfo.Arguments = $"\"{currentDir}\" \"{firstRun}\" \"{beta}\""; compiler.StartInfo.UseShellExecute = true; compiler.Start(); } } + + private void updateBetaMenuItem_Click(object sender, EventArgs e) + { + this.checkForUpdate(false, true); + } } } diff --git a/pseudocodeIde/PseudocodeIDEForm.resx b/pseudocodeIde/PseudocodeIDEForm.resx index 40feaa8..f36c999 100644 --- a/pseudocodeIde/PseudocodeIDEForm.resx +++ b/pseudocodeIde/PseudocodeIDEForm.resx @@ -120,6 +120,26 @@ 17, 17 + + 165, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFRBdXRvY29tcGxldGVNZW51LVNjaW50aWxsYU5FVCwgVmVyc2lv + bj0xLjYuMi4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwMAwAAAFFTeXN0ZW0u + RHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIw + M2Y1ZjdmMTFkNTBhM2EFAQAAABlBdXRvY29tcGxldGVNZW51TlMuQ29sb3JzBgAAABo8Rm9yZUNvbG9y + PmtfX0JhY2tpbmdGaWVsZBo8QmFja0NvbG9yPmtfX0JhY2tpbmdGaWVsZCI8U2VsZWN0ZWRGb3JlQ29s + b3I+a19fQmFja2luZ0ZpZWxkIjxTZWxlY3RlZEJhY2tDb2xvcj5rX19CYWNraW5nRmllbGQjPFNlbGVj + dGVkQmFja0NvbG9yMj5rX19CYWNraW5nRmllbGQiPEhpZ2hsaWdodGluZ0NvbG9yPmtfX0JhY2tpbmdG + aWVsZAQEBAQEBBRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAAUU3lzdGVtLkRyYXdpbmcuQ29sb3IDAAAA + FFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAAABRTeXN0ZW0uRHJhd2luZy5Db2xvcgMAAAAUU3lzdGVtLkRy + YXdpbmcuQ29sb3IDAAAAFFN5c3RlbS5EcmF3aW5nLkNvbG9yAwAAAAIAAAAF/P///xRTeXN0ZW0uRHJh + d2luZy5Db2xvcgQAAAAEbmFtZQV2YWx1ZQprbm93bkNvbG9yBXN0YXRlAQAAAAkHBwMAAAAKAAAAAAAA + AAAjAAEAAfv////8////CgAAAAAAAAAApAABAAH6/////P///woAAAAAAAAAACMAAQAB+f////z///8K + AAAAAAAAAAB/AAEAAfj////8////CgAAAAAAAAAApAABAAH3/////P///woAAAAAAAAAAH8AAQAL + + 83 diff --git a/pseudocodeIde/SetClipboardHelper.cs b/pseudocodeIde/SetClipboardHelper.cs index 85bdb30..e531031 100644 --- a/pseudocodeIde/SetClipboardHelper.cs +++ b/pseudocodeIde/SetClipboardHelper.cs @@ -20,7 +20,7 @@ public SetClipboardHelper(string format, object data) protected override void Work() { - var obj = new System.Windows.Forms.DataObject( + DataObject obj = new System.Windows.Forms.DataObject( _format, _data ); @@ -35,7 +35,7 @@ public abstract class StaHelper public void Go() { - var thread = new Thread(new ThreadStart(DoWork)) + Thread thread = new Thread(new ThreadStart(DoWork)) { IsBackground = true, }; diff --git a/pseudocodeIde/findReplace/FindReplaceForm.Designer.cs b/pseudocodeIde/findReplace/FindReplaceForm.Designer.cs deleted file mode 100644 index 8da8e45..0000000 --- a/pseudocodeIde/findReplace/FindReplaceForm.Designer.cs +++ /dev/null @@ -1,319 +0,0 @@ -namespace pseudocodeIde -{ - partial class FindReplaceForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.tabPageReplace = new System.Windows.Forms.TabPage(); - this.cbMatchCase2 = new System.Windows.Forms.CheckBox(); - this.btReplaceAll = new System.Windows.Forms.Button(); - this.btReplace = new System.Windows.Forms.Button(); - this.btFindNext2 = new System.Windows.Forms.Button(); - this.tbReplaceWith = new System.Windows.Forms.TextBox(); - this.tbFindWhat2 = new System.Windows.Forms.TextBox(); - this.tabPageFind = new System.Windows.Forms.TabPage(); - this.btCount = new System.Windows.Forms.Button(); - this.cbMatchCase1 = new System.Windows.Forms.CheckBox(); - this.btFindNext1 = new System.Windows.Forms.Button(); - this.tbFindWhat1 = new System.Windows.Forms.TextBox(); - this.tabControl = new System.Windows.Forms.TabControl(); - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.tabPageReplace.SuspendLayout(); - this.tabPageFind.SuspendLayout(); - this.tabControl.SuspendLayout(); - this.statusStrip.SuspendLayout(); - this.SuspendLayout(); - // - // contextMenuStrip1 - // - this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4); - // - // tabPageReplace - // - this.tabPageReplace.Controls.Add(this.label2); - this.tabPageReplace.Controls.Add(this.label1); - this.tabPageReplace.Controls.Add(this.cbMatchCase2); - this.tabPageReplace.Controls.Add(this.btReplaceAll); - this.tabPageReplace.Controls.Add(this.btReplace); - this.tabPageReplace.Controls.Add(this.btFindNext2); - this.tabPageReplace.Controls.Add(this.tbReplaceWith); - this.tabPageReplace.Controls.Add(this.tbFindWhat2); - this.tabPageReplace.Location = new System.Drawing.Point(4, 29); - this.tabPageReplace.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageReplace.Name = "tabPageReplace"; - this.tabPageReplace.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageReplace.Size = new System.Drawing.Size(718, 146); - this.tabPageReplace.TabIndex = 1; - this.tabPageReplace.Text = "Ersetzen"; - this.tabPageReplace.UseVisualStyleBackColor = true; - // - // cbMatchCase2 - // - this.cbMatchCase2.AutoSize = true; - this.cbMatchCase2.Location = new System.Drawing.Point(9, 117); - this.cbMatchCase2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.cbMatchCase2.Name = "cbMatchCase2"; - this.cbMatchCase2.Size = new System.Drawing.Size(264, 24); - this.cbMatchCase2.TabIndex = 3; - this.cbMatchCase2.Text = "Groß-/Kleinschreibung beachten"; - this.cbMatchCase2.UseVisualStyleBackColor = true; - // - // btReplaceAll - // - this.btReplaceAll.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btReplaceAll.Location = new System.Drawing.Point(510, 100); - this.btReplaceAll.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btReplaceAll.Name = "btReplaceAll"; - this.btReplaceAll.Size = new System.Drawing.Size(195, 35); - this.btReplaceAll.TabIndex = 6; - this.btReplaceAll.Text = "Alles ersetzen"; - this.btReplaceAll.UseVisualStyleBackColor = true; - // - // btReplace - // - this.btReplace.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btReplace.Location = new System.Drawing.Point(510, 55); - this.btReplace.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btReplace.Name = "btReplace"; - this.btReplace.Size = new System.Drawing.Size(195, 35); - this.btReplace.TabIndex = 5; - this.btReplace.Text = "Ersetzen"; - this.btReplace.UseVisualStyleBackColor = true; - // - // btFindNext2 - // - this.btFindNext2.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btFindNext2.Location = new System.Drawing.Point(510, 10); - this.btFindNext2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btFindNext2.Name = "btFindNext2"; - this.btFindNext2.Size = new System.Drawing.Size(195, 35); - this.btFindNext2.TabIndex = 4; - this.btFindNext2.Text = "Suchen"; - this.btFindNext2.UseVisualStyleBackColor = true; - // - // tbReplaceWith - // - this.tbReplaceWith.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbReplaceWith.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbReplaceWith.Location = new System.Drawing.Point(83, 60); - this.tbReplaceWith.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tbReplaceWith.Name = "tbReplaceWith"; - this.tbReplaceWith.Size = new System.Drawing.Size(414, 26); - this.tbReplaceWith.TabIndex = 2; - // - // tbFindWhat2 - // - this.tbFindWhat2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbFindWhat2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbFindWhat2.Location = new System.Drawing.Point(83, 15); - this.tbFindWhat2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tbFindWhat2.Name = "tbFindWhat2"; - this.tbFindWhat2.Size = new System.Drawing.Size(414, 26); - this.tbFindWhat2.TabIndex = 1; - // - // tabPageFind - // - this.tabPageFind.Controls.Add(this.label3); - this.tabPageFind.Controls.Add(this.btCount); - this.tabPageFind.Controls.Add(this.cbMatchCase1); - this.tabPageFind.Controls.Add(this.btFindNext1); - this.tabPageFind.Controls.Add(this.tbFindWhat1); - this.tabPageFind.Location = new System.Drawing.Point(4, 29); - this.tabPageFind.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageFind.Name = "tabPageFind"; - this.tabPageFind.Padding = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabPageFind.Size = new System.Drawing.Size(718, 146); - this.tabPageFind.TabIndex = 0; - this.tabPageFind.Text = "Suchen"; - this.tabPageFind.UseVisualStyleBackColor = true; - // - // btCount - // - this.btCount.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btCount.Location = new System.Drawing.Point(510, 55); - this.btCount.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btCount.Name = "btCount"; - this.btCount.Size = new System.Drawing.Size(195, 35); - this.btCount.TabIndex = 4; - this.btCount.Text = "Zählen"; - this.btCount.UseVisualStyleBackColor = true; - // - // cbMatchCase1 - // - this.cbMatchCase1.AutoSize = true; - this.cbMatchCase1.Location = new System.Drawing.Point(9, 117); - this.cbMatchCase1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.cbMatchCase1.Name = "cbMatchCase1"; - this.cbMatchCase1.Size = new System.Drawing.Size(264, 24); - this.cbMatchCase1.TabIndex = 2; - this.cbMatchCase1.Text = "Groß-/Kleinschreibung beachten"; - this.cbMatchCase1.UseVisualStyleBackColor = true; - // - // btFindNext1 - // - this.btFindNext1.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.btFindNext1.Location = new System.Drawing.Point(510, 10); - this.btFindNext1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.btFindNext1.Name = "btFindNext1"; - this.btFindNext1.Size = new System.Drawing.Size(195, 35); - this.btFindNext1.TabIndex = 3; - this.btFindNext1.Text = "Suchen"; - this.btFindNext1.UseVisualStyleBackColor = true; - // - // tbFindWhat1 - // - this.tbFindWhat1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.tbFindWhat1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.tbFindWhat1.Location = new System.Drawing.Point(83, 15); - this.tbFindWhat1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tbFindWhat1.Name = "tbFindWhat1"; - this.tbFindWhat1.Size = new System.Drawing.Size(414, 26); - this.tbFindWhat1.TabIndex = 1; - // - // tabControl - // - this.tabControl.Controls.Add(this.tabPageFind); - this.tabControl.Controls.Add(this.tabPageReplace); - this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabControl.Location = new System.Drawing.Point(0, 0); - this.tabControl.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.tabControl.Name = "tabControl"; - this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(726, 179); - this.tabControl.TabIndex = 50; - this.tabControl.Selecting += new System.Windows.Forms.TabControlCancelEventHandler(this.tabControl_Selecting); - // - // statusStrip - // - this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24); - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.statusLabel}); - this.statusStrip.Location = new System.Drawing.Point(0, 179); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Padding = new System.Windows.Forms.Padding(2, 0, 21, 0); - this.statusStrip.Size = new System.Drawing.Size(726, 32); - this.statusStrip.TabIndex = 0; - this.statusStrip.Text = "statusStrip1"; - // - // statusLabel - // - this.statusLabel.Name = "statusLabel"; - this.statusLabel.Size = new System.Drawing.Size(17, 25); - this.statusLabel.Text = " "; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(8, 17); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(59, 20); - this.label1.TabIndex = 7; - this.label1.Text = "Suche:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(8, 62); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(68, 20); - this.label2.TabIndex = 8; - this.label2.Text = "Ersetze:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(8, 17); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(59, 20); - this.label3.TabIndex = 8; - this.label3.Text = "Suche:"; - // - // FindReplaceForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(726, 211); - this.Controls.Add(this.tabControl); - this.Controls.Add(this.statusStrip); - this.KeyPreview = true; - this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.MaximumSize = new System.Drawing.Size(149999990, 267); - this.MinimumSize = new System.Drawing.Size(739, 267); - this.Name = "FindReplaceForm"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.Text = "Suchen und Ersetzen"; - this.Activated += new System.EventHandler(this.FindReplaceForm_Activated); - this.Deactivate += new System.EventHandler(this.FindReplaceForm_Deactivate); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FindReplaceForm_FormClosing); - this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FindReplaceForm_KeyDown); - this.tabPageReplace.ResumeLayout(false); - this.tabPageReplace.PerformLayout(); - this.tabPageFind.ResumeLayout(false); - this.tabPageFind.PerformLayout(); - this.tabControl.ResumeLayout(false); - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; - private System.Windows.Forms.TabPage tabPageReplace; - private System.Windows.Forms.TabPage tabPageFind; - private System.Windows.Forms.StatusStrip statusStrip; - private System.Windows.Forms.TabControl tabControl; - private System.Windows.Forms.ToolStripStatusLabel statusLabel; - private System.Windows.Forms.CheckBox cbMatchCase2; - private System.Windows.Forms.Button btReplaceAll; - private System.Windows.Forms.Button btReplace; - private System.Windows.Forms.Button btFindNext2; - private System.Windows.Forms.TextBox tbReplaceWith; - private System.Windows.Forms.TextBox tbFindWhat2; - private System.Windows.Forms.Button btCount; - private System.Windows.Forms.CheckBox cbMatchCase1; - private System.Windows.Forms.Button btFindNext1; - private System.Windows.Forms.TextBox tbFindWhat1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label3; - } -} \ No newline at end of file diff --git a/pseudocodeIde/findReplace/FindReplaceForm.cs b/pseudocodeIde/findReplace/FindReplaceForm.cs deleted file mode 100644 index 27ab5aa..0000000 --- a/pseudocodeIde/findReplace/FindReplaceForm.cs +++ /dev/null @@ -1,328 +0,0 @@ -using pseudocodeIde.findReplace; -using System; -using System.Diagnostics; -using System.Drawing; -using System.Windows.Forms; - -namespace pseudocodeIde -{ - public partial class FindReplaceForm : Form - { - public PseudocodeIDEForm mainForm - { - get - { - return (PseudocodeIDEForm) Owner; - } - } - - /// - /// the search term to find - /// - private string findWhat = ""; - - /// - /// the term to replace the search term with - /// - private string replaceWith = ""; - - /// - /// whether the searching should be case sensitive - /// - private bool matchCase = false; - - public FindReplaceForm(PseudocodeIDEForm mainForm) - { - Owner = mainForm; - InitializeComponent(); - - // register some event listeners - - btFindNext1.Click += (ignored1, ignored2) => this.findNextAndUpdateStatus(); - btFindNext2.Click += (ignored1, ignored2) => this.findNextAndUpdateStatus(); - - btCount.Click += (ignored1, ignored2) => this.count(); - - btReplace.Click += (ignored1, ignored2) => this.replaceNextAndUpdateStatus(); - btReplaceAll.Click += (ignored1, ignored2) => this.replaceAll(); - - tbFindWhat1.TextChanged += (ignored1, ignored2) => this.findWhat = tbFindWhat1.Text; - tbFindWhat2.TextChanged += (ignored1, ignored2) => this.findWhat = tbFindWhat2.Text; - - tbReplaceWith.TextChanged += (ignored1, ignored2) => this.replaceWith = tbReplaceWith.Text; - - cbMatchCase1.CheckedChanged += (ignored1, ignored2) => this.matchCase = cbMatchCase1.Checked; - cbMatchCase2.CheckedChanged += (ignored1, ignored2) => this.matchCase = cbMatchCase2.Checked; - } - - // --------------------------------------------- - // EVENTS - // --------------------------------------------- - - private void FindReplaceForm_FormClosing(object sender, FormClosingEventArgs e) - { - if (Visible) - { - e.Cancel = true; - Hide(); - } - } - - private void FindReplaceForm_Activated(object sender, EventArgs e) - { - this.Opacity = 1; - } - - private void FindReplaceForm_Deactivate(object sender, EventArgs e) - { - this.Opacity = 0.5; - } - - private void FindReplaceForm_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - e.Handled = true; - this.findNextAndUpdateStatus(); - } - } - - private void tabControl_Selecting(object sender, TabControlCancelEventArgs e) - { - this.pageSwitch((FindReplaceTabs)e.TabPageIndex); - } - - // --------------------------------------------- - // METHODS - // --------------------------------------------- - - /// - /// Show the form. - /// - /// the tab to open - /// the initial value of the findWhat textbox - public void Show(FindReplaceTabs tab, string findWhat = "") - { - tabControl.SelectedIndex = (int)tab; - statusLabel.Text = " "; - statusLabel.ForeColor = SystemColors.ControlText; - - Show(); - Focus(); - - this.findWhat = findWhat != null && !findWhat.Equals("") ? findWhat : this.findWhat; - - this.pageSwitch(tab); - } - - /// - /// Go to a different tab - /// - /// the tab to switch to - private void pageSwitch(FindReplaceTabs tab) - { - Debug.WriteLine(tab); - switch (tab) - { - case FindReplaceTabs.REPLACE: - tbFindWhat2.Text = this.findWhat; - cbMatchCase2.Checked = this.matchCase; - tbFindWhat2.Select(); - tbFindWhat2.SelectAll(); - break; - - case FindReplaceTabs.FIND: - default: - tbFindWhat1.Text = this.findWhat; - cbMatchCase1.Checked = this.matchCase; - tbFindWhat1.Select(); - tbFindWhat1.SelectAll(); - break; - } - } - - /// - /// Find the next occurrence and update the status bar. - /// - public void findNextAndUpdateStatus() - { - switch (this.findNext()) - { - case FindReplaceResult.WRAPPED: - statusLabel.Text = $"Suchen: Ende des Dokuments erreicht. Fortsetzung am Anfang."; - statusLabel.ForeColor = Color.Green; - break; - - case FindReplaceResult.NOTHING_FOUND: - statusLabel.Text = $"Suchen: Konnte \"{this.findWhat}\" nicht finden."; - statusLabel.ForeColor = Color.Red; - break; - - default: - statusLabel.Text = " "; - statusLabel.ForeColor = SystemColors.ControlText; - break; - } - } - - /// - /// Find the next occurrence. - /// - public FindReplaceResult findNext() - { - string code = this.matchCase ? this.mainForm.code : this.mainForm.code.ToLower(); - string findWhat = this.matchCase ? this.findWhat : this.findWhat.ToLower(); - FindReplaceResult result = FindReplaceResult.NONE; - - int firstOccurence = code.IndexOf(findWhat, this.mainForm.getSelectionEnd()); - - if (firstOccurence < 0) - { - if (this.mainForm.getSelectionEnd() != 0) - { - result = FindReplaceResult.WRAPPED; - - // wrap around - this.mainForm.selectText(0, 0); - firstOccurence = code.IndexOf(findWhat, this.mainForm.getSelectionEnd()); - } - - if (firstOccurence < 0) - { - result = FindReplaceResult.NOTHING_FOUND; - return result; - } - } - - this.mainForm.selectText(firstOccurence, findWhat.Length); - return result; - } - - /// - /// Count the occurrences of a search term and update the status bar. - /// - public void count() - { - string code = this.matchCase ? this.mainForm.code : this.mainForm.code.ToLower(); - string findWhat = this.matchCase ? this.findWhat : this.findWhat.ToLower(); - - statusLabel.Text = $"Zählen: {code.allIndexesOf(findWhat).Count} Vorkommen gefunden."; - statusLabel.ForeColor = Color.Blue; - } - - /// - /// Replace the current occurrence, find the next and update the status bar. - /// If there isn't a current occurence, just find the next. - /// - public void replaceNextAndUpdateStatus() - { - switch (this.replaceNext()) - { - case FindReplaceResult.WRAPPED: - statusLabel.Text = $"Suchen: Ende des Dokuments erreicht. Fortsetzung am Anfang."; - statusLabel.ForeColor = Color.Green; - break; - - case FindReplaceResult.REPLACED_WRAPPED: - statusLabel.Text = $"Ersetzen: 1 Vorkommen ersetzt. Fortsetzung am Anfang."; - statusLabel.ForeColor = Color.Blue; - break; - - case FindReplaceResult.NOTHING_FOUND: - statusLabel.Text = $"Suchen: Konnte \"{this.findWhat}\" nicht finden."; - statusLabel.ForeColor = Color.Red; - break; - - case FindReplaceResult.NOTHING_MORE_FOUND: - statusLabel.Text = $"Ersetzen: Letztes Vorkommen ersetzt."; - statusLabel.ForeColor = Color.Blue; - break; - - case FindReplaceResult.REPLACED: - statusLabel.Text = $"Ersetzen: 1 Vorkommen ersetzt."; - statusLabel.ForeColor = Color.Blue; - break; - - default: - statusLabel.Text = " "; - statusLabel.ForeColor = SystemColors.ControlText; - break; - } - } - - /// - /// Replace the current occurrence and find the next. - /// If there isn't a current occurence, just find the next. - /// - public FindReplaceResult replaceNext() - { - // if selection doesn't match search term, find next - if ((!this.matchCase && !this.mainForm.getSelection().ToLower().Equals(this.findWhat.ToLower())) - || (this.matchCase && !this.mainForm.getSelection().Equals(this.findWhat))) - { - this.mainForm.selectText(this.mainForm.getSelectionStart(), 0); - return this.findNext(); - } - - // the selected text will be the search result, so replace it - this.mainForm.setSelectedText(this.replaceWith); - this.mainForm.updateUndoStack(true); - - // find the next result - FindReplaceResult result = this.findNext(); - - switch (result) - { - case FindReplaceResult.NOTHING_FOUND: - result = FindReplaceResult.NOTHING_MORE_FOUND; - break; - case FindReplaceResult.NONE: - result = FindReplaceResult.REPLACED; - break; - case FindReplaceResult.WRAPPED: - result = FindReplaceResult.REPLACED_WRAPPED; - break; - default: - break; - } - - return result; - } - - /// - /// Replace all occurrencea and update the status bar. - /// - public void replaceAll() - { - string code = this.matchCase ? this.mainForm.code : this.mainForm.code.ToLower(); - string findWhat = this.matchCase ? this.findWhat : this.findWhat.ToLower(); - int count = code.allIndexesOf(findWhat).Count; - - // no result found - if (count == 0) - { - statusLabel.Text = $"Suchen: Konnte \"{this.findWhat}\" nicht finden."; - statusLabel.ForeColor = Color.Red; - return; - } - - // go to beginning - this.mainForm.selectText(0, 0); - - // find the first occurence - this.findNext(); - - // loop through the occurences and replace them all, the count - 1 is needed to allow undo to work correctly - this.mainForm.noNewUndoPoint = true; - for (int i = 0; i < (count - 1); i++) - { - this.replaceNext(); - } - this.mainForm.noNewUndoPoint = false; - this.replaceNext(); - - statusLabel.Text = $"Ersetzen: {count} Vorkommen ersetzt."; - statusLabel.ForeColor = Color.Blue; - } - } -} diff --git a/pseudocodeIde/findReplace/FindReplaceForm.resx b/pseudocodeIde/findReplace/FindReplaceForm.resx deleted file mode 100644 index b6a0c12..0000000 --- a/pseudocodeIde/findReplace/FindReplaceForm.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 133, 17 - - - 288, 17 - - \ No newline at end of file diff --git a/pseudocodeIde/findReplace/FindReplaceResult.cs b/pseudocodeIde/findReplace/FindReplaceResult.cs deleted file mode 100644 index 484ab01..0000000 --- a/pseudocodeIde/findReplace/FindReplaceResult.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace pseudocodeIde.findReplace -{ - public enum FindReplaceResult - { - NOTHING_FOUND, NOTHING_MORE_FOUND, REPLACED, WRAPPED, REPLACED_WRAPPED, NONE - } -} diff --git a/pseudocodeIde/findReplace/FindReplaceTabs.cs b/pseudocodeIde/findReplace/FindReplaceTabs.cs deleted file mode 100644 index 4573055..0000000 --- a/pseudocodeIde/findReplace/FindReplaceTabs.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace pseudocodeIde.findReplace -{ - public enum FindReplaceTabs - { - FIND = 0, REPLACE = 1 - } -} diff --git a/pseudocodeIde/interpreter/scanner/Scanner.cs b/pseudocodeIde/interpreter/scanner/Scanner.cs index 538754e..e1b71a4 100644 --- a/pseudocodeIde/interpreter/scanner/Scanner.cs +++ b/pseudocodeIde/interpreter/scanner/Scanner.cs @@ -76,6 +76,10 @@ static Scanner() KEYWORDS.Add("NEU", NEW); KEYWORDS.Add("NICHTS", NULL); + + KEYWORDS.Add("schreibe", IDENTIFIER); + KEYWORDS.Add("warte", IDENTIFIER); + KEYWORDS.Add("benutzereingabe", IDENTIFIER); } public Scanner(string code) diff --git a/pseudocodeIde/pseudocodeIde.csproj b/pseudocodeIde/pseudocodeIde.csproj index 5112c9a..5e413ad 100644 --- a/pseudocodeIde/pseudocodeIde.csproj +++ b/pseudocodeIde/pseudocodeIde.csproj @@ -8,7 +8,7 @@ pseudocode-ide PocketMiner82 pseudocode-ide - 1.2.7 + 1.3.0.4 false false @@ -37,7 +37,7 @@ - + all @@ -45,6 +45,8 @@ + + @@ -67,12 +69,6 @@ - - Form - - - FindReplaceForm.cs - Form @@ -85,9 +81,6 @@ OutputForm.cs - - FindReplaceForm.cs - OutputForm.cs diff --git a/pseudocodeIdeUpdater/Program.cs b/pseudocodeIdeUpdater/Program.cs index d9902ac..912c879 100644 --- a/pseudocodeIdeUpdater/Program.cs +++ b/pseudocodeIdeUpdater/Program.cs @@ -24,6 +24,7 @@ static void Main(string[] args) { string path = args[0]; bool firstRun = bool.Parse(args[1]); + bool beta = bool.Parse(args[2]); if (!firstRun) { @@ -41,9 +42,25 @@ static void Main(string[] args) AutoUpdater.ExecutablePath = "pseudocode-ide.exe"; Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; - AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}"); + + if (assemblyVersion.Revision > 0) + { + // beta release + AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}.{assemblyVersion.Revision}"); + } + else if (assemblyVersion.Revision > 0 && !beta) + { + // hack to allow to go back to stable release, as the last version tag (pre release count) will be missing + // without this hack, the AutoUpdater would think that the new release is a lower version than this + AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major - 1}.{assemblyVersion.Minor}.{assemblyVersion.Build}"); + } + else + { + // stable release + AutoUpdater.InstalledVersion = new Version($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}"); + } - AutoUpdater.Start("https://raw.githubusercontent.com/PocketMiner82/pseudocode-ide/main/AutoUpdater.xml"); + AutoUpdater.Start($"https://raw.githubusercontent.com/PocketMiner82/pseudocode-ide/{(beta ? "dev" : "main")}/AutoUpdater.xml"); } catch diff --git a/pseudocodeIdeUpdater/pseudocodeIdeUpdater.csproj b/pseudocodeIdeUpdater/pseudocodeIdeUpdater.csproj index e2584bb..21c0c4d 100644 --- a/pseudocodeIdeUpdater/pseudocodeIdeUpdater.csproj +++ b/pseudocodeIdeUpdater/pseudocodeIdeUpdater.csproj @@ -7,7 +7,7 @@ pseudocodeIdeUpdater Copyright © 2023 ..\bin\$(Configuration)\updater\ - 1.2.7 + 1.3.0.4 false false false