@@ -33,7 +33,6 @@ import Graphics.Vty.Prelude
33import Graphics.Vty.Config
33import Graphics.Vty.Config
35import Graphics.Vty.Output.Interface
35import Graphics.Vty.Output.Interface
36−import Graphics.Vty.Output.MacOSX as MacOSX
37import Graphics.Vty.Output.XTermColor as XTermColor
36import Graphics.Vty.Output.XTermColor as XTermColor
38import Graphics.Vty.Output.TerminfoBased as TerminfoBased
37import Graphics.Vty.Output.TerminfoBased as TerminfoBased
@@ -58,40 +57,15 @@ import System.Posix.Env (getEnv)
59-- Selection of a terminal is done as follows:
58-- Selection of a terminal is done as follows:
61−-- * If TERM == xterm
60+-- * If TERM == xterm use XTermColor.
62−-- then the terminal might be one of the Mac OS X .app terminals. Check if that might be
63−-- the case and use MacOSX if so.
64−-- otherwise use XTermColor.
66-- * for any other TERM value TerminfoBased is used.
61-- * for any other TERM value TerminfoBased is used.
68−-- To differentiate between Mac OS X terminals this uses the TERM_PROGRAM environment variable.
69−-- However, an xterm started by Terminal or iTerm *also* has TERM_PROGRAM defined since the
70−-- environment variable is not reset/cleared by xterm. However a Terminal.app or iTerm.app started
71−-- from an xterm under X11 on mac os x will likely be done via open. Since this does not propogate
72−-- environment variables (I think?) this assumes that XTERM_VERSION will never be set for a true
73−-- Terminal.app or iTerm.app session.
75-- \todo add an implementation for windows that does not depend on terminfo. Should be installable
63-- \todo add an implementation for windows that does not depend on terminfo. Should be installable
76-- with only what is provided in the haskell platform. Use ansi-terminal
64-- with only what is provided in the haskell platform. Use ansi-terminal
77outputForConfig :: Config -> IO Output
65outputForConfig :: Config -> IO Output
78outputForConfig Config{ outputFd = Just fd, termName = Just termName, .. } = do
66outputForConfig Config{ outputFd = Just fd, termName = Just termName, .. } = do
79 t <- if "xterm" `isPrefixOf` termName
67 t <- if "xterm" `isPrefixOf` termName
81− -- the explicit nature of the code below was nice for development, not needed anymore.
82− maybeTerminalApp <- getEnv "TERM_PROGRAM"
83− case maybeTerminalApp of
85− -> XTermColor.reserveTerminal termName fd
86− Just v | v == "Apple_Terminal" || v == "iTerm.app"
88− maybeXterm <- getEnv "XTERM_VERSION"
90− Nothing -> MacOSX.reserveTerminal v fd
91− Just _ -> XTermColor.reserveTerminal termName fd
92− -- Assume any other terminal that sets TERM_PROGRAM to not be an OS X terminal.app
94− _ -> XTermColor.reserveTerminal termName fd
68+ then XTermColor.reserveTerminal termName fd
95 -- Not an xterm-like terminal. try for generic terminfo.
69 -- Not an xterm-like terminal. try for generic terminfo.
96 else TerminfoBased.reserveTerminal termName fd
70 else TerminfoBased.reserveTerminal termName fd