-- | An Editor backend implementation, made of the instance of Engine of InsideAppend.
-moduleBuffer(InsideAppend(..))
-where
-
-importData.Maybe
-importEngine
-importTest.QuickCheck
-
--- |See the "Engine" class docs
-dataInsideAppend
--- | the cursor when its pointing to a real line (eg line function doesn't fail)
-=Inside{
-left::[String],-- ^ lines before the cursor (reversed order)
-cursor::String,-- ^ addressed line
-right::[String]-- ^ lines after the cursor
-}
--- | the cursor is pointing either to insert at the front of the file or
--- append at the end of the file.
-|Append
-{
-elems::Either[String][String]-- ^ Left lines is in append mode, Right is in insert at front mode.
-}
-deriving(Show,Eq)
-
-instanceEngineInsideAppendwhere
-listInxs=Append(Rightxs)
-prev(Append(Right_))=Nothing
-prev(Append(Left[]))=error"empty Append Left"
-prev(Append(Left(l:ls)))=Just$Insidelsl[]
-prev(Inside[]xls)=Just$Append(Right(x:ls))
-prev(Inside(l:ls)xrs)=Just$Insidelsl(x:rs)
-next(Append(Right[]))=Nothing
-next(Append(Right(r:rs)))=Just$Inside[]rrs
-next(Append(Left[]))=error"empty Append Left"
-next(Append(Left_))=Nothing
-next(Insidelsx[])=Just$Append(Left(x:ls))
-next(Insidelsx(r:rs))=Just$Inside(x:ls)rrs
-endw@(Append(Left_))=Justw
-endw=nextw>>=end
-startw@(Append(Right_))=Justw
-startw=prevw>>=start
-pos(Append(Leftls))=End(lengthls+1)
-pos(Append(Right_))=Begin
-pos(Insidels__)=Line$lengthls+1
-del(Append_)=Nothing
-del(Inside[]_[])=Just$Append(Right[])
-del(Insidels_[])=Just$Append(Leftls)
-del(Insidels_(r:rs))=Just$Insidelsrrs
-delnnw|n==0=Justw
-|True=delw>>=deln(n-1)
-addxs(Append(Left_))=Nothing
-addxs(Append(Rightrs))=Just$Append$Right(xs++rs)
-addxs(Insidelsxrs)=Just$Insidelsx(xs++rs)
-insxsw=prevw>>=addxs>>=next
-jumpnw=startw>>=rjumpn
-listOutw=startw>>=\(Append(Rightrs))->returnrs
-linen0_=Just[]
-linen_(Append_)=Nothing
-linennw@(Inside_x_)=nextw>>=linen(n-1)>>=Just.(x:)
-
-tillendw=filterisInside(runnernextw)
-
-fromstartw=reverse$filterisInside(runnerprevw)
-
-fwdcyclew=filterisInside$runnernextw++reverse(runnerprevw)++[w]
-bwdcyclew=filterisInside$runnerprevw++reverse(runnernextw)++[w]
-
-isInside::InsideAppend->Bool
-isInside(Inside___)=True
-isInside_=False
-
-runner::ChangeInsideAppend->InsideAppend->[InsideAppend]
-runneropw=maybe[](\w->(w:runneropw))(opw)
-
-prop_E1_IA=prop_E1::(WInsideAppend)->String->Bool
---prop_Empty_IA = prop_Empty ::
-t=listIn["paolo","va","in","bici"]::InsideAppend
-