mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-22 08:57:37 +01:00
- added marking of entries in file explorer window.
This commit is contained in:
parent
c6f741d3a8
commit
7619408c0f
@ -614,6 +614,8 @@
|
||||
|
||||
(define-key "N" #'repeat-search *filesystem-explorer-keymap*)
|
||||
|
||||
(define-key "m" #'file-explorer-mark-entry *filesystem-explorer-keymap*)
|
||||
|
||||
(define-key "up" #'file-explorer-go-up *filesystem-explorer-keymap*)
|
||||
|
||||
(define-key "down" #'file-explorer-go-down *filesystem-explorer-keymap*)
|
||||
|
@ -21,11 +21,11 @@
|
||||
((or (fs:backreference-dir-p path)
|
||||
(fs:loopback-reference-dir-p path)
|
||||
(not dirp))
|
||||
(list :path path :dirp dirp))
|
||||
(list :path path :dirp dirp :markedp nil))
|
||||
(dirp
|
||||
(if (scan "/$" path)
|
||||
(list :path path :dirp t)
|
||||
(list :path (strcat path "/") :dirp t)))))
|
||||
(list :path path :dirp t :markedp nil)
|
||||
(list :path (strcat path "/") :dirp t :markedp nil)))))
|
||||
|
||||
(defun make-root-tree (&optional (path "/"))
|
||||
(mtree:make-node (make-node-data path t)))
|
||||
@ -88,11 +88,13 @@ Returns nil if Returns nil if the path does not point to an actual file."))
|
||||
(defmethod calculate :after ((object filesystem-tree-window) dt)
|
||||
(declare (ignore object dt)))
|
||||
|
||||
(defmethod draw :after ((object filesystem-tree-window)))
|
||||
|
||||
(defmacro gen-tree-data-fetcher (name key)
|
||||
`(defun ,(misc:format-fn-symbol t "tree-~a" name) (data)
|
||||
(getf data ,key)))
|
||||
(let ((fn-name (misc:format-fn-symbol t "tree-~a" name)))
|
||||
`(progn
|
||||
(defun ,fn-name (data)
|
||||
(getf data ,key))
|
||||
(defsetf ,fn-name (data) (val)
|
||||
`(setf (getf ,data ,,key) ,val)))))
|
||||
|
||||
(gen-tree-data-fetcher path :path)
|
||||
|
||||
@ -207,10 +209,6 @@ Returns nil if Returns nil if the path does not point to an actual file."))
|
||||
path-to-expand))))))
|
||||
(funcall expand-fn matching-node)))
|
||||
|
||||
(defmethod draw :around ((object filesystem-tree-window))
|
||||
(when-window-shown (object)
|
||||
(call-next-method)))
|
||||
|
||||
(defun %build-annotated-tree-rows (window root-node)
|
||||
(with-accessors ((render-arrow-value render-arrow-value)
|
||||
(render-leaf-value render-leaf-value)
|
||||
@ -419,11 +417,29 @@ Returns nil if Returns nil if the path does not point to an actual file."))
|
||||
for y from y-start by 1
|
||||
for ct from 0
|
||||
for row in rows do
|
||||
(if (selectedp row)
|
||||
(print-text object (text-ellipsis (selected-text row) window-width)
|
||||
x y)
|
||||
(print-text object (text-ellipsis (normal-text row) window-width)
|
||||
x y))))))
|
||||
(cond
|
||||
((selectedp row)
|
||||
(let ((text (tui:copy-tui-string (selected-text row))))
|
||||
(print-text object (text-ellipsis text window-width) x y)))
|
||||
((tree-marked-p (fields row))
|
||||
(let ((text (tui:copy-tui-string (normal-text row))))
|
||||
(print-text object
|
||||
(tui:apply-attributes (text-ellipsis text window-width)
|
||||
:all
|
||||
(tui:combine-attributes (tui:attribute-reverse)
|
||||
(tui:attribute-bold)))
|
||||
x y)))
|
||||
(t
|
||||
(let ((text (tui:copy-tui-string (normal-text row))))
|
||||
(print-text object (text-ellipsis text window-width) x y))))))))
|
||||
|
||||
(defun mark-node (window path &key (toggle t))
|
||||
(when-let* ((root-node (filesystem-root window))
|
||||
(matching-node (find-node root-node path)))
|
||||
(if toggle
|
||||
(setf (tree-marked-p (data matching-node))
|
||||
(not (tree-marked-p (data matching-node))))
|
||||
(setf (tree-marked-p (data matching-node)) t))))
|
||||
|
||||
(defun init (root)
|
||||
"Initialize the window"
|
||||
|
@ -1324,6 +1324,7 @@
|
||||
:make-tui-char
|
||||
:make-tui-string
|
||||
:tui-string-apply-colors
|
||||
:copy-tui-string
|
||||
:apply-attributes))
|
||||
|
||||
(defpackage :command-line
|
||||
@ -2037,6 +2038,7 @@
|
||||
:download-treenode
|
||||
:upload-treenode
|
||||
:filesystem-query-treenode
|
||||
:mark-node
|
||||
:resync-rows-db
|
||||
:init))
|
||||
|
||||
@ -2801,7 +2803,8 @@
|
||||
:file-explorer-create-path
|
||||
:file-explorer-go-down
|
||||
:file-explorer-go-up
|
||||
:file-explorer-search))
|
||||
:file-explorer-search
|
||||
:file-explorer-mark-entry))
|
||||
|
||||
(defpackage :scheduled-events
|
||||
(:use
|
||||
|
@ -425,6 +425,9 @@ latter has a length equals to `total-size'"))
|
||||
(setf (bgcolor char) bgcolor)))
|
||||
results))
|
||||
|
||||
(defun copy-tui-string (text)
|
||||
(croatoan::copy-complex-string text))
|
||||
|
||||
(defgeneric apply-attributes (object index attributes))
|
||||
|
||||
(defmethod apply-attributes ((object complex-string) (index fixnum) attributes)
|
||||
|
@ -2543,3 +2543,12 @@ printed, on the main window."
|
||||
:payload re)))))
|
||||
(ask-string-input #'on-input-complete
|
||||
:prompt (_ "search for: "))))
|
||||
|
||||
(defun file-explorer-mark-entry ()
|
||||
(when-let* ((win *filesystem-explorer-window*)
|
||||
(fields (line-oriented-window:selected-row-fields win))
|
||||
(path (fstree:tree-path fields)))
|
||||
(with-enqueued-process ()
|
||||
(fstree:mark-node win path)
|
||||
(windows:win-clear win)
|
||||
(windows:draw win))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user