aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-10-08 21:48:15 +0530
committerAkshay Nair <phenax5@gmail.com>2025-10-08 23:05:31 +0530
commitb687795db6d57188d6f7d65437f0a8dc0f9a89a4 (patch)
treec688f7716461ee2936c7637eaa7dc868aa189d5b
parent4e8e81b05afa4ba56d64ba714c78ba307f936076 (diff)
downloaddaffm-b687795db6d57188d6f7d65437f0a8dc0f9a89a4.tar.gz
daffm-b687795db6d57188d6f7d65437f0a8dc0f9a89a4.zip
Add truncate for current directory
-rw-r--r--lib/Daffm/View.hs14
-rw-r--r--notes.org18
2 files changed, 20 insertions, 12 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}) =
diff --git a/notes.org b/notes.org
index 8f746d3..f7c7eaa 100644
--- a/notes.org
+++ b/notes.org
@@ -31,19 +31,19 @@
- [X] Command: search, search-next, search-prev
- [X] cd into dir symlinks
- [X] Command: map
-- [ ] theme from config
-- [ ] shorten/trim from left in header for long paths
-- [ ] cmdline tab completion
+- [X] shorten/trim from left in header for long paths
- [ ] Allow escaping % in commands
- [ ] Cmdline history
- [ ] Store last directory path (for auto cd in shell)
-- [ ] Store selections path (for copy/move/paste across instances)
-- [ ] Rethink % substituions
- [ ] Preserve back directory when going inside sym link to directories
** Later
-- [ ] Fix keymap evaluation? (If vd is bound, it doesnt evaluate a v binding)
+- [ ] Rethink % substituions
+- [ ] cmdline tab completion
+- [ ] theme from config
+- [ ] Fix keymap evaluation with timeout? (If vd is bound, it doesnt evaluate a v binding)
- [ ] Allow escaping % in commands
-- [ ] watch for changes
-- [ ] bind command: define keybindings
+- [ ] Custom commands
+- [ ] aliases for builtin commands
- [ ] some caching for file list?
-- [ ] Command aliases
+- [ ] copy/move/paste across instances?
+- [ ] watch for changes?