diff --git a/Terminal.Gui/FileServices/FileDialogState.cs b/Terminal.Gui/FileServices/FileDialogState.cs
index 677409665..8682b630d 100644
--- a/Terminal.Gui/FileServices/FileDialogState.cs
+++ b/Terminal.Gui/FileServices/FileDialogState.cs
@@ -53,7 +53,7 @@ namespace Terminal.Gui {
if (Parent.AllowedTypes.Any () && Parent.OpenMode == OpenMode.File) {
children = children.Where (
- c => c.IsDir () ||
+ c => c.IsDir ||
(c.FileSystemInfo is IFileInfo f && Parent.IsCompatibleWithAllowedExtensions (f)))
.ToList ();
}
@@ -77,7 +77,7 @@ namespace Terminal.Gui {
protected bool MatchesApiFilter (FileSystemInfoStats arg)
{
- return arg.IsDir () ||
+ return arg.IsDir ||
(arg.FileSystemInfo is IFileInfo f && Parent.CurrentFilter.IsAllowed (f.FullName));
}
}
diff --git a/Terminal.Gui/FileServices/FileDialogStyle.cs b/Terminal.Gui/FileServices/FileDialogStyle.cs
index 66ddc3089..4e7dcdf17 100644
--- a/Terminal.Gui/FileServices/FileDialogStyle.cs
+++ b/Terminal.Gui/FileServices/FileDialogStyle.cs
@@ -91,12 +91,12 @@ namespace Terminal.Gui {
/// Gets or sets the text on the 'Ok' button. Typically you may want to change this to
/// "Open" or "Save" etc.
///
- public string OkButtonText { get; set; } = "Ok";
+ public string OkButtonText { get; set; } = Strings.btnOk;
///
/// Gets or sets the text on the 'Cancel' button.
///
- public string CancelButtonText { get; set; } = "Cancel";
+ public string CancelButtonText { get; set; } = Strings.btnCancel;
///
/// Gets or sets whether to flip the order of the Ok and Cancel buttons. Defaults
diff --git a/Terminal.Gui/FileServices/FileSystemInfoStats.cs b/Terminal.Gui/FileServices/FileSystemInfoStats.cs
index f850bf2e2..3d7a7d020 100644
--- a/Terminal.Gui/FileServices/FileSystemInfoStats.cs
+++ b/Terminal.Gui/FileServices/FileSystemInfoStats.cs
@@ -4,6 +4,7 @@ using System.Globalization;
using System.IO;
using System.IO.Abstractions;
using System.Linq;
+using Terminal.Gui.Resources;
namespace Terminal.Gui {
@@ -26,7 +27,7 @@ namespace Terminal.Gui {
private const long ByteConversion = 1024;
- private static readonly string [] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
+ private static readonly string [] SizeSuffixes = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
private static readonly List ImageExtensions = new List { ".JPG", ".JPEG", ".JPE", ".BMP", ".GIF", ".PNG" };
private static readonly List ExecutableExtensions = new List { ".EXE", ".BAT" };
@@ -46,7 +47,8 @@ namespace Terminal.Gui {
this.Type = fi.Extension;
} else {
this.HumanReadableLength = string.Empty;
- this.Type = "dir";
+ this.Type = $"<{Strings.fdDirectory}>";
+ this.IsDir = true;
}
}
@@ -66,10 +68,7 @@ namespace Terminal.Gui {
public bool IsParent { get; internal set; }
public string Name => this.IsParent ? ".." : this.FileSystemInfo.Name;
- public bool IsDir ()
- {
- return this.Type == "dir";
- }
+ public bool IsDir { get; }
public bool IsImage ()
{
@@ -96,7 +95,7 @@ namespace Terminal.Gui {
}
if (value == 0) {
- return "0.0 bytes";
+ return "0.0 B";
}
int mag = (int)Math.Log (value, ByteConversion);
diff --git a/Terminal.Gui/Resources/Strings.Designer.cs b/Terminal.Gui/Resources/Strings.Designer.cs
index a71f357ce..3a77922a0 100644
--- a/Terminal.Gui/Resources/Strings.Designer.cs
+++ b/Terminal.Gui/Resources/Strings.Designer.cs
@@ -195,6 +195,60 @@ namespace Terminal.Gui.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to _Delete.
+ ///
+ internal static string fdCtxDelete {
+ get {
+ return ResourceManager.GetString("fdCtxDelete", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _Hide {0}.
+ ///
+ internal static string fdCtxHide {
+ get {
+ return ResourceManager.GetString("fdCtxHide", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _New.
+ ///
+ internal static string fdCtxNew {
+ get {
+ return ResourceManager.GetString("fdCtxNew", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _Rename.
+ ///
+ internal static string fdCtxRename {
+ get {
+ return ResourceManager.GetString("fdCtxRename", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _Sort {0} ASC.
+ ///
+ internal static string fdCtxSortAsc {
+ get {
+ return ResourceManager.GetString("fdCtxSortAsc", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to _Sort {0} DESC.
+ ///
+ internal static string fdCtxSortDesc {
+ get {
+ return ResourceManager.GetString("fdCtxSortDesc", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Are you sure you want to delete '{0}'? This operation is permanent.
///
diff --git a/Terminal.Gui/Resources/Strings.ja-JP.resx b/Terminal.Gui/Resources/Strings.ja-JP.resx
index 35d0e2bf8..14e5ac1de 100644
--- a/Terminal.Gui/Resources/Strings.ja-JP.resx
+++ b/Terminal.Gui/Resources/Strings.ja-JP.resx
@@ -255,4 +255,22 @@
名前を付けて保存 (_S)
+
+ 削除 (_D)
+
+
+ {0}を隠す (_H)
+
+
+ 新規 (_N)
+
+
+ 名前変更 (_R)
+
+
+ {0}で昇順ソート (_S)
+
+
+ {0}で降順ソート (_S)
+
\ No newline at end of file
diff --git a/Terminal.Gui/Resources/Strings.resx b/Terminal.Gui/Resources/Strings.resx
index 887431f43..d8159c6e0 100644
--- a/Terminal.Gui/Resources/Strings.resx
+++ b/Terminal.Gui/Resources/Strings.resx
@@ -259,4 +259,22 @@
Cancel
+
+ _Delete
+
+
+ _Hide {0}
+
+
+ _New
+
+
+ _Rename
+
+
+ _Sort {0} ASC
+
+
+ _Sort {0} DESC
+
\ No newline at end of file
diff --git a/Terminal.Gui/Resources/Strings.zh-Hans.resx b/Terminal.Gui/Resources/Strings.zh-Hans.resx
index b0358523f..da767eaa3 100644
--- a/Terminal.Gui/Resources/Strings.zh-Hans.resx
+++ b/Terminal.Gui/Resources/Strings.zh-Hans.resx
@@ -255,4 +255,22 @@
取消 (_C)
+
+ 删除 (_D)
+
+
+ 隐藏{0} (_H)
+
+
+ 新建 (_N)
+
+
+ 重命名 (_R)
+
+
+ {0}顺序排序 (_S)
+
+
+ {0}逆序排序 (_S)
+
\ No newline at end of file
diff --git a/Terminal.Gui/Views/FileDialog.cs b/Terminal.Gui/Views/FileDialog.cs
index 725bbfa86..95d637a66 100644
--- a/Terminal.Gui/Views/FileDialog.cs
+++ b/Terminal.Gui/Views/FileDialog.cs
@@ -1291,7 +1291,7 @@ namespace Terminal.Gui {
// This portion is never reordered (aways .. at top then folders)
var forcedOrder = stats
.OrderByDescending (f => f.IsParent)
- .ThenBy (f => f.IsDir () ? -1 : 100);
+ .ThenBy (f => f.IsDir ? -1 : 100);
// This portion is flexible based on the column clicked (e.g. alphabetical)
var ordered =
@@ -1325,10 +1325,10 @@ namespace Terminal.Gui {
// work out new sort order
if (this.currentSortColumn == clickedCol && this.currentSortIsAsc) {
isAsc = false;
- return $"{tableView.Table.ColumnNames [clickedCol]} DESC";
+ return string.Format (Strings.fdCtxSortDesc, tableView.Table.ColumnNames [clickedCol]);
} else {
isAsc = true;
- return $"{tableView.Table.ColumnNames [clickedCol]} ASC";
+ return string.Format (Strings.fdCtxSortAsc, tableView.Table.ColumnNames [clickedCol]);
}
}
@@ -1341,8 +1341,8 @@ namespace Terminal.Gui {
e.MouseEvent.Y + 1,
new MenuBarItem (new MenuItem []
{
- new MenuItem($"Hide {StripArrows(tableView.Table.ColumnNames[clickedCol])}", string.Empty, () => this.HideColumn(clickedCol)),
- new MenuItem($"Sort {StripArrows(sort)}",string.Empty, ()=> this.SortColumn(clickedCol,isAsc)),
+ new MenuItem(string.Format (Strings.fdCtxHide, StripArrows (tableView.Table.ColumnNames[clickedCol])), string.Empty, () => this.HideColumn (clickedCol)),
+ new MenuItem(StripArrows (sort), string.Empty, () => this.SortColumn (clickedCol, isAsc)),
})
);
@@ -1365,9 +1365,9 @@ namespace Terminal.Gui {
e.MouseEvent.Y + 1,
new MenuBarItem (new MenuItem []
{
- new MenuItem($"New", string.Empty, () => New()),
- new MenuItem($"Rename",string.Empty, ()=> Rename()),
- new MenuItem($"Delete",string.Empty, ()=> Delete()),
+ new MenuItem(Strings.fdCtxNew, string.Empty, New),
+ new MenuItem(Strings.fdCtxRename, string.Empty, Rename),
+ new MenuItem(Strings.fdCtxDelete,string.Empty, Delete),
})
);
diff --git a/UnitTests/FileServices/FileDialogTests.cs b/UnitTests/FileServices/FileDialogTests.cs
index fb1b28b3f..93e1b1ca8 100644
--- a/UnitTests/FileServices/FileDialogTests.cs
+++ b/UnitTests/FileServices/FileDialogTests.cs
@@ -385,21 +385,21 @@ namespace Terminal.Gui.FileServicesTests {
string expected =
@$"
- ┌──────────────────────────────────────────────────────────────────┐
- │/demo/ │
-│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
- │┌────────────┬──────────┬──────────────────────────────┬─────────┐│
- ││Filename (▲)│Size │Modified │Type ││
- │├────────────┼──────────┼──────────────────────────────┼─────────┤│
- ││.. │ │ │dir ││
- ││/subfolder │ │2002-01-01T22:42:10 │dir ││
- ││image.gif │4.00 bytes│2002-01-01T22:42:10 │.gif ││
- ││jQuery.js │7.00 bytes│2001-01-01T11:44:42 │.js ││
- │ │
- │ │
- │ │
-│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} Ok {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
- └──────────────────────────────────────────────────────────────────┘
+┌─────────────────────────────────────────────────────────────────────────┐
+│/demo/ │
+│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
+│┌────────────┬──────────┬──────────────────────────────┬────────────────┐│
+││Filename (▲)│Size │Modified │Type ││
+│├────────────┼──────────┼──────────────────────────────┼────────────────┤│
+││.. │ │ │ ││
+││/subfolder │ │2002-01-01T22:42:10 │ ││
+││image.gif │4.00 B │2002-01-01T22:42:10 │.gif ││
+││jQuery.js │7.00 B │2001-01-01T11:44:42 │.js ││
+│ │
+│ │
+│ │
+│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} OK {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
+└─────────────────────────────────────────────────────────────────────────┘
";
TestHelpers.AssertDriverContentsAre (expected, output, true);
}
@@ -421,21 +421,21 @@ namespace Terminal.Gui.FileServicesTests {
string expected =
@$"
-┌──────────────────────────────────────────────────────────────────┐
-│c:\demo\ │
-│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
-│┌────────────┬──────────┬──────────────────────────────┬─────────┐│
-││Filename (▲)│Size │Modified │Type ││
-│├────────────┼──────────┼──────────────────────────────┼─────────┤│
-││.. │ │ │dir ││
-││\subfolder │ │2002-01-01T22:42:10 │dir ││
-││image.gif │4.00 bytes│2002-01-01T22:42:10 │.gif ││
-││jQuery.js │7.00 bytes│2001-01-01T11:44:42 │.js ││
-││mybinary.exe│7.00 bytes│2001-01-01T11:44:42 │.exe ││
-│ │
-│ │
-│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} Ok {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
-└──────────────────────────────────────────────────────────────────┘
+┌─────────────────────────────────────────────────────────────────────────┐
+│c:\demo\ │
+│{CM.Glyphs.LeftBracket}▲{CM.Glyphs.RightBracket} │
+│┌────────────┬──────────┬──────────────────────────────┬────────────────┐│
+││Filename (▲)│Size │Modified │Type ││
+│├────────────┼──────────┼──────────────────────────────┼────────────────┤│
+││.. │ │ │ ││
+││\subfolder │ │2002-01-01T22:42:10 │ ││
+││image.gif │4.00 B │2002-01-01T22:42:10 │.gif ││
+││jQuery.js │7.00 B │2001-01-01T11:44:42 │.js ││
+││mybinary.exe│7.00 B │2001-01-01T11:44:42 │.exe ││
+│ │
+│ │
+│{CM.Glyphs.LeftBracket} ►► {CM.Glyphs.RightBracket} Enter Search {CM.Glyphs.LeftBracket} OK {CM.Glyphs.RightBracket} {CM.Glyphs.LeftBracket} Cancel {CM.Glyphs.RightBracket} │
+└─────────────────────────────────────────────────────────────────────────┘
";
TestHelpers.AssertDriverContentsAre (expected, output, true);
}
@@ -559,7 +559,8 @@ namespace Terminal.Gui.FileServicesTests {
fileSystem.AddFile (@"c:\demo\subfolder\image2.gif", new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 }) { LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10) });
var fd = new FileDialog (fileSystem) {
- Height = 15
+ Height = 15,
+ Width = 75
};
fd.Path = @"c:\demo\";
Begin (fd);
@@ -583,7 +584,8 @@ namespace Terminal.Gui.FileServicesTests {
fileSystem.AddFile (@"/demo/subfolder/image2.gif", new MockFileData (new byte [] { 0x12, 0x34, 0x56, 0xd2 }) { LastWriteTime = new DateTime (2002, 01, 01, 22, 42, 10) });
var fd = new FileDialog (fileSystem) {
- Height = 15
+ Height = 15,
+ Width = 75
};
fd.Path = @"/demo/";
Begin (fd);