Skip to content

Commit e6b6652

Browse files
committed
Make path label more obvious
1 parent e4853b2 commit e6b6652

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

js/common/file_dialog.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const extensionMap = {
4242
"mp4": {style: FA_STYLE_REGULAR, icon: "file-video", type: "bin"},
4343
"mpy": {style: FA_STYLE_REGULAR, icon: "file", type: "bin"},
4444
"pdf": {style: FA_STYLE_REGULAR, icon: "file-pdf", type: "bin"},
45-
"py": {style: FA_STYLE_REGULAR, icon: "file-lines", type: "text"},
45+
"py": {style: FA_STYLE_REGULAR, icon: "file-code", type: "text"},
4646
"toml": {style: FA_STYLE_REGULAR, icon: "file-lines", type: "text"},
4747
"txt": {style: FA_STYLE_REGULAR, icon: "file-lines", type: "text"},
4848
"wav": {style: FA_STYLE_REGULAR, icon: "file-audio", type: "bin"},
@@ -57,6 +57,9 @@ const FILESIZE_UNITS = ["bytes", "KB", "MB", "GB", "TB"];
5757
const COMPACT_UNITS = ["", "K", "M", "G", "T"];
5858

5959
function getFileExtension(filename) {
60+
if (filename === null) {
61+
return null;
62+
}
6063
let extension = filename.split('.').pop();
6164
if (extension !== null) {
6265
return String(extension).toLowerCase();
@@ -189,7 +192,7 @@ class FileDialog extends GenericModal {
189192
this._currentPath = path;
190193
}
191194
const currentPathLabel = this._getElement('currentPathLabel');
192-
currentPathLabel.innerHTML = this._currentPath;
195+
currentPathLabel.innerHTML = `<i class="${FA_STYLE_REGULAR} fa-folder-open"></i> ` + this._currentPath;
193196

194197
if (this._currentPath != "/") {
195198
this._addFile({path: "..", isDir: true}, "fa-folder-open");

js/script.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {indentWithTab} from "@codemirror/commands"
55
import { python } from "@codemirror/lang-python";
66
import { syntaxHighlighting, indentUnit } from "@codemirror/language";
77
import { classHighlighter } from "@lezer/highlight";
8+
import { getFileIcon } from "./common/file_dialog.js";
89

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

238239
/* Update the filename and update the UI */
239240
function setFilename(path) {
241+
// Use the extension_map to figure out the file icon
240242
let filename = path;
243+
244+
// Prepend an icon to the path
245+
const [style, icon] = getFileIcon(path);
246+
filename = `<i class="${style} ${icon}"></i> ` + filename;
247+
241248
if (path === null) {
242249
filename = "[New Document]";
243250
btnSave.forEach((b) => b.style.display = 'none');

0 commit comments

Comments
 (0)