mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Prompt: clean up and optimize moveWord a bit
This commit is contained in:
parent
06b3767cae
commit
1e7cd73544
@ -404,17 +404,13 @@ moveWord d = do
|
|||||||
c <- gets command
|
c <- gets command
|
||||||
o <- gets offset
|
o <- gets offset
|
||||||
let (f,ss) = splitAt o c
|
let (f,ss) = splitAt o c
|
||||||
lp = length . reverse . fst . break isSpace
|
lenToS = length . fst . break isSpace
|
||||||
ln = length . fst . break isSpace
|
ln p s = case p s of
|
||||||
prev s = case reverse s of
|
' ':x -> 1 + lenToS x
|
||||||
' ':x -> 1 + (lp x)
|
x -> lenToS x
|
||||||
x -> lp x
|
|
||||||
next s = case s of
|
|
||||||
' ':x -> 1 + (ln x)
|
|
||||||
x -> ln x
|
|
||||||
newoff = case d of
|
newoff = case d of
|
||||||
Prev -> o - prev f
|
Prev -> o - (ln reverse f )
|
||||||
_ -> o + next ss
|
_ -> o + (ln id ss)
|
||||||
modify $ \s -> s { offset = newoff }
|
modify $ \s -> s { offset = newoff }
|
||||||
|
|
||||||
moveHistory :: Direction -> XP ()
|
moveHistory :: Direction -> XP ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user