From 1ac6d7790b03b527a8de05a8e72da2127737907c Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:43:53 +0200 Subject: [PATCH] Automatically redraw console window when size chnages --- YesNt.CodeEditor/Editor.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/YesNt.CodeEditor/Editor.cs b/YesNt.CodeEditor/Editor.cs index 7c8c08b..d88677b 100644 --- a/YesNt.CodeEditor/Editor.cs +++ b/YesNt.CodeEditor/Editor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Timers; using YesNt.Interpreter.Runtime; @@ -36,6 +37,22 @@ internal class TextEditor syntaxHighlighter = new(YesNtInterpreter.StatementInformation); inputHandler = new InputHandler(this); Console.CancelKeyPress += Console_CancelKeyPress; + + Timer timer = new Timer(500); + timer.Elapsed += (s, e) => + { + if (SizeChanged() && EditMode != Mode.Debug) + { + Display(true); + + if (EditMode == Mode.Command) + { + InputHandler.WriteStatus(string.Empty); + Console.SetCursorPosition(3, Console.WindowHeight - 2); + } + } + }; + timer.Start(); } public void Run()