From 5eff9e1c6fc2555f0720c6dac5c6c439ff14044e Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Wed, 12 Jan 2011 20:14:38 -0500 Subject: [PATCH] Extensions: Removed mask on ScriptText and added function GetSelectedText. --- Projects/Simba/psextension.pas | 1 + Units/MMLAddon/PSInc/Wrappers/extensions.inc | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Projects/Simba/psextension.pas b/Projects/Simba/psextension.pas index f8c83d5..47756e9 100644 --- a/Projects/Simba/psextension.pas +++ b/Projects/Simba/psextension.pas @@ -192,6 +192,7 @@ begin AddFunction(@ext_MessageDlg,'function MessageDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer;'); AddFunction(@ext_InputQuery,'function InputQuery(const ACaption, APrompt : String; var Value : String) : Boolean;'); AddFunction(@ext_ScriptText,'function ScriptText: string;'); + AddFunction(@ext_GetSelectedText, 'function GetSelectedText: string;'); AddFunction(@ext_OpenScript,'procedure OpenScript(Name, Data: string; Run: boolean);'); AddFunction(@ext_OpenScriptEx,'procedure OpenScriptEx(FileName: string; Run: boolean);'); AddRegisteredPTRVariable('Settings','TMMLSettingsSandbox'); diff --git a/Units/MMLAddon/PSInc/Wrappers/extensions.inc b/Units/MMLAddon/PSInc/Wrappers/extensions.inc index 3e0d1ce..b125994 100644 --- a/Units/MMLAddon/PSInc/Wrappers/extensions.inc +++ b/Units/MMLAddon/PSInc/Wrappers/extensions.inc @@ -126,7 +126,23 @@ end; function ext_ScriptText: string; begin Result := SimbaForm.CurrScript.SynEdit.Lines.Text; - Result := ReplaceRegExpr('([N|n][A|a][M|m][E|e]|[P|p][A|a][S|s]{2}|[P|p][I|i][N|n])\s*\:\=\s*\''.*?\'';', Result, '$1 := ''*********'';', True); +end; + +function ext_GetSelectedText: string; +var + I: integer; +begin + with SimbaForm.CurrScript.SynEdit do + begin + if (not (BlockBegin.Y = BlockEnd.Y)) then + begin + Result := Copy(Lines[BlockBegin.Y - 1], BlockBegin.X, Length(Lines[BlockBegin.Y - 1])) + MEOL; + for I := BlockBegin.Y + 1 to BlockEnd.Y - 1 do + Result := Result + Lines[I - 1] + MEOL; + Result := Result + Copy(Lines[BlockEnd.Y - 1], 1, BlockEnd.X - 1); + end else + Result := Copy(Lines[BlockBegin.Y - 1], BlockBegin.X, BlockEnd.X - BlockBegin.X); + end; end; procedure ext_OpenScript(vName, Data: string; Run: boolean);