package miaou-core
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Miaou core/widgets (no drivers, no SDL)
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.5.2.tar.gz
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/src/miaou_widgets_layout/file_icons.ml.html
Source file file_icons.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115(*****************************************************************************) (* *) (* SPDX-License-Identifier: MIT *) (* Copyright (c) 2026 Nomadic Labs <contact@nomadic-labs.com> *) (* *) (*****************************************************************************) module W = Miaou_widgets_display.Widgets let nerd_font_enabled () = match Sys.getenv_opt "MIAOU_NERD_FONT" with | Some ("1" | "true" | "TRUE" | "yes" | "YES") -> true | _ -> false (* Lower-case the trailing extension (no leading dot). Returns "" for files without a recognisable extension. *) let extension_lower name = match Filename.extension name with | "" -> "" | ext -> let s = String.sub ext 1 (String.length ext - 1) in String.lowercase_ascii s (* (icon-without-nerd, icon-nerd, fg-256-color-or-(-1)) per extension/special. *) let table = [ ("ml", ("๐ซ", "", 214)); ("mli", ("๐ซ", "", 214)); ("rs", ("๐ฆ", "", 208)); ("py", ("๐", "", 33)); ("js", ("๐", "", 220)); ("ts", ("๐", "", 75)); ("json", ("๐ฆ", "", 178)); ("yaml", ("๐ฆ", "", 178)); ("yml", ("๐ฆ", "", 178)); ("toml", ("๐ฆ", "", 178)); ("md", ("๐", "", 252)); ("markdown", ("๐", "", 252)); ("txt", ("๐", "", 250)); ("log", ("๐", "", 244)); ("sh", ("๐ง", "", 64)); ("bash", ("๐ง", "", 64)); ("zsh", ("๐ง", "", 64)); ("fish", ("๐ง", "", 64)); ("html", ("๐", "", 202)); ("css", ("๐จ", "", 39)); ("png", ("๐ผ", "", 141)); ("jpg", ("๐ผ", "", 141)); ("jpeg", ("๐ผ", "", 141)); ("gif", ("๐ผ", "", 141)); ("svg", ("๐ผ", "", 141)); ("pdf", ("๐", "", 124)); ("zip", ("๐ฆ", "", 130)); ("tar", ("๐ฆ", "", 130)); ("gz", ("๐ฆ", "", 130)); ("xz", ("๐ฆ", "", 130)); ("bz2", ("๐ฆ", "", 130)); ("7z", ("๐ฆ", "", 130)); ("rar", ("๐ฆ", "", 130)); ("c", ("๐", "", 67)); ("h", ("๐", "", 67)); ("cpp", ("๐", "", 67)); ("hpp", ("๐", "", 67)); ("go", ("๐น", "", 75)); ("hs", ("๐", "", 99)); ("rb", ("๐", "", 197)); ("lock", ("๐", "", 244)); ] let lookup ext = match List.assoc_opt ext table with Some v -> Some v | None -> None let choose_icon ~nerd unicode nerd_icon = if nerd && nerd_icon <> "" then nerd_icon else unicode let dir_unicode = "๐" let dir_nerd = "๏ป" (* nf-fa-folder *) let parent_unicode = "๐" let parent_nerd = "๏ผ" (* nf-fa-folder_open *) let plain_unicode = "๐" let plain_nerd = "๏" (* nf-fa-file_o *) let icon_for ~name ~is_dir = let nerd = nerd_font_enabled () in let icon = if name = ".." then choose_icon ~nerd parent_unicode parent_nerd else if is_dir then choose_icon ~nerd dir_unicode dir_nerd else let ext = extension_lower name in match lookup ext with | Some (u, n, _) -> choose_icon ~nerd u n | None -> choose_icon ~nerd plain_unicode plain_nerd in icon ^ " " let color_for ~name ~is_dir = if is_dir then Some 75 (* cyan-ish for directories *) else let ext = extension_lower name in match lookup ext with Some (_, _, c) -> Some c | None -> None let decorate ~name ~is_dir label = let icon = icon_for ~name ~is_dir in let colored = match color_for ~name ~is_dir with Some c -> W.fg c label | None -> label in icon ^ colored let () = Miaou_registry.register ~name:"file_icons" ~mli:[%blob "file_icons.mli"] ()
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>