Skip to content

Commit c9af65d

Browse files
author
Ali Abrar
committed
Use reflex-vty 0.2
1 parent 459a81b commit c9af65d

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

ChangeLog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Revision history for reflex-ghci
22

3+
## 0.1.5.2
4+
5+
* Use reflex-vty 0.2
6+
37
## 0.1.5.1
48

59
* Extend version bounds to support reflex 0.8

reflex-ghci.cabal

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.4
22
name: reflex-ghci
3-
version: 0.1.5.1
3+
version: 0.1.5.2
44
synopsis: A GHCi widget library for use in reflex applications
55
description:
66
Run GHCi from within a Reflex FRP (<https://reflex-frp.org>) application and interact with it using a functional reactive interface.
@@ -35,7 +35,7 @@ library
3535
, reflex-fsnotify >= 0.2 && < 0.3
3636
, reflex-process >= 0.3 && < 0.4
3737
, regex-tdfa >= 1.2.3 && < 1.4
38-
, reflex-vty >= 0.1.3 && < 0.2
38+
, reflex-vty >= 0.2 && < 0.3
3939
, text >= 1.2 && < 1.3
4040
, unix >= 2.7 && < 2.8
4141
, vty >=5.21 && <5.29

src-bin/ghci.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ main = do
4444
showVersion version
4545
]
4646
GhciArg { _ghciArg_replCommand = cmd, _ghciArg_execCommand = expr } <- execParser opts
47-
mainWidget $ do
47+
mainWidget $ initManager_ $ do
4848
exit <- keyCombo (V.KChar 'c', [V.MCtrl])
4949
g <- ghciWatch (shell cmd) $ T.encodeUtf8 . T.pack <$> expr
5050
case expr of

src/Reflex/Vty/GHCi.hs

+47-13
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ import qualified System.Process as P
2525
statusDisplay
2626
:: ( PostBuild t m
2727
, MonadHold t m
28+
, HasDisplayRegion t m
29+
, HasImageWriter t m
30+
, HasTheme t m
2831
)
2932
=> Ghci t
30-
-> VtyWidget t m ()
33+
-> m ()
3134
statusDisplay g = do
3235
pb <- getPostBuild
3336
text <=< hold "" $ leftmost
@@ -40,17 +43,24 @@ statusDisplay g = do
4043
-- when there is additional content to view.
4144
scrollableOutput
4245
:: ( Reflex t
43-
, MonadNodeId m
44-
, MonadHold t m
46+
, HasDisplayRegion t m
47+
, HasFocus t m
48+
, HasFocusReader t m
49+
, HasImageWriter t m
50+
, HasInput t m
51+
, HasLayout t m
52+
, HasTheme t m
4553
, MonadFix m
54+
, MonadHold t m
55+
, MonadNodeId m
4656
, PostBuild t m
4757
)
4858
=> Behavior t ByteString
49-
-> VtyWidget t m ()
59+
-> m ()
5060
scrollableOutput out = col $ do
5161
dh <- displayHeight
52-
scroll <- stretch $ scrollableText never $ T.decodeUtf8 <$> out
53-
fixed 1 $ text $
62+
scroll <- tile flex $ scrollableText never $ T.decodeUtf8 <$> out
63+
grout (fixed 1) $ text $
5464
let f h (ix, n) = if n - ix + 1 > h
5565
then "↓ More ↓"
5666
else ""
@@ -62,9 +72,13 @@ scrollingOutput
6272
, Monad m
6373
, MonadHold t m
6474
, MonadFix m
75+
, HasDisplayRegion t m
76+
, HasInput t m
77+
, HasImageWriter t m
78+
, HasTheme t m
6579
)
6680
=> Dynamic t ByteString
67-
-> VtyWidget t m ()
81+
-> m ()
6882
scrollingOutput out = do
6983
dh <- displayHeight
7084
let scrollBy h (ix, n) =
@@ -82,15 +96,22 @@ ghciModuleStatus
8296
, MonadHold t m
8397
, MonadFix m
8498
, Adjustable t m
99+
, HasLayout t m
100+
, HasImageWriter t m
101+
, HasFocusReader t m
102+
, HasDisplayRegion t m
103+
, HasInput t m
104+
, HasTheme t m
105+
, HasFocus t m
85106
)
86107
=> Ghci t
87-
-> VtyWidget t m ()
108+
-> m ()
88109
ghciModuleStatus g = col $ do
89110
let ghciExit = _process_exit $ _ghci_process g
90111
ghciExited <- hold False $ True <$ ghciExit
91-
fixed 3 $ boxStatic def $ statusDisplay g
112+
grout (fixed 3) $ boxStatic def $ statusDisplay g
92113
out <- moduleOutput (not <$> ghciExited) g
93-
stretch $ void $
114+
tile flex $ void $
94115
networkHold (scrollableOutput $ current out) $ ffor (_ghci_reload g) $
95116
const $ scrollableOutput $ current out
96117

@@ -99,9 +120,14 @@ ghciExecOutput
99120
:: ( MonadHold t m
100121
, MonadFix m
101122
, Adjustable t m
123+
, HasDisplayRegion t m
124+
, HasInput t m
125+
, HasImageWriter t m
126+
, HasTheme t m
127+
, HasInput t m
102128
)
103129
=> Ghci t
104-
-> VtyWidget t m ()
130+
-> m ()
105131
ghciExecOutput g = do
106132
ghciExited <- hold False $ True <$ _process_exit (_ghci_process g)
107133
out <- execOutput (not <$> ghciExited) g
@@ -117,9 +143,16 @@ ghciPanes
117143
, MonadNodeId m
118144
, PostBuild t m
119145
, Adjustable t m
146+
, HasInput t m
147+
, HasImageWriter t m
148+
, HasFocusReader t m
149+
, HasDisplayRegion t m
150+
, HasTheme t m
151+
, HasLayout t m
152+
, HasFocus t m
120153
)
121154
=> Ghci t
122-
-> VtyWidget t m ()
155+
-> m ()
123156
ghciPanes g = void $ splitVDrag
124157
(hRule doubleBoxStyle)
125158
(ghciModuleStatus g)
@@ -130,10 +163,11 @@ ghciPanes g = void $ splitVDrag
130163
getExitEvent
131164
:: ( PerformEvent t m
132165
, MonadIO (Performable m)
166+
, HasInput t m
133167
)
134168
=> Ghci t
135169
-> Event t a
136-
-> VtyWidget t m (Event t ())
170+
-> m (Event t ())
137171
getExitEvent g externalExitReq = do
138172
exitReq <- keyCombo (V.KChar 'c', [V.MCtrl])
139173
let exitReqs = leftmost

0 commit comments

Comments
 (0)