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

Fixes #2150. Revamping FileDialog #2259

merged 208 commits into from
Apr 9, 2023

Conversation

tznind
Copy link
Collaborator

@tznind tznind commented Dec 28, 2022

Fixes #2150.

FileDialog2

Note: This branch/PR includes #2258 (SplitContainer)

The goals are:

Speed

If using a console TUI, entering a file/directory should be as fast as on the shell directly

  • Allow immediate direct typing of the full/remaining path
    • no tabbing around the UI
    • no moving cursor around in text box etc
  • Support tab autocomplete while typing
  • Support up/down cycling autocomplete

Coloring

Listing files on the console with ls gives coloring that shows what is a directory, what is an image, executable etc.

  • Highlight contents at least as well as ls command
  • Use colors consistent with ls

Navigation (Backwards/Forwards/Up)

After making a navigation into a folder there should be a single key click you can make to take you back. Once moving back you should be able to use another keystroke to move forward again.

  • Hitting Backspace in the Table view changes history
  • Shift+Backspace moves forward again

More File Info

Being able to sort by FileSize or Date Modified is super handy

  • Support hideable/sortable columns for these file details

Other Places

Most GUI file explorers have either a list or a tree recent/root places (e.g. drives)

  • Show relevant SpecialFolder and LogicalDrives on left in a collapsable pane.

TODO

  • Fix all the bugs
  • Make it bulletproof (to permissions, invalid characters etc)
  • Cancellable event for picking existing e.g. 'x.doc already exists, Do you want to replace it'. This allows Save dialogs to function as on Windows/Linux. If user hits No they can continue to make a different selection.
  • Eliminate duplicates in tree view
  • Keyboard controls for column operations (show menu / sort / hide etc)
  • Allow delete files/folders
  • Allow create folder
  • Allow rename files/folders
  • Swallow on Search (or restart the search - this covers use case where you search then tab to new dir then hit Ctrl+F to focus search again and hit enter to restart the search in the new dir).
  • Empower AllowedType e.g. Regex, Default=true etc
  • AllowedType should have max length e.g. if user has 20 file extensions listed
  • Default contains search implementation should treat "blah csv" as 2 search terms (users can always override with custom interface implementation).
  • Make things controllable from config manager
    • Including column stuff e.g. minimum size, column default visibility etc.
  • Fix Title centering when width is odd number and ensure no leading whitespace in title.
  • Multi select
  • Select File/Folder
  • Filter on type (e.g. demand user open only a *.csv file)
  • Maybe some kind of 'contains' search box
  • For scenario, don't use Unicode characters for 'icons' on windows where they are unlikely to not be installed. Instead maybe use ' ' for files and '\' for directories
  • Dark blue for folders is quite hard to read on Windows, default to monochrome mode or light blue?
  • Home/End in TableView should go to first/last row not first/last cell (improves UX when acting like a list)
  • Tests
  • Moving selection to .. should set the text entry to the current dir (not last selected file at that level)
  • Pressing a letter in the TableView should cycle selection (like with ListView).
  • Pressing LEFT cursor when TileView is expanded and first cell in table is selected should move focus to the tree
  • Performance test - go to '/' and search for 'e'. UI should remain responsive even as thousands of files are found.
  • Prevent re-entry e.g. sym link to parent dirs when searching (maybe just don't search them)
  • Show sym links in light blue see: https://stackoverflow.com/a/26473940/4824531

# Additional Review TODOs


  • Show initial sort order
  • Revisit Icons so good default behaviour and understandable docs for user configuration
  • Split up .cs into new folder for filesystem
  • Make spinner reusable
  • Improve usability when pushing a column of table off the screen
  • Revisit forward/backward/up single character buttons
  • get rid of Path chevron
  • Respect ColorScheme more
  • Run Ctrl+K,D on all changed files at end

Reference Examples

Since we are in the domain of terminal use here we should first look at what the basic console offers. The user can select a directory with autocomplete by typing it directly and hitting tab to complete or enter to confirm. Some terminals have more or less autocomplete e.g. with fish will show full autocomplete suggestions in gray:

image
Folder selection in the console

image
Windows file dialog

image
Save/Export dialog in GIMP

image
MacOS file open dialog

image
MS-Dos open dialog for text editor

image
Terminal.Gui file dialog

Fixes #_____ - Include a terse summary of the change or which issue is fixed.

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@tig
Copy link
Collaborator

tig commented Dec 31, 2022

Awesome!

@tznind tznind marked this pull request as ready for review April 8, 2023 09:08
@tznind
Copy link
Collaborator Author

tznind commented Apr 8, 2023

Putting this back in ready for review. I think I have addressed most of the feedback. I still need to look more into configuration manager support and now that we have System.IO.Abstractions I can write some more tests but I think all the functionality is there otherwise.

@tznind
Copy link
Collaborator Author

tznind commented Apr 8, 2023

Tickets that would be nice to have to refactor this include:

@tznind
Copy link
Collaborator Author

tznind commented Apr 8, 2023

Bugs

  • Sometimes the Back arrow will take you from "c:\somedir" back to "c:\somedir". These duplicates should not happen
  • Tab Autocomplete has a case sensitivity issue where if you have a file system:
/folder/item1
/folder/item2

And you enter a capital I (i.e. "/folder/I") then it will correctly propose "item1" and tab completion will work BUT if youpress Down arrow the focus will move to table view (i.e. it will not cycle suggestions).

Copy link
Collaborator

@tig tig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is simply fantastic. I know you're now remembering that the last 10% is the hardest 90% ;-).

Feel free to punt all of my change requests to new Issues we can fix at our leisure except the namespace/file location ones.

Terminal.Gui/FileServices/DefaultFileOperations.cs Outdated Show resolved Hide resolved
Terminal.Gui/Views/FileDialog.cs Show resolved Hide resolved
Terminal.Gui/Views/FileDialog.cs Outdated Show resolved Hide resolved
Terminal.Gui/Views/FileDialog.cs Show resolved Hide resolved
UnitTests/FileDialogTests.cs Outdated Show resolved Hide resolved
UnitTests/FileDialogTests.cs Outdated Show resolved Hide resolved
UnitTests/FileDialogTests.cs Outdated Show resolved Hide resolved
@tznind
Copy link
Collaborator Author

tznind commented Apr 9, 2023

I've updated the class diagram to show all the new classes involved in the dialog:

image

@tig tig merged commit c1a5788 into gui-cs:v2_develop Apr 9, 2023
@tznind tznind deleted the fs branch April 9, 2023 09:31
@Likarion
Copy link

Lets's make FileDialog more customizible for buttons. I suggest adding to the constructor the label for Cancel button and the ability to change the order of the buttons ([ Cancel ][ Open ] -> [ Open ][ Cancel ] -> [ Open ][ Done ]):
`..., ustring prompt, ustring cancel, bool buttonsReverseOrder,...'

@tig
Copy link
Collaborator

tig commented Sep 15, 2023

I'm a fan of making it more customizable but not via a constructor. Constructors should be parameter-less.

@tznind
Copy link
Collaborator Author

tznind commented Sep 15, 2023

Lets's make FileDialog more customizible for buttons. I suggest adding to the constructor the label for Cancel button and the ability to change the order of the buttons ([ Cancel ][ Open ] -> [ Open ][ Cancel ] -> [ Open ][ Done ]):
`..., ustring prompt, ustring cancel, bool buttonsReverseOrder,...'
[...]
And the ability to change the order of the buttons ([ Wait no! ][ Lets go! ] -> [ Lets go! ][ Wait no! ])
// does not exist
// fd.Style.ButtonsReverseOrder = true;

@Likarion

I'm a fan of making it more customizable but not via a constructor. Constructors should be parameter-less.
@tig

Most of what you describe can be accomplished with the Style class. But there are improvements that could be made. I've put what works at the top of this code sample and what we could enable in the bottom (in comments).

fd.Style.OkButtonText = "Lets go!";
fd.Style.ModifiedColumnName = "Date";
fd.Title = "Blerg";

// does not exist
// fd.Style.OkCancelText = "Wait no!";

// currently has internal setters (so you cannot do this).  Also needs slight adjustment
// in order of initialization so user changes would take effect
//fd.Style.PathCaption = "Pick a file";
//fd.Style.SearchCaption = "Find yer stuff";

image
FileDialog with custom title, ok message and table column name

@Likarion
Copy link

And the ability to change the order of the buttons ([ Wait no! ][ Lets go! ] -> [ Lets go! ][ Wait no! ])
// does not exist
// fd.Style.ButtonsReverseOrder = true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants