@@ -18,8 +18,7 @@ module treemap_renderer |
| 18 | 18 | scan_and_render_with_interaction, find_node_at_position, navigate_into_node, & |
| 19 | 19 | navigate_up, get_breadcrumb_path, get_path_depth, get_node_count, & |
| 20 | 20 | get_node_center_by_index, find_node_in_direction, register_progress_callback, & |
| 21 | | - scan_directory, invalidate_layout, get_current_view_node, remove_selected_node_from_view, & |
| 22 | | - set_filter_pattern |
| 21 | + scan_directory, invalidate_layout, get_current_view_node, remove_selected_node_from_view |
| 23 | 22 | |
| 24 | 23 | ! Callback interfaces for progress updates |
| 25 | 24 | abstract interface |
@@ -69,9 +68,6 @@ module treemap_renderer |
| 69 | 68 | procedure(hide_progress_callback), pointer, save :: hide_progress_cb => null() |
| 70 | 69 | procedure(update_progress_callback), pointer, save :: update_progress_cb => null() |
| 71 | 70 | |
| 72 | | - ! Filter pattern for search/filtering |
| 73 | | - character(len=256), save :: filter_pattern = "" |
| 74 | | - |
| 75 | 71 | contains |
| 76 | 72 | |
| 77 | 73 | ! Initialize renderer |
@@ -266,9 +262,6 @@ contains |
| 266 | 262 | bounds%height = int(height) |
| 267 | 263 | |
| 268 | 264 | if (associated(current_view_node) .and. current_view_node%size > 0) then |
| 269 | | - ! Apply filter by temporarily setting filtered nodes' sizes to 0 |
| 270 | | - call apply_filter_to_view(current_view_node) |
| 271 | | - |
| 272 | 265 | call calculate_treemap(current_view_node, bounds) |
| 273 | 266 | end if |
| 274 | 267 | |
@@ -323,9 +316,6 @@ contains |
| 323 | 316 | bounds%height = int(height) |
| 324 | 317 | |
| 325 | 318 | if (associated(current_view_node) .and. current_view_node%size > 0) then |
| 326 | | - ! Apply filter by temporarily setting filtered nodes' sizes to 0 |
| 327 | | - call apply_filter_to_view(current_view_node) |
| 328 | | - |
| 329 | 319 | call calculate_treemap(current_view_node, bounds) |
| 330 | 320 | end if |
| 331 | 321 | |
@@ -1020,7 +1010,6 @@ contains |
| 1020 | 1010 | ! Render only the direct children of the current view |
| 1021 | 1011 | if (allocated(view_node%children) .and. view_node%num_children > 0) then |
| 1022 | 1012 | print *, "DEBUG: Rendering", view_node%num_children, "children" |
| 1023 | | - print *, "DEBUG: Current filter pattern: '", trim(filter_pattern), "'" |
| 1024 | 1013 | |
| 1025 | 1014 | ! Count visible nodes |
| 1026 | 1015 | visible_count = 0 |
@@ -1028,7 +1017,7 @@ contains |
| 1028 | 1017 | ! Skip nodes without names (shouldn't happen but be defensive) |
| 1029 | 1018 | if (.not. allocated(view_node%children(i)%name)) cycle |
| 1030 | 1019 | |
| 1031 | | - if (view_node%children(i)%size > 0 .and. matches_filter(view_node%children(i)%name)) then |
| 1020 | + if (view_node%children(i)%size > 0) then |
| 1032 | 1021 | visible_count = visible_count + 1 |
| 1033 | 1022 | if (visible_count <= 5) then |
| 1034 | 1023 | print *, "DEBUG: Visible child", i, ":", trim(view_node%children(i)%name), & |
@@ -1042,12 +1031,7 @@ contains |
| 1042 | 1031 | ! Skip nodes without names (shouldn't happen but be defensive) |
| 1043 | 1032 | if (.not. allocated(view_node%children(i)%name)) cycle |
| 1044 | 1033 | |
| 1045 | | - ! Skip nodes that don't match the filter |
| 1046 | | - if (.not. matches_filter(view_node%children(i)%name)) then |
| 1047 | | - cycle |
| 1048 | | - end if |
| 1049 | | - |
| 1050 | | - ! Skip nodes with size 0 (filtered out or deleted) |
| 1034 | + ! Skip nodes with size 0 (deleted) |
| 1051 | 1035 | if (view_node%children(i)%size == 0) then |
| 1052 | 1036 | cycle |
| 1053 | 1037 | end if |
@@ -1277,68 +1261,6 @@ contains |
| 1277 | 1261 | end if |
| 1278 | 1262 | end subroutine render_label |
| 1279 | 1263 | |
| 1280 | | - ! Set the filter pattern for filename filtering |
| 1281 | | - subroutine set_filter_pattern(pattern) |
| 1282 | | - character(len=*), intent(in) :: pattern |
| 1283 | | - |
| 1284 | | - filter_pattern = trim(pattern) |
| 1285 | | - print *, "Filter pattern set to: '", trim(filter_pattern), "'" |
| 1286 | | - |
| 1287 | | - ! If filter is being cleared, restore all sizes |
| 1288 | | - if (len_trim(filter_pattern) == 0 .and. associated(current_view_node)) then |
| 1289 | | - print *, "Filter cleared - restoring all sizes" |
| 1290 | | - call recalculate_sizes(root_node) |
| 1291 | | - end if |
| 1292 | | - |
| 1293 | | - ! Invalidate layout when filter changes |
| 1294 | | - layout_calculated = .false. |
| 1295 | | - end subroutine set_filter_pattern |
| 1296 | | - |
| 1297 | | - ! Check if a filename matches the current filter pattern (case-insensitive substring match) |
| 1298 | | - function matches_filter(filename) result(matches) |
| 1299 | | - character(len=*), intent(in) :: filename |
| 1300 | | - logical :: matches |
| 1301 | | - character(len=256) :: lower_name, lower_pattern |
| 1302 | | - integer :: i, ascii_val |
| 1303 | | - |
| 1304 | | - ! If no filter is set, everything matches |
| 1305 | | - if (len_trim(filter_pattern) == 0) then |
| 1306 | | - matches = .true. |
| 1307 | | - return |
| 1308 | | - end if |
| 1309 | | - |
| 1310 | | - ! If filename is empty, don't match (defensive check) |
| 1311 | | - if (len_trim(filename) == 0) then |
| 1312 | | - matches = .false. |
| 1313 | | - return |
| 1314 | | - end if |
| 1315 | | - |
| 1316 | | - ! Convert both to lowercase for case-insensitive comparison |
| 1317 | | - lower_name = "" |
| 1318 | | - lower_pattern = "" |
| 1319 | | - |
| 1320 | | - do i = 1, min(len_trim(filename), 256) |
| 1321 | | - ascii_val = iachar(filename(i:i)) |
| 1322 | | - if (ascii_val >= 65 .and. ascii_val <= 90) then ! A-Z |
| 1323 | | - lower_name(i:i) = achar(ascii_val + 32) |
| 1324 | | - else |
| 1325 | | - lower_name(i:i) = filename(i:i) |
| 1326 | | - end if |
| 1327 | | - end do |
| 1328 | | - |
| 1329 | | - do i = 1, min(len_trim(filter_pattern), 256) |
| 1330 | | - ascii_val = iachar(filter_pattern(i:i)) |
| 1331 | | - if (ascii_val >= 65 .and. ascii_val <= 90) then ! A-Z |
| 1332 | | - lower_pattern(i:i) = achar(ascii_val + 32) |
| 1333 | | - else |
| 1334 | | - lower_pattern(i:i) = filter_pattern(i:i) |
| 1335 | | - end if |
| 1336 | | - end do |
| 1337 | | - |
| 1338 | | - ! Check if pattern is a substring of filename |
| 1339 | | - matches = index(trim(lower_name), trim(lower_pattern)) > 0 |
| 1340 | | - end function matches_filter |
| 1341 | | - |
| 1342 | 1264 | ! Recursively recalculate directory sizes from their children |
| 1343 | 1265 | ! This restores sizes that may have been set to 0 by filtering |
| 1344 | 1266 | recursive subroutine recalculate_sizes(node) |
@@ -1370,35 +1292,4 @@ contains |
| 1370 | 1292 | end if |
| 1371 | 1293 | end subroutine recalculate_sizes |
| 1372 | 1294 | |
| 1373 | | - ! Apply filter to view by setting non-matching nodes' sizes to 0 |
| 1374 | | - subroutine apply_filter_to_view(node) |
| 1375 | | - type(file_node), intent(inout) :: node |
| 1376 | | - integer :: i |
| 1377 | | - integer :: match_count |
| 1378 | | - |
| 1379 | | - ! If no filter is set, nothing to do |
| 1380 | | - if (len_trim(filter_pattern) == 0) return |
| 1381 | | - |
| 1382 | | - ! If node has no children, nothing to do |
| 1383 | | - if (.not. allocated(node%children)) return |
| 1384 | | - if (node%num_children == 0) return |
| 1385 | | - |
| 1386 | | - ! First, recalculate all sizes from scratch (restores any previously filtered sizes) |
| 1387 | | - call recalculate_sizes(node) |
| 1388 | | - |
| 1389 | | - ! Now apply filter by setting non-matching children to size 0 |
| 1390 | | - ! Note: original_size is already backed up during scanning, so no need to back up here |
| 1391 | | - match_count = 0 |
| 1392 | | - do i = 1, node%num_children |
| 1393 | | - if (matches_filter(node%children(i)%name)) then |
| 1394 | | - match_count = match_count + 1 |
| 1395 | | - else |
| 1396 | | - ! Set size to 0 for filtered nodes so layout skips them |
| 1397 | | - node%children(i)%size = 0_int64 |
| 1398 | | - end if |
| 1399 | | - end do |
| 1400 | | - |
| 1401 | | - print *, "Filter applied:", match_count, "of", node%num_children, "items match" |
| 1402 | | - end subroutine apply_filter_to_view |
| 1403 | | - |
| 1404 | 1295 | end module treemap_renderer |