-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteste.js
77 lines (67 loc) · 1.98 KB
/
teste.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Example Program for Blessed
* Copyright (c) 2013, Christopher Jeffrey (MIT License).
* https://github.com/chjj/blessed
*/
import blessed from "blessed";
let program = blessed.program();
process.title = "blessed";
program.on("keypress", function (ch, key) {
if (key.name === "q") {
program.clear();
program.disableMouse();
program.showCursor();
program.normalBuffer();
process.exit(0);
}
});
program.on("mouse", function (data) {
if (data.action === "mouseup") return;
program.move(1, program.rows);
program.eraseInLine("right");
if (data.action === "wheelup") {
program.write("Mouse wheel up at: " + data.x + ", " + data.y);
} else if (data.action === "wheeldown") {
program.write("Mouse wheel down at: " + data.x + ", " + data.y);
} else if (data.action === "mousedown" && data.button === "left") {
program.write("Left button down at: " + data.x + ", " + data.y);
} else if (data.action === "mousedown" && data.button === "right") {
program.write("Right button down at: " + data.x + ", " + data.y);
} else {
program.write("Mouse at: " + data.x + ", " + data.y);
}
program.move(data.x, data.y);
program.bg("red");
program.write(" ");
program.bg("!red");
});
program.on("focus", function () {
program.move(1, program.rows);
program.write("Gained focus.");
});
program.on("blur", function () {
program.move(1, program.rows);
program.write("Lost focus.");
});
program.alternateBuffer();
program.enableMouse();
program.hideCursor();
program.clear();
program.move(1, 1);
program.bg("black");
program.write("Hello world", "blue fg");
program.setx(((program.cols / 2) | 0) - 4);
program.down(5);
program.write("Hi again!");
program.bg("!black");
program.feed();
program.getCursor(function (err, data) {
if (!err) {
program.write("Cursor is at: " + data.x + ", " + data.y + ".");
program.feed();
}
program.charset("SCLD");
program.write("abcdefghijklmnopqrstuvwxyz0123456789");
program.charset("US");
program.setx(1);
});