Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #436 from mhwombat/master

Support for custom key bindings in CUA
  • Loading branch information...
commit 42857966c385b13e2af6727b5825edeae647a804 2 parents cc9a63a + e1dcf92
@ethercrow ethercrow authored
View
54 yi-contrib/src/Yi/Config/Users/Amy.hs
@@ -0,0 +1,54 @@
+import Yi
+
+import Prelude ()
+import Yi.Prelude
+
+-- Import the desired UI as needed.
+-- Some are not complied in, so we import none here.
+
+-- import Yi.UI.Vty (start)
+-- import Yi.UI.Cocoa (start)
+-- import Yi.UI.Pango (start)
+
+import Yi.Keymap.Cua
+
+myConfig = defaultCuaConfig
+
+defaultUIConfig = configUI myConfig
+
+-- Add M-x (which is probably Alt-x on your system) to the default
+-- keyset, and have it launch our custom macro.
+extendedCuaKeymapSet = customizedCuaKeymapSet $
+ choice [
+ metaCh 'x' ?>>! helloWorld
+ ]
+
+-- A custom macro
+helloWorld :: YiM ()
+helloWorld = withBuffer $ insertN "Hello, world!"
+
+
+main :: IO ()
+main = yi $ myConfig
+ {
+ -- Keymap Configuration
+ defaultKm = extendedCuaKeymapSet,
+
+ -- UI Configuration
+ -- Override the default UI as such:
+ startFrontEnd = startFrontEnd myConfig,
+ -- Yi.UI.Vty.start -- for Vty
+ -- (can be overridden at the command line)
+ -- Options:
+ configUI = defaultUIConfig
+ {
+ configFontSize = Nothing,
+ -- 'Just 10' for specifying the size.
+ configTheme = configTheme defaultUIConfig,
+ -- darkBlueTheme -- Change the color scheme here.
+
+ configWindowFill = ' '
+ }
+ }
+
+
View
19 yi/src/library/Yi/Keymap/Cua.hs
@@ -1,6 +1,14 @@
-- Copyright (c) 2008 Jean-Philippe Bernardy
-module Yi.Keymap.Cua (keymap, portableKeymap, cut, paste, copy, del) where
+module Yi.Keymap.Cua (
+ keymap
+ , portableKeymap
+ , customizedCuaKeymapSet
+ , cut
+ , paste
+ , copy
+ , del
+ ) where
import Prelude (length, take, drop)
import Yi.Core
@@ -10,6 +18,15 @@ import Yi.Misc (adjBlock)
import Yi.Rectangle
import Yi.String
+customizedCuaKeymapSet :: Keymap -> KeymapSet
+customizedCuaKeymapSet userKeymap =
+ modelessKeymapSet $ selfInsertKeymap
+ <|> move
+ <|> select
+ <|> rect
+ <|> userKeymap
+ <|> other ctrl
+
keymap :: KeymapSet
keymap = portableKeymap ctrl
Please sign in to comment.
Something went wrong with that request. Please try again.