Skip to content

Commit

Permalink
add directory-mode attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Jul 17, 2023
1 parent 8ff2b4d commit 471327f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/ext/directory-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@
A keyword, one of :pathname (sort by file name), :mtime (last modification time) and :size.")

(define-attribute current-directory-attribute
(t :bold t :foreground :base0B))

(define-attribute file-size-attribute
(t :bold t))

(define-attribute file-date-attribute
(t :bold t))

(define-attribute file-attribute
(t))
(t :bold t))

(define-attribute directory-attribute
(t :foreground :base0D :bold t))
Expand Down Expand Up @@ -178,9 +187,11 @@
(with-point ((start point))
(let ((name (or content (namestring (enough-namestring pathname directory)))))
(insert-string point " " 'pathname pathname 'name name)
(insert-string point (format nil " ~5@A "
(let ((size (file-size pathname)))
(if size (human-readable-file-size size) ""))))
(insert-string point
(format nil " ~5@A "
(let ((size (file-size pathname)))
(if size (human-readable-file-size size) "")))
:attribute 'file-size-attribute)
(multiple-value-bind (second minute hour day month year week)
(let ((date (file-write-date pathname)))
(if date
Expand All @@ -190,7 +201,8 @@
(format nil "~4,'0D/~2,'0D/~2,'0D ~2,'0D:~2,'0D:~2,'0D ~A "
year month day hour minute second
(if week (aref #("Mon" "Tue" "Wed" "Thr" "Fri" "Sat" "Sun") week)
" "))))
" "))
:attribute 'file-date-attribute))
(unless (string= name "..")
(insert-icon point name))
(insert-string point
Expand Down Expand Up @@ -227,7 +239,7 @@
(line-number (line-number-at-point p)))
(erase-buffer buffer)
(buffer-start p)
(insert-string p (format nil "~A~2%" directory))
(insert-string p (format nil "~A~2%" directory) :attribute 'current-directory-attribute)
(insert-directories-and-files p directory
:sort-method sort-method
:without-parent-directory nil)
Expand Down

0 comments on commit 471327f

Please sign in to comment.