-- exported for use in definition sugaring.
make ::
    MonadA m =>
    ExpressionGui.AnnotationOptions ->
    ExprGuiT.ShowAnnotation -> Widget.Id -> Widget.Id ->
    Sugar.FuncParam (Info m) -> ExprGuiM m (ExpressionGui m)
make annotationOpts showType prevId nextId param =
    assignCursor $
    do
        config <- ExprGuiM.readConfig
        let paramEventMap = mconcat
                [ eventParamDelEventMap mFpDel (Config.delForwardKeys config) "" nextId
                , eventParamDelEventMap mFpDel (Config.delBackwardKeys config) " backwards" prevId
                , eventMapAddNextParam config mFpAdd
                ]
        makeNameEdit myId
            <&> ExpressionGui.egWidget %~ Widget.weakerEvents paramEventMap
            <&> ExpressionGui.egAlignment . _1 .~ 0.5
            >>= ExpressionGui.maybeAddAnnotationWith annotationOpts showType
                (param ^. Sugar.fpAnnotation)
                (param ^. Sugar.fpId)
    where
        entityId = param ^. Sugar.fpId
        myId = WidgetIds.fromEntityId entityId
        Info makeNameEdit mFpDel mFpAdd = param ^. Sugar.fpInfo
        hiddenIds = map WidgetIds.fromEntityId $ param ^. Sugar.fpHiddenIds
        assignCursor x =
            foldr (`ExprGuiM.assignCursorPrefix` const myId) x hiddenIds
make ::
    MonadA m =>
    ExpressionGui.AnnotationOptions ->
    ExprGuiT.ShowAnnotation -> Widget.Id -> Widget.Id ->
    Sugar.FuncParam (Info m) -> ExprGuiM m (ExpressionGui m)
make annotationOpts showType prevId nextId param =
    assignCursor $
    do
        config <- ExprGuiM.readConfig
        let paramEventMap = mconcat
                [ eventParamDelEventMap mFpDel (Config.delForwardKeys config) "" nextId
                , eventParamDelEventMap mFpDel (Config.delBackwardKeys config) " backwards" prevId
                , eventMapAddNextParam config mFpAdd
                ]
        makeNameEdit myId
            <&> ExpressionGui.egWidget %~ Widget.weakerEvents paramEventMap
            <&> ExpressionGui.egAlignment . _1 .~ 0.5
            >>= ExpressionGui.maybeAddAnnotationWith annotationOpts showType
                (param ^. Sugar.fpAnnotation)
                (param ^. Sugar.fpId)
    where
        entityId = param ^. Sugar.fpId
        myId = WidgetIds.fromEntityId entityId
        Info makeNameEdit mFpDel mFpAdd = param ^. Sugar.fpInfo
        hiddenIds = map WidgetIds.fromEntityId $ param ^. Sugar.fpHiddenIds
        assignCursor x =
            foldr (`ExprGuiM.assignCursorPrefix` const myId) x hiddenIds
make annotationOpts showType prevId nextId param =
    assignCursor $
    do
        config <- ExprGuiM.readConfig
        let paramEventMap = mconcat
                [ eventParamDelEventMap mFpDel (Config.delForwardKeys config) "" nextId
                , eventParamDelEventMap mFpDel (Config.delBackwardKeys config) " backwards" prevId
                , eventMapAddNextParam config mFpAdd
                ]
        makeNameEdit myId
            <&> ExpressionGui.egWidget %~ Widget.weakerEvents paramEventMap
            <&> ExpressionGui.egAlignment . _1 .~ 0.5
            >>= ExpressionGui.maybeAddAnnotationWith annotationOpts showType
                (param ^. Sugar.fpAnnotation)
                (param ^. Sugar.fpId)
    where
        entityId = param ^. Sugar.fpId
        myId = WidgetIds.fromEntityId entityId
        Info makeNameEdit mFpDel mFpAdd = param ^. Sugar.fpInfo
        hiddenIds = map WidgetIds.fromEntityId $ param ^. Sugar.fpHiddenIds
        assignCursor x =
            foldr (`ExprGuiM.assignCursorPrefix` const myId) x hiddenIds