@@ -51,7 +51,10 @@ import Graphics.Vty.Output.Interface
51import Graphics.Vty.Picture
51import Graphics.Vty.Picture
52import Graphics.Vty.Image
52import Graphics.Vty.Image
53import Graphics.Vty.Attributes
53import Graphics.Vty.Attributes
54+import Graphics.Vty.UnicodeWidthTable.IO
55+import Graphics.Vty.UnicodeWidthTable.Install
57+import qualified Control.Exception as E
55import Control.Monad (when)
58import Control.Monad (when)
56import Control.Concurrent.STM
59import Control.Concurrent.STM
@@ -110,10 +113,43 @@ data Vty = Vty
110mkVty :: Config -> IO Vty
113mkVty :: Config -> IO Vty
111mkVty appConfig = do
114mkVty appConfig = do
112 config <- (<> appConfig) <$> userConfig
115 config <- (<> appConfig) <$> userConfig
116+ installWidthTable config
113 input <- inputForConfig config
117 input <- inputForConfig config
114 out <- outputForConfig config
118 out <- outputForConfig config
115 intMkVty input out
119 intMkVty input out
121+installWidthTable :: Config -> IO ()
122+installWidthTable c = do
123+ let doLog s = case debugLog c of
124+ Nothing -> return ()
125+ Just path -> appendFile path $ "installWidthTable: " <> s <> "\n"
127+ customInstalled <- isCustomTableReady
128+ when (not customInstalled) $ do
129+ mTerm <- currentTerminalName
132+ doLog "No current terminal name available"
134+ case lookup currentTerm (termWidthMaps c) of
136+ doLog "Current terminal not found in custom character width mapping list"
138+ tableResult <- readUnicodeWidthTable path
141+ doLog $ "Error reading custom character width table " <>
142+ "at " <> show path <> ": " <> msg
144+ installResult <- E.try $ installUnicodeWidthTable table
145+ case installResult of
146+ Left (e::E.SomeException) ->
147+ doLog $ "Error installing unicode table (" <>
148+ show path <> ": " <> show e
150+ doLog $ "Successfully installed Unicode width table " <>
151+ " from " <> show path
117intMkVty :: Input -> Output -> IO Vty
153intMkVty :: Input -> Output -> IO Vty
118intMkVty input out = do
154intMkVty input out = do
119 reserveDisplay out
155 reserveDisplay out