diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-08 21:48:15 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-08 23:05:31 +0530 |
| commit | b687795db6d57188d6f7d65437f0a8dc0f9a89a4 (patch) | |
| tree | c688f7716461ee2936c7637eaa7dc868aa189d5b /lib/Daffm | |
| parent | 4e8e81b05afa4ba56d64ba714c78ba307f936076 (diff) | |
| download | daffm-b687795db6d57188d6f7d65437f0a8dc0f9a89a4.tar.gz daffm-b687795db6d57188d6f7d65437f0a8dc0f9a89a4.zip | |
Add truncate for current directory
Diffstat (limited to '')
| -rw-r--r-- | lib/Daffm/View.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Daffm/View.hs b/lib/Daffm/View.hs index e65a13a..da6a11b 100644 --- a/lib/Daffm/View.hs +++ b/lib/Daffm/View.hs @@ -1,7 +1,7 @@ module Daffm.View where -import Brick.Types (Widget) -import Brick.Widgets.Core (Padding (Max, Pad), emptyWidget, hBox, hLimit, padLeft, padRight, str, txt, vBox, vLimit, withAttr, (<+>)) +import Brick.Types (Context (availWidth), Size (Fixed), Widget (Widget, render), getContext) +import Brick.Widgets.Core (Padding (Max, Pad), TextWidth (textWidth), emptyWidget, hBox, hLimit, padLeft, padRight, str, txt, vBox, vLimit, withAttr, (<+>)) import Brick.Widgets.Edit (renderEditor) import qualified Brick.Widgets.List as L import Daffm.Attrs (directoryAttr, directoryLinkAttr, directorySelectedAttr, fileAttr, fileSelectedAttr, invalidLinkAttr, linkAttr, searchMarchAttr) @@ -27,7 +27,15 @@ hFixed :: Int -> Widget n -> Widget n hFixed w = hLimit w . padRight Max headerView :: AppState -> Widget n -headerView (AppState {stateCwd}) = txt stateCwd +headerView (AppState {stateCwd}) = Widget Fixed Fixed $ do + c <- getContext + let width = availWidth c - 2 -- with padding + render . toWidget . trunc width $ stateCwd + where + toWidget = padLeft (Pad 1) . padRight (Pad 1) . txt + trunc width text + | width < textWidth text = "…" <> Text.takeEnd (width - 1) text + | otherwise = Text.takeEnd width text fileItemView :: AppState -> Int -> Bool -> FileInfo -> Widget FocusTarget fileItemView appState index sel fileInfo@(FileInfo {filePath, fileSize, fileType, fileMode}) = |
