Skip to content

Commit a720bd2

Browse files
committed
#35 keys for branch handling also configured
1 parent 54e1104 commit a720bd2

File tree

6 files changed

+103
-81
lines changed

6 files changed

+103
-81
lines changed

config/key/mc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,16 @@
4949
"rightPane": [
5050
"right"
5151
]
52+
},
53+
"branch": {
54+
"checkOut": [
55+
"enter"
56+
],
57+
"delete": [
58+
"d"
59+
],
60+
"add": [
61+
"a"
62+
]
5263
}
5364
}

config/key/vi.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,16 @@
4949
"rightPane": [
5050
"right"
5151
]
52+
},
53+
"branch": {
54+
"checkOut": [
55+
"enter"
56+
],
57+
"delete": [
58+
"C-d"
59+
],
60+
"add": [
61+
"C-a"
62+
]
5263
}
5364
}

controller/branch.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var _ = require('lodash');
22

33
var BranchView = require('../view/branch');
4+
var config = require('../config');
45

56
var parent = null,
67
view = null;
@@ -36,7 +37,7 @@ var branch = {
3637

3738
view = BranchView(parent.screen);
3839

39-
view.list.key(['enter'], function () {
40+
view.list.key(config.keys.branch.checkOut, function () {
4041
try {
4142
parent.git.checkout(this.selected);
4243
branch.hide(true);
@@ -46,7 +47,7 @@ var branch = {
4647
}
4748
});
4849

49-
view.list.key(['C-d'], function () {
50+
view.list.key(config.keys.branch.delete, function () {
5051
try {
5152
parent.git.delBranch(this.selected);
5253
branch.show();
@@ -56,7 +57,7 @@ var branch = {
5657
}
5758
});
5859

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

71-
view.list.key(['escape'], function () {
72+
view.list.key(config.keys.main.quit, function () {
7273
branch.hide();
7374
});
7475
}

view/branch.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var blessed = require('blessed'),
2-
styles = require('./style/branch.json');
2+
config = require('../config'),
3+
styles = require('./style/branch')(config);
34

45
var layout = null,
56
list = null,

view/style/branch.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
'use strict';
2+
3+
module.exports = function (config) {
4+
return {
5+
"layout": {
6+
"hidden": true,
7+
"top": "center",
8+
"left": "center",
9+
"width": "50%",
10+
"height": "50%"
11+
},
12+
"list": {
13+
"top": "top",
14+
"left": "left",
15+
"width": "100%",
16+
"height": "100%-4",
17+
"data": null,
18+
"border": "line",
19+
"align": "left",
20+
"vi": true,
21+
"keys": true,
22+
"style": {
23+
"border": {
24+
"fg": "white"
25+
},
26+
"selected": {
27+
"bg": "blue"
28+
}
29+
}
30+
},
31+
"menubar": {
32+
"align": "center",
33+
"bottom": 0,
34+
"width": "100%",
35+
"height": 3,
36+
"border": "line",
37+
"mouse": true,
38+
"vi": true,
39+
"keys": true,
40+
"style": {
41+
"prefix": {
42+
"fg": "white"
43+
},
44+
"item": {
45+
"fg": "cyan"
46+
},
47+
"selected": {
48+
"fg": "cyan"
49+
}
50+
},
51+
"commands": {
52+
"CHECKOUT": {
53+
"keys": config.keys.branch.checkOut
54+
},
55+
"ADD": {
56+
"keys": config.keys.branch.add
57+
},
58+
"DEL": {
59+
"keys": config.keys.branch.delete
60+
}
61+
}
62+
},
63+
"prompt": {
64+
"top": "center",
65+
"left": "center",
66+
"width": "80%",
67+
"height": "shrink",
68+
"border": "line",
69+
"align": "left",
70+
"vi": true,
71+
"keys": true
72+
}
73+
};
74+
};

view/style/branch.json

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)