From 6e40ae80f39c766d611b4ca29aea0f6685db80dc Mon Sep 17 00:00:00 2001 From: MichaelTheShifter Date: Mon, 4 Jul 2016 17:43:04 -0400 Subject: Add luatextbox widget and more. - Syntax highlighting textbox for Lua API - That textbox also supports C# syntax highlighting - Added framework for custom desktop environments in Lua. --- .../WindowsFormsApplication1/Engine/Lua_Interp.cs | 136 ++++++++++++++++++++- 1 file changed, 132 insertions(+), 4 deletions(-) (limited to 'source/WindowsFormsApplication1/Engine') diff --git a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs index ed9c31f..21acb3c 100644 --- a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs +++ b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs @@ -111,6 +111,128 @@ namespace ShiftOS /// public void RegisterCore() { + //Desktop environment + mod.on_unity_check += new Action((desktop, func) => + { + desktop.OnUnityCheck += () => + { + mod(func + "()"); + }; + }); + mod.on_desktop_reset += new Action((desktop, func) => + { + desktop.OnDesktopReload += () => + { + mod(func + "()"); + }; + }); + mod.on_clock_skin += new Action((desktop, func) => + { + desktop.OnClockSkin += () => + { + mod(func + "()"); + }; + }); + mod.on_window_open += new Action((desktop, func) => + { + desktop.WindowOpened += (win) => + { + mod.win = win; + mod(func + "(win)"); + }; + }); + mod.on_window_close += new Action((desktop, func) => + { + desktop.WindowClosed += (win) => + { + mod.win = win; + mod(func + "(win)"); + }; + }); + mod.on_window_titlebar_redraw += new Action((desktop, func) => + { + desktop.TitlebarReset += (win) => + { + mod.win = win; + mod(func + "(win)"); + }; + }); + mod.on_window_border_redraw += new Action((desktop, func) => + { + desktop.BorderReset += (win) => + { + mod.win = win; + mod(func + "(win)"); + }; + }); + mod.on_window_skin += new Action((desktop, func) => + { + desktop.WindowSkinReset += (win) => + { + mod.win = win; + mod(func + "(win)"); + }; + }); + mod.get_border = new Func((Form win) => + { + WindowBorder b = null; + foreach(Control c in win.Controls) + { + if ((string)c.Tag == "api_brdr") + b = (WindowBorder)c; + } + return b; + }); + + mod.on_app_launcher_populate += new Action((desktop, func) => + { + desktop.OnAppLauncherPopulate += (items) => + { + mod.al_items = items; + mod(func + "(clr_to_table(al_items))"); + }; + }); + mod.on_panelbutton_populate += new Action((desktop, func) => + { + desktop.OnPanelButtonPopulate += (items) => + { + mod.pb_items = items; + mod(func + "(clr_to_table(pb_items))"); + }; + }); + mod.intercept_ctrlt += new Action((func) => + { + API.CurrentSession.AllowCtrlTIntercept(); + API.CurrentSession.CtrlTPressed += () => + { + mod(func + "()"); + }; + }); + mod.stop_intercept_ctrlt += new Action(() => + { + API.CurrentSession.DisableCtrlTIntercept(); + + }); + + mod.on_desktopicon_populate += new Action((desktop, func) => + { + desktop.DesktopIconsPopulated += (items) => + { + mod.dl_items = items; + mod(func + "(clr_to_table(dl_items))"); + }; + }); + + + mod(@"function clr_to_table(clrlist) + local t = {} + local it = clrlist:GetEnumerator() + while it:MoveNext() do + t[#t+1] = it.Current + end + return t +end"); + mod.httpget = new Func((url) => { WebRequest request = WebRequest.Create(url); @@ -533,7 +655,7 @@ namespace ShiftOS } }; }); - mod.gen_font = new Func((style, size) => { + mod.font = new Func((style, size) => { return new Font(style, size); }); @@ -817,9 +939,9 @@ namespace ShiftOS API.CreateFileSkimmerSession(fi, File_Skimmer.FileSkimmerMode.Open); API.FileSkimmerSession.FormClosing += (object s, FormClosingEventArgs a) => { - mod($"{fu}({API.GetFSResult()})"); + mod($"{fu}(\"{API.GetFSResult().Replace(Paths.SaveRoot, "").Replace("\\", "/")}\")"); }; - } + } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// /// Prompt user to save a file. @@ -831,7 +953,7 @@ namespace ShiftOS API.CreateFileSkimmerSession(fi, File_Skimmer.FileSkimmerMode.Save); API.FileSkimmerSession.FormClosing += (object s, FormClosingEventArgs a) => { - mod($"{fu}({API.GetFSResult()})"); + mod($"{fu}(\"{API.GetFSResult().Replace(Paths.SaveRoot, "").Replace("\\", "/")}\")"); }; } @@ -933,6 +1055,12 @@ namespace ShiftOS var ctrl = new Control(); switch(type.ToLower()) { + case "luatextbox": + var stxt = new SyntaxRichTextBox(); + stxt.Text = text; + stxt.SetLanguage(SyntaxSettings.Language.Lua); + ctrl = stxt; + break; case "button": var btn = new Button(); btn.FlatStyle = FlatStyle.Flat; -- cgit v1.2.3