1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | process.title = 'multiplex.js';
|
11 |
|
12 | var blessed = require('blessed')
|
13 | , screen;
|
14 |
|
15 | screen = blessed.screen({
|
16 | smartCSR: true,
|
17 | log: process.env.HOME + '/blessed-terminal.log',
|
18 | fullUnicode: true,
|
19 | dockBorders: true,
|
20 | ignoreDockContrast: true
|
21 | });
|
22 |
|
23 | var topleft = blessed.terminal({
|
24 | parent: screen,
|
25 | cursor: 'line',
|
26 | cursorBlink: true,
|
27 | screenKeys: false,
|
28 | label: ' multiplex.js ',
|
29 | left: 0,
|
30 | top: 0,
|
31 | width: '50%',
|
32 | height: '50%',
|
33 | border: 'line',
|
34 | style: {
|
35 | fg: 'default',
|
36 | bg: 'default',
|
37 | focus: {
|
38 | border: {
|
39 | fg: 'green'
|
40 | }
|
41 | }
|
42 | }
|
43 | });
|
44 |
|
45 | topleft.pty.on('data', function(data) {
|
46 | screen.log(JSON.stringify(data));
|
47 | });
|
48 |
|
49 | var topright = blessed.terminal({
|
50 | parent: screen,
|
51 | cursor: 'block',
|
52 | cursorBlink: true,
|
53 | screenKeys: false,
|
54 | label: ' multiplex.js ',
|
55 | left: '50%-1',
|
56 | top: 0,
|
57 | width: '50%+1',
|
58 | height: '50%',
|
59 | border: 'line',
|
60 | style: {
|
61 | fg: 'red',
|
62 | bg: 'black',
|
63 | focus: {
|
64 | border: {
|
65 | fg: 'green'
|
66 | }
|
67 | }
|
68 | }
|
69 | });
|
70 |
|
71 | var bottomleft = blessed.terminal({
|
72 | parent: screen,
|
73 | cursor: 'block',
|
74 | cursorBlink: true,
|
75 | screenKeys: false,
|
76 | label: ' multiplex.js ',
|
77 | left: 0,
|
78 | top: '50%-1',
|
79 | width: '50%',
|
80 | height: '50%+1',
|
81 | border: 'line',
|
82 | style: {
|
83 | fg: 'default',
|
84 | bg: 'default',
|
85 | focus: {
|
86 | border: {
|
87 | fg: 'green'
|
88 | }
|
89 | }
|
90 | }
|
91 | });
|
92 |
|
93 | var bottomright = blessed.terminal({
|
94 | parent: screen,
|
95 | cursor: 'block',
|
96 | cursorBlink: true,
|
97 | screenKeys: false,
|
98 | label: ' multiplex.js ',
|
99 | left: '50%-1',
|
100 | top: '50%-1',
|
101 | width: '50%+1',
|
102 | height: '50%+1',
|
103 | border: 'line',
|
104 | style: {
|
105 | fg: 'default',
|
106 | bg: 'default',
|
107 | focus: {
|
108 | border: {
|
109 | fg: 'green'
|
110 | }
|
111 | }
|
112 | }
|
113 | });
|
114 |
|
115 | [topleft, topright, bottomleft, bottomright].forEach(function(term) {
|
116 | term.enableDrag(function(mouse) {
|
117 | return !!mouse.ctrl;
|
118 | });
|
119 | term.on('title', function(title) {
|
120 | screen.title = title;
|
121 | term.setLabel(' ' + title + ' ');
|
122 | screen.render();
|
123 | });
|
124 | term.on('click', term.focus.bind(term));
|
125 | });
|
126 |
|
127 | topleft.focus();
|
128 |
|
129 | screen.key('C-q', function() {
|
130 | topleft.kill();
|
131 | topright.kill();
|
132 | bottomleft.kill();
|
133 | bottomright.kill();
|
134 | return screen.destroy();
|
135 | });
|
136 |
|
137 | screen.program.key('S-tab', function() {
|
138 | screen.focusNext();
|
139 | screen.render();
|
140 | });
|
141 |
|
142 | screen.render();
|