Skip to content

Commit

Permalink
golbin#35 keys for branch handling also configured
Browse files Browse the repository at this point in the history
  • Loading branch information
jzsfkzm committed Aug 4, 2015
1 parent 54e1104 commit a720bd2
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 81 deletions.
11 changes: 11 additions & 0 deletions config/key/mc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,16 @@
"rightPane": [
"right"
]
},
"branch": {
"checkOut": [
"enter"
],
"delete": [
"d"
],
"add": [
"a"
]
}
}
11 changes: 11 additions & 0 deletions config/key/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,16 @@
"rightPane": [
"right"
]
},
"branch": {
"checkOut": [
"enter"
],
"delete": [
"C-d"
],
"add": [
"C-a"
]
}
}
9 changes: 5 additions & 4 deletions controller/branch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var _ = require('lodash');

var BranchView = require('../view/branch');
var config = require('../config');

var parent = null,
view = null;
Expand Down Expand Up @@ -36,7 +37,7 @@ var branch = {

view = BranchView(parent.screen);

view.list.key(['enter'], function () {
view.list.key(config.keys.branch.checkOut, function () {
try {
parent.git.checkout(this.selected);
branch.hide(true);
Expand All @@ -46,7 +47,7 @@ var branch = {
}
});

view.list.key(['C-d'], function () {
view.list.key(config.keys.branch.delete, function () {
try {
parent.git.delBranch(this.selected);
branch.show();
Expand All @@ -56,7 +57,7 @@ var branch = {
}
});

view.list.key(['C-a'], function () {
view.list.key(config.keys.branch.add, function () {
view.prompt.input('Input the new branch name', '', function (err, value) {
try {
parent.git.addBranch(value);
Expand All @@ -68,7 +69,7 @@ var branch = {
});
});

view.list.key(['escape'], function () {
view.list.key(config.keys.main.quit, function () {
branch.hide();
});
}
Expand Down
3 changes: 2 additions & 1 deletion view/branch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var blessed = require('blessed'),
styles = require('./style/branch.json');
config = require('../config'),
styles = require('./style/branch')(config);

var layout = null,
list = null,
Expand Down
74 changes: 74 additions & 0 deletions view/style/branch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'use strict';

module.exports = function (config) {
return {
"layout": {
"hidden": true,
"top": "center",
"left": "center",
"width": "50%",
"height": "50%"
},
"list": {
"top": "top",
"left": "left",
"width": "100%",
"height": "100%-4",
"data": null,
"border": "line",
"align": "left",
"vi": true,
"keys": true,
"style": {
"border": {
"fg": "white"
},
"selected": {
"bg": "blue"
}
}
},
"menubar": {
"align": "center",
"bottom": 0,
"width": "100%",
"height": 3,
"border": "line",
"mouse": true,
"vi": true,
"keys": true,
"style": {
"prefix": {
"fg": "white"
},
"item": {
"fg": "cyan"
},
"selected": {
"fg": "cyan"
}
},
"commands": {
"CHECKOUT": {
"keys": config.keys.branch.checkOut
},
"ADD": {
"keys": config.keys.branch.add
},
"DEL": {
"keys": config.keys.branch.delete
}
}
},
"prompt": {
"top": "center",
"left": "center",
"width": "80%",
"height": "shrink",
"border": "line",
"align": "left",
"vi": true,
"keys": true
}
};
};
76 changes: 0 additions & 76 deletions view/style/branch.json

This file was deleted.

0 comments on commit a720bd2

Please sign in to comment.