diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-02 18:43:24 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-02 18:43:24 +0530 |
| commit | 51e29e21ca118ec690f20eaaf7b2b42c0a90e5e6 (patch) | |
| tree | 455b215c64d493bda6a8d6bb689a02c58b15567f /lib/Daffm/View.hs | |
| parent | 5364332c05749268000c2ac3f0e6880f965e5fdc (diff) | |
| download | daffm-51e29e21ca118ec690f20eaaf7b2b42c0a90e5e6.tar.gz daffm-51e29e21ca118ec690f20eaaf7b2b42c0a90e5e6.zip | |
Simple file explorer ui
Diffstat (limited to '')
| -rw-r--r-- | lib/Daffm/View.hs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Daffm/View.hs b/lib/Daffm/View.hs new file mode 100644 index 0000000..02529ac --- /dev/null +++ b/lib/Daffm/View.hs @@ -0,0 +1,25 @@ +module Daffm.View where + +import Brick.Types (Widget) +import Brick.Widgets.Core (str, vBox, vLimit, withAttr, (<+>)) +import qualified Brick.Widgets.List as L +import Daffm.Attrs (selectedFileAttr) +import Daffm.Types (AppState (..), FileInfo (..)) +import qualified Data.Vector as Vec + +appView :: AppState -> [Widget ()] +appView (AppState {stateFiles, stateCwd}) = [ui] + where + ui = vBox [vLimit 1 header, box, vLimit 1 cmdline] + header = str stateCwd + cmdline = str "Item " <+> cur <+> str " of " <+> total + cur = case L.listSelected stateFiles of + Nothing -> str "-" + Just i -> str (show (i + 1)) + total = str $ show $ Vec.length $ L.listElements stateFiles + box = L.renderList fileItemView True stateFiles + +fileItemView :: Bool -> FileInfo -> Widget () +fileItemView sel (FileInfo {fileName, fileSize, fileType}) = + let wrap w = if sel then withAttr selectedFileAttr w else w + in wrap (str fileName) <+> str (" : " <> show fileSize <> " | " <> show fileType) |
