-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathlayout.mjs
90 lines (74 loc) · 2.22 KB
/
layout.mjs
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
78
79
80
81
82
83
84
85
86
87
88
89
90
import { ConsoleManager,ConfirmPopup, PageBuilder } from "../dist/esm/ConsoleGui.mjs"
const opt = {
title: "Layout Test",
layoutOptions: {
type: "quad",
boxed: true, // Set to true to enable boxed layout
showTitle: true, // Set to false to hide title
changeFocusKey: "ctrl+l", // Change layout with ctrl+l to switch to the logs page
boxColor: "yellow",
boxStyle: "bold",
fitHeight: true,
},
logLocation: 1,
enableMouse: true
}
const GUI = new ConsoleManager(opt)
GUI.on("exit", () => {
closeApp()
})
GUI.on("keypressed", (key) => {
switch (key.name) {
case "q":
new ConfirmPopup({
id: "popupQuit", title: "Are you sure you want to quit?"
}).show().on("confirm", () => closeApp())
break
default:
break
}
})
const closeApp = () => {
console.clear()
process.exit()
}
GUI.refresh()
const loremIpsumPage = new PageBuilder()
loremIpsumPage.addRow({
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
color: "red",
bg: "blue",
})
loremIpsumPage.addRow({
text: "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
color: "blue",
bg: "red",
})
loremIpsumPage.addRow({
text: "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
color: "green",
bg: "yellow",
})
loremIpsumPage.addRow({
text: "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
color: "yellow",
bg: "green",
})
loremIpsumPage.addRow({
text: "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
color: "cyan",
bg: "magenta",
})
const loremIpsumOverflowedPage = new PageBuilder()
// add some random text to the page
for (let i = 0; i < 100; i++) {
loremIpsumOverflowedPage.addRow({
text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
color: "red",
bg: "blue",
})
}
GUI.setPage(loremIpsumPage, 0, "Lorem Ipsum")
GUI.setPage(loremIpsumOverflowedPage, 3, "Lorem Ipsum Overflowed")
GUI.setPage(new PageBuilder(), 2, "Page 3")
console.log("Done")