Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
63 changes: 62 additions & 1 deletion src/components/terminal/terminalManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ declare namespace Acode {
*/
close(id: string): void;

/**
* Terminal Touch Selection More Options Methods
*/
moreOptions: TerminalMoreOptionsMethods;

touchSelection: {
moreOptions: TerminalMoreOptionsMethods;
}

themes: {
/**
* Register a plugin theme
Expand Down Expand Up @@ -102,12 +111,64 @@ declare namespace Acode {
name?: string;
serverMode?: boolean;
port?: number;
pinned?: boolean;
render?: boolean;
}

interface TerminalInstance {
id: string;
name: string;
file: EditorFile;
container: HTMLDivElement;
}
}

interface TerminalMoreOptionsMethods {
/**
* Register an option for the "More" menu in touch selection.
* */
add: (option: TerminalMoreOptionParams | TerminalMoreOptionParams[]) => void;
/**
* Remove an option from the "More" menu in touch selection.
* @returns
*/
remove: (option: TerminalMoreOptionParams | TerminalMoreOptionParams[]) => void;
/**
* List all registered options in the "More" menu in touch selection.
*/
list: () => void;
}

interface TerminalMoreOptionParams {
id?: string;
label?: string | ((context: TerminalMoreOptionsContext) => string);
text?: string;
title?: string;
icon?: string;
enabled?: boolean | ((object: object) => boolean);
action?: (context: TerminalMoreOptionsContext) => void | Promise<void>;
onselect?: (context: TerminalMoreOptionsContext) => void | Promise<void>;
onclick?: (context: TerminalMoreOptionsContext) => void | Promise<void>;
}

interface TerminalMoreOptionsContext {
terminal: TerminalInstance;
// TODO: declaration.
touchSelection: any;
selection: Xterm.Terminal["getSelection"];
/**
* Clear the current selection in the terminal.
* @returns
*/
clearSelection: () => void;
/**
* Copy the current selection in the terminal.
* @returns
*/
copySelection: () => void;
/**
* Paste from the clipboard into the terminal.
* @returns
*/
pasteFromClipboard: () => void;
}
}
36 changes: 25 additions & 11 deletions src/plugins/system/System.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,33 @@ interface System {
openInBrowser(src: string): void;

/**
* Launches an Android application.
* @param app - Package name of the app to launch.
* @param className - Optional class name to launch.
* @param data - Optional data to pass.
* @param success - Callback on success.
* @param error - Error callback.
*/
* Launch an Android application activity.
*
* @param {string} app - Package name of the application (e.g. `com.example.app`).
* @param {string} className - Fully qualified activity class name (e.g. `com.example.app.MainActivity`).
* @param {Object<string, (string|number|boolean)>} [extras] - Optional key-value pairs passed as Intent extras.
* @param {(message: string) => void} [onSuccess] - Callback invoked when the activity launches successfully.
* @param {(error: any) => void} [onFail] - Callback invoked if launching the activity fails.
*
* @example
* System.launchApp(
* "com.example.app",
* "com.example.app.MainActivity",
* {
* user: "example",
* age: 20,
* premium: true
* },
* (msg) => console.log(msg),
* (err) => console.error(err)
* );
*/
launchApp(
app: string,
className: string | null,
data: string | null,
success: SystemSuccessCallback,
error: SystemErrorCallback,
extras: string | null,
onSuccess: SystemSuccessCallback,
onFail: SystemErrorCallback,
): void;

/**
Expand Down Expand Up @@ -520,7 +534,7 @@ interface System {
key: string,
success: SystemSuccessCallback,
error: SystemErrorCallback,
): void;
): void;

/**
* Compares file content with provided text in a background thread.
Expand Down