mirror of
https://github.com/rgleichman/glance.git
synced 2024-08-16 18:30:36 +03:00
Delete non-nested pattern apply icon and syntax node.
This commit is contained in:
parent
33eac07c59
commit
7bb206e616
50
app/Icons.hs
50
app/Icons.hs
@ -67,8 +67,6 @@ lineCol = lineC colorScheme
|
||||
|
||||
iconToDiagram :: SpecialBackend b n => Icon -> TransformableDia b n
|
||||
iconToDiagram icon = case icon of
|
||||
PAppIcon n str ->
|
||||
generalTextAppDia (patternTextC colorScheme) (patternC colorScheme) n str
|
||||
TextBoxIcon s -> textBox s
|
||||
BindTextBoxIcon s -> identDiaFunc $ bindTextBox s
|
||||
GuardIcon n -> nestedGuardDia $ replicate (1 + (2 * n)) Nothing
|
||||
@ -161,7 +159,6 @@ nestedGuardPortAngles args port maybeNodeName = case maybeNodeName of
|
||||
|
||||
getPortAngles :: SpecialNum n => Icon -> Port -> Maybe NodeName -> [Angle n]
|
||||
getPortAngles icon port maybeNodeName = case icon of
|
||||
PAppIcon _ _ -> applyPortAngles port
|
||||
TextBoxIcon _ -> []
|
||||
BindTextBoxIcon _ -> []
|
||||
GuardIcon _ -> guardPortAngles port
|
||||
@ -212,7 +209,6 @@ argumentPorts :: SyntaxNode -> [Port]
|
||||
argumentPorts n = case n of
|
||||
LikeApplyNode _ _-> defaultPorts
|
||||
NestedApplyNode _ _ _ -> defaultPorts
|
||||
PatternApplyNode _ _-> defaultPorts
|
||||
NestedPatternApplyNode _ _-> defaultPorts
|
||||
FunctionDefNode _ -> defaultPorts
|
||||
NestedCaseOrGuardNode _ _ _-> defaultPorts
|
||||
@ -228,7 +224,6 @@ argumentPorts n = case n of
|
||||
|
||||
-- END Exported icon functions --
|
||||
|
||||
|
||||
-- BEGIN Diagram helper functions --
|
||||
|
||||
-- | Make an identity TransformableDia
|
||||
@ -293,45 +288,6 @@ resultIcon = lw none $ fc (lamArgResC colorScheme) unitSquare
|
||||
|
||||
-- BEGIN Apply like icons
|
||||
|
||||
-- | apply port locations:
|
||||
-- inputPortConst: Function
|
||||
-- resultPortConst: Result
|
||||
-- Ports 2,3..: Arguments
|
||||
coloredApplyADia ::
|
||||
(SpecialBackend b n) =>
|
||||
Colour Double -> Int -> SpecialQDiagram b n
|
||||
coloredApplyADia appColor n = centerXY finalDia where
|
||||
trianglePortsCircle = hcat [
|
||||
reflectX (apply0Triangle appColor)
|
||||
, hcat $ take n
|
||||
$ map
|
||||
(\x -> makePort x <> portCircle <> strutX (circleRadius * 1.5))
|
||||
argPortsConst
|
||||
, makePort resultPortConst
|
||||
<> alignR
|
||||
(lc appColor $ lwG defaultLineWidth $ fc appColor $ circle circleRadius)
|
||||
]
|
||||
allPorts = makePort inputPortConst <> alignL trianglePortsCircle
|
||||
topAndBottomLineWidth = width allPorts - circleRadius
|
||||
topAndBottomLine
|
||||
= alignL $ lwG defaultLineWidth $ lc appColor $ hrule topAndBottomLineWidth
|
||||
finalDia = topAndBottomLine === allPorts === topAndBottomLine
|
||||
|
||||
generalTextAppDia :: SpecialBackend b n =>
|
||||
Colour Double -> Colour Double -> Int -> String -> TransformableDia b n
|
||||
generalTextAppDia
|
||||
textCol
|
||||
borderCol
|
||||
numArgs
|
||||
str
|
||||
(TransformParams name _ reflect angle)
|
||||
= nameDiagram name rotateDia
|
||||
where
|
||||
rotateDia =
|
||||
transformCorrectedTextBox str textCol borderCol reflect angle
|
||||
|||
|
||||
coloredApplyADia borderCol numArgs
|
||||
|
||||
-- TODO Refactor with generalNestedDia
|
||||
nestedPAppDia :: SpecialBackend b n =>
|
||||
[Colour Double] -> [(Maybe NamedIcon, String)] -> TransformableDia b n
|
||||
@ -388,6 +344,10 @@ nestedPAppDia
|
||||
beside' :: (Semigroup a, Juxtaposable a) => V a (N a) -> a -> a -> a
|
||||
beside' dir dia1 dia2 = juxtapose dir dia1 dia2 <> dia1
|
||||
|
||||
-- | apply port locations:
|
||||
-- inputPortConst: Function
|
||||
-- resultPortConst: Result
|
||||
-- Ports 2,3..: Arguments
|
||||
generalNestedDia :: SpecialBackend b n
|
||||
=> (Colour Double -> SpecialQDiagram b n)
|
||||
-> [Colour Double]
|
||||
@ -496,7 +456,7 @@ commentTextArea textColor t =
|
||||
multilineComment :: SpecialBackend b n =>
|
||||
Colour Double
|
||||
-> AlphaColour Double -> String -> SpecialQDiagram b n
|
||||
multilineComment textColor boxColor t = lwG (0.6 * defaultLineWidth) textDia
|
||||
multilineComment textColor _boxColor t = lwG (0.6 * defaultLineWidth) textDia
|
||||
where
|
||||
textLines = lines t
|
||||
textAreas = map (commentTextArea textColor) textLines
|
||||
|
@ -181,15 +181,16 @@ makeNestedPatternGraph applyIconName funStr argVals = nestedApplyResult
|
||||
newGraph = SyntaxGraph icons [] nestedSinks allBinds newEMap
|
||||
nestedApplyResult = (newGraph <> combinedGraph, nameAndPort applyIconName (resultPort pAppNode))
|
||||
|
||||
makePatternGraph' :: NodeName -> String -> [GraphAndRef] -> (SyntaxGraph, NameAndPort)
|
||||
makePatternGraph' applyIconName funStr argVals = (newGraph <> combinedGraph, nameAndPort applyIconName (resultPort pAppNode))
|
||||
where
|
||||
pAppNode = PatternApplyNode funStr numArgs
|
||||
argumentNamePorts = map (nameAndPort applyIconName) $ argumentPorts pAppNode
|
||||
combinedGraph = combineExpressions True $ zip argVals argumentNamePorts
|
||||
numArgs = length argVals
|
||||
icons = [SgNamedNode applyIconName pAppNode]
|
||||
newGraph = syntaxGraphFromNodes icons
|
||||
-- TODO Delete makePatternGraph'
|
||||
-- makePatternGraph' :: NodeName -> String -> [GraphAndRef] -> (SyntaxGraph, NameAndPort)
|
||||
-- makePatternGraph' applyIconName funStr argVals = (newGraph <> combinedGraph, nameAndPort applyIconName (resultPort pAppNode))
|
||||
-- where
|
||||
-- pAppNode = PatternApplyNode funStr numArgs
|
||||
-- argumentNamePorts = map (nameAndPort applyIconName) $ argumentPorts pAppNode
|
||||
-- combinedGraph = combineExpressions True $ zip argVals argumentNamePorts
|
||||
-- numArgs = length argVals
|
||||
-- icons = [SgNamedNode applyIconName pAppNode]
|
||||
-- newGraph = syntaxGraphFromNodes icons
|
||||
|
||||
evalPApp :: Show l => QName l -> [Pat l] -> State IDState (SyntaxGraph, NameAndPort)
|
||||
evalPApp name patterns = case patterns of
|
||||
|
@ -41,7 +41,8 @@ import Data.Semigroup(Semigroup, (<>))
|
||||
import Types(Icon, SyntaxNode(..), Edge(..), EdgeOption(..),
|
||||
NameAndPort(..), IDState, SgNamedNode(..), NodeName(..), Port,
|
||||
LikeApplyFlavor(..), CaseOrGuardTag(..), IDState(..), NamedIcon(..))
|
||||
import Util(noEnds, nameAndPort, makeSimpleEdge, justName, maybeBoolToBool, mapNodeInNamedNode, nodeNameToInt, tupleToNamedIcon)
|
||||
import Util(noEnds, nameAndPort, makeSimpleEdge, justName, maybeBoolToBool
|
||||
, mapNodeInNamedNode, nodeNameToInt)
|
||||
import Icons(Icon(..), inputPort, resultPort, argumentPorts, guardRhsPorts, guardBoolPorts)
|
||||
|
||||
{-# ANN module "HLint: ignore Use list comprehension" #-}
|
||||
@ -250,7 +251,6 @@ nodeToIcon (LikeApplyNode flavor n)
|
||||
= NestedApply flavor Nothing (replicate n Nothing)
|
||||
nodeToIcon (NestedApplyNode flavor x edges)
|
||||
= nestedApplySyntaxNodeToIcon flavor x edges
|
||||
nodeToIcon (PatternApplyNode s n) = PAppIcon n s
|
||||
nodeToIcon (NestedPatternApplyNode s children)
|
||||
= nestedPatternNodeToIcon s children
|
||||
nodeToIcon (NameNode s) = TextBoxIcon s
|
||||
|
@ -37,7 +37,6 @@ data Icon = TextBoxIcon String
|
||||
| GuardIcon
|
||||
Int -- Number of alternatives
|
||||
| FlatLambdaIcon [String]
|
||||
| PAppIcon Int String
|
||||
| CaseIcon Int
|
||||
| CaseResultIcon
|
||||
| BindTextBoxIcon String
|
||||
@ -59,8 +58,6 @@ data SyntaxNode =
|
||||
LikeApplyNode LikeApplyFlavor Int -- Function application, composition, and applying to a composition
|
||||
-- NestedApplyNode is only created in GraphAlgorithms, not during translation.
|
||||
| NestedApplyNode LikeApplyFlavor Int [(SgNamedNode, Edge)]
|
||||
| PatternApplyNode String Int -- Destructors as used in patterns
|
||||
-- | NestedPatternApplyNode String Int [(SgNamedNode, Edge)]
|
||||
| NestedPatternApplyNode String [(Maybe SgNamedNode, String)]
|
||||
| NameNode String -- Identifiers or symbols
|
||||
| BindNameNode String
|
||||
|
Loading…
Reference in New Issue
Block a user