mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 23:19:24 +02:00
Larger File Open dialog for larger console/terminal dimensions
This commit is contained in:
parent
f419e9dfab
commit
8d7a6cc778
@ -1180,6 +1180,35 @@ begin
|
|||||||
EventMask := EventMask or evBroadcast;
|
EventMask := EventMask or evBroadcast;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{****************************************************************************}
|
||||||
|
{ AdjustNameSize for TFileInfoPane }
|
||||||
|
{****************************************************************************}
|
||||||
|
function AdjustNameSize(S:String;ASize:sw_integer):String;
|
||||||
|
var St: String;
|
||||||
|
NameLen:sw_integer;
|
||||||
|
K,N : sw_integer;
|
||||||
|
begin
|
||||||
|
NameLen:=12;
|
||||||
|
Str(NameLen,St);
|
||||||
|
NameLen:=ASize-10-9-3-2-4-2-2-1-2;
|
||||||
|
if NameLen>12 then
|
||||||
|
Str(NameLen,St);
|
||||||
|
k:=1;
|
||||||
|
while k<=length(S) do
|
||||||
|
begin
|
||||||
|
if (S[k] in ['0'..'9']) then break;
|
||||||
|
inc(k);
|
||||||
|
end;
|
||||||
|
N:=K;
|
||||||
|
while N<=length(S) do
|
||||||
|
begin
|
||||||
|
if not (S[N] in ['0'..'9']) then break;
|
||||||
|
inc(N);
|
||||||
|
end;
|
||||||
|
S:=Copy(S,1,K-1)+St+Copy(S,N,length(S));
|
||||||
|
AdjustNameSize:=S;
|
||||||
|
end;
|
||||||
|
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
{ TFileInfoPane.Draw }
|
{ TFileInfoPane.Draw }
|
||||||
{****************************************************************************}
|
{****************************************************************************}
|
||||||
@ -1242,6 +1271,7 @@ begin
|
|||||||
FmtId := sFileLine;
|
FmtId := sFileLine;
|
||||||
Params[1] := S.Size;
|
Params[1] := S.Size;
|
||||||
end;
|
end;
|
||||||
|
FmtId:=AdjustNameSize(FmtId,Size.X);
|
||||||
UnpackTime(S.Time, Time);
|
UnpackTime(S.Time, Time);
|
||||||
M := Month[Time.Month];
|
M := Month[Time.Month];
|
||||||
Params[2] := ptruint(@M);
|
Params[2] := ptruint(@M);
|
||||||
@ -1460,6 +1490,7 @@ begin
|
|||||||
|
|
||||||
R.Assign(3,3,31,4);
|
R.Assign(3,3,31,4);
|
||||||
FileName := New(PFileInputLine, Init(R, 79));
|
FileName := New(PFileInputLine, Init(R, 79));
|
||||||
|
FileName^.GrowMode:=gfGrowHiX;
|
||||||
FileName^.Data^ := WildCard;
|
FileName^.Data^ := WildCard;
|
||||||
Insert(FileName);
|
Insert(FileName);
|
||||||
R.Assign(2,2,3+CStrLen(InputName),3);
|
R.Assign(2,2,3+CStrLen(InputName),3);
|
||||||
@ -1467,6 +1498,7 @@ begin
|
|||||||
Insert(Control);
|
Insert(Control);
|
||||||
R.Assign(31,3,34,4);
|
R.Assign(31,3,34,4);
|
||||||
FileHistory := New(PFileHistory, Init(R, FileName, HistoryId));
|
FileHistory := New(PFileHistory, Init(R, FileName, HistoryId));
|
||||||
|
FileHistory^.GrowMode:=gfGrowHiX or gfGrowLoX;
|
||||||
Insert(FileHistory);
|
Insert(FileHistory);
|
||||||
|
|
||||||
R.Assign(3,14,34,15);
|
R.Assign(3,14,34,15);
|
||||||
@ -1474,6 +1506,7 @@ begin
|
|||||||
Insert(Control);
|
Insert(Control);
|
||||||
R.Assign(3,6,34,14);
|
R.Assign(3,6,34,14);
|
||||||
FileList := New(PFileList, Init(R, PScrollBar(Control)));
|
FileList := New(PFileList, Init(R, PScrollBar(Control)));
|
||||||
|
FileList^.GrowMode:=gfGrowHiX or gfGrowHiY;
|
||||||
Insert(FileList);
|
Insert(FileList);
|
||||||
R.Assign(2,5,8,6);
|
R.Assign(2,5,8,6);
|
||||||
Control := New(PLabel, Init(R, slFiles, FileList));
|
Control := New(PLabel, Init(R, slFiles, FileList));
|
||||||
@ -1483,29 +1516,39 @@ begin
|
|||||||
Opt := bfDefault;
|
Opt := bfDefault;
|
||||||
if AOptions and fdOpenButton <> 0 then
|
if AOptions and fdOpenButton <> 0 then
|
||||||
begin
|
begin
|
||||||
Insert(New(PButton, Init(R,slOpen, cmFileOpen, Opt)));
|
Control:=New(PButton, Init(R,slOpen, cmFileOpen, Opt));
|
||||||
|
Control^.GrowMode:=gfGrowHiX or gfGrowLoX;
|
||||||
|
Insert(Control);
|
||||||
Opt := bfNormal;
|
Opt := bfNormal;
|
||||||
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
||||||
end;
|
end;
|
||||||
if AOptions and fdOkButton <> 0 then
|
if AOptions and fdOkButton <> 0 then
|
||||||
begin
|
begin
|
||||||
Insert(New(PButton, Init(R,slOk, cmFileOpen, Opt)));
|
Control:=New(PButton, Init(R,slOk, cmFileOpen, Opt));
|
||||||
|
Control^.GrowMode:=gfGrowHiX or gfGrowLoX;
|
||||||
|
Insert(Control);
|
||||||
Opt := bfNormal;
|
Opt := bfNormal;
|
||||||
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
||||||
end;
|
end;
|
||||||
if AOptions and fdReplaceButton <> 0 then
|
if AOptions and fdReplaceButton <> 0 then
|
||||||
begin
|
begin
|
||||||
Insert(New(PButton, Init(R, slReplace,cmFileReplace, Opt)));
|
Control:=New(PButton, Init(R, slReplace,cmFileReplace, Opt));
|
||||||
|
Control^.GrowMode:=gfGrowHiX or gfGrowLoX;
|
||||||
|
Insert(Control);
|
||||||
Opt := bfNormal;
|
Opt := bfNormal;
|
||||||
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
||||||
end;
|
end;
|
||||||
if AOptions and fdClearButton <> 0 then
|
if AOptions and fdClearButton <> 0 then
|
||||||
begin
|
begin
|
||||||
Insert(New(PButton, Init(R, slClear,cmFileClear, Opt)));
|
Control:=New(PButton, Init(R, slClear,cmFileClear, Opt));
|
||||||
|
Control^.GrowMode:=gfGrowHiX or gfGrowLoX;
|
||||||
|
Insert(Control);
|
||||||
Opt := bfNormal;
|
Opt := bfNormal;
|
||||||
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
||||||
end;
|
end;
|
||||||
Insert(New(PButton, Init(R, slCancel, cmCancel, bfNormal)));
|
Control:=New(PButton, Init(R, slCancel, cmCancel, bfNormal));
|
||||||
|
Control^.GrowMode:=gfGrowHiX or gfGrowLoX;
|
||||||
|
Insert(Control);
|
||||||
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
Inc(R.A.Y,3); Inc(R.B.Y,3);
|
||||||
if AOptions and fdHelpButton <> 0 then
|
if AOptions and fdHelpButton <> 0 then
|
||||||
begin
|
begin
|
||||||
@ -1515,6 +1558,7 @@ begin
|
|||||||
|
|
||||||
R.Assign(1,16,48,18);
|
R.Assign(1,16,48,18);
|
||||||
Control := New(PFileInfoPane, Init(R));
|
Control := New(PFileInfoPane, Init(R));
|
||||||
|
Control^.GrowMode:=gfGrowHiX or gfGrowHiY or gfGrowLoY;
|
||||||
Insert(Control);
|
Insert(Control);
|
||||||
|
|
||||||
SelectNext(False);
|
SelectNext(False);
|
||||||
|
@ -97,7 +97,7 @@ end;
|
|||||||
|
|
||||||
procedure TIDEApp.DoPrimaryFile;
|
procedure TIDEApp.DoPrimaryFile;
|
||||||
var
|
var
|
||||||
D : PFileDialog;
|
D : PFPFileDialog;
|
||||||
FileName : string;
|
FileName : string;
|
||||||
begin
|
begin
|
||||||
New(D, Init('*.pri;*.pas',label_primaryfile_primaryfile,'*.pri;*.pas',fdOpenButton,hidPrimaryFile));
|
New(D, Init('*.pri;*.pas',label_primaryfile_primaryfile,'*.pri;*.pas',fdOpenButton,hidPrimaryFile));
|
||||||
|
@ -74,7 +74,7 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
procedure TIDEApp.Open(FileName: string;FileDir:string);
|
procedure TIDEApp.Open(FileName: string;FileDir:string);
|
||||||
var D: PFileDialog;
|
var D : PFPFileDialog;
|
||||||
OpenIt: boolean;
|
OpenIt: boolean;
|
||||||
DriveNumber : byte;
|
DriveNumber : byte;
|
||||||
StoreDir,StoreDir2 : DirStr;
|
StoreDir,StoreDir2 : DirStr;
|
||||||
@ -141,7 +141,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TIDEApp.OpenSearch(FileName: string) : boolean;
|
function TIDEApp.OpenSearch(FileName: string) : boolean;
|
||||||
var D: PFileDialog;
|
var D : PFPFileDialog;
|
||||||
OpenIt: boolean;
|
OpenIt: boolean;
|
||||||
P : PString;
|
P : PString;
|
||||||
Dir,S : String;
|
Dir,S : String;
|
||||||
|
@ -169,7 +169,7 @@ procedure THelpFilesDialog.HandleEvent(var Event: TEvent);
|
|||||||
StoreHtmlIndexFile := Re <> cmCancel;
|
StoreHtmlIndexFile := Re <> cmCancel;
|
||||||
end;
|
end;
|
||||||
var I: integer;
|
var I: integer;
|
||||||
D: PFileDialog;
|
D : PFPFileDialog;
|
||||||
FileName: string;
|
FileName: string;
|
||||||
Re: word;
|
Re: word;
|
||||||
S: string;
|
S: string;
|
||||||
|
@ -1621,7 +1621,7 @@ end;
|
|||||||
{$endif COLORSEL}
|
{$endif COLORSEL}
|
||||||
|
|
||||||
procedure TIDEApp.OpenINI;
|
procedure TIDEApp.OpenINI;
|
||||||
var D: PFileDialog;
|
var D : PFPFileDialog;
|
||||||
FileName: string;
|
FileName: string;
|
||||||
begin
|
begin
|
||||||
New(D, Init('*'+ExtOf(INIFileName),dialog_openoptions,dialog_ini_filename,fdOpenButton,hidOpenIniFile));
|
New(D, Init('*'+ExtOf(INIFileName),dialog_openoptions,dialog_ini_filename,fdOpenButton,hidOpenIniFile));
|
||||||
@ -1646,7 +1646,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TIDEApp.SaveAsINI;
|
procedure TIDEApp.SaveAsINI;
|
||||||
var D: PFileDialog;
|
var D : PFPFileDialog;
|
||||||
FileName: string;
|
FileName: string;
|
||||||
CanWrite: boolean;
|
CanWrite: boolean;
|
||||||
begin
|
begin
|
||||||
|
@ -22,7 +22,7 @@ unit WEditor;
|
|||||||
interface
|
interface
|
||||||
{tes}
|
{tes}
|
||||||
uses
|
uses
|
||||||
Dos,Objects,Drivers,Views,Dialogs,Menus,
|
Dos,Objects,Drivers,Views,Dialogs,Menus,Stddlg,
|
||||||
FVConsts,
|
FVConsts,
|
||||||
WUtils,WViews;
|
WUtils,WViews;
|
||||||
|
|
||||||
@ -750,6 +750,18 @@ type
|
|||||||
|
|
||||||
PSearchHelperDialog = ^TSearchHelperDialog;
|
PSearchHelperDialog = ^TSearchHelperDialog;
|
||||||
|
|
||||||
|
PFPFileInputLine = ^TFPFileInputLine;
|
||||||
|
TFPFileInputLine = object(TFileInputLine)
|
||||||
|
constructor Init(var Bounds: TRect; AMaxLen: Sw_Integer);
|
||||||
|
procedure HandleEvent(var Event: TEvent); virtual;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PFPFileDialog = ^TFPFileDialog;
|
||||||
|
TFPFileDialog = object(TFileDialog)
|
||||||
|
constructor Init(AWildCard: TWildStr; const ATitle,
|
||||||
|
InputName: String; AOptions: Word; HistoryId: Byte);
|
||||||
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
{ used for ShiftDel and ShiftIns to avoid
|
{ used for ShiftDel and ShiftIns to avoid
|
||||||
GetShiftState to be considered for extending
|
GetShiftState to be considered for extending
|
||||||
@ -802,7 +814,7 @@ procedure RegisterWEditor;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Strings,Video,MsgBox,App,StdDlg,Validate,
|
Strings,Video,MsgBox,App,Validate,
|
||||||
{$ifdef WinClipSupported}
|
{$ifdef WinClipSupported}
|
||||||
WinClip,
|
WinClip,
|
||||||
{$endif WinClipSupported}
|
{$endif WinClipSupported}
|
||||||
@ -7285,6 +7297,14 @@ begin
|
|||||||
inherited HandleEvent(Event);
|
inherited HandleEvent(Event);
|
||||||
ClearEvent(Event);
|
ClearEvent(Event);
|
||||||
end
|
end
|
||||||
|
else if ((Event.KeyCode=kbCtrlDel)) then
|
||||||
|
{ Cut & discard }
|
||||||
|
begin
|
||||||
|
{ now remove the selected part }
|
||||||
|
Event.keyCode:=kbDel;
|
||||||
|
inherited HandleEvent(Event);
|
||||||
|
ClearEvent(Event);
|
||||||
|
end
|
||||||
else
|
else
|
||||||
Inherited HandleEvent(Event);
|
Inherited HandleEvent(Event);
|
||||||
End
|
End
|
||||||
@ -7294,6 +7314,118 @@ begin
|
|||||||
Message(Owner,evBroadCast,cmInputLineLen,pointer(Length(st)));
|
Message(Owner,evBroadCast,cmInputLineLen,pointer(Length(st)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TFPFileInputLine.Init(var Bounds: TRect; AMaxLen: Sw_Integer);
|
||||||
|
begin
|
||||||
|
inherited Init(Bounds, AMaxLen);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPFileInputLine.HandleEvent(var Event: TEvent);
|
||||||
|
var s : sw_astring;
|
||||||
|
i : sw_integer;
|
||||||
|
st: string;
|
||||||
|
begin
|
||||||
|
If (Event.What=evKeyDown) then
|
||||||
|
begin
|
||||||
|
if ((Event.KeyCode=kbShiftIns) or (Event.KeyCode=paste_key)) and
|
||||||
|
Assigned(weditor.Clipboard) and (weditor.Clipboard^.ValidBlock) then
|
||||||
|
{ paste from clipboard }
|
||||||
|
begin
|
||||||
|
i:=Clipboard^.SelStart.Y;
|
||||||
|
s:=Clipboard^.GetDisplayText(i);
|
||||||
|
i:=Clipboard^.SelStart.X;
|
||||||
|
if i>0 then
|
||||||
|
s:=copy(s,i+1,length(s));
|
||||||
|
if (Clipboard^.SelStart.Y=Clipboard^.SelEnd.Y) then
|
||||||
|
begin
|
||||||
|
i:=Clipboard^.SelEnd.X-i;
|
||||||
|
s:=copy(s,1,i);
|
||||||
|
end;
|
||||||
|
for i:=1 to length(s) do
|
||||||
|
begin
|
||||||
|
st:=Data^+s[i];
|
||||||
|
If not assigned(validator) or
|
||||||
|
Validator^.IsValidInput(st,False) then
|
||||||
|
Begin
|
||||||
|
Event.What:=evKeyDown;
|
||||||
|
Event.CharCode:=s[i];
|
||||||
|
Event.Scancode:=0;
|
||||||
|
Inherited HandleEvent(Event);
|
||||||
|
End;
|
||||||
|
end;
|
||||||
|
ClearEvent(Event);
|
||||||
|
end
|
||||||
|
else if ((Event.KeyCode=kbCtrlIns) or (Event.KeyCode=copy_key)) and
|
||||||
|
Assigned(Clipboard) then
|
||||||
|
{ Copy to clipboard }
|
||||||
|
begin
|
||||||
|
s:=GetStr(Data);
|
||||||
|
s:=copy(s,selstart+1,selend-selstart);
|
||||||
|
Clipboard^.SelStart:=Clipboard^.CurPos;
|
||||||
|
Clipboard^.InsertText(s);
|
||||||
|
Clipboard^.SelEnd:=Clipboard^.CurPos;
|
||||||
|
ClearEvent(Event);
|
||||||
|
end
|
||||||
|
else if ((Event.KeyCode=kbShiftDel) or (Event.KeyCode=cut_key)) and
|
||||||
|
Assigned(Clipboard) then
|
||||||
|
{ Cut to clipboard }
|
||||||
|
begin
|
||||||
|
s:=GetStr(Data);
|
||||||
|
s:=copy(s,selstart+1,selend-selstart);
|
||||||
|
Clipboard^.SelStart:=Clipboard^.CurPos;
|
||||||
|
Clipboard^.InsertText(s);
|
||||||
|
Clipboard^.SelEnd:=Clipboard^.CurPos;
|
||||||
|
{ now remove the selected part }
|
||||||
|
Event.keyCode:=kbDel;
|
||||||
|
inherited HandleEvent(Event);
|
||||||
|
ClearEvent(Event);
|
||||||
|
end
|
||||||
|
else if ((Event.KeyCode=kbCtrlDel)) then
|
||||||
|
{ Cut & discard }
|
||||||
|
begin
|
||||||
|
{ now remove the selected part }
|
||||||
|
Event.keyCode:=kbDel;
|
||||||
|
inherited HandleEvent(Event);
|
||||||
|
ClearEvent(Event);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Inherited HandleEvent(Event);
|
||||||
|
End
|
||||||
|
else
|
||||||
|
Inherited HandleEvent(Event);
|
||||||
|
//st:=getstr(data);
|
||||||
|
//Message(Owner,evBroadCast,cmInputLineLen,pointer(Length(st)));
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFPFileDialog.Init(AWildCard: TWildStr; const ATitle,
|
||||||
|
InputName: String; AOptions: Word; HistoryId: Byte);
|
||||||
|
var R: TRect;
|
||||||
|
DInput : PFPFileInputLine;
|
||||||
|
Control : PView;
|
||||||
|
History : PHistory;
|
||||||
|
S : String;
|
||||||
|
begin
|
||||||
|
inherited init(AWildCard,ATitle,InputName,AOptions,HistoryId);
|
||||||
|
FileName^.getData(S);
|
||||||
|
R.Assign(3, 3, 31, 4);
|
||||||
|
DInput := New(PFPFileInputLine, Init(R, 79{FileNameLen+4}));
|
||||||
|
DInput^.SetData(S);
|
||||||
|
InsertBefore(DInput,FileName); {insert before to preserv order as it was}
|
||||||
|
Delete(FileName);
|
||||||
|
Dispose(FileName,done);
|
||||||
|
DInput^.GrowMode:=gfGrowHiX;
|
||||||
|
FileName:=DInput;
|
||||||
|
FileHistory^.Link:=DInput;
|
||||||
|
{resize}
|
||||||
|
if Desktop^.Size.Y > 26 then
|
||||||
|
GrowTo(Size.X,Desktop^.Size.Y-6);
|
||||||
|
if Desktop^.Size.X > 80 then
|
||||||
|
GrowTo(Min(Desktop^.Size.X-(80-Size.X),102),Size.Y);
|
||||||
|
FileList^.NumCols:= Max((FileList^.Size.X-(FileList^.Size.X div 14)) div 14,2);
|
||||||
|
{set focus on the new input line}
|
||||||
|
DInput^.Focus;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TSearchHelperDialog.HandleEvent(var Event : TEvent);
|
procedure TSearchHelperDialog.HandleEvent(var Event : TEvent);
|
||||||
begin
|
begin
|
||||||
case Event.What of
|
case Event.What of
|
||||||
@ -7595,7 +7727,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
else begin Title:='???'; DefExt:=''; end;
|
else begin Title:='???'; DefExt:=''; end;
|
||||||
end;
|
end;
|
||||||
Re:=Application^.ExecuteDialog(New(PFileDialog, Init(DefExt,
|
Re:=Application^.ExecuteDialog(New(PFPFileDialog, Init(DefExt,
|
||||||
Title, label_name, fdOkButton, FileId)), @Name);
|
Title, label_name, fdOkButton, FileId)), @Name);
|
||||||
case Dialog of
|
case Dialog of
|
||||||
edSaveAs :
|
edSaveAs :
|
||||||
|
Loading…
Reference in New Issue
Block a user