Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom key bindings in CUA #436

Merged
merged 1 commit into from Apr 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 54 additions & 0 deletions 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 = ' '
}
}


19 changes: 18 additions & 1 deletion 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
Expand All @@ -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

Expand Down