mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-30 06:02:02 +03:00
Rename Name to CursorName since that is what it is
This commit is contained in:
parent
1df6668712
commit
2809fd4a19
@ -50,7 +50,7 @@ appEvent e st =
|
||||
|
||||
initialState :: St
|
||||
initialState =
|
||||
St { _stEditor = editor (Name "edit") ""
|
||||
St { _stEditor = editor (CursorName "edit") ""
|
||||
, _stList = list listDrawElem []
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module Brick.Core
|
||||
( Location(..)
|
||||
, Name(..)
|
||||
, CursorName(..)
|
||||
, CursorLocation(..)
|
||||
, HandleEvent(..)
|
||||
, SetSize(..)
|
||||
@ -20,12 +20,12 @@ instance Monoid Location where
|
||||
mempty = origin
|
||||
mappend (Location (w1, h1)) (Location (w2, h2)) = Location (w1+w2, h1+h2)
|
||||
|
||||
newtype Name = Name String
|
||||
deriving (Eq, Show)
|
||||
newtype CursorName = CursorName String
|
||||
deriving (Eq, Show)
|
||||
|
||||
data CursorLocation =
|
||||
CursorLocation { cursorLocation :: !Location
|
||||
, cursorLocationName :: !(Maybe Name)
|
||||
, cursorLocationName :: !(Maybe CursorName)
|
||||
}
|
||||
deriving Show
|
||||
|
||||
|
@ -8,7 +8,7 @@ where
|
||||
import Data.Monoid ((<>))
|
||||
import Graphics.Vty (Event(..), Key(..), Modifier(..))
|
||||
|
||||
import Brick.Core (Location(..), Name(..), HandleEvent(..), SetSize(..))
|
||||
import Brick.Core (Location(..), CursorName(..), HandleEvent(..), SetSize(..))
|
||||
import Brick.Prim
|
||||
import Brick.Scroll (HScroll(..), hScroll, hScrollToView)
|
||||
import Brick.Util (clamp)
|
||||
@ -16,7 +16,7 @@ import Brick.Util (clamp)
|
||||
data Editor =
|
||||
Editor { editStr :: !String
|
||||
, editCursorPos :: !Int
|
||||
, editorName :: !Name
|
||||
, editorCursorName :: !CursorName
|
||||
, editorScroll :: !HScroll
|
||||
}
|
||||
|
||||
@ -82,12 +82,12 @@ instance SetSize Editor where
|
||||
in e { editorScroll = hScrollToView (editCursorPos e) updatedScroll
|
||||
}
|
||||
|
||||
editor :: Name -> String -> Editor
|
||||
editor name s = Editor s (length s) name (HScroll 0 0)
|
||||
editor :: CursorName -> String -> Editor
|
||||
editor cName s = Editor s (length s) cName (HScroll 0 0)
|
||||
|
||||
drawEditor :: Editor -> Prim Editor
|
||||
drawEditor e =
|
||||
SetSize setSize $
|
||||
ShowCursor (editorName e) (Location (editCursorPos e - hScrollLeft (editorScroll e), 0)) $
|
||||
ShowCursor (editorCursorName e) (Location (editCursorPos e - hScrollLeft (editorScroll e), 0)) $
|
||||
hScroll (editorScroll e) $
|
||||
Txt (editStr e) <<+ HPad ' '
|
||||
|
@ -10,12 +10,12 @@ where
|
||||
|
||||
import Data.Maybe (listToMaybe)
|
||||
|
||||
import Brick.Core (Name(..), CursorLocation(..))
|
||||
import Brick.Core (CursorName(..), CursorLocation(..))
|
||||
|
||||
data FocusRing = FocusRingEmpty
|
||||
| FocusRingNonempty ![Name] !Int
|
||||
| FocusRingNonempty ![CursorName] !Int
|
||||
|
||||
focusRing :: [Name] -> FocusRing
|
||||
focusRing :: [CursorName] -> FocusRing
|
||||
focusRing [] = FocusRingEmpty
|
||||
focusRing names = FocusRingNonempty names 0
|
||||
|
||||
@ -31,7 +31,7 @@ focusPrev (FocusRingNonempty ns i) = FocusRingNonempty ns i'
|
||||
where
|
||||
i' = (i + (length ns) - 1) `mod` (length ns)
|
||||
|
||||
focusGetCurrent :: FocusRing -> Maybe Name
|
||||
focusGetCurrent :: FocusRing -> Maybe CursorName
|
||||
focusGetCurrent FocusRingEmpty = Nothing
|
||||
focusGetCurrent (FocusRingNonempty ns i) = Just $ ns !! i
|
||||
|
||||
|
@ -9,7 +9,7 @@ where
|
||||
import Control.Applicative ((<$>), (<|>))
|
||||
import Graphics.Vty (Event(..), Key(..))
|
||||
|
||||
import Brick.Core (HandleEvent(..), SetSize(..), Name(..))
|
||||
import Brick.Core (HandleEvent(..), SetSize(..))
|
||||
import Brick.Prim (Prim(..), Priority(..), (<<=))
|
||||
import Brick.Scroll (VScroll(..), vScroll, vScrollToView)
|
||||
import Brick.Util (clamp, for)
|
||||
|
@ -13,7 +13,7 @@ import Control.Lens (Lens')
|
||||
import Data.String (IsString(..))
|
||||
import Graphics.Vty (DisplayRegion, Image, Attr)
|
||||
|
||||
import Brick.Core (Location(..), Name(..))
|
||||
import Brick.Core (Location(..), CursorName(..))
|
||||
|
||||
data Priority = High | Low
|
||||
deriving (Show, Eq)
|
||||
@ -34,7 +34,7 @@ data Prim a = Txt !String
|
||||
| CropRightBy !Int !(Prim a)
|
||||
| CropTopBy !Int !(Prim a)
|
||||
| CropBottomBy !Int !(Prim a)
|
||||
| ShowCursor !Name !Location !(Prim a)
|
||||
| ShowCursor !CursorName !Location !(Prim a)
|
||||
| SetSize (DisplayRegion -> a -> a) !(Prim a)
|
||||
| HRelease !(Prim a)
|
||||
| VRelease !(Prim a)
|
||||
|
Loading…
Reference in New Issue
Block a user