Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #44 from ethercrow/readline

Looks good for me.
  • Loading branch information...
commit 3c97531f400272940d7373f5f6c7bdc297a31c5a 2 parents 9965d30 + a4a160a
@mgajda mgajda authored
View
21 yi/src/library/Yi/Keymap/Readline.hs
@@ -0,0 +1,21 @@
+module Yi.Keymap.Readline
+ ( standardMovementBindings
+ ) where
+
+import Yi.Buffer
+import Yi.Keymap
+import Yi.Keymap.Keys
+
+-- | Readline-like movement bindings intended for minibuffer keymaps
+standardMovementBindings :: Keymap
+standardMovementBindings =
+ choice [ ctrlCh 'b' ?>>! moveXorSol 1
+ , ctrlCh 'f' ?>>! moveXorEol 1
+ , metaCh 'b' ?>>! moveB unitWord Backward
+ , metaCh 'f' ?>>! moveB unitWord Forward
+ , spec KLeft ?>>! moveXorSol 1
+ , spec KRight ?>>! moveXorEol 1
+ , ctrlCh 'a' ?>>! moveToSol
+ , ctrlCh 'e' ?>>! moveToEol
+ ]
+
View
10 yi/src/library/Yi/Keymap/Vim.hs
@@ -59,7 +59,7 @@ import System.PosixCompat.Files (fileExist)
#else
import System.Posix (fileExist)
#endif
-import System.FilePath (FilePath, takeFileName)
+import System.FilePath (takeFileName)
import System.Directory (getCurrentDirectory, setCurrentDirectory)
import Control.Monad.State hiding (mapM_, mapM, sequence)
@@ -83,6 +83,7 @@ import Yi.Tag
import Yi.Window (bufkey)
import Yi.Hoogle (hoogle, hoogleSearch)
import qualified Codec.Binary.UTF8.String as UTF8
+import Yi.Keymap.Readline
import Yi.Keymap.Vim.TagStack
@@ -1236,7 +1237,8 @@ exMode self prompt = do
,spec KRight ?>>! moveXorEol 1
,ctrlCh 'w' ?>>! actionAndHistoryPrefix $ deleteB unitWord Backward
,ctrlCh 'u' ?>>! moveToSol >> deleteToEol]
- <|| (insertChar >>! setHistoryPrefix)
+ <|| standardMovementBindings
+ <|| (insertChar >>! setHistoryPrefix)
actionAndHistoryPrefix act = do
discard $ withBuffer0 $ act
setHistoryPrefix
@@ -1265,8 +1267,8 @@ exMode self prompt = do
fmap bufInfoFileName bufInfoB
let sanitizedFileName = case currentFileName of
- ('/':'/':f) -> '/':f
- otherwise -> currentFileName
+ ('/':'/':f') -> '/':f'
+ _ -> currentFileName
-- now modifying minibuffer
withBuffer $ do
View
1  yi/yi.cabal
@@ -127,6 +127,7 @@ library
Yi.Keymap.Emacs.KillRing
Yi.Keymap.Emacs.Utils
Yi.Keymap.Keys
+ Yi.Keymap.Readline
Yi.Keymap.Vim
Yi.Keymap.Vim.TagStack
Yi.KillRing
Please sign in to comment.
Something went wrong with that request. Please try again.