Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 4d1564f

Browse files
committed
Exit command, folder structure changes and comments everywhere.
1 parent b72d883 commit 4d1564f

File tree

9 files changed

+194
-132
lines changed

9 files changed

+194
-132
lines changed

settings.js renamed to BackEnd/settings.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
1+
// This gets the file system of the computer, eg. Finder, File explorer, etc.
12
const fs = require("fs");
2-
3+
// These are the default settings for this application
34
const default_settings = {
5+
// Background color
46
bgColor: "rgba(26, 27, 38, 0.1)",
7+
// Width
58
cols: 158,
9+
// Height
610
rows: 45,
11+
// The shell used
712
shellSettings: "/bin/zsh",
13+
// Cursor blinking
814
CursorBlink: true,
15+
// The text font
916
FontFamily: "SauceCodePro Nerd Font",
17+
// The text size
1018
FontSize: 14,
19+
// Blur type
20+
// type string | null - Can be appearance-based, light, dark, titlebar, selection, menu, popover, sidebar, medium-light, ultra-dark, header, sheet, window, hud, fullscreen-ui, tooltip, content, under-window, or under-page.
1121
blurType: "hud",
22+
// Toggles the blur
1223
completeTransparent: false,
1324
};
25+
// The file name and path for the configuration file.
26+
// It gets stored in the .config folder in your home directory
1427
var fileName = `${process.env["HOME"]}/.config/kaiium_config.json`;
1528

29+
// Gets the settings
1630
const getSettings = () => {
1731
const getSettingsFromFile = () => {
32+
// If the file already exists, it will read its data
1833
if (!!fs.existsSync(fileName)) {
1934
const data = fs.readFileSync(fileName, { encoding: "utf-8" });
2035
return JSON.parse(data);
21-
} else {
36+
}
37+
// In case it doesn't exist, it creates the file instead
38+
else {
2239
fs.writeFile(fileName, JSON.stringify(default_settings), (err) => {
2340
if (err) {
2441
console.log("An error ocurred creating the file " + err.message);

index.html renamed to FrontEnd/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Kaiium</title>
7-
<link rel="stylesheet" href="xterm/css/xterm.css" />
8-
<script src="xterm/lib/xterm.js"></script>
7+
<link rel="stylesheet" href="../xterm/css/xterm.css" />
8+
<script src="../xterm/lib/xterm.js"></script>
99
</head>
1010
<body>
1111
<!--<div

FrontEnd/index.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// This imports the webGL addon for xterm, which allows for gpu acceleration
2+
const { WebglAddon } = require("xterm-addon-webgl");
3+
// Imports the getSettings function
4+
const { getSettings } = require("../BackEnd/settings");
5+
// This imports the FitAddon which allows for window resizing
6+
//const { FitAddon } = require("../xterm-addon-fit/typings/xterm-addon-fit");
7+
const { FitAddon } = require("xterm-addon-fit");
8+
// This gets the ipc from electron
9+
const ipc = require("electron").ipcRenderer;
10+
// This gets the settings variables required in this file
11+
const { bgColor, CursorBlink, FontFamily, FontSize } = getSettings();
12+
13+
//const FitAddon = require("xterm-addon-fit");
14+
// This creates the xterm.js front end
15+
var term = new Terminal({
16+
// Sets the size of the text
17+
fontSize: FontSize,
18+
// Sets the font of the text
19+
fontFamily: FontFamily,
20+
// Sets if the cursor blinks or not
21+
cursorBlink: CursorBlink,
22+
// This gives the terminal name to other programs like neofetch
23+
termProgram: "Kaiium",
24+
experimentalCharAtlas: "dynamic",
25+
// This allows xterm.js to use rgba backgrounds
26+
allowTransparency: "true",
27+
});
28+
// This sets the background color of xterm.js
29+
term.setOption("theme", {
30+
background: bgColor,
31+
});
32+
// This instantiates the webGL addon
33+
const webgl = new WebglAddon();
34+
//var fitAddon = new FitAddon.FitAddon();
35+
// This instantiates the fitAddon addon
36+
const fitAddon = new FitAddon();
37+
38+
/*term.onData(function (data) {
39+
term.write(data);
40+
});*/
41+
// This sets the background color of the window itself, so that you don't get white borders around xterm.js
42+
document.body.style.backgroundColor = bgColor;
43+
// This spawns xterm.js in the terminal div
44+
term.open(document.getElementById("terminal"));
45+
// Loads the fitAddon addon into xterm.js
46+
term.loadAddon(fitAddon);
47+
// Loads the webGL addon into xterm.js
48+
term.loadAddon(webgl);
49+
// This fits xterm.js into your window
50+
fitAddon.fit();
51+
52+
// Logs xterm.js dimensions, call this function to debug window resizing.
53+
function log() {
54+
console.log(
55+
term.cols,
56+
term.rows,
57+
viewport.style.lineHeight,
58+
viewport.style.height
59+
);
60+
}
61+
// Gets the xterm viewport, which appears after spawning xterm.js
62+
var viewport = document.querySelector(".xterm-viewport");
63+
//var canvas = document.querySelectorAll("canvas");
64+
// This logs in the inspect element console, enable when needed
65+
// log();
66+
// Fits again, because im paranoid
67+
term.onRender = function () {
68+
fitAddon.fit();
69+
};
70+
// Same here
71+
window.onresize = function () {
72+
// Logs the window dimensions when resized
73+
//log();
74+
fitAddon.fit();
75+
};
76+
// Writes incoming data from the pty process into xterm.js
77+
ipc.on("terminal.incomingData", (event, data) => {
78+
term.write(data);
79+
});
80+
// Does the same kindof
81+
term.onData((e) => {
82+
ipc.send("terminal.keystroke", e);
83+
});
84+
// To debug the background color, enable if needed
85+
// console.log(bgColor);
86+
// This resizes the pty process itself
87+
term.onResize(function (size) {
88+
ipc.send("terminal.resize", size);
89+
});
90+
// This writes the version number into the terminal window
91+
term.write("Kaiium V1.0.9 ");
92+
// This handles the copy and paste for the pty process
93+
term.attachCustomKeyEventHandler((arg) => {
94+
if (arg.ctrlKey && arg.code === "KeyV" && arg.type === "keydown") {
95+
navigator.clipboard.readText().then((text) => {
96+
term.write(text);
97+
});
98+
}
99+
return true;
100+
});
File renamed without changes.
File renamed without changes.

index.js

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

0 commit comments

Comments
 (0)