From 49870831ab25d1bfe2d63812cf1403799b9b8c91 Mon Sep 17 00:00:00 2001 From: Nick Paul Date: Wed, 9 Aug 2017 15:16:35 -0400 Subject: [PATCH] Add function for removing key bindings --- src/EditorConfig.jl | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/EditorConfig.jl b/src/EditorConfig.jl index ab27b53..a24399e 100644 --- a/src/EditorConfig.jl +++ b/src/EditorConfig.jl @@ -69,14 +69,22 @@ configIsParam(sym::Symbol) = sym in keys(CONFIG) const KEY_BINDINGS = Dict{UInt32, String}() +"""Remove a keybinding""" +function rmKeyBinding(c::Char) + delete!(KEY_BINDINGS, UInt32(c) & 0x1f) +end + +"""Set a keybinding""" function setKeyBinding(c::Char, s::String) KEY_BINDINGS[UInt32(c) & 0x1f] = s end -function getKeyBinding(c::Char) +"""Get command from keybinding""" +function getKeyBinding(c::Char) ::String get(KEY_BINDINGS, UInt32(c) & 0x1f, "") end +"""Return true if the given key is bound to a command""" isKeyBound(c::Char) = (UInt32(c) & 0x1f) in keys(KEY_BINDINGS) @@ -100,32 +108,12 @@ setKeyBinding('f', "find") setKeyBinding('q', "quit") -# # In juliarc: -# # using Acorn -# -# -# ## KEY_BINDINGS -# #Acorn.addKeyBinding('f', "find") -# Acorn.addKeyBinding('o', "open") -# Acorn.addKeyBinding('s', "save") -# -# """ -# bind f find -# bind o open -# bind s save -# set tab_stop 4 -# set expandtab true -# """ - -# TODO: -# hard/soft tabs -# show hidden characters - export configGet, configSet, configIsParam, configDesc, + rmKeyBinding, setKeyBinding, getKeyBinding, isKeyBound