mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 23:09:09 +02:00
* editing added
This commit is contained in:
parent
250c8a835c
commit
c2ae860fc1
@ -29,7 +29,6 @@ Uses Process,SysUtils,Video,Keyboard,FList
|
|||||||
Function Do_File_cmd(path:String):String;
|
Function Do_File_cmd(path:String):String;
|
||||||
|
|
||||||
Const BufSize = 1024;
|
Const BufSize = 1024;
|
||||||
|
|
||||||
TheProgram = 'file' {$IFDEF Win32}+'.exe' {$ENDIF};
|
TheProgram = 'file' {$IFDEF Win32}+'.exe' {$ENDIF};
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +36,6 @@ Var S : TProcess;
|
|||||||
Buf : Array[1..BUFSIZE] of char;
|
Buf : Array[1..BUFSIZE] of char;
|
||||||
I,Count : longint;
|
I,Count : longint;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
S:=TProcess.Create(Nil);
|
S:=TProcess.Create(Nil);
|
||||||
S.Commandline:=theprogram+' '+path;
|
S.Commandline:=theprogram+' '+path;
|
||||||
@ -82,6 +80,7 @@ Var
|
|||||||
Forced,
|
Forced,
|
||||||
ForcedFull: Boolean;
|
ForcedFull: Boolean;
|
||||||
C : Char;
|
C : Char;
|
||||||
|
Editor,
|
||||||
Pager : AnsiString;
|
Pager : AnsiString;
|
||||||
Procedure ReDraw;
|
Procedure ReDraw;
|
||||||
|
|
||||||
@ -93,6 +92,16 @@ Begin
|
|||||||
UpdateScreen(true);
|
UpdateScreen(true);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
procedure loadutil(const envvar,default : string;var symbol : string);
|
||||||
|
|
||||||
|
begin
|
||||||
|
Symbol:=GetEnvironmentVariable(envvar);
|
||||||
|
if Symbol='' Then
|
||||||
|
Symbol:=default;
|
||||||
|
if Pos('/',Symbol)=0 Then
|
||||||
|
Symbol:=FileSearch(Symbol,GetEnvironmentVariable('PATH'));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
InitVideo;
|
InitVideo;
|
||||||
@ -105,12 +114,11 @@ Begin
|
|||||||
ExitNow:=False;
|
ExitNow:=False;
|
||||||
{$ifdef win32}
|
{$ifdef win32}
|
||||||
Pager:='notepad.exe';
|
Pager:='notepad.exe';
|
||||||
|
Editor:='notepad.exe';
|
||||||
{$else}
|
{$else}
|
||||||
Pager:=GetEnvironmentVariable('PAGER');
|
loadutil('EDITOR','joe' ,editor);
|
||||||
if Pos('/',Pager)=0 Then
|
loadutil('PAGER' ,'less',pager);
|
||||||
Pager:=FileSearch(Pager,GetEnvironmentVariable('PATH'));
|
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
If ParamCount()>0 Then
|
If ParamCount()>0 Then
|
||||||
FileSpec:=ParamStr(1);
|
FileSpec:=ParamStr(1);
|
||||||
{$ifdef debug}
|
{$ifdef debug}
|
||||||
@ -193,8 +201,10 @@ Begin
|
|||||||
#13 : Begin
|
#13 : Begin
|
||||||
If D.Cursor>=D.DirCount Then
|
If D.Cursor>=D.DirCount Then
|
||||||
Begin
|
Begin
|
||||||
S:=ExtractFileExt(D[D.Cursor]);
|
{$ifdef win32} // try to get "open" action ?
|
||||||
Delete(S,1,1);
|
S:=ExtractFileExt(D[D.Cursor]);
|
||||||
|
Delete(S,1,1);
|
||||||
|
{$endif}
|
||||||
ExecuteProcess(Pager,[D.Directory+D[D.Cursor]]);
|
ExecuteProcess(Pager,[D.Directory+D[D.Cursor]]);
|
||||||
// TextOut(10,1,' ');
|
// TextOut(10,1,' ');
|
||||||
//TextOut(10,1,D[D.Cursor]);
|
//TextOut(10,1,D[D.Cursor]);
|
||||||
@ -218,6 +228,19 @@ Begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
|
'e','E' : begin
|
||||||
|
If D.Cursor>=D.DirCount Then
|
||||||
|
Begin
|
||||||
|
{$ifdef win32} // try to get "edit" action ?
|
||||||
|
S:=ExtractFileExt(D[D.Cursor]);
|
||||||
|
Delete(S,1,1);
|
||||||
|
{$endif}
|
||||||
|
ExecuteProcess(Editor,[D.Directory+D[D.Cursor]]);
|
||||||
|
// TextOut(10,1,' ');
|
||||||
|
//TextOut(10,1,D[D.Cursor]);
|
||||||
|
ForcedFull:=True;
|
||||||
|
End
|
||||||
|
end;
|
||||||
#27,'q' : exitnow:=True;
|
#27,'q' : exitnow:=True;
|
||||||
' ' : Begin
|
' ' : Begin
|
||||||
D.Toggle(D.Cursor);
|
D.Toggle(D.Cursor);
|
||||||
@ -268,7 +291,10 @@ End.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.1 2005-04-06 08:54:16 marco
|
Revision 1.2 2005-04-06 18:45:47 marco
|
||||||
|
* editing added
|
||||||
|
|
||||||
|
Revision 1.1 2005/04/06 08:54:16 marco
|
||||||
* new Unix demo: lister
|
* new Unix demo: lister
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user