2 #! nix --experimental-features ``nix-command flakes`` shell --impure --expr ``
3 #! nix let nixpkgs = builtins.getFlake "nixpkgs"; in
4 #! nix let pkgs = import nixpkgs {}; in
5 #! nix [ (pkgs.haskellPackages.ghcWithPackages (haskellPkgs: with haskellPkgs; [
7 #! nix unicode-transforms
10 #! nix --command runhaskell
12 {-# LANGUAGE GHC2024 #-}
13 {-# LANGUAGE BlockArguments #-}
14 {-# LANGUAGE OverloadedStrings #-}
16 import Control.Monad (forM_)
17 import Data.Char (chr, ord)
18 import Data.Function ((&))
19 import Data.List qualified as List
20 import Data.Text (Text)
21 import Data.Text qualified as Text
22 import Data.Text.Normalize
23 import System.Environment (lookupEnv)
24 import Text.Printf qualified as Printf
29 term <- lookupEnv "TERM"
30 forM_ combs \comb -> do
31 forM_ baseChars \baseChar -> do
32 let txt = baseChar <> comb
33 putStrLn $ analyse txt
34 when (term == Just "xterm-ghostty") $
35 shells ("ghostty +show-face --string=" <> txt) empty
38 baseChars = ["ɑ", "ɛ", "y"]
41 [ combiningDiacriticalMarks
42 , combiningDiacriticalMarksExtended
43 , combiningDiacriticalMarksForSymbols
47 combiningDiacriticalMarks =
48 [ chr c & Text.singleton
49 | c <- [0x0300 .. 0x036F]
51 combiningDiacriticalMarksExtended =
52 [ chr c & Text.singleton
53 | c <- [0x1AB0 .. 0x1AEB]
55 combiningDiacriticalMarksForSymbols =
56 [ chr c & Text.singleton
57 | c <- [0x20D0 .. 0x20F0]
60 [ chr c & Text.singleton
61 | c <- [0xFE20 .. 0xFE2F]
64 analyse :: Text -> String
66 List.intercalate " " $
69 (text & normalize NFKD & escape)
70 (text & normalize NFKD)
73 escape :: Text -> Text
77 & foldMap (\c -> Printf.printf "\\x%X" (ord c))