refactor
This commit is contained in:
parent
c1b88265d1
commit
23023238cb
@ -6,6 +6,7 @@ A simple text UI for hledger, based on the vty library.
|
|||||||
|
|
||||||
module Commands.UI
|
module Commands.UI
|
||||||
where
|
where
|
||||||
|
import Safe (headDef)
|
||||||
import Graphics.Vty
|
import Graphics.Vty
|
||||||
import Ledger
|
import Ledger
|
||||||
import Options
|
import Options
|
||||||
@ -278,12 +279,11 @@ scrollToTransaction (Just t) a@AppState{abuf=buf} = setCursorY cy $ setScrollY s
|
|||||||
currentTransaction :: AppState -> Maybe Transaction
|
currentTransaction :: AppState -> Maybe Transaction
|
||||||
currentTransaction a@AppState{aledger=l,abuf=buf} = ptransaction p
|
currentTransaction a@AppState{aledger=l,abuf=buf} = ptransaction p
|
||||||
where
|
where
|
||||||
p = safehead nullposting $ filter ismatch $ ledgerPostings l
|
p = headDef nullposting $ filter ismatch $ ledgerPostings l
|
||||||
ismatch p = postingDate p == parsedate (take 10 datedesc)
|
ismatch p = postingDate p == parsedate (take 10 datedesc)
|
||||||
&& take 70 (showPostingWithBalance False p nullmixedamt) == (datedesc ++ acctamt)
|
&& take 70 (showPostingWithBalance False p nullmixedamt) == (datedesc ++ acctamt)
|
||||||
datedesc = take 32 $ fromMaybe "" $ find (not . (" " `isPrefixOf`)) $ safehead "" rest : reverse above
|
datedesc = take 32 $ fromMaybe "" $ find (not . (" " `isPrefixOf`)) $ headDef "" rest : reverse above
|
||||||
acctamt = drop 32 $ safehead "" rest
|
acctamt = drop 32 $ headDef "" rest
|
||||||
safehead d ls = if null ls then d else head ls
|
|
||||||
(above,rest) = splitAt y buf
|
(above,rest) = splitAt y buf
|
||||||
y = posY a
|
y = posY a
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user