Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lang/ar-ye.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
Comment thread
bajrangCoder marked this conversation as resolved.
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/be-by.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/bn-bd.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/cs-cz.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/de-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/es-sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/fr-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/he-il.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/hi-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/hu-hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Legutóbbi fájlok",
"command palette": "Parancspaletta megnyitása",
"change theme": "Téma módosítása",
"documentation": "Dokumentáció"
"documentation": "Dokumentáció",
"open in terminal": "Open in Terminal"
Comment thread
bajrangCoder marked this conversation as resolved.
}
3 changes: 2 additions & 1 deletion src/lang/id-id.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/ir-fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/it-it.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/ja-jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/ko-kr.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/ml-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/mm-unicode.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/mm-zawgyi.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/pl-pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/pu-in.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/ru-ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/tl-ph.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/tr-tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/uk-ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/uz-uz.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/vi-vn.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
3 changes: 2 additions & 1 deletion src/lang/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,6 @@
"recent": "Recent Files",
"command palette": "Open Command Palette",
"change theme": "Change Theme",
"documentation": "Documentation"
"documentation": "Documentation",
"open in terminal": "Open in Terminal"
}
76 changes: 75 additions & 1 deletion src/lib/openFolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sidebarApps from "sidebarApps";
import collapsableList from "components/collapsableList";
import FileTree from "components/fileTree";
import Sidebar from "components/sidebar";
import { TerminalManager } from "components/terminal";
import tile from "components/tile";
import toast from "components/toast";
import alert from "dialogs/alert";
Expand All @@ -27,6 +28,39 @@ const isAcodeTerminalPublicSafUri = (value = "") =>
const isTerminalSafUri = (value = "") =>
isTermuxSafUri(value) || isAcodeTerminalPublicSafUri(value);

const getTerminalPaths = () => {
const packageName = window.BuildInfo?.packageName || "com.foxdebug.acode";
const dataDir = `/data/user/0/${packageName}`;
const alpineRoot = `${dataDir}/files/alpine`;
const publicDir = `${dataDir}/files/public`;
return { alpineRoot, publicDir, dataDir };
};

const isTerminalAccessiblePath = (url = "") => {
if (isAcodeTerminalPublicSafUri(url)) return true;
const { alpineRoot, publicDir } = getTerminalPaths();
const cleanUrl = url.replace(/^file:\/\//, "");
if (cleanUrl.startsWith(alpineRoot) || cleanUrl.startsWith(publicDir)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just check if a file starts with file:// and if it’s readable, but this works too.

return true;
}
return false;
};

const convertToProotPath = (url = "") => {
const { alpineRoot, publicDir } = getTerminalPaths();
if (isAcodeTerminalPublicSafUri(url)) {
return "/public";
}
const cleanUrl = url.replace(/^file:\/\//, "");
if (cleanUrl.startsWith(publicDir)) {
return cleanUrl.replace(publicDir, "/public");
}
if (cleanUrl.startsWith(alpineRoot)) {
return cleanUrl.replace(alpineRoot, "") || "/";
}
return cleanUrl;
};
Comment thread
bajrangCoder marked this conversation as resolved.

/**
* @typedef {import('../components/collapsableList').Collapsible} Collapsible
*/
Expand Down Expand Up @@ -311,14 +345,34 @@ async function handleContextmenu(type, url, name, $target) {
}

options.push(NEW_FILE, NEW_FOLDER, OPEN_FOLDER, INSERT_FILE);

if (isTerminalAccessiblePath(url)) {
const OPEN_IN_TERMINAL = [
"open-in-terminal",
strings["open in terminal"] || "Open in Terminal",
"licons terminal",
];
options.push(OPEN_IN_TERMINAL);
}
Comment thread
bajrangCoder marked this conversation as resolved.
} else if (type === "root") {
options = [];

if (clipBoard.url != null) {
options.push(PASTE);
}

options.push(NEW_FILE, NEW_FOLDER, INSERT_FILE, CLOSE_FOLDER);
options.push(NEW_FILE, NEW_FOLDER, INSERT_FILE);

if (isTerminalAccessiblePath(url)) {
const OPEN_IN_TERMINAL = [
"open-in-terminal",
strings["open in terminal"] || "Open in Terminal",
"licons terminal",
];
options.push(OPEN_IN_TERMINAL);
}

options.push(CLOSE_FOLDER);
}

if (clipBoard.action) options.push(CANCEL);
Expand Down Expand Up @@ -378,6 +432,9 @@ function execOperation(type, action, url, $target, name) {

case "install-plugin":
return installPlugin();

case "open-in-terminal":
return openInTerminal();
}

async function installPlugin() {
Expand All @@ -396,6 +453,23 @@ function execOperation(type, action, url, $target, name) {
}
}

async function openInTerminal() {
try {
const prootPath = convertToProotPath(url);
const terminal = await TerminalManager.createTerminal({
name: `Terminal - ${name}`,
render: true,
});
if (terminal?.component) {
terminal.component.write(`cd ${JSON.stringify(prootPath)}\n`);
Sidebar.hide();
}
} catch (error) {
console.error("Failed to open terminal:", error);
toast(strings["error"] || "Error");
}
Comment thread
bajrangCoder marked this conversation as resolved.
Comment thread
bajrangCoder marked this conversation as resolved.
}

async function deleteFile() {
const msg = strings["delete entry"].replace("{name}", name);
const confirmation = await confirm(strings.warning, msg);
Expand Down