fortrangoingonforty/fortty / c65ecb0

Browse files

Fix selection highlighting for spaces and improve fallback fonts

- Draw selection background for all cells including spaces, not just
text characters, so selections appear continuous
- Add macOS font paths for fallback fonts (Apple Symbols, Library/Fonts)
- Prioritize finding fonts with common Unicode symbols (❯ chevron)
before icon-only fonts
Authored by espadonne
SHA
c65ecb08f769f46ce592058286da25b4f6e52924
Parents
2f2c104
Tree
31d52be

1 changed file

StatusFile+-
M src/fortty.f90 34 13
src/fortty.f90modified
@@ -97,8 +97,15 @@ program fortty
9797
   end if
9898
 
9999
   ! If no configured fallback or it failed, try fontconfig auto-detection
100
+  ! First try to find a font with common Unicode symbols (chevron, arrows, etc.)
101
+  if (.not. ren%font%has_fallback) then
102
+    fallback_path = font_find_for_codepoint(int(z'276F'))  ! Heavy right-pointing angle (❯)
103
+    if (len_trim(fallback_path) > 0) then
104
+      call renderer_load_fallback_font(ren, trim(fallback_path))
105
+    end if
106
+  end if
107
+  ! Then try Nerd Font-specific devicons
100108
   if (.not. ren%font%has_fallback) then
101
-    ! Try Nerd Font-specific devicons first (U+E5FF), then common icons (U+F07B)
102109
     fallback_path = font_find_for_codepoint(int(z'E5FF'))  ! Nerd Font devicon
103110
     if (len_trim(fallback_path) > 0) then
104111
       call renderer_load_fallback_font(ren, trim(fallback_path))
@@ -117,7 +124,20 @@ program fortty
117124
     end if
118125
   end if
119126
 
120
-  ! If fontconfig didn't work, try hardcoded paths
127
+  ! If fontconfig didn't work, try hardcoded paths (macOS)
128
+  if (.not. ren%font%has_fallback) then
129
+    fallback_path = "/System/Library/Fonts/Apple Symbols.ttf"
130
+    call renderer_load_fallback_font(ren, trim(fallback_path))
131
+  end if
132
+  if (.not. ren%font%has_fallback) then
133
+    fallback_path = "/Library/Fonts/MesloLGLDZNerdFontMono-Regular.ttf"
134
+    call renderer_load_fallback_font(ren, trim(fallback_path))
135
+  end if
136
+  if (.not. ren%font%has_fallback) then
137
+    fallback_path = "/Library/Fonts/MesloLGMNerdFontMono-Regular.ttf"
138
+    call renderer_load_fallback_font(ren, trim(fallback_path))
139
+  end if
140
+  ! Linux paths
121141
   if (.not. ren%font%has_fallback) then
122142
     fallback_path = "/usr/share/fonts/TTF/MesloLGLDZNerdFontMono-Regular.ttf"
123143
     call renderer_load_fallback_font(ren, trim(fallback_path))
@@ -281,14 +301,14 @@ program fortty
281301
 
282302
           x = real(col - 1) * cell_width
283303
 
304
+          ! Draw selection background if selected (for all cells including spaces)
305
+          if (selection_contains(sel, row, col)) then
306
+            call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), &
307
+                                    0.3, 0.3, 0.6, 1.0)
308
+          end if
309
+
284310
           ! Only render cells with actual text content
285311
           if (cell%codepoint /= 32 .and. cell%codepoint /= 0) then
286
-            ! Draw selection background if selected (only for text cells)
287
-            if (selection_contains(sel, row, col)) then
288
-              call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), &
289
-                                      0.3, 0.3, 0.6, 1.0)
290
-            end if
291
-
292312
             r = real(cell%fg%r) / 255.0
293313
             g = real(cell%fg%g) / 255.0
294314
             b = real(cell%fg%b) / 255.0
@@ -308,13 +328,14 @@ program fortty
308328
 
309329
             x = real(col - 1) * cell_width
310330
 
331
+            ! Draw selection background if selected (for all cells including spaces)
332
+            if (selection_contains(sel, row, col)) then
333
+              call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), &
334
+                                      0.3, 0.3, 0.6, 1.0)
335
+            end if
336
+
311337
             ! Only render cells with actual text content
312338
             if (cell%codepoint /= 32 .and. cell%codepoint /= 0) then
313
-              ! Draw selection background if selected (only for text cells)
314
-              if (selection_contains(sel, row, col)) then
315
-                call renderer_draw_rect(ren, x, y, real(cell_width), real(cell_height), &
316
-                                        0.3, 0.3, 0.6, 1.0)
317
-              end if
318339
               r = real(cell%fg%r) / 255.0
319340
               g = real(cell%fg%g) / 255.0
320341
               b = real(cell%fg%b) / 255.0