1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 02:32:19 -05:00

Extension: Paster Update

This commit is contained in:
John P (Dgby714) 2010-10-10 16:29:20 -04:00
parent 75ef62302d
commit b09880a116

View File

@ -95,8 +95,6 @@ end;
function PasteIt(out Data: string; HOST: string): boolean; function PasteIt(out Data: string; HOST: string): boolean;
begin begin
if (HOST = '') then
HOST := HOSTDef;
if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Upload this script to ' + HOST + '?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then if (MessageDlg(GetName + ' ' + GetVersion + ' Extension', 'Upload this script to ' + HOST + '?', mtConfirmation, [mbYes, mbNo], 0) = mrYes) then
begin begin
Data := '{"language": "delphi", "code": "' + EncodeString(ScriptText) + '", "private": ' + Lowercase(BoolToStr(Private_MenuItem.Checked)) + '}'; Data := '{"language": "delphi", "code": "' + EncodeString(ScriptText) + '", "private": ' + Lowercase(BoolToStr(Private_MenuItem.Checked)) + '}';
@ -114,6 +112,8 @@ procedure Paste(Host: string);
var var
Data: string; Data: string;
begin begin
if (HOST = '') then
HOST := HOSTDef;
if PasteIt(Data, Host) then if PasteIt(Data, Host) then
begin begin
if (Browser_MenuItem.Checked) then if (Browser_MenuItem.Checked) then
@ -157,6 +157,10 @@ procedure OnClick(Sender: TObject);
var var
I, K: integer; I, K: integer;
begin; begin;
{$IFDEF DEV}
if (Sender is TMenuItem) then
WriteLn('Sender is '#39 + TMenuItem(Sender).Name + #39'.'); //(Sender as TMenuItem).Name
{$ENDIF}
case Sender of case Sender of
Paster_MenuItem: Paste(''); Paster_MenuItem: Paste('');
GetPaste_MenuItem: GetPaste(''); GetPaste_MenuItem: GetPaste('');
@ -175,13 +179,11 @@ begin;
for K := 1 to 4 do for K := 1 to 4 do
if (Sender = AltHost_MenuItems[I][K]) then if (Sender = AltHost_MenuItems[I][K]) then
begin begin
{$IFDEF DEV}WriteLn('Sender = ' + IntToStr(I) + ', ' + IntToStr(K));{$ENDIF} case K of
if (K = 4) then 4: UpdateHost(I);
UpdateHost(I); 2: GetPaste(Settings.getKeyValue('Host' + IntToStr(I)));
if (K = 2) then 1: Paste(Settings.getKeyValue('Host' + IntToStr(I)));
GetPaste(Settings.getKeyValue('Host' + IntToStr(I))); end;
if (K = 1) then
Paste(Settings.getKeyValue('Host' + IntToStr(I)));
Break; Break;
end; end;
end; end;
@ -226,6 +228,7 @@ begin;
Paster_MenuItem := TMenuItem.Create(Paster_Menu); Paster_MenuItem := TMenuItem.Create(Paster_Menu);
with Paster_MenuItem do with Paster_MenuItem do
begin begin
Name := 'Default_Paste';
Caption := 'Paste It!'; Caption := 'Paste It!';
OnClick := @OnClick; OnClick := @OnClick;
end; end;
@ -234,6 +237,7 @@ begin;
GetPaste_MenuItem := TMenuItem.Create(Paster_Menu); GetPaste_MenuItem := TMenuItem.Create(Paster_Menu);
with GetPaste_MenuItem do with GetPaste_MenuItem do
begin begin
Name := 'Default_GetPaste';
Caption := 'Get Paste!'; Caption := 'Get Paste!';
OnClick := @OnClick; OnClick := @OnClick;
end; end;
@ -250,6 +254,7 @@ begin;
Private_MenuItem := TMenuItem.Create(Paster_Menu); Private_MenuItem := TMenuItem.Create(Paster_Menu);
with Private_MenuItem do with Private_MenuItem do
begin begin
Name := 'Private_Setting';
Caption := 'Private'; Caption := 'Private';
OnClick := @OnClick; OnClick := @OnClick;
Checked := (Lowercase(Settings.getKeyValueDef('Private', 'true')) = 'true'); Checked := (Lowercase(Settings.getKeyValueDef('Private', 'true')) = 'true');
@ -259,6 +264,7 @@ begin;
Browser_MenuItem := TMenuItem.Create(Paster_Menu); Browser_MenuItem := TMenuItem.Create(Paster_Menu);
with Browser_MenuItem do with Browser_MenuItem do
begin begin
Name := 'Browser_Setting';
Caption := 'Open in Browser'; Caption := 'Open in Browser';
OnClick := @OnClick; OnClick := @OnClick;
Checked := (Lowercase(Settings.getKeyValueDef('OpenBrowser', 'true')) = 'true'); Checked := (Lowercase(Settings.getKeyValueDef('OpenBrowser', 'true')) = 'true');
@ -281,10 +287,19 @@ begin;
begin begin
AltHost_MenuItems[I][K] := TMenuItem.Create(AltHost_Menus[I]); AltHost_MenuItems[I][K] := TMenuItem.Create(AltHost_Menus[I]);
case K of case K of
1: AltHost_MenuItems[I][1].Caption := 'Paste It!'; 1: begin
2: AltHost_MenuItems[I][2].Caption := 'Get Paste!'; 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) + '_GetPaste';
AltHost_MenuItems[I][2].Caption := 'Get Paste!';
end;
3: AltHost_MenuItems[I][3].Caption := '-'; 3: AltHost_MenuItems[I][3].Caption := '-';
4: AltHost_MenuItems[I][4].Caption := 'Update Host'; 4: begin
AltHost_MenuItems[I][4].Name := 'Host' + IntToStr(I) + '_Update';
AltHost_MenuItems[I][4].Caption := 'Update Host';
end;
end; end;
AltHost_MenuItems[I][K].OnClick := @OnClick; AltHost_MenuItems[I][K].OnClick := @OnClick;
if ((not ((K = 3) or (K = 4))) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then if ((not ((K = 3) or (K = 4))) and (AltHost_Menus[I].Caption = 'Host ' + IntToStr(I))) then