forked from chjj/blessed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for blessed+term.js. see chjj#168.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var blessed = require('../'); | ||
|
||
var screen = blessed.screen({ | ||
dump: __dirname + '/logs/termblessed.log', | ||
smartCSR: true, | ||
warnings: true | ||
}); | ||
|
||
var terminal = blessed.terminal({ | ||
parent: screen, | ||
// cursor: 'line', | ||
cursorBlink: true, | ||
screenKeys: false, | ||
top: 'center', | ||
left: 'center', | ||
width: '90%', | ||
height: '90%', | ||
border: 'line', | ||
handler: function() {}, | ||
style: { | ||
fg: 'default', | ||
bg: 'default', | ||
focus: { | ||
border: { | ||
fg: 'green' | ||
} | ||
} | ||
} | ||
}); | ||
|
||
terminal.focus(); | ||
|
||
var term = terminal.term; | ||
|
||
var screen2 = blessed.screen({ | ||
dump: __dirname + '/logs/termblessed2.log', | ||
smartCSR: true, | ||
warnings: true, | ||
input: term, | ||
output: term | ||
}); | ||
|
||
var box1 = blessed.box({ | ||
parent: screen2, | ||
top: 'center', | ||
left: 'center', | ||
width: 20, | ||
height: 10, | ||
border: 'line', | ||
content: 'Hello world' | ||
}); | ||
|
||
screen.key('C-q', function() { | ||
// NOTE: | ||
// not necessary since screen.destroy causes terminal.term to be destroyed | ||
// (screen2's input and output are no longer readable/writable) | ||
// screen2.destroy(); | ||
return screen.destroy(); | ||
}); | ||
|
||
screen2.render(); | ||
screen.render(); |