Skip to content

Commit 1adb8a1

Browse files
authored
Merge branch 'Acode-Foundation:main' into main
2 parents 4954d48 + fd4b2c6 commit 1adb8a1

File tree

10 files changed

+213
-140
lines changed

10 files changed

+213
-140
lines changed

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
# Change Log
22

3+
## v1.11.6 (965)
4+
5+
* fix: Terminal in F-Droid flavour by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1478
6+
* feat: update target SDK to API 35 and fix edge-to-edge compatibility by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1486
7+
* improve German translation by @brian200508 in https://github.com/Acode-Foundation/Acode/pull/1487
8+
* Translation: Update hu-hu.json by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/1489
9+
* chore(update IAP library to lateset version) by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/1405
10+
* feat: font manager ui for managing custom fonts by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1491
11+
* feat: add package updated time display on plugin page by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1494
12+
* chore: update id-id.json by @hyperz111 in https://github.com/Acode-Foundation/Acode/pull/1495
13+
* fix: document provider by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1497
14+
* feat(sponsor page) by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/1496
15+
* fix: load custom fonts on restart by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1499
16+
* Update hu-hu.json by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/1498
17+
* fix: resolve GitHub URI preview issues in server by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1501
18+
* fix: plugins page scrolling by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/1505
19+
* [chore] bump workflow dependencies to latest versions by @Jvr2022 in https://github.com/Acode-Foundation/Acode/pull/1506
20+
* fix: load base app stylesheet in custom editor tab by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/1507
21+
* update src/lang/pt-br.json by @sebastianjnuwu in https://github.com/Acode-Foundation/Acode/pull/1510
22+
* Add code formatter keybind by @UnschooledGamer in https://github.com/Acode-Foundation/Acode/pull/1511
23+
* Added hyphen in quicktools and more strings for i18n by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1516
24+
* chore(i18n): update id-id.json with new strings by @hyperz111 in https://github.com/Acode-Foundation/Acode/pull/1521
25+
* chore(i18n): update hu-hu.json with new strings by @summoner001 in https://github.com/Acode-Foundation/Acode/pull/1520
26+
* Add/Update Bengali (bn-BD) Translation File by @thebadhonbiswas in https://github.com/Acode-Foundation/Acode/pull/1522
27+
* feat: take confirmation before uninstalling terminal by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1528
28+
* fix ui issue by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1527
29+
* fix: disable changing editor theme when system is selected by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1529
30+
* fix: svg render issue by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1530
31+
* fix: encoding detection by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1533
32+
* fix: big screen ui and global search worker issue by @deadlyjack in https://github.com/Acode-Foundation/Acode/pull/1534
33+
* fix: improved terminal mounts by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1537
34+
* chore(i18n): refine Russian (ru-ru.json) localization with updated and new strings by @Nein-Ich-wurde-Gewinnen in https://github.com/Acode-Foundation/Acode/pull/1541
35+
* Fixed Plugin installation issues(in some cases) by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1546
36+
* feat: add option to auto detect encoding by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1547
37+
* fix: ftp infinite loading by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1552
38+
* fix: tab active state when switching tab with api by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1557
39+
* fix: resize of terminal and some small patches by @bajrangCoder in https://github.com/Acode-Foundation/Acode/pull/1562
40+
* fix: fdroid builds by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1565
41+
342
## v1.11.5 (963)
443

544
* Alpine Linux Backend by @RohitKushvaha01 in https://github.com/Acode-Foundation/Acode/pull/1401

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8' ?>
2-
<widget id="com.foxdebug.acode" android-versionCode="963" version="1.11.5"
2+
<widget id="com.foxdebug.acode" android-versionCode="965" version="1.11.6"
33
xmlns="http://www.w3.org/ns/widgets"
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
xmlns:cdv="http://cordova.apache.org/ns/1.0">

hooks/post-process.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ enableStaticContext();
3434
patchTargetSdkVersion();
3535

3636

37+
function getTmpDir() {
38+
const tmpdirEnv = process.env.TMPDIR;
39+
40+
if (tmpdirEnv) {
41+
try {
42+
fs.accessSync(tmpdirEnv, fs.constants.R_OK | fs.constants.W_OK);
43+
return tmpdirEnv;
44+
} catch {
45+
// TMPDIR exists but not accessible
46+
}
47+
}
48+
49+
try {
50+
fs.accessSync("/tmp", fs.constants.R_OK | fs.constants.W_OK);
51+
return "/tmp";
52+
} catch {
53+
console.error("Error: No usable temporary directory found (TMPDIR or /tmp not accessible).");
54+
process.exit(1);
55+
}
56+
}
57+
3758
function patchTargetSdkVersion() {
3859
const prefix = execSync('npm prefix').toString().trim();
3960
const gradleFile = path.join(prefix, 'platforms/android/app/build.gradle');
@@ -49,13 +70,16 @@ function patchTargetSdkVersion() {
4970

5071
if (sdkRegex.test(content)) {
5172
let api = "35";
52-
const froidFlag = path.join(prefix, 'fdroid.bool');
73+
const froidFlag = path.join(getTmpDir(), 'fdroid.bool');
5374

5475
if (fs.existsSync(froidFlag)) {
5576
const fdroid = fs.readFileSync(froidFlag, 'utf-8').trim();
5677
if (fdroid == "true") {
5778
api = "28";
5879
}
80+
} else {
81+
console.error(`${getTmpDir()}/fdroid.bool not found`);
82+
process.exit(1);
5983
}
6084

6185
content = content.replace(sdkRegex, 'targetSdkVersion ' + api);

package-lock.json

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "com.foxdebug.acode",
33
"displayName": "Acode",
4-
"version": "1.11.5",
4+
"version": "1.11.6",
55
"description": "Acode is a code editor for android",
66
"scripts": {
77
"lang": "node ./utils/lang.js",
@@ -36,7 +36,6 @@
3636
"cordova-plugin-websocket": {},
3737
"cordova-plugin-buildinfo": {},
3838
"com.foxdebug.acode.rk.exec.terminal": {},
39-
"com.foxdebug.acode.rk.exec.proot": {},
4039
"cordova-plugin-browser": {},
4140
"cordova-plugin-system": {}
4241
},
@@ -63,7 +62,6 @@
6362
"@types/url-parse": "^1.4.11",
6463
"autoprefixer": "^10.4.21",
6564
"babel-loader": "^10.0.0",
66-
"com.foxdebug.acode.rk.exec.proot": "file:src/plugins/proot",
6765
"com.foxdebug.acode.rk.exec.terminal": "file:src/plugins/terminal",
6866
"cordova-android": "^14.0.1",
6967
"cordova-clipboard": "^1.3.0",

src/components/terminal/terminal.js

Lines changed: 54 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default class TerminalComponent {
3232
rows: options.rows || 24,
3333
cols: options.cols || 80,
3434
port: options.port || 8767,
35+
renderer: options.renderer || "auto", // 'auto' | 'canvas' | 'webgl'
3536
fontSize: terminalSettings.fontSize,
3637
fontFamily: terminalSettings.fontFamily,
3738
fontWeight: terminalSettings.fontWeight,
@@ -80,7 +81,7 @@ export default class TerminalComponent {
8081
system.openInBrowser(uri);
8182
}
8283
});
83-
this.webglAddon = new WebglAddon();
84+
this.webglAddon = null;
8485

8586
// Load addons
8687
this.terminal.loadAddon(this.fitAddon);
@@ -244,36 +245,12 @@ export default class TerminalComponent {
244245
// Ensure scroll position is within valid bounds
245246
const safeScrollPosition = Math.min(targetScrollPosition, maxScroll);
246247

247-
// Only adjust if we have significant content and the position is different
248+
// Only adjust if we have significant content and the position differs
248249
if (
249250
buffer.length > this.terminal.rows &&
250-
Math.abs(buffer.viewportY - safeScrollPosition) > 2
251+
buffer.viewportY !== safeScrollPosition
251252
) {
252-
// Gradually adjust to prevent jarring movements
253-
const steps = 3;
254-
const diff = safeScrollPosition - buffer.viewportY;
255-
const stepSize = Math.ceil(Math.abs(diff) / steps);
256-
257-
let currentStep = 0;
258-
const adjustStep = () => {
259-
if (currentStep >= steps) return;
260-
261-
const currentPos = buffer.viewportY;
262-
const remaining = safeScrollPosition - currentPos;
263-
const adjustment =
264-
Math.sign(remaining) * Math.min(stepSize, Math.abs(remaining));
265-
266-
if (Math.abs(adjustment) >= 1) {
267-
this.terminal.scrollLines(adjustment);
268-
}
269-
270-
currentStep++;
271-
if (currentStep < steps && Math.abs(remaining) > 1) {
272-
setTimeout(adjustStep, 50);
273-
}
274-
};
275-
276-
setTimeout(adjustStep, 100);
253+
this.terminal.scrollToLine(safeScrollPosition);
277254
}
278255
}
279256

@@ -468,7 +445,6 @@ export default class TerminalComponent {
468445
position: relative;
469446
background: ${this.options.theme.background};
470447
overflow: hidden;
471-
padding: 0.25rem;
472448
box-sizing: border-box;
473449
`;
474450

@@ -490,32 +466,49 @@ export default class TerminalComponent {
490466
this.container.style.background = this.options.theme.background;
491467

492468
try {
493-
try {
494-
this.terminal.loadAddon(this.webglAddon);
495-
this.terminal.open(container);
496-
} catch (error) {
497-
console.error("Failed to load WebglAddon:", error);
498-
this.webglAddon.dispose();
499-
}
500-
501-
if (!this.terminal.element) {
502-
// webgl loading failed for some reason, attach with DOM renderer
503-
this.terminal.open(container);
469+
// Open first to ensure a stable renderer is attached
470+
this.terminal.open(container);
471+
472+
// Renderer selection: 'canvas' (default core), 'webgl', or 'auto'
473+
if (
474+
this.options.renderer === "webgl" ||
475+
this.options.renderer === "auto"
476+
) {
477+
try {
478+
const addon = new WebglAddon();
479+
this.terminal.loadAddon(addon);
480+
if (typeof addon.onContextLoss === "function") {
481+
addon.onContextLoss(() => this._handleWebglContextLoss());
482+
}
483+
this.webglAddon = addon;
484+
} catch (error) {
485+
console.error("Failed to enable WebGL renderer:", error);
486+
try {
487+
this.webglAddon?.dispose?.();
488+
} catch {}
489+
this.webglAddon = null; // stay on canvas
490+
}
504491
}
505492
const terminalSettings = getTerminalSettings();
506493
// Load ligatures addon if enabled
507494
if (terminalSettings.fontLigatures) {
508495
this.loadLigaturesAddon();
509496
}
510497

511-
// Wait for terminal to render then fit
512-
setTimeout(() => {
513-
this.fitAddon.fit();
514-
this.terminal.focus();
515-
516-
// Initialize touch selection after terminal is mounted
517-
this.setupTouchSelection();
518-
}, 10);
498+
// First render pass: schedule a fit + focus once the frame is ready
499+
if (typeof requestAnimationFrame === "function") {
500+
requestAnimationFrame(() => {
501+
this.fitAddon.fit();
502+
this.terminal.focus();
503+
this.setupTouchSelection();
504+
});
505+
} else {
506+
setTimeout(() => {
507+
this.fitAddon.fit();
508+
this.terminal.focus();
509+
this.setupTouchSelection();
510+
}, 0);
511+
}
519512
} catch (error) {
520513
console.error("Failed to mount terminal:", error);
521514
}
@@ -726,32 +719,6 @@ export default class TerminalComponent {
726719
* Focus terminal
727720
*/
728721
focus() {
729-
// Ensure cursor is visible before focusing to prevent half-visibility
730-
if (this.terminal.buffer && this.terminal.buffer.active) {
731-
const buffer = this.terminal.buffer.active;
732-
const cursorY = buffer.cursorY;
733-
const cursorViewportPos = buffer.baseY + cursorY;
734-
const viewportTop = buffer.viewportY;
735-
const viewportBottom = viewportTop + this.terminal.rows - 1;
736-
737-
// Check if cursor is fully visible (with margin to prevent half-visibility)
738-
const isCursorFullyVisible =
739-
cursorViewportPos >= viewportTop + 1 &&
740-
cursorViewportPos <= viewportBottom - 2;
741-
742-
// If cursor is not fully visible, scroll to make it properly visible
743-
if (!isCursorFullyVisible && buffer.length > this.terminal.rows) {
744-
const targetScroll = Math.max(
745-
0,
746-
Math.min(
747-
buffer.length - this.terminal.rows,
748-
cursorViewportPos - Math.floor(this.terminal.rows * 0.25),
749-
),
750-
);
751-
this.terminal.scrollToLine(targetScroll);
752-
}
753-
}
754-
755722
this.terminal.focus();
756723
}
757724

@@ -1018,3 +985,16 @@ export default class TerminalComponent {
1018985
onBell() {}
1019986
onProcessExit(exitData) {}
1020987
}
988+
989+
// Internal helpers for WebGL renderer lifecycle
990+
TerminalComponent.prototype._handleWebglContextLoss = function () {
991+
try {
992+
console.warn("WebGL context lost; falling back to canvas renderer");
993+
try {
994+
this.webglAddon?.dispose?.();
995+
} catch {}
996+
this.webglAddon = null;
997+
} catch (e) {
998+
console.error("Error handling WebGL context loss:", e);
999+
}
1000+
};

0 commit comments

Comments
 (0)