Skip to content

Commit 71a33a2

Browse files
authored
Merge branch 'main' into ai-agent
2 parents 7715ae6 + 8e3c109 commit 71a33a2

File tree

8 files changed

+129
-4
lines changed

8 files changed

+129
-4
lines changed

.github/workflows/close-inactive-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
2525
days-before-pr-stale: -1
2626
days-before-pr-close: -1
27-
any-of-issue-labels: "bug, todo, new plugin idea"
27+
exempt-issue-labels: "new plugin idea, todo"
2828
operations-per-run: 100
2929
repo-token: ${{ secrets.GITHUB_TOKEN }}
3030

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"cordova-plugin-advanced-http": {
3737
"ANDROIDBLACKLISTSECURESOCKETPROTOCOLS": "SSLv3,TLSv1"
3838
},
39-
"cordova-sqlite-storage": {}
39+
"cordova-sqlite-storage": {},
40+
"com.foxdebug.acode.exec": {}
4041
},
4142
"platforms": [
4243
"android"
@@ -62,6 +63,7 @@
6263
"@types/url-parse": "^1.4.11",
6364
"autoprefixer": "^10.4.19",
6465
"babel-loader": "^9.1.3",
66+
"com.foxdebug.acode.exec": "file:src/plugins/Executor",
6567
"cordova-android": "^13.0.0",
6668
"cordova-clipboard": "^1.3.0",
6769
"cordova-plugin-advanced-http": "^3.3.1",

src/ace/touchHandler.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,17 @@ export default function addTouchListeners(editor, minimal, onclick) {
684684
const range = editor.getSelectionRange();
685685
const { pageX, pageY } = renderer.textToScreenCoordinates(range.start);
686686
const { lineHeight } = renderer;
687-
const [x, y] = relativePosition(pageX - teardropSize, pageY + lineHeight);
688687

689-
$start.style.left = `${x}px`;
688+
// Calculate desired position but ensure it stays within viewport
689+
let targetX = pageX - teardropSize;
690+
const [relativeX, y] = relativePosition(targetX, pageY + lineHeight);
691+
692+
// Ensure the teardrop doesn't go outside the left edge
693+
// Leave some padding (e.g., 4px) so it's not flush against the edge
694+
const minX = 4;
695+
const constrainedX = Math.max(relativeX, minX);
696+
697+
$start.style.left = `${constrainedX}px`;
690698
$start.style.top = `${y}px`;
691699

692700
if (!$start.isConnected) $el.append($start);

src/plugins/Executor/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function exec(cmd,success,failure) {
2+
const ACTION = 'exec';
3+
cordova.exec(success, failure, 'Executor', ACTION, [cmd]);
4+
}
5+
6+
export default {
7+
exec,
8+
};

src/plugins/Executor/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "com.foxdebug.acode.exec",
3+
"version": "1.0.0",
4+
"description": "Execute linux commands",
5+
"cordova": {
6+
"id": "com.foxdebug.acode.exec",
7+
"platforms": [
8+
"android"
9+
]
10+
},
11+
"keywords": [
12+
"ecosystem:cordova",
13+
"cordova-android"
14+
],
15+
"author": "",
16+
"license": "ISC"
17+
}

src/plugins/Executor/plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<plugin id="com.foxdebug.acode.exec" version="1.0.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android"><name>Executor</name><js-module name="Executor" src="index.js"><clobbers target="cordova.plugins.Executor" /></js-module><platform name="android"><config-file parent="/*" target="res/xml/config.xml"><feature name="Executor"><param name="android-package" value="com.foxdebug.acode.exec.Executor" /></feature></config-file><config-file parent="/*" target="AndroidManifest.xml"></config-file><source-file src="src/android/Executor.java" target-dir="src/com/foxdebug/acode/exec/Executor" /></platform></plugin>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.foxdebug.acode.exec;
2+
3+
import org.apache.cordova.CordovaPlugin;
4+
import org.apache.cordova.CallbackContext;
5+
6+
import org.json.JSONArray;
7+
import org.json.JSONException;
8+
9+
import java.io.BufferedReader;
10+
import java.io.InputStreamReader;
11+
12+
public class Executor extends CordovaPlugin {
13+
14+
@Override
15+
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
16+
cordova.getThreadPool().execute(new Runnable() {
17+
@Override
18+
public void run() {
19+
if ("exec".equals(action)) {
20+
try {
21+
String cmd = args.getString(0);
22+
exec(cmd, callbackContext);
23+
} catch (JSONException e) {
24+
callbackContext.error("Invalid arguments");
25+
}
26+
} else {
27+
callbackContext.error("Unknown action");
28+
}
29+
}
30+
});
31+
32+
return true;
33+
}
34+
35+
private void exec(String cmd, CallbackContext callbackContext) {
36+
try {
37+
if (cmd != null && !cmd.isEmpty()) {
38+
Process process = Runtime.getRuntime().exec(cmd);
39+
40+
// Capture stdout
41+
BufferedReader stdOutReader = new BufferedReader(
42+
new InputStreamReader(process.getInputStream()));
43+
StringBuilder stdOut = new StringBuilder();
44+
String line;
45+
while ((line = stdOutReader.readLine()) != null) {
46+
stdOut.append(line).append("\n");
47+
}
48+
49+
// Capture stderr
50+
BufferedReader stdErrReader = new BufferedReader(
51+
new InputStreamReader(process.getErrorStream()));
52+
StringBuilder stdErr = new StringBuilder();
53+
while ((line = stdErrReader.readLine()) != null) {
54+
stdErr.append(line).append("\n");
55+
}
56+
57+
int exitCode = process.waitFor();
58+
if (exitCode == 0) {
59+
callbackContext.success(stdOut.toString().trim());
60+
} else {
61+
// Return stderr if command fails
62+
String errorOutput = stdErr.toString().trim();
63+
if (errorOutput.isEmpty()) {
64+
errorOutput = "Command exited with code: " + exitCode;
65+
}
66+
callbackContext.error(errorOutput);
67+
}
68+
} else {
69+
callbackContext.error("Expected one non-empty string argument.");
70+
}
71+
} catch (Exception e) {
72+
e.printStackTrace();
73+
callbackContext.error("Exception: " + e.getMessage());
74+
}
75+
}
76+
77+
}

0 commit comments

Comments
 (0)