emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/hyperdrive bf955d34d3 28/32: Add/Change: (hyperdrive-colum


From: ELPA Syncer
Subject: [nongnu] elpa/hyperdrive bf955d34d3 28/32: Add/Change: (hyperdrive-column-headers)
Date: Mon, 4 Sep 2023 18:59:35 -0400 (EDT)

branch: elpa/hyperdrive
commit bf955d34d32d7e384696be0a5dbe4bb3e8840d6a
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Add/Change: (hyperdrive-column-headers)
---
 hyperdrive-handlers.el | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/hyperdrive-handlers.el b/hyperdrive-handlers.el
index 7825566f9e..9e75000aa7 100644
--- a/hyperdrive-handlers.el
+++ b/hyperdrive-handlers.el
@@ -113,13 +113,7 @@ arguments."
                                    :encode t))
                                 entry-names))
                (parent-entry (hyperdrive-parent directory-entry))
-               (main-header (hyperdrive-entry-description directory-entry))
-               (header (concat main-header "\n"
-                               (format "%6s  %s  %s"
-                                       (propertize "Size" 'face 
'hyperdrive-column-header)
-                                       (format 
hyperdrive-timestamp-format-string
-                                               (propertize "Last Modified" 
'face 'hyperdrive-column-header))
-                                       (propertize "Name" 'face 
'hyperdrive-column-header))))
+               (header (hyperdrive-column-headers 
(hyperdrive-entry-description directory-entry)))
                (num-entries (length entries)) (num-filled 0)
               ;; (debug-start-time (current-time))
                (metadata-queue) (ewoc) (prev-entry) (prev-point))
@@ -179,6 +173,34 @@ arguments."
           (when then
             (funcall then)))))))
 
+(defun hyperdrive-column-headers (prefix)
+  "Return column headers as a string with PREFIX.
+Columns are suffixed with up/down arrows according to
+`hyperdrive-sort-entries'."
+  (let ((name-arrow "") (size-arrow "") (date-arrow ""))
+    (pcase-exhaustive hyperdrive-directory-sort
+      (`(hyperdrive-entry-name . ,predicate)
+       (setf name-arrow (pcase-exhaustive predicate
+                          ('string< "▲")
+                          ('string> "▼"))))
+      (`(hyperdrive-entry-size . ,predicate)
+       (setf size-arrow (pcase-exhaustive predicate
+                          ('< "▲")
+                          ('> "▼"))))
+      (`(hyperdrive-entry-date . ,predicate)
+       (setf date-arrow (pcase-exhaustive predicate
+                          ('time-less-p< "▲")
+                          ((pred functionp) "▼")))))
+    (concat prefix "\n"
+            (format "%6s%s  %s%s  %s%s"
+                    (propertize "Size" 'face 'hyperdrive-column-header)
+                    size-arrow
+                    (format hyperdrive-timestamp-format-string
+                            (propertize "Last Modified" 'face 
'hyperdrive-column-header))
+                    date-arrow
+                    (propertize "Name" 'face 'hyperdrive-column-header)
+                    name-arrow))))
+
 (cl-defun hyperdrive-handler-streamable (entry &key _then)
   ;; TODO: Is there any reason to not pass THEN through?
   ;; FIXME: Opening a streamable entry from a hyperdrive-dir buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]