Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
✨ Shortcut+Option to hide UNIX hidden files in fsD
Browse files Browse the repository at this point in the history
hide files starting with a dot (.) close #421
  • Loading branch information
GitSquared committed Feb 7, 2019
1 parent 933eff2 commit eeecd5d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 64 deletions.
1 change: 1 addition & 0 deletions src/_boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ if (!fs.existsSync(settingsFile)) {
nointro: false,
allowWindowed: false,
excludeSelfFromToplist: false,
hideDotfiles: false,
experimentalGlobeFeatures: false,
experimentalFeatures: false
}, 4));
Expand Down
16 changes: 15 additions & 1 deletion src/_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ async function initUI() {

document.getElementById("main_shell").setAttribute("style", "opacity: 0;");
document.body.innerHTML += `
<section id="filesystem" style="width: 0px;">
<section id="filesystem" style="width: 0px;" class="${window.settings.hideDotfiles ? "hideDotfiles" : ""}">
</section>
<section id="keyboard" style="opacity:0;">
</section>`;
Expand Down Expand Up @@ -654,6 +654,14 @@ window.openSettings = async () => {
<option>${!window.settings.excludeSelfFromToplist}</option>
</select></td>
</tr>
<tr>
<td>hideDotfiles</td>
<td>Hide files and directories starting with a dot in file display</td>
<td><select id="settingsEditor-hideDotfiles">
<option>${window.settings.hideDotfiles}</option>
<option>${!window.settings.hideDotfiles}</option>
</select></td>
</tr>
<tr>
<td>experimentalGlobeFeatures</td>
<td>Toggle experimental features for the network globe</td>
Expand Down Expand Up @@ -705,6 +713,7 @@ window.writeSettingsFile = () => {
iface: document.getElementById("settingsEditor-iface").value,
allowWindowed: (document.getElementById("settingsEditor-allowWindowed").value === "true"),
excludeSelfFromToplist: (document.getElementById("settingsEditor-excludeSelfFromToplist").value === "true"),
hideDotfiles: (document.getElementById("settingsEditor-hideDotfiles").value === "true"),
experimentalGlobeFeatures: (document.getElementById("settingsEditor-experimentalGlobeFeatures").value === "true"),
experimentalFeatures: (document.getElementById("settingsEditor-experimentalFeatures").value === "true")
};
Expand Down Expand Up @@ -801,6 +810,11 @@ function registerKeyboardShortcuts() {
globalShortcut.register("CommandOrControl+5", () => {
window.focusShellTab(4);
});

// Toggle hiding dotfiles in fsDisp
globalShortcut.register("CommandOrControl+Shift+H", () => {
window.fsDisp.toggleHidedotfiles();
});
}
registerKeyboardShortcuts();

Expand Down
8 changes: 8 additions & 0 deletions src/assets/css/filesystem.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ section#filesystem > h3.title {
padding-right: 0;
}

section#filesystem.hideDotfiles > h3.title > p#fs_disp_title_dir::before {
content: "dotfiles hidden - ";
}

h2#fs_disp_error {
font-weight: bold;
text-align: center;
Expand Down Expand Up @@ -67,6 +71,10 @@ div#fs_disp_container > *.hidden {
opacity: 0.7;
}

section#filesystem.hideDotfiles > div#fs_disp_container > *.hidden {
display: none;
}

div#fs_disp_container > * > svg {
width: 5vh;
}
Expand Down
108 changes: 45 additions & 63 deletions src/classes/filesystem.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ class FilesystemDisplay {
});
};

this.toggleHidedotfiles = () => {
if (window.settings.hideDotfiles) {
container.setAttribute("class", "");
window.settings.hideDotfiles = false;
} else {
container.setAttribute("class", "hideDotfiles");
window.settings.hideDotfiles = true;
}
};

this.readFS = async dir => {
if (this.failed === true) return false;
let tcwd = dir;
Expand All @@ -141,66 +151,36 @@ class FilesystemDisplay {
content.forEach(async (file, i) => {
let fstat = await this._asyncFSwrapper.lstat(path.join(tcwd, file)).catch(reject);

let e = {
name: window._escapeHtml(file),
type: "other",
category: "other",
hidden: false
};

if (fstat.isDirectory()) {
if (tcwd === settingsDir && file === "themes") {
this.cwd.push({
name: window._escapeHtml(file),
type: "edex-themesDir",
category: "dir"
});
} else if (tcwd === settingsDir && file === "keyboards") {
this.cwd.push({
name: window._escapeHtml(file),
type: "edex-kblayoutsDir",
category: "dir"
});
} else {
this.cwd.push({
name: window._escapeHtml(file),
type: "dir",
category: "dir"
});
}
} else if (fstat.isSymbolicLink()) {
this.cwd.push({
name: window._escapeHtml(file),
type: "symlink",
category: "symlink"
});
} else if (fstat.isFile()) {
if (tcwd === themesDir && file.endsWith(".json")) {
this.cwd.push({
name: window._escapeHtml(file),
type: "edex-theme",
category: "file"
});
} else if (tcwd === keyboardsDir && file.endsWith(".json")) {
this.cwd.push({
name: window._escapeHtml(file),
type: "edex-kblayout",
category: "file"
});
} else if (tcwd === settingsDir && file === "settings.json") {
this.cwd.push({
name: window._escapeHtml(file),
type: "edex-settings",
category: "file"
});
} else {
this.cwd.push({
name: window._escapeHtml(file),
type: "file",
category: "file"
});
}
} else {
this.cwd.push({
name: window._escapeHtml(file),
type: "other",
category: "other"
});
e.category = "dir";
e.type = "dir";
}
if (e.category === "dir" && tcwd === settingsDir && file === "themes") e.type="edex-themesDir";
if (e.category === "dir" && tcwd === settingsDir && file === "keyboards") e.type = "edex-kblayoutsDir";

if (fstat.isSymbolicLink()) {
e.category = "symlink";
e.type = "symlink";
}

if (fstat.isFile()) {
e.category = "file";
e.type = "file";
}
if (e.category === "file" && tcwd === themesDir && file.endsWith(".json")) e.type = "edex-theme";
if (e.category === "file" && tcwd === keyboardsDir && file.endsWith(".json")) e.type = "edex-kblayout";
if (e.category === "file" && tcwd === settingsDir && file === "settings.json") e.type = "edex-settings";

if (file.startsWith(".")) e.hidden = true;

this.cwd.push(e);
if (i === content.length-1) resolve();
});
}).catch(() => { this.setFailedState() });
Expand Down Expand Up @@ -277,10 +257,7 @@ class FilesystemDisplay {

let filesDOM = ``;
blockList.forEach(e => {
let hidden = "";
if (e.name.startsWith(".")) {
hidden = " hidden";
}
let hidden = e.hidden ? " hidden" : "";

let cmd = `window.term[window.currentTerm].write('\\'${e.name}\\'')`;
if (e.type === "dir" || e.type === "up" || e.type.endsWith("Dir")) {
Expand Down Expand Up @@ -403,8 +380,13 @@ class FilesystemDisplay {
// Render animation
let id = 0;
while (this.filesContainer.childNodes[id]) {
this.filesContainer.childNodes[id].setAttribute("class", this.filesContainer.childNodes[id].getAttribute("class").replace(" animationWait", ""));
await _delay(50);
let e = this.filesContainer.childNodes[id];
e.setAttribute("class", e.className.replace(" animationWait", ""));

if (window.settings.hideDotfiles !== true || e.className.indexOf("hidden") === -1) {
await _delay(30);
}

id++;
}
};
Expand Down

0 comments on commit eeecd5d

Please # to comment.