Skip to content

Commit

Permalink
Added status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed Apr 16, 2023
1 parent a1c6632 commit 7331d19
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.5.9

- Changed help text to status bar + help text

## 0.5.8

- Fixed debug print of file paths
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ Docfd operates in modes, the initial mode is `Navigation` mode.
- Open document
- `Enter`
- Docfd tries to use `$VISUAL` first, if that fails then Docfd tries `$EDITOR`
- Switch to `Content search` mode
- Switch to `Search` mode
- `/`
- Clear search phrase
- `x`
- Exit Docfd
- `q` or `Ctrl+c`

`Content search` mode
`Search` mode

- Content search field is active in this mode
- Search field is active in this mode
- `Enter` to confirm search phrase and exit search mode

## Single file mode
Expand Down
51 changes: 37 additions & 14 deletions src/docfd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,44 @@ let run
(file_view ())
content_search_results
in
let content_search_control_label =
let attr = Notty.A.(st bold ++ fg lightyellow) in
Notty.(I.hcat
[ I.string attr "/"
; I.string A.empty ": switch to search mode, "
; I.string attr "Enter"
; I.string A.empty ": confirm, "
; I.string attr "x"
; I.string A.empty ": clear"
]
let status_bar =
let key_msg_pair key msg =
let bg_color = Notty.A.white in
let fg_color = Notty.A.black in
let key_attr = Notty.A.(bg bg_color ++ fg fg_color ++ st bold) in
let msg_attr = Notty.A.(bg bg_color ++ fg fg_color) in
Notty.(I.hcat
[ I.string key_attr key
; I.string msg_attr " "
; I.string msg_attr msg
; I.string A.empty " "
]
)
in
Lwd.map ~f:(fun mode ->
match mode with
| Navigate -> (
Notty.(I.hcat
[ I.string A.(st bold) "NAVIGATE "
; key_msg_pair "/" "switch to search mode"
; key_msg_pair "x" "clear search"
; key_msg_pair "q" "exit"
]
)
|> Nottui.Ui.atom
)
|> Nottui.Ui.atom
|> Lwd.return
| Search -> (
Notty.(I.hcat
[ I.string A.(st bold) "SEARCH "
; key_msg_pair "Enter" "confirm and exit search mode"
]
)
|> Nottui.Ui.atom
)
)
(Lwd.get input_mode)
in
let content_search_label_str = "Content search:" in
let content_search_label_str = "Search:" in
let label_strs =
[ content_search_label_str ]
in
Expand Down Expand Up @@ -487,7 +510,7 @@ let run
in
let bottom_pane_components =
[
content_search_control_label;
status_bar;
Nottui_widgets.hbox
[
content_search_label;
Expand Down
2 changes: 1 addition & 1 deletion src/version_string.ml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let s = "0.5.8"
let s = "0.5.9"

0 comments on commit 7331d19

Please # to comment.