From f21a1f23ab53ab628ed2677c8d85869fa7e22b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Tue, 27 Aug 2013 00:40:46 -0300 Subject: Improve identing --- State.hs | 58 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'State.hs') diff --git a/State.hs b/State.hs index f9623dc..5b91d15 100644 --- a/State.hs +++ b/State.hs @@ -101,20 +101,21 @@ curRowAsInteger st = toInteger $ currentRow st colPadAsInteger st = toInteger $ columnPadding st -incrementSelectedRow st | (selectedRow st) < limit = case (mode st) of - MaildirMode -> - let - sr = (selectedRowMD . maildirState) st - maildirState' = (maildirState st) { selectedRowMD = sr + 1 } - in - st { maildirState = maildirState' } - IndexMode -> - let - sr = (selectedRowIn . indexState) st - indexState' = (indexState st) { selectedRowIn = sr + 1 } - in - st { indexState = indexState' } - _ -> st +incrementSelectedRow st | (selectedRow st) < limit = + case (mode st) of + MaildirMode -> + let + sr = (selectedRowMD . maildirState) st + maildirState' = (maildirState st) { selectedRowMD = sr + 1 } + in + st { maildirState = maildirState' } + IndexMode -> + let + sr = (selectedRowIn . indexState) st + indexState' = (indexState st) { selectedRowIn = sr + 1 } + in + st { indexState = indexState' } + _ -> st | otherwise = st where limit' = case (mode st) of @@ -124,20 +125,21 @@ incrementSelectedRow st | (selectedRow st) < limit = case (mode st) of then fromIntegral $ limit' - 2 else fromIntegral limit' -decrementSelectedRow st | (selectedRow st) > 0 = case (mode st) of - MaildirMode -> - let - sr = (selectedRowMD . maildirState) st - maildirState' = (maildirState st) { selectedRowMD = sr - 1 } - in - st { maildirState = maildirState' } - IndexMode -> - let - sr = (selectedRowIn . indexState) st - indexState' = (indexState st) { selectedRowIn = sr - 1 } - in - st { indexState = indexState' } - _ -> st +decrementSelectedRow st | (selectedRow st) > 0 = + case (mode st) of + MaildirMode -> + let + sr = (selectedRowMD . maildirState) st + maildirState' = (maildirState st) { selectedRowMD = sr - 1 } + in + st { maildirState = maildirState' } + IndexMode -> + let + sr = (selectedRowIn . indexState) st + indexState' = (indexState st) { selectedRowIn = sr - 1 } + in + st { indexState = indexState' } + _ -> st | otherwise = st selectedRow st = case (mode st) of -- cgit v1.2.3