Skip to content

Commit

Permalink
Make path label more obvious
Browse files Browse the repository at this point in the history
  • Loading branch information
makermelissa committed Aug 5, 2024
1 parent e4853b2 commit e6b6652
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/common/file_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const extensionMap = {
"mp4": {style: FA_STYLE_REGULAR, icon: "file-video", type: "bin"},
"mpy": {style: FA_STYLE_REGULAR, icon: "file", type: "bin"},
"pdf": {style: FA_STYLE_REGULAR, icon: "file-pdf", type: "bin"},
"py": {style: FA_STYLE_REGULAR, icon: "file-lines", type: "text"},
"py": {style: FA_STYLE_REGULAR, icon: "file-code", type: "text"},
"toml": {style: FA_STYLE_REGULAR, icon: "file-lines", type: "text"},
"txt": {style: FA_STYLE_REGULAR, icon: "file-lines", type: "text"},
"wav": {style: FA_STYLE_REGULAR, icon: "file-audio", type: "bin"},
Expand All @@ -57,6 +57,9 @@ const FILESIZE_UNITS = ["bytes", "KB", "MB", "GB", "TB"];
const COMPACT_UNITS = ["", "K", "M", "G", "T"];

function getFileExtension(filename) {
if (filename === null) {
return null;
}
let extension = filename.split('.').pop();
if (extension !== null) {
return String(extension).toLowerCase();
Expand Down Expand Up @@ -189,7 +192,7 @@ class FileDialog extends GenericModal {
this._currentPath = path;
}
const currentPathLabel = this._getElement('currentPathLabel');
currentPathLabel.innerHTML = this._currentPath;
currentPathLabel.innerHTML = `<i class="${FA_STYLE_REGULAR} fa-folder-open"></i> ` + this._currentPath;

if (this._currentPath != "/") {
this._addFile({path: "..", isDir: true}, "fa-folder-open");
Expand Down
7 changes: 7 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {indentWithTab} from "@codemirror/commands"
import { python } from "@codemirror/lang-python";
import { syntaxHighlighting, indentUnit } from "@codemirror/language";
import { classHighlighter } from "@lezer/highlight";
import { getFileIcon } from "./common/file_dialog.js";

import { Terminal } from '@xterm/xterm';
import { FitAddon } from '@xterm/addon-fit';
Expand Down Expand Up @@ -237,7 +238,13 @@ async function checkReadOnly() {

/* Update the filename and update the UI */
function setFilename(path) {
// Use the extension_map to figure out the file icon
let filename = path;

// Prepend an icon to the path
const [style, icon] = getFileIcon(path);
filename = `<i class="${style} ${icon}"></i> ` + filename;

if (path === null) {
filename = "[New Document]";
btnSave.forEach((b) => b.style.display = 'none');
Expand Down

0 comments on commit e6b6652

Please sign in to comment.