1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-26 03:28:02 +02:00

Improved cwd handling in comptime, generator file/folder edit

This commit is contained in:
Brian Fiete 2022-05-27 12:20:11 -07:00
parent 49716559e4
commit 087a129007
6 changed files with 130 additions and 32 deletions

View file

@ -57,6 +57,7 @@ namespace IDE.ui
public String mRelPath ~ delete _;
PathKind mPathKind;
DarkButton mBrowseButton;
public String mDefaultFolderPath ~ delete _;
public this(PathKind pathKind = .Unknown)
{
@ -73,6 +74,9 @@ namespace IDE.ui
{
String path = scope .();
GetText(path);
if (path.IsWhiteSpace)
path.Set(mDefaultFolderPath);
#if !CLI
FolderBrowserDialog folderDialog = scope .();
folderDialog.SelectedPath = path;
@ -83,6 +87,30 @@ namespace IDE.ui
}
#endif
}
else if (mPathKind == .File)
{
String path = scope .();
GetText(path);
String dirPath = scope .();
Path.GetDirectoryPath(path, dirPath).IgnoreError();
if ((dirPath.IsWhiteSpace) && (mDefaultFolderPath != null))
dirPath.Set(mDefaultFolderPath);
#if !CLI
OpenFileDialog fileDialog = scope .();
fileDialog.FileName = path;
if (!dirPath.IsWhiteSpace)
fileDialog.InitialDirectory = dirPath;
mWidgetWindow.PreModalChild();
if (fileDialog.ShowDialog(gApp.GetActiveWindow()).GetValueOrDefault() == .OK)
{
if (!fileDialog.FileNames.IsEmpty)
SetText(scope String()..Append(fileDialog.FileNames[0]));
}
#endif
}
});
mEditWidgetContent.mTextInsets.mRight += GS!(20);
}