Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/UI/FoldToggle.elm
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,21 @@ isOpen isOpen_ toggle =
{ toggle | position = position }


isClosed : Bool -> FoldToggle msg -> FoldToggle msg
isClosed isClosed_ toggle =
isOpen (not isClosed_) toggle


open : FoldToggle msg -> FoldToggle msg
open toggle =
withPosition Opened toggle


close : FoldToggle msg -> FoldToggle msg
close toggle =
withPosition Closed toggle


isDisabled : Bool -> FoldToggle msg -> FoldToggle msg
isDisabled isDisabled_ toggle =
if isDisabled_ then
Expand Down
18 changes: 14 additions & 4 deletions src/Workspace/WorkspaceItem.elm
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ viewSource zoom onSourceToggleClick sourceConfig item =
viewToggableSource foldToggle renderedSource =
div [ class "definition-source" ]
[ FoldToggle.view foldToggle, renderedSource ]

isBuiltin_ =
isBuiltinItem item
in
case item of
TermItem (Term _ _ detail) ->
Expand All @@ -480,24 +483,31 @@ viewSource zoom onSourceToggleClick sourceConfig item =
( Source.numTermSignatureLines detail.source
, Source.viewNamedTermSignature sourceConfig detail.info.name (Term.termSignature detail.source)
)

foldToggle =
if isBuiltin_ then
FoldToggle.disabled |> FoldToggle.close

else
FoldToggle.foldToggle onSourceToggleClick |> FoldToggle.isOpen (zoom == Near)
in
( numLines, source )
|> Tuple.mapBoth viewLineGutter (viewToggableSource (FoldToggle.foldToggle onSourceToggleClick |> FoldToggle.isOpen (zoom == Near)))
|> Tuple.mapBoth viewLineGutter (viewToggableSource foldToggle)

TypeItem (Type _ _ detail) ->
( detail.source, detail.source )
|> Tuple.mapBoth Source.numTypeLines (Source.viewTypeSource sourceConfig)
|> Tuple.mapBoth viewLineGutter (viewToggableSource (FoldToggle.disabled |> FoldToggle.open))
|> Tuple.mapBoth viewLineGutter (viewToggableSource (FoldToggle.disabled |> FoldToggle.isClosed isBuiltin_))

DataConstructorItem (DataConstructor _ detail) ->
( detail.source, detail.source )
|> Tuple.mapBoth Source.numTypeLines (Source.viewTypeSource sourceConfig)
|> Tuple.mapBoth viewLineGutter (viewToggableSource (FoldToggle.disabled |> FoldToggle.open))
|> Tuple.mapBoth viewLineGutter (viewToggableSource (FoldToggle.disabled |> FoldToggle.isClosed isBuiltin_))

AbilityConstructorItem (AbilityConstructor _ detail) ->
( detail.source, detail.source )
|> Tuple.mapBoth Source.numTypeLines (Source.viewTypeSource sourceConfig)
|> Tuple.mapBoth viewLineGutter (viewToggableSource (FoldToggle.disabled |> FoldToggle.open))
|> Tuple.mapBoth viewLineGutter (viewToggableSource (FoldToggle.disabled |> FoldToggle.isClosed isBuiltin_))


viewItem : Reference -> ItemData -> Bool -> Html Msg
Expand Down