From af4ff1dfe10071caa8cd5fd63fa6334f7f341826 Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Sun, 28 Jun 2015 11:13:04 -0700 Subject: [PATCH] Rename editStr to editContents --- programs/Main.hs | 2 +- src/Brick/Widgets/Edit.hs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/programs/Main.hs b/programs/Main.hs index 123975e..3229840 100644 --- a/programs/Main.hs +++ b/programs/Main.hs @@ -150,4 +150,4 @@ theApp = main :: IO () main = do st <- defaultMain theApp initialState - putStrLn $ "You entered: " <> (editStr $ st^.stEditor) + putStrLn $ "You entered: " <> (editContents $ st^.stEditor) diff --git a/src/Brick/Widgets/Edit.hs b/src/Brick/Widgets/Edit.hs index 5fbbc4a..90f1cae 100644 --- a/src/Brick/Widgets/Edit.hs +++ b/src/Brick/Widgets/Edit.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} module Brick.Widgets.Edit - ( Editor(editStr) + ( Editor(editContents) , editor , renderEditor , editAttr @@ -16,7 +16,7 @@ import Brick.Util (clamp) import Brick.AttrMap data Editor = - Editor { editStr :: !String + Editor { editContents :: !String , editCursorPos :: !Int , editDrawContents :: String -> Widget , editorName :: Name @@ -37,7 +37,7 @@ instance HandleEvent Editor where editSetCursorPos :: Int -> Editor -> Editor editSetCursorPos pos e = - let newCP = clamp 0 (length $ editStr e) pos + let newCP = clamp 0 (length $ editContents e) pos in e { editCursorPos = newCP } @@ -56,26 +56,26 @@ gotoBOL :: Editor -> Editor gotoBOL = editSetCursorPos 0 gotoEOL :: Editor -> Editor -gotoEOL e = editSetCursorPos (length $ editStr e) e +gotoEOL e = editSetCursorPos (length $ editContents e) e deleteChar :: Editor -> Editor -deleteChar e = e { editStr = s' +deleteChar e = e { editContents = s' } where n = editCursorPos e - s = editStr e + s = editContents e s' = take n s <> drop (n+1) s insertChar :: Char -> Editor -> Editor insertChar c theEdit = - theEdit { editStr = s + theEdit { editContents = s , editCursorPos = newCursorPos } where s = take n oldStr ++ [c] ++ drop n oldStr n = editCursorPos theEdit newCursorPos = n + 1 - oldStr = editStr theEdit + oldStr = editContents theEdit editor :: Name -> (String -> Widget) -> String -> Editor editor name draw s = Editor s (length s) draw name @@ -92,4 +92,4 @@ renderEditor e = showCursor (editorName e) cursorLoc $ visibleRegion cursorLoc (1, 1) $ editDrawContents e $ - editStr e + editContents e