Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support for custom key bindings in CUA #436

Merged
merged 1 commit into from

2 participants

@mhwombat

Added support for custom key bindings in CUA, with a configuration example showing how to use it. Code written by Dmitry Ivanov; I added some comments and tested it.

@ethercrow ethercrow merged commit 4285796 into yi-editor:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 2, 2013
  1. @mhwombat
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.