mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 08:50:06 +02:00
better keyboard mapping
This commit is contained in:
parent
2fb843a8d6
commit
f71aa87b7d
4 changed files with 50 additions and 34 deletions
|
@ -4585,6 +4585,7 @@ var CommandBuffer = Backbone.Model.extend({
|
|||
var Main = require('../app');
|
||||
Main.getEvents().trigger('processCommand', popped, callback);
|
||||
} else {
|
||||
// no more commands to process
|
||||
this.clear();
|
||||
}
|
||||
},
|
||||
|
@ -13912,11 +13913,8 @@ exports.MultiView = MultiView;
|
|||
require.define("/src/js/util/keyboard.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keyMap = {
|
||||
var mapKeycodeToKey = function(keycode) {
|
||||
var keyMap = {
|
||||
37: 'left',
|
||||
38: 'up',
|
||||
39: 'right',
|
||||
|
@ -13924,8 +13922,14 @@ function KeyboardListener(options) {
|
|||
27: 'esc',
|
||||
13: 'enter'
|
||||
};
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
return keyMap[keycode];
|
||||
};
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
this.listen();
|
||||
}
|
||||
|
||||
|
@ -13941,10 +13945,12 @@ KeyboardListener.prototype.keydown = function(e) {
|
|||
var which = e.which;
|
||||
console.log('key which', which);
|
||||
|
||||
if (this.keyMap[which] === undefined) {
|
||||
var key = mapKeycodeToKey(which);
|
||||
if (key === undefined) {
|
||||
return;
|
||||
}
|
||||
this.fireEvent(this.keyMap[which]);
|
||||
|
||||
this.fireEvent(key);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||
|
@ -13953,7 +13959,7 @@ KeyboardListener.prototype.fireEvent = function(eventName) {
|
|||
};
|
||||
|
||||
exports.KeyboardListener = KeyboardListener;
|
||||
|
||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||
|
||||
});
|
||||
|
||||
|
@ -15982,6 +15988,7 @@ var CommandBuffer = Backbone.Model.extend({
|
|||
var Main = require('../app');
|
||||
Main.getEvents().trigger('processCommand', popped, callback);
|
||||
} else {
|
||||
// no more commands to process
|
||||
this.clear();
|
||||
}
|
||||
},
|
||||
|
@ -16559,11 +16566,8 @@ require("/src/js/util/index.js");
|
|||
require.define("/src/js/util/keyboard.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keyMap = {
|
||||
var mapKeycodeToKey = function(keycode) {
|
||||
var keyMap = {
|
||||
37: 'left',
|
||||
38: 'up',
|
||||
39: 'right',
|
||||
|
@ -16571,8 +16575,14 @@ function KeyboardListener(options) {
|
|||
27: 'esc',
|
||||
13: 'enter'
|
||||
};
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
return keyMap[keycode];
|
||||
};
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
this.listen();
|
||||
}
|
||||
|
||||
|
@ -16588,10 +16598,12 @@ KeyboardListener.prototype.keydown = function(e) {
|
|||
var which = e.which;
|
||||
console.log('key which', which);
|
||||
|
||||
if (this.keyMap[which] === undefined) {
|
||||
var key = mapKeycodeToKey(which);
|
||||
if (key === undefined) {
|
||||
return;
|
||||
}
|
||||
this.fireEvent(this.keyMap[which]);
|
||||
|
||||
this.fireEvent(key);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||
|
@ -16600,7 +16612,7 @@ KeyboardListener.prototype.fireEvent = function(eventName) {
|
|||
};
|
||||
|
||||
exports.KeyboardListener = KeyboardListener;
|
||||
|
||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||
|
||||
});
|
||||
require("/src/js/util/keyboard.js");
|
||||
|
|
|
@ -80,6 +80,7 @@ var CommandBuffer = Backbone.Model.extend({
|
|||
var Main = require('../app');
|
||||
Main.getEvents().trigger('processCommand', popped, callback);
|
||||
} else {
|
||||
// no more commands to process
|
||||
this.clear();
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keyMap = {
|
||||
var mapKeycodeToKey = function(keycode) {
|
||||
var keyMap = {
|
||||
37: 'left',
|
||||
38: 'up',
|
||||
39: 'right',
|
||||
|
@ -13,8 +10,14 @@ function KeyboardListener(options) {
|
|||
27: 'esc',
|
||||
13: 'enter'
|
||||
};
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
return keyMap[keycode];
|
||||
};
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
this.keydownListener = _.bind(this.keydown, this);
|
||||
this.listen();
|
||||
}
|
||||
|
||||
|
@ -30,10 +33,12 @@ KeyboardListener.prototype.keydown = function(e) {
|
|||
var which = e.which;
|
||||
console.log('key which', which);
|
||||
|
||||
if (this.keyMap[which] === undefined) {
|
||||
var key = mapKeycodeToKey(which);
|
||||
if (key === undefined) {
|
||||
return;
|
||||
}
|
||||
this.fireEvent(this.keyMap[which]);
|
||||
|
||||
this.fireEvent(key);
|
||||
};
|
||||
|
||||
KeyboardListener.prototype.fireEvent = function(eventName) {
|
||||
|
@ -42,4 +47,4 @@ KeyboardListener.prototype.fireEvent = function(eventName) {
|
|||
};
|
||||
|
||||
exports.KeyboardListener = KeyboardListener;
|
||||
|
||||
exports.mapKeycodeToKey = mapKeycodeToKey;
|
||||
|
|
12
todo.txt
12
todo.txt
|
@ -8,15 +8,13 @@ Big Graphic things:
|
|||
Medium things:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Views
|
||||
=========
|
||||
|
||||
Commands
|
||||
========
|
||||
[ ] refactor some kind of 'filter' that processes or yields commands
|
||||
[ ] then each sandbox is essentially a series of filters
|
||||
[ ] make a shim so a level engine can check after every git command if
|
||||
they succeeded and then do finish animation
|
||||
[ ] sip from buffer with post-command hooks. ideally the git engine
|
||||
knows nothing about the level being played
|
||||
[ ] text input from the commandPromptView must flow down into
|
||||
filters. no hacky stuff anymore where it's part of the option parser,
|
||||
wtf
|
||||
|
||||
Small things to implement:
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue