Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2150. Revamping FileDialog #2259

Merged
merged 208 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
d10101e
Investigating new file dialog
tznind Dec 27, 2022
7d40047
Column sorting
tznind Dec 27, 2022
a6a997d
Add navigationStack
tznind Dec 27, 2022
6212da6
Append autocomplete half working
tznind Dec 27, 2022
4cf0dd3
Change autocomplete append to use draw effect instead of selection ef…
tznind Dec 28, 2022
e7370f1
WIP on FileDialog2
tznind Dec 28, 2022
f43e23c
Refactor sort order and add more 'ls' colors
tznind Dec 28, 2022
66bf342
Refactor history to its own class
tznind Dec 28, 2022
25cc8a8
FileDialog2 navigation fixes/improvements
tznind Dec 28, 2022
258b1a9
Added centered Title
tznind Dec 28, 2022
e4f8865
Add tree view and split container
tznind Dec 28, 2022
3ff0bf9
Add FileDialogState
tznind Dec 29, 2022
2a82c16
Add AllowsMultipleSelection
tznind Dec 30, 2022
1887e16
Add result fields and Scenario
tznind Dec 30, 2022
db428cd
Added FileDialo2 test file
tznind Dec 31, 2022
b42fa62
Merge branch 'develop' into fs
tznind Dec 31, 2022
dcc7cc2
Fix FileDialog2 Redraw padding to respect max/min view bounds
tznind Dec 31, 2022
7a5191d
Fix unit tests and warnings
tznind Dec 31, 2022
aa873a9
Started on better keyboard navigation in FileDialog2
tznind Dec 31, 2022
9539288
Merge branch 'splitcontainer' into fs
tznind Jan 4, 2023
a248c93
Update to match new SplitContainer API
tznind Jan 4, 2023
bfdb720
Quality of Life improvements
tznind Jan 4, 2023
51eb85a
Fix recommending parent folder
tznind Jan 4, 2023
5fa407d
Remove border from SplitContainer in FileDialog2 and fixed tests
tznind Jan 5, 2023
3ed9583
Bugfixes and improvements to FileDialog2
tznind Jan 5, 2023
761bd3a
usability improvements to FileDialog2
tznind Jan 5, 2023
cbb461e
Merge branch 'develop' into fs
tznind Jan 5, 2023
f547e34
Add multi select and OpenMode
tznind Jan 5, 2023
7380aa9
Enforce OpenMode when making a multi selection
tznind Jan 5, 2023
ecad831
Prevent typing illegal characters
tznind Jan 5, 2023
862f62f
Added AllowedTypes to FileDialog2
tznind Jan 5, 2023
6a9c900
Added combo box filter AllowedType
tznind Jan 5, 2023
4635fe3
Improve code readability by reordering members
tznind Jan 5, 2023
e29f37b
Do not update FileDialog2 text box when selecting ".." in TableView
tznind Jan 5, 2023
00420f0
Fix history navigation in FileDialog2
tznind Jan 5, 2023
5798858
Restore selection after navigating backwards in history
tznind Jan 5, 2023
834fb99
Add FileDialog2 tests
tznind Jan 5, 2023
ad31a07
Make FileDialog2 Title user configurable
tznind Jan 5, 2023
85dd834
Fix DirectTyping_Allowed unit test when running on linux
tznind Jan 5, 2023
045eb8b
Change Home/End to go to first/last cell in table in FileDialog2
tznind Jan 5, 2023
af444c1
Remove overloaded Title property
tznind Jan 5, 2023
8208ff3
Merge branch 'develop' into fs
tznind Jan 5, 2023
90ab6ec
Switch to `ustring.IsNullOrEmpty`
tznind Jan 5, 2023
aad75db
Merge branch 'fs' of https://github.com/tznind/gui.cs into fs
tznind Jan 5, 2023
e74beae
Merge branch 'splitcontainer' into fs
tznind Feb 6, 2023
d2446db
Update to latest TileView API
tznind Feb 6, 2023
f6ad599
Add TableView navigation by letter using CollectionNavigator
tznind Feb 6, 2023
8bc83b9
Fix recreating search navigator too often
tznind Feb 6, 2023
d9e484b
Merge pull request #154 from tig/tznind-splitcontainer
tznind Feb 13, 2023
67cdb56
Add tests for proper disposing
tznind Feb 13, 2023
1407705
Make Ctrl+F10 toggle split line focusability
tznind Feb 18, 2023
c5243ff
Fix layout bug in first tile when orientation is horizontal
tznind Feb 18, 2023
6f8ae9b
Merge branch 'develop' into splitcontainer
tznind Feb 18, 2023
0d022da
Merge branch 'splitcontainer' of https://github.com/tznind/gui.cs int…
tznind Feb 18, 2023
6f2ac69
Merge branch 'develop' into splitcontainer
tig Feb 20, 2023
369cd67
merged line canvas etc
tig Feb 20, 2023
67a9e05
Switch to GenerateImage
tznind Feb 20, 2023
971062c
Merge branch 'develop' into splitcontainer
tig Feb 22, 2023
3c3a014
Fix not calling base constructor
tznind Feb 24, 2023
edf766e
Merge branch 'splitcontainer' into tznind-splitcontainer
tznind Feb 24, 2023
6be0972
Merge pull request #158 from tig/tznind-splitcontainer
tznind Feb 24, 2023
a068933
Revert "Merges latest LineCanvas into TileView"
tznind Feb 24, 2023
44c6978
Merge pull request #160 from tznind/revert-158-tznind-splitcontainer
tznind Feb 24, 2023
ed17727
Fix keyboard tab navigation problems
tznind Feb 25, 2023
7929084
Workaround for changing CanFocus throwing Exceptions sometimes
tznind Feb 25, 2023
bd066c0
Merge branch 'gui-cs:develop' into fs
tznind Feb 25, 2023
fb4e2fc
Merge branch 'splitcontainer' into fs
tznind Feb 25, 2023
f870764
Update to latest splitcontainer API
tznind Feb 25, 2023
016e377
Adjust suggestions to be gray and properly update on keystrokes
tznind Feb 25, 2023
33f9137
Move ok and cancel to bottom
tznind Feb 25, 2023
2bf4463
Add MustExist and fix multi selection of 1 result
tznind Feb 25, 2023
f828ea3
bugfixes and quality of life
tznind Feb 25, 2023
270d879
Navigating to .. clears path up to current dir
tznind Feb 25, 2023
d21b23e
Better arrow key navigation
tznind Feb 25, 2023
c35f956
Make title pretty and informative
tznind Feb 25, 2023
9dcb34e
Fix test
tznind Feb 25, 2023
8d255ff
Fix test
tznind Feb 25, 2023
7e446ff
Merge branch 'develop' into fs
tznind Feb 25, 2023
e9a100c
Trim default Titles to be more compact and readable
tznind Feb 26, 2023
d182c66
Merge branch 'v2' into fs
tznind Mar 3, 2023
8d62f39
Fix bad merge changes
tznind Mar 3, 2023
80eb291
Remove EscSeqReq files that are not in v2... came from develop?!
tznind Mar 3, 2023
5aef9fa
Fix nullable and enable toggle select on table view
tznind Mar 3, 2023
95148f0
Fix multi select return value
tznind Mar 3, 2023
0766f66
Add icon and monochrome support
tznind Mar 3, 2023
f73e985
Add search elements
tznind Mar 3, 2023
f077334
Add search for current directory
tznind Mar 3, 2023
a5c2554
Merge branch 'v2_develop' into fs
tznind Mar 3, 2023
0cc4c27
WIP: Async search
tznind Mar 3, 2023
a2e5169
Merge branch 'fs' of https://github.com/tznind/gui.cs into fs
tznind Mar 3, 2023
d05aa6d
Thread safety and disposal
tznind Mar 3, 2023
6e1c436
Improve UX
tznind Mar 3, 2023
76cdba7
Fix for rapid search results
tznind Mar 3, 2023
4cc0c3a
Fix warnings and whitespace
tznind Mar 3, 2023
f670cc8
Don't add more than 10000 search results
tznind Mar 4, 2023
efd0041
Add support for adjusting search matching
tznind Mar 4, 2023
9646e5b
Added ISearchMatcher example to FileDialog2Example
tznind Mar 5, 2023
b5f5127
Remove double spaces after periods
tznind Mar 6, 2023
4cab118
Make MaxSearchResults a config setting
tznind Mar 6, 2023
684102b
Localization for FileDialog2
tznind Mar 8, 2023
a163238
Merge branch 'fs' of https://github.com/tznind/gui.cs into fs
tznind Mar 8, 2023
debff32
Fix build error
tznind Mar 8, 2023
f7f223e
Support for custom open button Text
tznind Mar 8, 2023
3abffa8
Improve file dialog scenario UX
tznind Mar 8, 2023
36503b6
Change feedback to a drawing effect in center of screen
tznind Mar 8, 2023
0fd95bc
Merge branch 'v2_develop' into fs
tznind Mar 9, 2023
085dff4
Explore MenuBar instead of ComboBox for AllowedTypes
tznind Mar 10, 2023
c493580
Fix prompt and move file open into try/catch for errors reading files
tznind Mar 11, 2023
f9fce97
Open menu when tabbed to
tznind Mar 11, 2023
2512c21
Merge branch 'v2_develop' into fs
tznind Mar 17, 2023
be4e3ab
FileDialog2 improvements
tznind Mar 17, 2023
7f452b2
Add style settings in scenario and make autocomplete case insensitive…
tznind Mar 17, 2023
51c4bc9
Move ok button text to Style
tznind Mar 17, 2023
1ea2e1b
xmldoc
tznind Mar 17, 2023
5b9805e
Remove old FileDialog and re-wire OpenDialog and SaveDialog to use Fi…
tznind Mar 17, 2023
c532b49
localization
tznind Mar 17, 2023
62a3257
Move open/save dialog to their own files
tznind Mar 17, 2023
bfd596a
Rename FileDialog2 to FileDialog
tznind Mar 17, 2023
050a564
Fix repetition in string
tznind Mar 17, 2023
bc88614
Add IAllowedType
tznind Mar 18, 2023
3aab5a8
Get rid of AllowedTypesIsStrict
tznind Mar 18, 2023
cab2128
Add max length to AllowedType ToString
tznind Mar 19, 2023
f6bc747
Pressing Enter in find restarts search instead of confirm selection
tznind Mar 19, 2023
9c1a80e
Add TreeRootGetter for customizing the quick access items in FileDialog
tznind Mar 19, 2023
cedc4fb
Add FilesSelected event
tznind Mar 19, 2023
382f978
Merge branch 'v2_develop' into fs
tznind Mar 19, 2023
b629d69
merge v2_develop into fs
tznind Mar 20, 2023
fb20edd
Update to new sender, event args signature
tznind Mar 20, 2023
2f557f5
Fix naming on MouseEventArgs
tznind Mar 20, 2023
fe38c77
Merge branch 'events-mouse-fix' into fs
tznind Mar 20, 2023
15182fe
Fix mouse events naming
tznind Mar 20, 2023
97c50b5
Revert "Fix naming on MouseEventArgs"
tznind Mar 22, 2023
8583bd4
Merge branch 'v2_develop' into fs
tznind Mar 22, 2023
323c1cf
Add deletion support
tznind Mar 22, 2023
10469e3
Move delete keybinding to tableview
tznind Mar 22, 2023
6fc6a2e
Scaffold for rename and new operations
tznind Mar 22, 2023
0051d7a
Prevent delete dialog popping up again on cancel
tznind Mar 22, 2023
080a4cd
Add rename and new folder implementations
tznind Mar 22, 2023
08e89d7
Add rename,delete,new to context menu
tznind Mar 23, 2023
c1a4a18
On rename or new, reselect the file in its new location in tree
tznind Mar 23, 2023
123d186
Support searching on multiple terms
tznind Mar 23, 2023
3ff7058
Localization support for new/rename/delete
tznind Mar 23, 2023
bc05775
Refactor internal classes and add class diagram
tznind Mar 23, 2023
05d12cc
Move some visual properties to FileDialogStyle
tznind Mar 23, 2023
da63caa
Ensure MultiSelected is never null and always contains Path if relevant
tznind Mar 23, 2023
bffa647
Fix spacing/indentation
tznind Mar 23, 2023
e02881f
WIP: Add new namespace Terminal.Gui.FileServices
tznind Mar 24, 2023
6a86ae2
Improve appearance of back/forward/up
tznind Mar 24, 2023
1d78f57
Move SpinnerLabel to Views
tznind Mar 27, 2023
9ee207c
Merge branch 'fs' of https://github.com/tznind/gui.cs into fs
tznind Mar 27, 2023
e1e3e06
Add SpinnerView
tznind Mar 27, 2023
a0c02c6
Code formatting
tznind Mar 27, 2023
172036f
Add AutoSpin test
tznind Mar 27, 2023
3ee6760
Avoid ever removing spinner timeout twice
tznind Mar 27, 2023
1f68487
Make SpinnerView show/hide instead of stopping
tznind Mar 27, 2023
e147012
Merge branch 'v2_develop' into spinner
tznind Mar 30, 2023
dda6dee
Merge branch 'spinner' into fs
tznind Apr 1, 2023
4d8a261
Merge branch 'suggest-append' into fs
tznind Apr 1, 2023
53fc7c2
Merge branch 'caption' into fs
tznind Apr 1, 2023
544681a
WIP: Refactor to use 3 sub PRs
tznind Apr 1, 2023
a597eea
Add FilepathSuggestionGenerator
tznind Apr 2, 2023
6d981ac
WIP: FileDialog autocomplete append mostly working again
tznind Apr 2, 2023
c2db954
Improve file autocomplete
tznind Apr 2, 2023
20f773d
Move IconGetter to Style and provide default implementation
tznind Apr 2, 2023
2b01a4c
Fix failing unit test
tznind Apr 2, 2023
6bd8340
Improved colors and layout
tznind Apr 2, 2023
ebb1f74
Adjust use of unicode
tznind Apr 3, 2023
6b59847
Merge branch 'v2_develop' into fs
tznind Apr 3, 2023
82c1fca
Fix UseUnicodeCharacters
tznind Apr 3, 2023
63ccc23
Update table style to include scroll indicators and lines
tznind Apr 3, 2023
267121a
Fix cycle suggestion with down cursor
tznind Apr 3, 2023
179c653
Adjust sort indicators
tznind Apr 3, 2023
eec04f9
Add default sort order on isDir then name
tznind Apr 3, 2023
32369df
Always use left/right unicode arrows
tznind Apr 3, 2023
043983c
Fix autocomplete suggesting in empty textbox
tznind Apr 4, 2023
b64ef67
Press escape to cancel ongoing search (when search box is focused)
tznind Apr 4, 2023
1b05ac9
When entering a TreeView if there is no selection then select first o…
tznind Apr 4, 2023
5411dd9
Move CursorIsAtEnd to TextField
tznind Apr 4, 2023
9805ada
Improve layout
tznind Apr 4, 2023
0ad3cbb
Change UseColors to be a cell color fill
tznind Apr 4, 2023
1e44498
Merge branch 'table-cell-draw-fix' into fs
tznind Apr 4, 2023
f61f31b
Merge branch 'v2_develop' into fs
tznind Apr 6, 2023
4093fb5
Fxied tests for new apis
tznind Apr 6, 2023
5c799fc
Remove manual title drawing code
tznind Apr 6, 2023
a5f9c07
Fix MoveEnd name conflicting with base class
tznind Apr 6, 2023
5b8ba95
Merge v2_develop into fs
tznind Apr 7, 2023
5b15240
Fix merge conflicts
tznind Apr 7, 2023
7d35ca8
Switched to IFileSystem for unit testing
tznind Apr 7, 2023
8f0778c
Add unit test
tznind Apr 7, 2023
7f19cd4
Revert "Fix MoveEnd name conflicting with base class"
tznind Apr 7, 2023
489c338
Fix MoveEnd name collision with 'new' keyword
tznind Apr 7, 2023
2bbcf18
Fixed tree not toggling
tznind Apr 7, 2023
847626a
DateTime fixes and mocking
tznind Apr 7, 2023
a474588
Fix TestDirectoryContents_Windows
tznind Apr 8, 2023
1960576
Expose UseColors and UseUnicodeCharacters as config settings
tznind Apr 8, 2023
212d61e
Fix linter settings having removed curly brackets
tznind Apr 8, 2023
e7206b2
Fix namespace on test
tznind Apr 9, 2023
30879c4
Move tests to file services folder
tznind Apr 9, 2023
380e901
Remove the FileServices namespace
tznind Apr 9, 2023
ad7ebf3
Updated class diagram
tznind Apr 9, 2023
0189a38
Clear title from tests for futureproofing
tznind Apr 9, 2023
a6c5743
Merge branch 'v2_develop' into fs
tznind Apr 9, 2023
428c2ac
Localization support for FileDialog title
tznind Apr 9, 2023
6ad0410
Merge branch 'fs' of https://github.com/tznind/gui.cs into fs
tznind Apr 9, 2023
0040338
Remove trailing whitespace in "open existing"
tznind Apr 9, 2023
3ba344f
Merge branch 'v2_develop' into fs
tig Apr 9, 2023
7081250
Fix listing suggestions immediately after folder path entered
tznind Apr 9, 2023
cf27b45
Merge branch 'fs' of https://github.com/tznind/gui.cs into fs
tznind Apr 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions Terminal.Gui/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Terminal.Gui/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,47 @@
<data name="wzNext" xml:space="preserve">
<value>_Next...</value>
</data>
<data name="fdDirectoryAlreadyExistsFeedback" xml:space="preserve">
<value>Directory already exists with that name</value>
<comment>When trying to save a file with a name already taken by a directory</comment>
</data>
<data name="fdDirectoryMustExistFeedback" xml:space="preserve">
<value>Must select an existing directory</value>
</data>
<data name="fdFileAlreadyExistsFeedback" xml:space="preserve">
<value>File already exists with that name</value>
</data>
<data name="fdFileMustExistFeedback" xml:space="preserve">
<value>Must select an existing file</value>
<comment>When trying to save a directory with a name already used by a file</comment>
</data>
<data name="fdFilename" xml:space="preserve">
<value>Filename</value>
</data>
<data name="fdFileOrDirectoryMustExistFeedback" xml:space="preserve">
<value>Must select an existing file or directory</value>
</data>
<data name="fdModified" xml:space="preserve">
<value>Modified</value>
</data>
<data name="fdPathCaption" xml:space="preserve">
<value>Enter Path</value>
</data>
<data name="fdSearchCaption" xml:space="preserve">
<value>Enter Search</value>
</data>
<data name="fdSize" xml:space="preserve">
<value>Size</value>
</data>
<data name="fdType" xml:space="preserve">
<value>Type</value>
</data>
<data name="fdWrongFileTypeFeedback" xml:space="preserve">
<value>Wrong file type</value>
<comment>When trying to open/save a file that does not match the provided filter (e.g. csv)</comment>
</data>
<data name="fdAnyFiles" xml:space="preserve">
<value>Any Files</value>
<comment>Describes an AllowedType that matches anything</comment>
</data>
</root>
88 changes: 88 additions & 0 deletions Terminal.Gui/Windows/AllowedType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System;
using System.Data;
using System.IO;
using System.Linq;
using Terminal.Gui.Resources;

namespace Terminal.Gui {

/// <summary>
/// Interface for <see cref="FileDialog"/> restrictions on which file type(s) the
/// user is allowed to select/enter.
/// </summary>
public interface IAllowedType
{
/// <summary>
/// Returns true if the file at <paramref name="path"/> is compatible with this
/// allow option. Note that the file may not exist (e.g. in the case of saving).
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
bool IsAllowed (string path);
}
/// <summary>
/// Describes a requirement on what <see cref="FileInfo"/> can be selected
/// in a <see cref="FileDialog"/>.
/// </summary>
public class AllowedType : IAllowedType {

/// <summary>
/// Initializes a new instance of the <see cref="AllowedType"/> class.
/// </summary>
/// <param name="description">The human readable text to display.</param>
/// <param name="extensions">Extension(s) to match e.g. .csv.</param>
public AllowedType (string description, params string [] extensions)
{
if (extensions.Length == 0) {
throw new ArgumentException ("You must supply at least one extension");
}

this.Description = description;
this.Extensions = extensions;
}

/// <summary>
/// Gets a value of <see cref="AllowedType"/> that matches any file.
/// </summary>
public static AllowedType Any { get; } = new AllowedType (Strings.fdAnyFiles, ".*");

/// <summary>
/// Gets or Sets the human readable description for the file type
/// e.g. "Comma Separated Values".
/// </summary>
public string Description { get; set; }

/// <summary>
/// Gets or Sets the permitted file extension(s) (e.g. ".csv").
/// </summary>
public string [] Extensions { get; set; }


/// <summary>
/// Returns <see cref="Description"/> plus all <see cref="Extensions"/> separated by semicolons.
/// </summary>
public override string ToString ()
{
return $"{this.Description} ({string.Join (";", this.Extensions.Select (e => '*' + e).ToArray ())})";
}

/// <inheritdoc/>
public bool IsAllowed(string path)
{
if (this == Any) {
return true;
}

var extension = Path.GetExtension (path);

// There is a requirement to have a particular extension and we have none
if (string.IsNullOrEmpty (extension)) {
return false;
}
tznind marked this conversation as resolved.
Show resolved Hide resolved


return this.Extensions.Any (e => e.Equals (extension));
}
}

}
Loading