detection for terminals so that wezterm, ghostty, etc don't have cutoff always
- SHA
af339b7e41b2ea87372ee13d5f59813292cbb121- Parents
-
1379370 - Tree
cf299a1
af339b7
af339b7e41b2ea87372ee13d5f59813292cbb1211379370
cf299a1| Status | File | + | - |
|---|---|---|---|
| M |
src/display_module.f90
|
8 | 3 |
| M |
src/fuss_main.f90
|
13 | 3 |
src/display_module.f90modified@@ -129,15 +129,20 @@ contains | ||
| 129 | 129 | end subroutine print_tree_node |
| 130 | 130 | |
| 131 | 131 | subroutine draw_interactive_tree(tree_root, items, n_items, selected, & |
| 132 | - repo_name, branch_name, viewport_offset, visible_items) | |
| 132 | + repo_name, branch_name, viewport_offset, visible_items, top_padding) | |
| 133 | 133 | type(tree_node), pointer, intent(in) :: tree_root |
| 134 | 134 | integer, intent(in) :: n_items, selected |
| 135 | 135 | type(selectable_item), intent(in) :: items(:) |
| 136 | 136 | character(len=*), intent(in) :: repo_name, branch_name |
| 137 | - integer, intent(in) :: viewport_offset, visible_items | |
| 138 | - integer :: item_idx, viewport_end | |
| 137 | + integer, intent(in) :: viewport_offset, visible_items, top_padding | |
| 138 | + integer :: item_idx, viewport_end, i | |
| 139 | 139 | character(len=512) :: status_line |
| 140 | 140 | |
| 141 | + ! Add blank lines at top as padding for terminals that need it (fixes WezTerm/Ghostty) | |
| 142 | + do i = 1, top_padding | |
| 143 | + print '(A)', '' | |
| 144 | + end do | |
| 145 | + | |
| 141 | 146 | ! Display repo:branch info at top if available |
| 142 | 147 | if (len_trim(repo_name) > 0 .and. len_trim(branch_name) > 0) then |
| 143 | 148 | write(status_line, '(A,A,A,A,A,A,A)') & |
src/fuss_main.f90modified@@ -91,13 +91,23 @@ contains | ||
| 91 | 91 | integer :: n_files, n_items, selected, i, status |
| 92 | 92 | character(len=1) :: key |
| 93 | 93 | logical :: running |
| 94 | - character(len=256) :: repo_name, branch_name | |
| 95 | - integer :: term_height, viewport_offset, visible_items | |
| 94 | + character(len=256) :: repo_name, branch_name, term_program | |
| 95 | + integer :: term_height, viewport_offset, visible_items, top_padding | |
| 96 | 96 | type(tree_node), pointer :: tree_root |
| 97 | 97 | |
| 98 | 98 | ! Initialize tree pointer |
| 99 | 99 | tree_root => null() |
| 100 | 100 | |
| 101 | + ! Detect terminal type for padding (fixes WezTerm/Ghostty top line cutoff) | |
| 102 | + call get_environment_variable("TERM_PROGRAM", term_program) | |
| 103 | + if (index(term_program, "WezTerm") > 0 .or. index(term_program, "ghostty") > 0) then | |
| 104 | + top_padding = 2 ! WezTerm/Ghostty need 2 lines of padding | |
| 105 | + else if (index(term_program, "Apple_Terminal") > 0 .or. index(term_program, "iTerm") > 0) then | |
| 106 | + top_padding = 2 ! Terminal.app and iTerm2 also need 2 lines | |
| 107 | + else | |
| 108 | + top_padding = 1 ! Other terminals need 1 line | |
| 109 | + end if | |
| 110 | + | |
| 101 | 111 | ! Get repo and branch info |
| 102 | 112 | call get_repo_info(repo_name, branch_name) |
| 103 | 113 | |
@@ -161,7 +171,7 @@ contains | ||
| 161 | 171 | ! Clear screen and redraw |
| 162 | 172 | call clear_screen() |
| 163 | 173 | call draw_interactive_tree(tree_root, items, n_items, selected, & |
| 164 | - repo_name, branch_name, viewport_offset, visible_items) | |
| 174 | + repo_name, branch_name, viewport_offset, visible_items, top_padding) | |
| 165 | 175 | |
| 166 | 176 | ! Read key |
| 167 | 177 | call read_key(key) |