Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remote editing with PuTTY

git-svn-id: http://svn.eludia.ru/eludia/steludio@2906 430c9a1f-3e2d-0410-8b9a-efe3048821f3
  • Loading branch information...
commit be2a3c04294285eff51335d14570b87be0c57f2c 1 parent b01533f
do authored
Showing with 194 additions and 12 deletions.
  1. +74 −3 Config.pas
  2. +23 −5 Edit.pas
  3. +3 −1 Main.dfm
  4. +93 −3 Main.pas
  5. +1 −0  setup.iss
View
77 Config.pas
@@ -5,7 +5,7 @@ interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, SynEdit, SynEditHighlighter, SynHighlighterPerl, ComCtrls, SearchReplace, SynEditKeyCmds, Registry,
- StdCtrls, ExtCtrls, SynHighlighterPHP;
+ StdCtrls, ExtCtrls, SynHighlighterPHP, ShellApi;
type
TConfigForm = class(TForm)
@@ -40,11 +40,13 @@ TConfigForm = class(TForm)
procedure ReadSettings;
procedure TouchMenu;
public
+ ssh_address: string;
path, ext: string;
- procedure Init (_FileName: string; _StatusLine: TStatusBar; is_php: boolean);
+ procedure Init (_FileName: string; _StatusLine: TStatusBar; is_php: boolean; ssh_address: string);
procedure SaveFile;
procedure LoadFile;
function GetFileName: string;
+ procedure scp (path: string);
end;
var
@@ -56,6 +58,44 @@ implementation
{$R *.dfm}
+procedure TConfigForm.scp (path: string);
+var
+ remote_path, params: string;
+ p, l: integer;
+ c: char;
+begin
+
+ if ssh_address = '' then exit;
+
+ remote_path := StringReplace(path, '\', '/', [rfReplaceAll]);
+
+ p := 1 + pos ('/lib/', remote_path);
+
+ if p > 1 then inc (p, 4);
+
+ c := remote_path [p];
+
+ if not (c in ['A' .. 'Z']) then c := chr (ord (c) - 32);
+
+ remote_path [p] := c;
+
+ l := length (remote_path) - p + 1;
+
+ remote_path := copy (remote_path, p, l);
+
+ params := '-C -scp ' + path + ' ' + ssh_address + '/lib/' + remote_path;
+
+ ShellExecute (
+ self.Handle,
+ 'open',
+ pchar ('c:\program files\putty\pscp.exe'),
+ pchar (params),
+ '',
+ SW_SHOWNORMAL
+ );
+
+end;
+
procedure TConfigForm.SetDirty (b: boolean);
begin
dirty := b;
@@ -99,6 +139,9 @@ procedure TConfigForm.SaveFile;
end;
SynEdit.Lines.SaveToFile (LastFileName);
+
+ scp (LastFileName);
+
LastLoadTime := FileDateToDateTime (FileAge (LastFileName));
SetDirty (false);
StatusLine.Panels [2].Text := LastFileName + ' saved.';
@@ -184,6 +227,7 @@ procedure TConfigForm.Init;
var
sr: TSearchRec;
begin
+ self.ssh_address := ssh_address;
if is_php then ext := 'str' else ext := 'pm';
if is_php then synedit.Highlighter := SynPHPSyn;
FileName := _FileName;
@@ -213,11 +257,38 @@ procedure TConfigForm.Init;
end;
procedure TConfigForm.TouchMenu;
-var handle: integer;
+var
+ handle, p, l: integer;
+ remote_path, params: string;
begin
handle := FileOpen (path + 'Content\menu.pm', 1);
FileSetDate (handle, DateTimeToFileDate (Now));
FileClose (handle);
+
+
+ if ssh_address = '' then exit;
+
+ remote_path := StringReplace (path + 'Content\menu.pm', '\', '/', [rfReplaceAll]);
+
+ p := pos ('/lib/', remote_path);
+
+ l := length (remote_path) - p;
+
+ remote_path := copy (remote_path, p, l);
+
+ params := ssh_address + '/lib/' + remote_path;
+
+ params := StringReplace (params, ':', ' touch ', []);
+
+ ShellExecute (
+ self.Handle,
+ 'open',
+ pchar ('c:\program files\putty\plink.exe'),
+ pchar (params),
+ '',
+ SW_SHOWNORMAL
+ );
+
end;
function TConfigForm.GetFileName: string;
View
28 Edit.pas
@@ -97,7 +97,7 @@ TEditForm = class(TForm)
procedure ReadSettings;
public
ConfigForm: TConfigForm;
- procedure Init (_path: string; _StatusLine: TStatusBar;is_php: boolean);
+ procedure Init (_path: string; _StatusLine: TStatusBar; is_php: boolean);
procedure SaveFile;
end;
@@ -251,6 +251,7 @@ procedure TEditForm.SaveFile;
LastLoadedText := SynEdit.Lines.DelimitedText;
LastLoadTime := FileDateToDateTime (FileAge (currentFile));
SetDirty (false);
+ self.ConfigForm.scp (currentFile);
StatusLine.Panels [2].Text := currentFile + ' saved.';
end;
@@ -679,7 +680,7 @@ procedure TEditForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftSta
Doc: IHtmlDocument2;
frames: IHTMLFramesCollection2;
window: IHTMLWindow2;
- Location: IHTMLLocation;
+// Location: IHTMLLocation;
url: string;
frame_dispatch: IDispatch;
@@ -691,6 +692,26 @@ procedure TEditForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftSta
if Shift = [ssCtrl, ssAlt, ssShift] then begin
+ if ConfigForm.ssh_address <> '' then begin
+
+ case Key of
+
+ ord ('C'), ord ('M'), ord ('S'), ord ('B'): begin
+
+ params := '-load ' + copy (ConfigForm.ssh_address, 1, pos(':', ConfigForm.ssh_address) - 1);
+
+ ShellExecute (self.Handle, 'open', 'c:\program files\putty\putty.exe', pchar (params), '', SW_SHOWNORMAL);
+
+ end;
+
+ else exit;
+
+ end;
+
+ exit;
+
+ end;
+
if ScmName = '' then begin
Application.MessageBox ('Version control tool not detected, sorry', 'Error', mb_ok);
exit;
@@ -746,9 +767,6 @@ procedure TEditForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftSta
if Shift = [] then case Key of
-
-
-
VK_F2: begin
try
View
4 Main.dfm
@@ -154,7 +154,9 @@ object MainForm: TMainForm
end
object OpenDialog: TOpenDialog
DefaultExt = '.pm'
- Filter = 'Perl projects|Config*.pm|PHP projects|config*.php'
+ Filter =
+ 'Perl projects|Config*.pm|PHP projects|config*.php|Link files|*.e' +
+ 'lnk'
Title = 'Root module'
Left = 46
Top = 7
View
96 Main.pas
@@ -4,7 +4,8 @@ interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, ComCtrls, Edit, Config, Help;
+ Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, ComCtrls, Edit, Config,
+ Help, ShellApi, FileCtrl;
type
TMainForm = class(TForm)
@@ -168,6 +169,16 @@ procedure TMainForm.FormShow(Sender: TObject);
p: integer;
is_php: boolean;
FileName: string;
+ ssh_file: textfile;
+ ssh_address: string;
+
+ SEInfo: TShellExecuteInfo;
+ ExitCode: DWORD;
+ ExecuteFile, ParamString, StartInString: string;
+
+ Drive: char;
+ DirPart, FilePart: string;
+
begin
case ParamCount of
@@ -208,6 +219,85 @@ procedure TMainForm.FormShow(Sender: TObject);
Exit;
end;
+ p := pos ('.elnk', path);
+
+ ProcessPath (path, Drive, DirPart, FilePart);
+
+ ssh_address := '';
+
+ if p > 0 then begin
+
+
+ StartInString := Drive + ':\' + DirPart;
+
+ assignfile (ssh_file, path);
+ reset (ssh_file);
+ readln(ssh_file, ssh_address);
+ closefile (ssh_file);
+
+ ExecuteFile := 'c:\Program Files\Putty\pscp.exe';
+ ParamString := '-r -C -scp ' + ssh_address + '/lib ..';
+
+ FillChar (SEInfo, SizeOf(SEInfo), 0);
+
+ SEInfo.cbSize := SizeOf (TShellExecuteInfo);
+
+ with SEInfo do begin
+
+ fMask := SEE_MASK_NOCLOSEPROCESS;
+ Wnd := Application.Handle;
+ lpFile := PChar (ExecuteFile);
+ lpParameters := PChar (ParamString);
+ lpDirectory := PChar (StartInString);
+ nShow := SW_SHOWNORMAL;
+ end;
+
+ if ShellExecuteEx(@SEInfo) then begin
+
+ repeat
+
+ Application.ProcessMessages;
+
+ GetExitCodeProcess (SEInfo.hProcess, ExitCode);
+
+ until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
+
+ end
+ else
+ begin
+
+ ShowMessage ('Can''t copy files with pscp!');
+ Close;
+ Exit;
+
+ end;
+
+
+
+ path := StringReplace (path, FilePart, 'config.pm', []);
+
+ FileName := 'config.pm';
+
+ if not fileexists(path) then begin
+
+ FileName := 'config.php';
+
+ StringReplace (path, FilePart, 'config.php', []);
+
+ end;
+
+ if not fileexists(path) then begin
+
+ ShowMessage ('Config.p[m|hp] not found');
+
+ Close;
+
+ Exit;
+
+ end;
+
+ end;
+
p := pos ('\config.pm', path);
is_php := false;
@@ -218,7 +308,7 @@ procedure TMainForm.FormShow(Sender: TObject);
end;
if p = 0 then begin
- Application.MessageBox (PChar(FileName + ' is not Config.p[m|hp]'), 'Wrong file name', MB_OK);
+ Application.MessageBox (PChar(path + ' is not Config.p[m|hp]'), 'Wrong file name', MB_OK);
Close;
Exit;
end;
@@ -238,7 +328,7 @@ procedure TMainForm.FormShow(Sender: TObject);
end;
Application.CreateForm (TConfigForm, ConfigForm);
- ConfigForm.Init (FileName, StatusLine, is_php);
+ ConfigForm.Init (FileName, StatusLine, is_php, ssh_address);
NewEditForm (is_php);
View
1  setup.iss
@@ -27,6 +27,7 @@ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescrip
[Registry]
Root: HKCR; Subkey: ".pm"; ValueType: string; ValueName: ""; ValueData: "Steludio"; Flags: uninsdeletevalue
Root: HKCR; Subkey: ".php"; ValueType: string; ValueName: ""; ValueData: "Steludio"; Flags: uninsdeletevalue
+Root: HKCR; Subkey: ".elnk"; ValueType: string; ValueName: ""; ValueData: "Steludio"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "Steludio"; ValueType: string; ValueName: ""; ValueData: "Steludio"; Flags: uninsdeletekey
Root: HKCR; Subkey: "Steludio\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\Steludio.exe,0"
Root: HKCR; Subkey: "Steludio\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\Steludio.exe"" ""%1"""
Please sign in to comment.
Something went wrong with that request. Please try again.