public void DrawItem (int nth, bool is_selected) { char ch; if (nth >= listing.Count) throw new Exception ("overflow"); is_selected = HasFocus && is_selected; Move (y + (nth-top) + 1, x + 1); Listing.FileNode node = listing [nth]; int color; if (node == null) throw new Exception (String.Format ("Problem fetching item {0}", nth)); if (node.Info.IsDirectory){ color = is_selected ? ColorFocus : ColorDir; ch = '/'; } else { color = is_selected ? ColorFocus : ColorNormal; ch = ' '; } if (node.Marked) color = is_selected ? ColorHotFocus : ColorHotNormal; Curses.attrset (color); for (int i = 0; i < node.Nested; i++) Curses.addstr (" "); Curses.addch (ch); Curses.addstr (node.Name); }
int CompareNodes (Listing.FileNode a, Listing.FileNode b) { if (a.Name == "..") { return b.Name != ".." ? -1 : 0; } int nl = a.Nested - b.Nested; if (nl != 0) return nl; if (sort_order == SortOrder.Unsorted) return 0; bool adir = a is Listing.DirNode; bool bdir = b is Listing.DirNode; if (adir ^ bdir) { if (adir) return -1; return 1; } switch (sort_order) { case SortOrder.Name: return string.Compare (a.Name, b.Name); case SortOrder.Extension: var sa = Path.GetExtension (a.Name); var sb = Path.GetExtension (b.Name); return string.Compare (sa, sb); case SortOrder.ModifyTime: return DateTime.Compare (a.Info.LastWriteTimeUtc, b.Info.LastWriteTimeUtc); case SortOrder.AccessTime: return DateTime.Compare (a.Info.LastAccessTimeUtc, b.Info.LastAccessTimeUtc); case SortOrder.ChangeTime: return DateTime.Compare (a.Info.LastStatusChangeTimeUtc, b.Info.LastStatusChangeTimeUtc); case SortOrder.Size: long r = a.Info.Length - b.Info.Length; if (r < 0) return -1; if (r > 0) return 1; return 0; case SortOrder.Inode: r = a.Info.Inode - b.Info.Inode; if (r < 0) return -1; if (r > 0) return 1; return 0; } return 0; }