From 34a23223118bf97ab9c381c42b4af8b20a92410a Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Tue, 3 May 2011 01:10:49 -0400 Subject: [PATCH 1/8] Extension: Paster Update --- Extensions/paster.sex | 113 +++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 51 deletions(-) diff --git a/Extensions/paster.sex b/Extensions/paster.sex index 5106a45..431eae1 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -10,17 +10,17 @@ end; function GetVersion: string; begin; - Result := '0.4a'; + Result := '0.5'; end; {$IFDEF EXTENSION} var Paster_Menu, GetPaste_MenuItem, Private_MenuItem, - Browser_MenuItem, Paster_MenuItem, AltHost_Menu: TMenuItem; - Divider_MenuItems: array[1..2] of TMenuItem; + Browser_MenuItem, AltHost_Menu: TMenuItem; + Paster_MenuItems, Divider_MenuItems: array[1..2] of TMenuItem; AltHost_Menus: array[1..5] of TMenuItem; - AltHost_MenuItems: array[1..5] of array[1..5] of TMenuItem; + AltHost_MenuItems: array[1..5] of array[1..6] of TMenuItem; function EncodeString(Data: string): string; var @@ -97,13 +97,13 @@ begin end; end; -function PasteIt(out Data: string; HOST: string): boolean; +function PasteIt(out Data: string; HOST, S: string): boolean; var ScriptTextEx: string; begin if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Upload this script to ' + HOST + '?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then begin - ScriptTextEx := ScriptText; + ScriptTextEx := S; if (ExecRegExpr('([N|n][A|a][M|m][E|e]|[P|p][A|a][S|s]{2}|[P|p][I|i][N|n])', ScriptTextEx)) then if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Would you like to mask sensitive data?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then @@ -120,13 +120,20 @@ begin end; end; -procedure Paste(Host: string); +procedure Paste(Host, S: string); var Data: string; begin if (HOST = '') then HOST := HOSTDef; - if PasteIt(Data, Host) then + + if (S = '') then + begin + WriteLn('[Paster]Error: Ether your script is empty or you didn''t select any text.'); + Exit; + end; + + if PasteIt(Data, Host, S) then begin if (Browser_MenuItem.Checked) then begin @@ -145,9 +152,9 @@ begin Settings.setKeyValue('DefaultHost', IntToStr(I)); for J := 1 to 5 do if (J = I) then - AltHost_MenuItems[J][4].Checked := True + AltHost_MenuItems[J][5].Checked := True else - AltHost_MenuItems[J][4].Checked := False; + AltHost_MenuItems[J][5].Checked := False; end; procedure UpdateHost(I: integer); @@ -167,7 +174,8 @@ begin AltHost_Menus[I].Caption := 'Host ' + IntToStr(I); AltHost_MenuItems[I][1].Enabled := False; AltHost_MenuItems[I][2].Enabled := False; - AltHost_MenuItems[I][4].Enabled := False; + AltHost_MenuItems[I][3].Enabled := False; + AltHost_MenuItems[I][5].Enabled := False; Settings.setKeyValue('Host' + IntToStr(I), 'Host ' + IntToStr(I)); if (Settings.getKeyValueDef('DefaultHost', '1') = IntToStr(I)) then UpdateDefault(1); @@ -176,7 +184,8 @@ begin AltHost_Menus[I].Caption := Data; AltHost_MenuItems[I][1].Enabled := True; AltHost_MenuItems[I][2].Enabled := True; - AltHost_MenuItems[I][4].Enabled := True; + AltHost_MenuItems[I][3].Enabled := True; + AltHost_MenuItems[I][5].Enabled := True; Settings.setKeyValue('Host' + IntToStr(I), Data); end; end; @@ -190,8 +199,11 @@ begin; WriteLn('Sender is '#39 + TMenuItem(Sender).Name + #39'.'); //(Sender as TMenuItem).Name {$ENDIF} case Sender of - Paster_MenuItem: Paste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1'))); + Paster_MenuItems[1]: Paste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1')), ScriptText); + Paster_MenuItems[2]: Paste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1')), GetSelectedText); + GetPaste_MenuItem: GetPaste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1'))); + Private_MenuItem: begin Private_MenuItem.Checked := (not (Private_MenuItem.Checked)); Settings.setKeyValue('Private', Lowercase(BoolToStr(Private_MenuItem.Checked))); @@ -203,15 +215,17 @@ begin; {$IFDEF DEV}WriteLn('OpenBrowser = ' + Lowercase(BoolToStr(Browser_MenuItem.Checked)));{$ENDIF} end; end; + for I := 1 to 5 do - for K := 1 to 5 do + for K := 1 to 6 do if (Sender = AltHost_MenuItems[I][K]) then begin case K of - 1: Paste(Settings.getKeyValue('Host' + IntToStr(I))); - 2: GetPaste(Settings.getKeyValue('Host' + IntToStr(I))); - 4: UpdateDefault(I); - 5: UpdateHost(I); + 1: Paste(Settings.getKeyValue('Host' + IntToStr(I)), ScriptText); + 2: Paste(Settings.getKeyValue('Host' + IntToStr(I)), GetSelectedText); + 3: GetPaste(Settings.getKeyValue('Host' + IntToStr(I))); + 5: UpdateDefault(I); + 6: UpdateHost(I); end; Break; end; @@ -228,24 +242,6 @@ begin Paster_Menu.Visible := False; end; -procedure Free; -{var - I, K: integer;} -begin - {for I := 5 downto 1 do - begin - for K := 5 downto 1 do - AltHost_MenuItems[I][K].Free; - AltHost_Menus[I].Free; - end; - AltHost_Menu.Free; - Private_MenuItem.Free; - for I := 2 downto 1 do - Divider_MenuItems[I].Free; - Paster_MenuItem.Free; - Paster_Menu.Free;} -end; - procedure init; var I, K: integer; @@ -254,14 +250,23 @@ begin; Paster_Menu.Caption := GetName; Simba_MainMenu.Items.Add(Paster_Menu); - Paster_MenuItem := TMenuItem.Create(Paster_Menu); - with Paster_MenuItem do + Paster_MenuItems[1] := TMenuItem.Create(Paster_Menu); + with Paster_MenuItems[1] do begin Name := 'Default_Paste'; Caption := 'Paste It!'; OnClick := @OnClick; end; - Paster_Menu.Add(Paster_MenuItem); + Paster_Menu.Add(Paster_MenuItems[1]); + + Paster_MenuItems[2] := TMenuItem.Create(Paster_Menu); + with Paster_MenuItems[2] do + begin + Name := 'Default_PasteS'; + Caption := 'Paste Selection!'; + OnClick := @OnClick; + end; + Paster_Menu.Add(Paster_MenuItems[2]); GetPaste_MenuItem := TMenuItem.Create(Paster_Menu); with GetPaste_MenuItem do @@ -315,7 +320,7 @@ begin; AltHost_Menus[I].Caption := Settings.getKeyValueDef('Host' + IntToStr(I), 'Host ' + IntToStr(I)); AltHost_Menu.Add(AltHost_Menus[I]); - for K := 1 to 5 do + for K := 1 to 6 do begin AltHost_MenuItems[I][K] := TMenuItem.Create(AltHost_Menus[I]); case K of @@ -324,24 +329,30 @@ begin; AltHost_MenuItems[I][1].Caption := 'Paste It!'; end; 2: begin - AltHost_MenuItems[I][2].Name := 'Host' + IntToStr(I) + '_GetPaste'; - AltHost_MenuItems[I][2].Caption := 'Get Paste!'; + AltHost_MenuItems[I][2].Name := 'Host' + IntToStr(I) + '_PasteS'; + AltHost_MenuItems[I][2].Caption := 'Paste Selection!'; end; - 3: AltHost_MenuItems[I][3].Caption := '-'; - 4: begin - AltHost_MenuItems[I][4].Name := 'Host' + IntToStr(I) + '_Default'; - AltHost_MenuItems[I][4].Caption := 'Default'; - AltHost_MenuItems[I][4].Checked := (Settings.getKeyValueDef('DefaultHost', '1') = IntToStr(I)); + 3: begin + AltHost_MenuItems[I][3].Name := 'Host' + IntToStr(I) + '_GetPaste'; + AltHost_MenuItems[I][3].Caption := 'Get Paste!'; end; + 4: AltHost_MenuItems[I][4].Caption := '-'; 5: begin - AltHost_MenuItems[I][5].Name := 'Host' + IntToStr(I) + '_Update'; - AltHost_MenuItems[I][5].Caption := 'Update Host'; + AltHost_MenuItems[I][5].Name := 'Host' + IntToStr(I) + '_Default'; + AltHost_MenuItems[I][5].Caption := 'Default'; + AltHost_MenuItems[I][5].Checked := (Settings.getKeyValueDef('DefaultHost', '1') = IntToStr(I)); + end; + 6: begin + AltHost_MenuItems[I][6].Name := 'Host' + IntToStr(I) + '_Update'; + AltHost_MenuItems[I][6].Caption := 'Update Host'; end; end; AltHost_MenuItems[I][K].OnClick := @OnClick; - if ((not ((K = 3) or (K = 5))) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then + + if ((not ((K = 4) or (K = 6))) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then AltHost_MenuItems[I][K].Enabled := False; - if ((I = 1) and (K = 5)) then + + if ((I = 1) and (K = 6)) then AltHost_MenuItems[I][K].Visible := False; AltHost_Menus[I].Add(AltHost_MenuItems[I][K]); end; From 3a7e6841c5020c57152bb6a11b0918d68dfd0d2a Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Tue, 3 May 2011 14:24:11 -0400 Subject: [PATCH 2/8] Extensions: Paster Update --- Extensions/paster.sex | 244 +++++++++++++++++++++++++----------------- 1 file changed, 148 insertions(+), 96 deletions(-) diff --git a/Extensions/paster.sex b/Extensions/paster.sex index 431eae1..fb3d34c 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -2,7 +2,7 @@ program Paster; //{$DEFINE DEV} const HOSTDef = 'paste.villavu.com'; - + function GetName: string; begin; Result := 'Paster'; @@ -10,17 +10,31 @@ end; function GetVersion: string; begin; - Result := '0.5'; + Result := '1.0'; end; {$IFDEF EXTENSION} +type + TAltHost_Menu = record + Index: integer; + Menu: TMenuItem; + Paste_MenuItem: TMenuItem; + PasteS_MenuItem: TMenuItem; + GetPaste_MenuItem: TMenuItem; + Divider_MenuItem: TMenuItem; + Default_MenuItem: TMenuItem; + Update_MenuItem: TMenuItem; + Delete_MenuItem: TMenuItem; + end; + TAltHost_Menus = array of TAltHost_Menu; + var Paster_Menu, GetPaste_MenuItem, Private_MenuItem, - Browser_MenuItem, AltHost_Menu: TMenuItem; - Paster_MenuItems, Divider_MenuItems: array[1..2] of TMenuItem; - AltHost_Menus: array[1..5] of TMenuItem; - AltHost_MenuItems: array[1..5] of array[1..6] of TMenuItem; + Browser_MenuItem, AltHost_Menu, AltHostAdd_MenuItem: TMenuItem; + Paster_MenuItems: array[1..2] of TMenuItem; + Divider_MenuItems: array[1..3] of TMenuItem; + AltHost_Menus: TAltHost_Menus; function EncodeString(Data: string): string; var @@ -145,16 +159,14 @@ begin WriteLn(Data); end; -procedure UpdateDefault(I: integer); +procedure UpdateDefault(Index: integer); var - J: integer; + I: integer; begin - Settings.setKeyValue('DefaultHost', IntToStr(I)); - for J := 1 to 5 do - if (J = I) then - AltHost_MenuItems[J][5].Checked := True - else - AltHost_MenuItems[J][5].Checked := False; + Settings.setKeyValue('DefaultHost', IntToStr(Index)); + for I := 0 to High(AltHost_Menus) do + AltHost_Menus[I].Default_MenuItem.Checked := False; + AltHost_Menus[Index].Default_MenuItem.Checked := True end; procedure UpdateHost(I: integer); @@ -165,34 +177,82 @@ begin begin {$IFDEF DEV}WriteLn('Data := '#39 + Data + #39';');{$ENDIF} if (Data = '') then - if (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I)) then - begin - WriteLn('[Paster]Error: The host cannot be blank!'); - Exit; - end else - begin - AltHost_Menus[I].Caption := 'Host ' + IntToStr(I); - AltHost_MenuItems[I][1].Enabled := False; - AltHost_MenuItems[I][2].Enabled := False; - AltHost_MenuItems[I][3].Enabled := False; - AltHost_MenuItems[I][5].Enabled := False; - Settings.setKeyValue('Host' + IntToStr(I), 'Host ' + IntToStr(I)); - if (Settings.getKeyValueDef('DefaultHost', '1') = IntToStr(I)) then - UpdateDefault(1); - Exit; - end; - AltHost_Menus[I].Caption := Data; - AltHost_MenuItems[I][1].Enabled := True; - AltHost_MenuItems[I][2].Enabled := True; - AltHost_MenuItems[I][3].Enabled := True; - AltHost_MenuItems[I][5].Enabled := True; - Settings.setKeyValue('Host' + IntToStr(I), Data); + begin + WriteLn('[Paster]Error: The host cannot be blank!'); + Exit; + end; + + AltHost_Menus[I].Menu.Caption := Data; + Settings.setKeyValue('Host' + IntToStr(AltHost_Menus[I].Index), Data); + end; +end; + +procedure OnClick(Sender: TObject); forward; + +procedure CreateAltMenu(I: integer); +var + J: integer; +begin + J := Length(AltHost_Menus); + SetLength(AltHost_Menus, J + 1); + with AltHost_Menus[J] do + begin + Index := I; + + Divider_MenuItems[3].Visible := (Divider_MenuItems[3].MenuIndex > 0); + + Menu := TMenuItem.Create(AltHost_Menu); + Menu.Name := 'Host_' + IntToStr(I) + '_Menu' + Menu.Caption := Settings.getKeyValueDef('Host' + IntToStr(I), ''); + AltHost_Menu.Insert(Divider_MenuItems[3].MenuIndex, Menu); + + Paste_MenuItem := TMenuItem.Create(Menu); + Paste_MenuItem.Name := Menu.Name + '_Paste'; + Paste_MenuItem.Caption := 'Paste'; + Paste_MenuItem.OnClick := @OnClick; + Menu.Add(Paste_MenuItem); + + PasteS_MenuItem := TMenuItem.Create(Menu); + PasteS_MenuItem.Name := Menu.Name + '_PasteS'; + PasteS_MenuItem.Caption := 'Paste Selection'; + PasteS_MenuItem.OnClick := @OnClick; + Menu.Add(PasteS_MenuItem); + + GetPaste_MenuItem := TMenuItem.Create(Menu); + GetPaste_MenuItem.Name := Menu.Name + '_GetPaste'; + GetPaste_MenuItem.Caption := 'Get Paste'; + GetPaste_MenuItem.OnClick := @OnClick; + Menu.Add(GetPaste_MenuItem); + + Divider_MenuItem := TMenuItem.Create(Menu); + Divider_MenuItem.Caption := '-'; + Menu.Add(Divider_MenuItem); + + Default_MenuItem := TMenuItem.Create(Menu); + Default_MenuItem.Name := Menu.Name + '_Default'; + Default_MenuItem.Caption := 'Default'; + Default_MenuItem.Checked := (Settings.getKeyValueDef('DefaultHost', '1') = IntToStr(I)); + Default_MenuItem.OnClick := @OnClick; + Menu.Add(Default_MenuItem); + + Update_MenuItem := TMenuItem.Create(Menu); + Update_MenuItem.Name := Menu.Name + '_Update'; + Update_MenuItem.Caption := 'Update Host'; + Update_MenuItem.OnClick := @OnClick; + Menu.Add(Update_MenuItem); + + { Delete_MenuItem := TMenuItem.Create(Menu); + Delete_MenuItem.Name := Menu.Name + '_Delete'; + Delete_MenuItem.Caption := 'Delete Host'; + Delete_MenuItem.OnClick := @OnClick; + Menu.Add(Delete_MenuItem); } // This is annoying to do so lets just leave it out for now... end; end; procedure OnClick(Sender: TObject); var I, K: integer; + Data: string; begin; {$IFDEF DEV} if (Sender is TMenuItem) then @@ -204,6 +264,25 @@ begin; GetPaste_MenuItem: GetPaste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1'))); + AltHostAdd_MenuItem: begin + I := 1; + while (Settings.IsKey('Host' + IntToStr(I))) do + Inc(I); + + if InputQuery(GetName + ' ' + GetVersion + ' Extension', 'Please input the LodgeIt Host! (Ex: paste.pocoo.org)', Data) then + begin + {$IFDEF DEV}WriteLn('Data := '#39 + Data + #39';');{$ENDIF} + if (Data = '') then + begin + WriteLn('[Paster]Error: The host cannot be blank!'); + Exit; + end; + + Settings.setKeyValue('Host' + IntToStr(I), Data); + CreateAltMenu(I); + end; + end; + Private_MenuItem: begin Private_MenuItem.Checked := (not (Private_MenuItem.Checked)); Settings.setKeyValue('Private', Lowercase(BoolToStr(Private_MenuItem.Checked))); @@ -216,18 +295,14 @@ begin; end; end; - for I := 1 to 5 do - for K := 1 to 6 do - if (Sender = AltHost_MenuItems[I][K]) then - begin - case K of - 1: Paste(Settings.getKeyValue('Host' + IntToStr(I)), ScriptText); - 2: Paste(Settings.getKeyValue('Host' + IntToStr(I)), GetSelectedText); - 3: GetPaste(Settings.getKeyValue('Host' + IntToStr(I))); - 5: UpdateDefault(I); - 6: UpdateHost(I); - end; - Break; + for I := 0 to High(AltHost_Menus) do + with AltHost_Menus[I] do + case Sender of + Paste_MenuItem: Paste(Settings.getKeyValue('Host' + IntToStr(Index)), ScriptText); + PasteS_MenuItem: Paste(Settings.getKeyValue('Host' + IntToStr(Index)), GetSelectedText); + GetPaste_MenuItem: GetPaste(Settings.getKeyValue('Host' + IntToStr(Index))); + Default_MenuItem: UpdateDefault(I); + Update_MenuItem: UpdateHost(I); end; end; @@ -242,14 +317,14 @@ begin Paster_Menu.Visible := False; end; -procedure init; +procedure Init; var I, K: integer; begin; Paster_Menu := TMenuItem.Create(Simba_MainMenu); Paster_Menu.Caption := GetName; Simba_MainMenu.Items.Add(Paster_Menu); - + Paster_MenuItems[1] := TMenuItem.Create(Paster_Menu); with Paster_MenuItems[1] do begin @@ -306,56 +381,32 @@ begin; Paster_Menu.Add(Browser_MenuItem); Paster_Menu.Add(Divider_MenuItems[2]); - + AltHost_Menu := TMenuItem.Create(Paster_Menu); AltHost_Menu.Caption := 'Hosts'; Paster_Menu.Add(AltHost_Menu); - - for I := 1 to 5 do + + Divider_MenuItems[3] := TMenuItem.Create(AltHost_Menu); + Divider_MenuItems[3].Caption := '-'; + Divider_MenuItems[3].Visible := False; + AltHost_Menu.Add(Divider_MenuItems[3]); + + AltHostAdd_MenuItem := TMenuItem.Create(AltHost_Menu); + AltHostAdd_MenuItem.Name := 'AddHost'; + AltHostAdd_MenuItem.Caption := 'Add Host'; + AltHostAdd_MenuItem.OnClick := @OnClick; + AltHost_Menu.Add(AltHostAdd_MenuItem); + + if (not (Settings.IsKey('Host1'))) then + Settings.setKeyValue('Host1', HOSTDef); + + I := 1; + while (Settings.IsKey('Host' + IntToStr(I))) do begin - AltHost_Menus[I] := TMenuItem.Create(AltHost_Menu); - if (I = 1) then - AltHost_Menus[I].Caption := HOSTDef - else - AltHost_Menus[I].Caption := Settings.getKeyValueDef('Host' + IntToStr(I), 'Host ' + IntToStr(I)); - AltHost_Menu.Add(AltHost_Menus[I]); - - for K := 1 to 6 do - begin - AltHost_MenuItems[I][K] := TMenuItem.Create(AltHost_Menus[I]); - case K of - 1: begin - AltHost_MenuItems[I][1].Name := 'Host' + IntToStr(I) + '_Paste'; - AltHost_MenuItems[I][1].Caption := 'Paste It!'; - end; - 2: begin - AltHost_MenuItems[I][2].Name := 'Host' + IntToStr(I) + '_PasteS'; - AltHost_MenuItems[I][2].Caption := 'Paste Selection!'; - end; - 3: begin - AltHost_MenuItems[I][3].Name := 'Host' + IntToStr(I) + '_GetPaste'; - AltHost_MenuItems[I][3].Caption := 'Get Paste!'; - end; - 4: AltHost_MenuItems[I][4].Caption := '-'; - 5: begin - AltHost_MenuItems[I][5].Name := 'Host' + IntToStr(I) + '_Default'; - AltHost_MenuItems[I][5].Caption := 'Default'; - AltHost_MenuItems[I][5].Checked := (Settings.getKeyValueDef('DefaultHost', '1') = IntToStr(I)); - end; - 6: begin - AltHost_MenuItems[I][6].Name := 'Host' + IntToStr(I) + '_Update'; - AltHost_MenuItems[I][6].Caption := 'Update Host'; - end; - end; - AltHost_MenuItems[I][K].OnClick := @OnClick; - - if ((not ((K = 4) or (K = 6))) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then - AltHost_MenuItems[I][K].Enabled := False; - - if ((I = 1) and (K = 6)) then - AltHost_MenuItems[I][K].Visible := False; - AltHost_Menus[I].Add(AltHost_MenuItems[I][K]); - end; + if (Settings.GetKeyValue('Host' + IntToStr(I)) = 'Host ' + IntToStr(I)) then + Continue; + CreateAltMenu(I); + Inc(I); end; end; {$ENDIF} @@ -369,3 +420,4 @@ begin {$ENDIF} end. + From 0ba8287468c4ef5471e2ee4b7a9f76d332a3d5de Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Fri, 6 May 2011 18:08:36 -0400 Subject: [PATCH 3/8] Extension: Paster Update --- Extensions/paster.sex | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Extensions/paster.sex b/Extensions/paster.sex index fb3d34c..d62ea95 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -317,10 +317,47 @@ begin Paster_Menu.Visible := False; end; +procedure UpdateCheck; +var + V, S: string; + I: integer; + SA: TStringArray; +begin + if (not (Settings.isKey('Version'))) then + Settings.setKeyValue('Version', '-1'); + + V := Settings.getKeyValue('Version'); + if (V = GetVersion) then + Exit; + + case V of + '-1', '0.4a': begin + SetLength(SA, 2); + SA[1] := HOSTDef; + for I := 2 to 5 do + begin + S := Settings.getKeyValueDef('Host' + IntToStr(I), 'Host' + IntToStr(I)); + if (S <> 'Host' + IntToStr(I)) then + begin + SetLength(SA, Length(SA) + 1); + SA[High(SA)] := S; + end; + Settings.DeleteKey('Host' + IntToStr(I)); + end; + for I := 1 to High(SA) do + Settings.setKeyValue('Host' + IntToStr(I), SA[I]); + end; + end; + + Settings.setKeyValue('Version', GetVersion); +end; + procedure Init; var I, K: integer; begin; + UpdateCheck; + Paster_Menu := TMenuItem.Create(Simba_MainMenu); Paster_Menu.Caption := GetName; Simba_MainMenu.Items.Add(Paster_Menu); From ed621254dd37948fe550025d58bc8094e6425f50 Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Fri, 6 May 2011 18:13:41 -0400 Subject: [PATCH 4/8] Extension: Paster Update --- Extensions/paster.sex | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Extensions/paster.sex b/Extensions/paster.sex index d62ea95..4f9c489 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -120,8 +120,15 @@ begin ScriptTextEx := S; if (ExecRegExpr('([N|n][A|a][M|m][E|e]|[P|p][A|a][S|s]{2}|[P|p][I|i][N|n])', ScriptTextEx)) then - if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Would you like to mask sensitive data?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then - ScriptTextEx := ReplaceRegExpr('([N|n][A|a][M|m][E|e]|[P|p][A|a][S|s]{2}|[P|p][I|i][N|n])\s*\:\=\s*\''.*?\'';', ScriptTextEx, '$1 := ''*********'';', True); + case (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Would you like to mask sensitive data?', mtConfirmation, [mbYes, mbNo, mbCancel], 0)) of + mrYes: ScriptTextEx := ReplaceRegExpr('([N|n][A|a][M|m][E|e]|[P|p][A|a][S|s]{2}|[P|p][I|i][N|n])\s*\:\=\s*\''.*?\'';', ScriptTextEx, '$1 := ''*********'';', True); + mrNo: WriteLn('[Paster]Warning: Not masking data!'); + else + begin + WriteLn('[Paster]: Paste canceled'); + Exit; + end; + end; Data := '{"language": "delphi", "code": "' + EncodeString(ScriptTextEx) + '", "private": ' + Lowercase(BoolToStr(Private_MenuItem.Checked)) + '}'; JSONRequest(Data, HOST, 'pastes.newPaste'); From a05281804b4812c9cc8ce3f47f35be887626263d Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Sat, 7 May 2011 17:11:08 -0400 Subject: [PATCH 5/8] Extension: Paster Update --- Extensions/paster.sex | 109 +++++++++++++++++++++++++++++------------- 1 file changed, 77 insertions(+), 32 deletions(-) diff --git a/Extensions/paster.sex b/Extensions/paster.sex index 4f9c489..3e479fd 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -35,6 +35,7 @@ var Paster_MenuItems: array[1..2] of TMenuItem; Divider_MenuItems: array[1..3] of TMenuItem; AltHost_Menus: TAltHost_Menus; + AltHost_Top: integer; function EncodeString(Data: string): string; var @@ -172,8 +173,11 @@ var begin Settings.setKeyValue('DefaultHost', IntToStr(Index)); for I := 0 to High(AltHost_Menus) do - AltHost_Menus[I].Default_MenuItem.Checked := False; - AltHost_Menus[Index].Default_MenuItem.Checked := True + AltHost_Menus[I].Default_MenuItem.Checked := (Index = AltHost_Menus[I].Index); + + Paster_MenuItems[1].Enabled := (Settings.getKeyValueDef('DefaultHost', '-1') <> '-1'); + Paster_MenuItems[2].Enabled := (Settings.getKeyValueDef('DefaultHost', '-1') <> '-1'); + GetPaste_MenuItem.Enabled := (Settings.getKeyValueDef('DefaultHost', '-1') <> '-1'); end; procedure UpdateHost(I: integer); @@ -206,8 +210,6 @@ begin begin Index := I; - Divider_MenuItems[3].Visible := (Divider_MenuItems[3].MenuIndex > 0); - Menu := TMenuItem.Create(AltHost_Menu); Menu.Name := 'Host_' + IntToStr(I) + '_Menu' Menu.Caption := Settings.getKeyValueDef('Host' + IntToStr(I), ''); @@ -215,7 +217,7 @@ begin Paste_MenuItem := TMenuItem.Create(Menu); Paste_MenuItem.Name := Menu.Name + '_Paste'; - Paste_MenuItem.Caption := 'Paste'; + Paste_MenuItem.Caption := 'Paste Script'; Paste_MenuItem.OnClick := @OnClick; Menu.Add(Paste_MenuItem); @@ -248,11 +250,11 @@ begin Update_MenuItem.OnClick := @OnClick; Menu.Add(Update_MenuItem); - { Delete_MenuItem := TMenuItem.Create(Menu); + Delete_MenuItem := TMenuItem.Create(Menu); Delete_MenuItem.Name := Menu.Name + '_Delete'; Delete_MenuItem.Caption := 'Delete Host'; Delete_MenuItem.OnClick := @OnClick; - Menu.Add(Delete_MenuItem); } // This is annoying to do so lets just leave it out for now... + Menu.Add(Delete_MenuItem); end; end; @@ -266,10 +268,10 @@ begin; WriteLn('Sender is '#39 + TMenuItem(Sender).Name + #39'.'); //(Sender as TMenuItem).Name {$ENDIF} case Sender of - Paster_MenuItems[1]: Paste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1')), ScriptText); - Paster_MenuItems[2]: Paste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1')), GetSelectedText); + Paster_MenuItems[1]: Paste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '-1')), ScriptText); + Paster_MenuItems[2]: Paste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '-1')), GetSelectedText); - GetPaste_MenuItem: GetPaste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '1'))); + GetPaste_MenuItem: GetPaste(Settings.getKeyValue('Host' + Settings.getKeyValueDef('DefaultHost', '-1'))); AltHostAdd_MenuItem: begin I := 1; @@ -287,6 +289,11 @@ begin; Settings.setKeyValue('Host' + IntToStr(I), Data); CreateAltMenu(I); + Inc(AltHost_Top); + Divider_MenuItems[3].Visible := (Divider_MenuItems[3].MenuIndex > 0); + + if (I = 1) then + UpdateDefault(I); end; end; @@ -308,8 +315,35 @@ begin; Paste_MenuItem: Paste(Settings.getKeyValue('Host' + IntToStr(Index)), ScriptText); PasteS_MenuItem: Paste(Settings.getKeyValue('Host' + IntToStr(Index)), GetSelectedText); GetPaste_MenuItem: GetPaste(Settings.getKeyValue('Host' + IntToStr(Index))); - Default_MenuItem: UpdateDefault(I); + Default_MenuItem: UpdateDefault(Index); Update_MenuItem: UpdateHost(I); + Delete_MenuItem: begin + if (not (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Are you sure you would like to delete the "' + Settings.getKeyValue('Host' + IntToStr(Index)) + '" host?', mtConfirmation, [mbYes, mbCancel], 0) = mrYes)) then + Exit; + + if (Settings.getKeyValueDef('DefaultHost', '-1') = IntToStr(Index)) then + UpdateDefault(-1); + + Menu.Free; + + if (not (Index = AltHost_Top)) then + begin + for K := I to High(AltHost_Menus) - 1 do + begin + AltHost_Menus[K] := AltHost_Menus[K + 1]; + Dec(AltHost_Menus[K].Index); + end; + + for K := Index to AltHost_Top - 1 do + Settings.setKeyValue('Host' + IntToStr(K), Settings.getKeyValue('Host' + IntToStr(K + 1))); + Settings.deleteKey('Host' + IntToStr(AltHost_Top)); + end else + Settings.deleteKey('Host' + IntToStr(Index)); + SetLength(AltHost_Menus, Length(AltHost_Menus) - 1); + Dec(AltHost_Top); + Divider_MenuItems[3].Visible := (Divider_MenuItems[3].MenuIndex > 0); + Exit; + end; end; end; @@ -339,20 +373,23 @@ begin case V of '-1', '0.4a': begin - SetLength(SA, 2); - SA[1] := HOSTDef; - for I := 2 to 5 do + SetLength(SA, 1); + SA[0] := HOSTDef; + for I := 1 to 5 do begin - S := Settings.getKeyValueDef('Host' + IntToStr(I), 'Host' + IntToStr(I)); - if (S <> 'Host' + IntToStr(I)) then + if (Settings.isKey('Host' + IntToStr(I))) then begin - SetLength(SA, Length(SA) + 1); - SA[High(SA)] := S; + S := Settings.getKeyValueDef('Host' + IntToStr(I), 'Host' + IntToStr(I)); + if (S <> 'Host' + IntToStr(I)) then + begin + SetLength(SA, Length(SA) + 1); + SA[High(SA)] := S; + end; + Settings.DeleteKey('Host' + IntToStr(I)); end; - Settings.DeleteKey('Host' + IntToStr(I)); end; - for I := 1 to High(SA) do - Settings.setKeyValue('Host' + IntToStr(I), SA[I]); + for I := 0 to High(SA) do + Settings.setKeyValue('Host' + IntToStr(I + 1), SA[I]); end; end; @@ -373,7 +410,7 @@ begin; with Paster_MenuItems[1] do begin Name := 'Default_Paste'; - Caption := 'Paste It!'; + Caption := 'Paste Script'; OnClick := @OnClick; end; Paster_Menu.Add(Paster_MenuItems[1]); @@ -382,7 +419,7 @@ begin; with Paster_MenuItems[2] do begin Name := 'Default_PasteS'; - Caption := 'Paste Selection!'; + Caption := 'Paste Selection'; OnClick := @OnClick; end; Paster_Menu.Add(Paster_MenuItems[2]); @@ -391,7 +428,7 @@ begin; with GetPaste_MenuItem do begin Name := 'Default_GetPaste'; - Caption := 'Get Paste!'; + Caption := 'Get Paste'; OnClick := @OnClick; end; Paster_Menu.Add(GetPaste_MenuItem); @@ -442,16 +479,24 @@ begin; AltHost_Menu.Add(AltHostAdd_MenuItem); if (not (Settings.IsKey('Host1'))) then - Settings.setKeyValue('Host1', HOSTDef); - - I := 1; - while (Settings.IsKey('Host' + IntToStr(I))) do begin - if (Settings.GetKeyValue('Host' + IntToStr(I)) = 'Host ' + IntToStr(I)) then - Continue; - CreateAltMenu(I); - Inc(I); + if (Settings.getKeyValueDef('DefaultHost', '-1') = '-1') then + Settings.setKeyValue('DefaultHost', '1'); + Settings.setKeyValue('Host1', HOSTDef); end; + + AltHost_Top := 1; + while (Settings.IsKey('Host' + IntToStr(AltHost_Top))) do + begin + if (Settings.GetKeyValue('Host' + IntToStr(AltHost_Top)) = 'Host ' + IntToStr(AltHost_Top)) then + Continue; + CreateAltMenu(AltHost_Top); + Inc(AltHost_Top); + end; + Dec(AltHost_Top); + + Divider_MenuItems[3].Visible := (Divider_MenuItems[3].MenuIndex > 0); + UpdateDefault(StrToInt(Settings.getKeyValueDef('DefaultHost', '-1'))); end; {$ENDIF} From c375bb13ee19bdfd7e87f19e118162c9136ba89f Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Mon, 9 May 2011 12:17:40 -0400 Subject: [PATCH 6/8] Extenstion: Paster update and version change. --- Extensions/paster.sex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Extensions/paster.sex b/Extensions/paster.sex index 3e479fd..ff017bf 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -10,7 +10,7 @@ end; function GetVersion: string; begin; - Result := '1.0'; + Result := '1.0a'; end; {$IFDEF EXTENSION} @@ -164,7 +164,8 @@ begin end else WriteLn('Script pasted at id "' + Data + '"'); end else - WriteLn(Data); + if (Data <> '') then + WriteLn(Data); end; procedure UpdateDefault(Index: integer); From 70fd6fce718ebc14be0f2cfe7c697025d12a08dc Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Thu, 9 Jun 2011 14:27:32 -0400 Subject: [PATCH 7/8] Extensions: Update to Paster, Updater, and SRL --- Extensions/Updater.sei | 10 ++++++++++ Extensions/paster.sex | 12 ++++-------- Extensions/srl.sex | 27 ++++++++++++++++++--------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Extensions/Updater.sei b/Extensions/Updater.sei index fb1c735..18a2ea4 100644 --- a/Extensions/Updater.sei +++ b/Extensions/Updater.sei @@ -322,6 +322,16 @@ begin Result := True; end; +{ procedure Free; //Doesn't Work +var + I: integer; +begin + for I := 0 to High(UpdaterArr) do + with UpdaterArr[I] do + if (Timer <> nil) then + Timer.Free; +end; } + procedure Attach; var I: integer; diff --git a/Extensions/paster.sex b/Extensions/paster.sex index ff017bf..a0ac284 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -10,7 +10,7 @@ end; function GetVersion: string; begin; - Result := '1.0a'; + Result := '1.0b'; end; {$IFDEF EXTENSION} @@ -361,7 +361,7 @@ end; procedure UpdateCheck; var - V, S: string; + V: string; I: integer; SA: TStringArray; begin @@ -380,15 +380,11 @@ begin begin if (Settings.isKey('Host' + IntToStr(I))) then begin - S := Settings.getKeyValueDef('Host' + IntToStr(I), 'Host' + IntToStr(I)); - if (S <> 'Host' + IntToStr(I)) then - begin - SetLength(SA, Length(SA) + 1); - SA[High(SA)] := S; - end; + SA[High(SA)] := Settings.getKeyValue('Host' + IntToStr(I)); Settings.DeleteKey('Host' + IntToStr(I)); end; end; + for I := 0 to High(SA) do Settings.setKeyValue('Host' + IntToStr(I + 1), SA[I]); end; diff --git a/Extensions/srl.sex b/Extensions/srl.sex index c449ac4..d9502c7 100644 --- a/Extensions/srl.sex +++ b/Extensions/srl.sex @@ -22,20 +22,29 @@ procedure OpenDefScript(Sender: TObject); var Script: TStringArray; begin - SetLength(Script, 6); + SetLength(Script, 7); Script[0] := 'program Untitled;'; - Script[1] := '//{$DEFINE SMART} //Uncomment for SMART'; - Script[2] := '{.include SRL/SRL.scar}'; + Script[1] := '{$DEFINE SMART}'; + Script[2] := '{$I SRL/SRL.scar}'; + if (TMenuItem(Sender).Parent.Caption = 'Reflection') then begin - SetLength(Script, 7); - Script[1] := '{$DEFINE SMART}'; - Script[3] := '{.include Reflection/Reflection.scar}'; + SetLength(Script, Length(Script) + 1); + Script[High(Script) - 4] := '{$I Reflection/Reflection.simba}'; end; - Script[Length(Script) - 3] := ''; - Script[Length(Script) - 2] := 'begin'; - Script[Length(Script) - 1] := 'end.'; + Script[High(Script) - 3] := ''; + Script[High(Script) - 2] := 'begin'; + Script[High(Script) - 1] := ' SetupSRL;'; + + if (TMenuItem(Sender).Parent.Caption = 'Reflection') then + begin + SetLength(Script, Length(Script) + 1); + Script[High(Script) - 1] := ' SetupReflection;'; + end; + + Script[High(Script)] := 'end.'; + WriteLn('Opening ' + TMenuItem(Sender).Parent.Caption + ' Default Script...'); OpenScript('', Implode({$IFDEF WIN}#13+{$ENDIF}#10, Script), False); end; From 6f1d38647a4b85086a673bb82a8ed1171578a549 Mon Sep 17 00:00:00 2001 From: "John P (Dgby714)" Date: Thu, 9 Jun 2011 14:29:59 -0400 Subject: [PATCH 8/8] Extension: Paster Update, Deleted wrong line. --- Extensions/paster.sex | 1 + 1 file changed, 1 insertion(+) diff --git a/Extensions/paster.sex b/Extensions/paster.sex index a0ac284..8410032 100644 --- a/Extensions/paster.sex +++ b/Extensions/paster.sex @@ -380,6 +380,7 @@ begin begin if (Settings.isKey('Host' + IntToStr(I))) then begin + SetLength(SA, Length(SA) + 1); SA[High(SA)] := Settings.getKeyValue('Host' + IntToStr(I)); Settings.DeleteKey('Host' + IntToStr(I)); end;