Permalink
Browse files

Move BufferM action for replacing character under cursor to Yi.Buffer…

….Misc
  • Loading branch information...
1 parent 11621cb commit cc6d0b392adfb5bd6675597b5f003901499ef7df @ethercrow committed Sep 29, 2012
Showing with 12 additions and 11 deletions.
  1. +5 −11 yi-contrib/src/Yi/FuzzyOpen.hs
  2. +7 −0 yi/src/library/Yi/Buffer/Misc.hs
@@ -107,15 +107,9 @@ updateMatchList bufRef fileList = do
withEditor $ withGivenBuffer0 bufRef $ do
replaceBufferContent $ showFileList filteredFiles
moveTo 0
- replaceCurrentChar '*'
+ replaceCharB '*'
return ()
-replaceCurrentChar :: Char -> BufferM ()
-replaceCurrentChar c = do
- deleteN 1
- insertB c
- leftB
-
openInThisWindow :: BufferRef -> YiM ()
openInThisWindow = openRoutine (return ())
@@ -147,12 +141,12 @@ insertChar = textChar >>= write . insertB
moveSelectionUp :: BufferRef -> EditorM ()
moveSelectionUp bufRef = withGivenBuffer0 bufRef $ do
- replaceCurrentChar ' '
+ replaceCharB ' '
lineUp
- replaceCurrentChar '*'
+ replaceCharB '*'
moveSelectionDown :: BufferRef -> EditorM ()
moveSelectionDown bufRef = withGivenBuffer0 bufRef $ do
- replaceCurrentChar ' '
+ replaceCharB ' '
lineDown
- replaceCurrentChar '*'
+ replaceCharB '*'
@@ -140,6 +140,7 @@ module Yi.Buffer.Misc
, BufferId
, file
, lastSyncTimeA
+ , replaceCharB
)
where
@@ -972,6 +973,12 @@ readAtB i = do
[c] -> c
_ -> '\0'
+replaceCharB :: Char -> BufferM ()
+replaceCharB c = do
+ deleteN 1
+ insertB c
+ leftB
+
-- | Delete @n@ characters forward from the current point
deleteN :: Int -> BufferM ()
deleteN n = pointB >>= deleteNAt Forward n

0 comments on commit cc6d0b3

Please sign in to comment.