diff --git a/lib/keyboard.js b/lib/keyboard.js
index 90906dc..12b02dd 100755
--- a/lib/keyboard.js
+++ b/lib/keyboard.js
@@ -29,6 +29,11 @@ var SPECIAL_KEYS = {
115: 'F4', 119: 'F8', 123: 'F12',
}
+var KEY_CODES = {}
+for(var k in SPECIAL_KEYS){
+ KEY_CODES[SPECIAL_KEYS[k]] = k
+}
+
// XXX some keys look really wrong...
function toKeyName(code){
@@ -46,7 +51,10 @@ function toKeyName(code){
return null
}
-function chr(c){
+function toKeyCode(c){
+ if(c in KEY_CODES){
+ return KEY_CODES[c]
+ }
return c.charCodeAt(0)
}
@@ -124,8 +132,15 @@ function makeKeyboardHandler(keybindings, unhandled){
}
// alias...
- while (typeof(handler) == typeof(123)) {
- handler = bindings[handler]
+ while (typeof(handler) == typeof(123) || typeof(handler) == typeof('str')) {
+ if(handler in bindings){
+ // XXX need to take care of that we can always be a number or a string...
+ handler = bindings[handler]
+ } else if(typeof(h) == typeof(1)) {
+ handler = bindings[toKeyName(handler)]
+ } else {
+ handler = bindings[toKeyCode(handler)]
+ }
}
// no handler...
if(handler == null){
@@ -172,6 +187,91 @@ function makeKeyboardHandler(keybindings, unhandled){
}
+// helper...
+function doc(text, func){
+ func.doc = text
+ return func
+}
+
+/* Build structure ready for conversion to HTML help.
+* Structure:
+* {
+* : {
+* doc: ...
+*
+* :
+* ...
+* }
+* }
+*
+* - list of key names.
+*
+*/
+function getKeyHandler(key, keybindings){
+}
+
+
+
+function buildKeyindingsHelp(keybindings){
+ var res = {}
+
+ for(var selector in keybindings){
+ var section = keybindings[selector]
+ var title = section.title == null ? selector : section.title
+ var res_sec = {
+ doc: section.doc,
+ }
+ res.title = res_sec
+
+ for(var k in section){
+ // handler...
+ var h = section[k]
+ var doc
+ var key = typeof(k) == typeof(1) ? toKeyName(k) : k
+
+ // an alias...
+ while(typeof(h) == typeof(1) || typeof(h) == typeof('s')){
+ if(h in section){
+ // XXX need to take care of that we can always be a number or a string...
+ h = section[h]
+ } else if(typeof(h) == typeof(1)) {
+ h = section[toKeyName(h)]
+ } else {
+ h = section[toKeyCode(h)]
+ }
+ }
+
+ // no handler...
+ if(h == null){
+ doc = 'Nothing'
+
+ // a handler with doc (array)...
+ } else if(typeof(h) == typeof([]) && handler.constructor.name == 'Array'){
+ doc = h[1]
+
+ // complex handler (object)...
+ } else if(typeof(h) == typeof({})){
+ // XXX
+
+
+ // simple handler (function)...
+ } else {
+ doc = h.doc != null ? h.doc : h
+
+ }
+
+ // push the actual data...
+ if(doc in res_sec){
+ res_sec[doc].push(key)
+ } else {
+ res_sec[doc] = [key]
+ }
+ }
+ }
+ return res
+}
+
+
/**********************************************************************
* vim:set ts=4 sw=4 : */
diff --git a/magazine-editor.css b/magazine-editor.css
index 7b5788d..9b55470 100755
--- a/magazine-editor.css
+++ b/magazine-editor.css
@@ -127,7 +127,7 @@
.editor-status {
display: block;
position: fixed;
- top: 30px;
+ top: 35px;
left: -200px;
z-index: 99999;
padding: 5px;