Skip to content

Commit

Permalink
PreUpdate 0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
SquitchYT committed Aug 28, 2021
1 parent eb93c61 commit 7e4db85
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 60 deletions.
23 changes: 14 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ let workers = [];
let mainWindow;
let shells = [];


//Detect if workdir specified
//Modifier getting with args
let customWorkdir;
if (argv.workdir) {
customWorkdir = argv.workdir;
let customCommand;

if (argv.workdir || argv.cd) {
customWorkdir = argv.workdir || argv.cd;
}
if (argv.command || argv.e) {
customCommand = argv.command || argv.e;
}
console.log("\x1b[33m[WARNING]\x1b[0m Tess is currently under development. You use an development release. You can have damage deal to your system");

Expand All @@ -34,7 +38,7 @@ console.log("\x1b[33m[WARNING]\x1b[0m Tess is currently under development. You u
let file = fs.readFileSync(osData.homeDir + "/Applications/tess/config/tess.config", "utf-8");
config = JSON.parse(file);
} catch (error) {
let toWrite= "{\"theme\":\"default\",\"background\":\"full\",\"cursorStyle\":\"block\",\"transparencyValue\":\"100\",\"imageBlur\":\"0\",\"imageLink\":\"\",\"plugin\":[],\"shortcut\":[{\"id\":1,\"action\":\"Default Shell\",\"control\":\"CTRL + T\"},{\"id\":2,\"action\":\"Config\",\"control\":\"CTRL + P\"},{\"id\":3,\"action\":\"Paste\",\"control\":\"CTRL + V\"},{\"id\":6,\"action\":\"Copy\",\"control\":\"CTRL + C\"},{\"id\":12,\"action\":\"Close\",\"control\":\"CTRL + W\"}],\"profil\":[{\"id\":1,\"programm\":\"sh -c $SHELL\",\"name\":\"Default Shell\",\"icon\":\"\"}],\"defaultProfil\":\"Default Shell\",\"terminalFontSize\":\"15\"}";
let toWrite= "{\"theme\":\"default\",\"background\":\"full\",\"cursorStyle\":\"block\",\"transparencyValue\":\"100\",\"imageBlur\":\"0\",\"imageLink\":\"\",\"plugin\":[],\"shortcut\":[{\"id\":1,\"action\":\"Default Shell\",\"control\":\"CTRL + T\"},{\"id\":2,\"action\":\"Config\",\"control\":\"CTRL + P\"},{\"id\":3,\"action\":\"Paste\",\"control\":\"CTRL + V\"},{\"id\":6,\"action\":\"Copy\",\"control\":\"CTRL + C\"},{\"id\":12,\"action\":\"Close\",\"control\":\"CTRL + W\"}],\"profil\":[{\"id\":1,\"programm\":\"sh -c $SHELL\",\"name\":\"Default Shell\",\"icon\":\"Default\"}],\"defaultProfil\":\"Default Shell\",\"terminalFontSize\":\"15\"}";

mkdir.sync(osData.homeDir + "/Applications/tess/config");
mkdir.sync(osData.homeDir + "/.config/");
Expand Down Expand Up @@ -142,7 +146,7 @@ function openWindow(config, colors) {

ipc.on("new-term", (e, data) => {
// Check if command exist
let Command = data.shell.split(" ");
let Command = (customCommand || data.shell).split(" ");
let prog = Command[0];
Command.shift();
let args = Command;
Expand All @@ -155,6 +159,7 @@ ipc.on("new-term", (e, data) => {
env: process.env,
});
customWorkdir = ""; //Reset Workdir
customCommand = "";

shell.onExit(() => {
try {
Expand Down Expand Up @@ -202,7 +207,7 @@ app.on("ready", () => {
if (needTransparent) {
setTimeout(() => {
openWindow(config, colors);
}, 200);
}, 275);
} else {
openWindow(config, colors);
}
Expand Down Expand Up @@ -300,7 +305,7 @@ function reloadConfig() {
let file = fs.readFileSync(osData.homeDir + "/Applications/tess/config/tess.config", "utf-8");
config = JSON.parse(file);
} catch (_) {
let toWrite = "{\"theme\":\"default\",\"background\":\"full\",\"cursorStyle\":\"block\",\"transparencyValue\":\"100\",\"imageBlur\":\"0\",\"imageLink\":\"\",\"plugin\":[],\"shortcut\":[{\"id\":1,\"action\":\"Default Shell\",\"control\":\"CTRL + T\"},{\"id\":2,\"action\":\"Config\",\"control\":\"CTRL + P\"},{\"id\":3,\"action\":\"Paste\",\"control\":\"CTRL + V\"},{\"id\":6,\"action\":\"Copy\",\"control\":\"CTRL + C\"},{\"id\":12,\"action\":\"Close\",\"control\":\"CTRL + W\"}],\"profil\":[{\"id\":1,\"programm\":\"sh -c $SHELL\",\"name\":\"Default Shell\",\"icon\":\"\"}],\"defaultProfil\":\"Default Shell\",\"terminalFontSize\":\"15\"}";
let toWrite = "{\"theme\":\"default\",\"background\":\"full\",\"cursorStyle\":\"block\",\"transparencyValue\":\"100\",\"imageBlur\":\"0\",\"imageLink\":\"\",\"plugin\":[],\"shortcut\":[{\"id\":1,\"action\":\"Default Shell\",\"control\":\"CTRL + T\"},{\"id\":2,\"action\":\"Config\",\"control\":\"CTRL + P\"},{\"id\":3,\"action\":\"Paste\",\"control\":\"CTRL + V\"},{\"id\":6,\"action\":\"Copy\",\"control\":\"CTRL + C\"},{\"id\":12,\"action\":\"Close\",\"control\":\"CTRL + W\"}],\"profil\":[{\"id\":1,\"programm\":\"sh -c $SHELL\",\"name\":\"Default Shell\",\"icon\":\"Default\"}],\"defaultProfil\":\"Default Shell\",\"terminalFontSize\":\"15\"}";

mkdir.sync(osData.homeDir + "/Applications/tess/config");
mkdir.sync(osData.homeDir + "/.config/");
Expand Down Expand Up @@ -336,4 +341,4 @@ ipc.on("openFileDialog", (e, data) => {
}).catch((err) => {
console.log(err);
});
});
});
42 changes: 24 additions & 18 deletions src/page/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ function HandleShortcut() {
}

function CreateNewTerminal(toStart, name, icon) {
if (icon == "Default") {
icon = undefined;
}

let tab = document.createElement("div");
tab.classList.add("tab", "tab-all-" + index, "tab-active");
tab.setAttribute("index", index + 1);
Expand Down Expand Up @@ -185,7 +189,7 @@ function CreateNewTerminal(toStart, name, icon) {
focusTerm(tab_link.classList[2], tab);
});

document.addEventListener("mousemove", (e) => {
document.addEventListener("mousemove", (e) => { // move that to global scope : optimizing
if (tab.getAttribute("mousedown") == "true") {
if (tab.getAttribute("dragged") != "true" && Math.abs(e.clientX - Number(tab.getAttribute("startDragX"))) > 15) {
tab.setAttribute("dragged", "true");
Expand Down Expand Up @@ -217,6 +221,24 @@ function CreateNewTerminal(toStart, name, icon) {
</svg>
`;

close_button.addEventListener("mousedown", (e) => {
e.stopPropagation();
if (t.type == "Page") {
Close(close_button.getAttribute("close-button-number"));
} else {
ipc.send("close-terminal", close_button.getAttribute("close-button-number"));
}

let tabs = document.querySelectorAll(".tab");
let indexList = [];
tabs.forEach((el) => {
indexList.push(Number(el.getAttribute("index")));
});

maxIndex = Math.max(...indexList);
});


let logo = document.createElement("img");
logo.src = (icon) ? icon : "../../img/shell.png";
logo.classList.add("logo");
Expand Down Expand Up @@ -323,22 +345,6 @@ function CreateNewTerminal(toStart, name, icon) {
};
}

close_button.addEventListener("click", () => {
if (t.type == "Page") {
Close(close_button.getAttribute("close-button-number"));
} else {
ipc.send("close-terminal", close_button.getAttribute("close-button-number"));
}

let tabs = document.querySelectorAll(".tab");
let indexList = [];
tabs.forEach((el) => {
indexList.push(Number(el.getAttribute("index")));
});

maxIndex = Math.max(...indexList);
});

n = index;
index++;

Expand Down Expand Up @@ -604,8 +610,8 @@ function updateTerminalApparence() {
if (el.type == "Terminal") {
el.term.setOption("theme", colors.terminal.theme);
el.term.setOption("fontSize", config.terminalFontSize);
el.term.setOption("cursorBlink", config.cursorBlink);
el.term.setOption("cursorStyle", config.cursorStyle);
el.term.setOption("cursorBlink", (config.cursorBlink === "true"));
}
});

Expand Down
1 change: 1 addition & 0 deletions src/page/app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ iframe {
border: none;
padding: 0;
margin: 0;
overflow: hidden;
}

svg {
Expand Down
47 changes: 27 additions & 20 deletions src/page/config/config.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ body {
font-family: 'Roboto', sans-serif;
width: calc(100vw + 3px);
overflow-x: hidden;
overflow-y: hidden;
}

* {
Expand Down Expand Up @@ -79,13 +80,12 @@ body {
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
max-height: 100%;
position: absolute;
height: calc(100vh + 35px + 100px);
max-height: full;
top: 0;
left: 0;
overflow-y: overlay !important;
overflow-x: hidden;
overflow-y: overlay;
}

.hidden-page {
Expand Down Expand Up @@ -234,7 +234,7 @@ input::-webkit-inner-spin-button {
justify-content: center;
align-items: center;
flex-direction: column;
margin-bottom: 16px;
margin-bottom: 15px;
margin-right: 15px;
}

Expand Down Expand Up @@ -372,10 +372,6 @@ input::-webkit-inner-spin-button {
padding-left: 20px;
}

.selected-page {
background: var(--app-dark-background) !important;
}

h2 {
color: var(--item-textcolor);
font-size: 16px;
Expand Down Expand Up @@ -411,7 +407,7 @@ h3 {
align-items: center;
justify-content: space-between;
width: 92%;
height: 63px;
height: 66px;
}

.description {
Expand Down Expand Up @@ -506,8 +502,9 @@ h3 {
display: flex;
align-items: center;
justify-content: center;
height: 60px;
width: calc(100% - 43px);
height: 45px;
margin-bottom: 15px;
}

.shortcutLine div {
Expand All @@ -529,23 +526,29 @@ h3 {
justify-content: center;
align-items: center;
width: 100%;
height: 60px;
height: 38px;
margin-top: 15px;
}

.shortcutAddButton {
width: 30%;
height: 29px;
border: 2.5px solid white;
max-width: 520px;
min-width: 150px;
color: white;
font-size: 17px;
width: 15.5em;
height: 100%;
border: 2px solid var(--item-textcolor);
color: var(--item-textcolor);
font-size: 18px;
font-weight: 500;
display: flex;
justify-content: center;
align-items: center;
user-select: none;
border-radius: 4px;
border-radius: 400px;
transition: 0.55s;
cursor: pointer;
}

.shortcutAddButton:hover {
box-shadow: inset 15.5em 0 0 0 var(--item-textcolor);
color: var(--item-background);
}

.invisible {
Expand All @@ -560,4 +563,8 @@ h3 {

.shortcut {
align-items: flex-start !important;
}

.selected-page {
background: var(--app-dark-background) !important;
}
8 changes: 3 additions & 5 deletions src/page/config/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
<div class="left-side-menu-items">
<h2 class="left-side-menu-title">Settings</h2>
<div class="link" link="apparence-page">
<div class="link selected-page" link="apparence-page">
<svg class="link-icon" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4 2a2 2 0 00-2 2v11a3 3 0 106 0V4a2 2 0 00-2-2H4zm1 14a1 1 0 100-2 1 1 0 000 2zm5-1.757l4.9-4.9a2 2 0 000-2.828L13.485 5.1a2 2 0 00-2.828 0L10 5.757v8.486zM16 18H9.071l6-6H16a2 2 0 012 2v2a2 2 0 01-2 2z" clip-rule="evenodd" />
</svg>
Expand Down Expand Up @@ -67,7 +67,7 @@ <h2 class="left-side-menu-title">Settings</h2>
</div>
</div>

<section class="page no-transition hidden-page" id="apparence-page">
<section class="page no-transition" id="apparence-page">
<div class="page-header">
<div class="return-button">
<svg viewBox="0 0 20 20" fill="currentColor" class="return-arrow">
Expand Down Expand Up @@ -181,9 +181,7 @@ <h2 class="left-side-menu-title">Settings</h2>
<span class="page-title">Shortcut</span>
</div>
<div class="shortcutAddDiv">
<div class="shortcutAddButton">
Add +
</div>
<div class="shortcutAddButton">Create shortcut</div>
</div>
</section>

Expand Down
29 changes: 21 additions & 8 deletions src/page/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ links.forEach((el) => {
leftSideMenu.parentNode.classList.add("menu-hidden");
el.classList.add("selected-page");
menuIcon.classList.add("menu-icon-close");

currentProfilPage = -1;
});
});

Expand All @@ -238,7 +240,6 @@ function changeProfilPage(el) {
inputProfilCommand.setAttribute("value", el.programm);
inputProfilCommand.value = el.programm;
inputProfilIcon.setAttribute("selected-value", el.icon);
// add inputIcon link
}
});

Expand Down Expand Up @@ -276,7 +277,6 @@ shortcutAddBtn.addEventListener("click", () => {
profils = profils.substring(0, profils.length - 1);

let shortcutId = 0;

config.shortcut.forEach((el) => {
shortcutId += el.id;
});
Expand Down Expand Up @@ -421,9 +421,17 @@ profilCreateBtn.addEventListener("click", () => {
id: newProfilId,
name: "New Profil",
programm: "sh -c $SHELL",
icon: ""
icon: "Default"
};
config.profil.push(newProfil);

let newProfilList = "";
config.profil.forEach((el) => {
newProfilList += el.name;
newProfilList += ";";
});
profilDropDownMenu.setAttribute("input-list", newProfilList.slice(0, -1));

saveUpdate();
});

Expand Down Expand Up @@ -516,7 +524,7 @@ function loadConfig() {
let details = document.createElement("span");
details.classList.add("details");
//details.innerHTML = "TODO : get plugins description";
details.innerHTML = plugin;
details.innerHTML = plugin; // get plugin description

description.appendChild(title);
description.appendChild(details);
Expand Down Expand Up @@ -661,6 +669,15 @@ function deleteProfil(id) {
}
});

let newProfilList = "";
config.profil.forEach((el) => {
newProfilList += el.name;
newProfilList += ";";
});
profilDropDownMenu.setAttribute("input-list", newProfilList.slice(0, -1));



if (config.defaultProfil == name) {
// update drop down menu for default profil
config.defaultProfil = "Default Shell";
Expand All @@ -670,10 +687,6 @@ function deleteProfil(id) {
if (currentProfilPage == id) {
let defaultShellProfilLink = document.querySelector("*[profil-id='1']");
defaultShellProfilLink.click();

setTimeout(() => {
defaultShellProfilLink.classList.add("selected-page");
}, 50);
}

let currentProfilLink = document.querySelector(`*[profil-id="${id}"]`);
Expand Down

0 comments on commit 7e4db85

Please sign in to comment.