From 4136bc63b47cc7b9cff2ab7451603f2ebc97d3ad Mon Sep 17 00:00:00 2001 From: Paul Chiusano Date: Tue, 24 Nov 2015 14:04:48 -0500 Subject: [PATCH] disable navigation while explorer open --- editor/src/Editor.hs | 3 ++- editor/src/Unison/DocView.hs | 14 ++++++++------ editor/src/Unison/TermExplorer.hs | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/editor/src/Editor.hs b/editor/src/Editor.hs index eaa527379..25f5a2747 100644 --- a/editor/src/Editor.hs +++ b/editor/src/Editor.hs @@ -72,7 +72,8 @@ termEditor term0 = do in mapDyn f state terms <- holdDyn term0 (fmapMaybe (\TermExplorer.S{..} -> Paths.asTerm overallTerm) (updated state)) - (e, dims, path) <- elClass "div" "root" $ DocView.widgets (dropWhen isExplorerOpen' keydown) (Width 400) docs + (e, dims, path) <- elClass "div" "root" $ + DocView.widgets (dropWhen isExplorerOpen' keydown) (dropWhen isExplorerOpen') (Width 400) docs info <- do let f e p = liftIO . Note.run $ Node.localInfo node e p infos <- pure $ pushAlways (\_ -> f <$> sample (current terms) <*> sample (current path)) openEvent diff --git a/editor/src/Unison/DocView.hs b/editor/src/Unison/DocView.hs index d11dd7681..07166935c 100644 --- a/editor/src/Unison/DocView.hs +++ b/editor/src/Unison/DocView.hs @@ -29,10 +29,11 @@ import qualified Unison.Signals as S import qualified Unison.UI as UI widgets :: (Show p, Path p, Eq p, MonadWidget t m) - => Event t Int -> Width -> Dynamic t (Doc Text p) + => Event t Int -> (Event t (X,Y) -> Event t (X,Y)) + -> Width -> Dynamic t (Doc Text p) -> m (Dynamic t (Maybe (El t)), Dynamic t (Width,Height), Dynamic t p) -widgets keydown available docs = do - p <- dyn =<< mapDyn (\doc -> widget keydown available doc) docs +widgets keydown filterMouse available docs = do + p <- dyn =<< mapDyn (\doc -> widget keydown filterMouse available doc) docs els <- holdDyn Nothing $ (\(e,_,_) -> Just e) <$> p dims <- holdDyn (Width 0, Height 0) ((\(_,xy,_) -> xy) <$> p) p0 <- S.now Path.root @@ -41,8 +42,9 @@ widgets keydown available docs = do pure (els, dims, paths) widget :: (Show p, Path p, Eq p, MonadWidget t m) - => Event t Int -> Width -> Doc Text p -> m (El t, (Width,Height), Dynamic t p) -widget keydown available d = + => Event t Int -> (Event t (X,Y) -> Event t (X,Y)) + -> Width -> Doc Text p -> m (El t, (Width,Height), Dynamic t p) +widget keydown filterMouse available d = let leaf txt = Text.replace " " " " txt width (_, (w,_)) = w @@ -77,7 +79,7 @@ widget keydown available d = let (_, (_,_,w,h)) = Doc.root b node <- runDom $ interpret (Doc.flatten b) (e,_) <- el' "div" $ unsafePlaceElement (Dom.unsafeAsHTMLElement node) - mouse <- UI.mouseMove' e + mouse <- filterMouse <$> UI.mouseMove' e nav <- pure $ mergeWith (.) [ const (Doc.up b) <$> (traceEvent "up" $ S.upArrow keydown), const (Doc.down b) <$> (traceEvent "down" $ S.downArrow keydown), diff --git a/editor/src/Unison/TermExplorer.hs b/editor/src/Unison/TermExplorer.hs index 1cee1c364..07f0a65a8 100644 --- a/editor/src/Unison/TermExplorer.hs +++ b/editor/src/Unison/TermExplorer.hs @@ -138,7 +138,7 @@ formatResult :: MonadWidget t m formatResult name e as w = let doc = Views.term name e txt = Text.unpack . Text.concat $ Doc.tokens "\n" (Doc.flow doc) - in (txt, w (as <$ DocView.widget never (Dimensions.Width 300) doc)) + in (txt, w (as <$ DocView.widget never (const never) (Dimensions.Width 300) doc)) formatLocals :: MonadWidget t m => (Reference -> Symbol View.DFO)