Skip to main content

Text Editor

The Text Editor edits device-side script projects and ordinary text files. When a development project is open, it can also connect to a test device, run, stop, debug, and generate encrypted artifacts or control-center packages.

Open the Text Editor​

Common entry points:

  • Double-click a text file in the File Manager, or right-click it and choose to edit it.
  • Right-click a device in the device list, browse device files, then open a text file from the device.
  • In Development Directory, right-click a project folder, choose Open Project, then click files in the project tree.
  • Right-click a device in the device list and create a temporary Lua file for quick testing.

Common Editing Actions​

  • Click Save to write changes back to the current file.
  • Click Reload to read the file again from its original location.
  • Right-click a tab to reveal the file in File Manager, rename it, or copy its path.
  • Use the bottom status bar to inspect line/column, indentation, encoding, line endings, and file type. If you are not sure, keep the defaults.
  • Use the minimap button to show or hide the code minimap.

If a file changed outside the editor after it was opened, saving shows an overwrite confirmation. Reloading or closing an unsaved tab also warns before discarding changes.

Set the Development Test Device​

Before running or debugging online, choose a development test device. The device must be imported, online, and reachable through XXTouch. Offline devices cannot browse files, run, or debug.

Common entry points:

  1. Right-click a device in the device list and choose Set as Development Test Device.
  2. Click the device button at the upper-left of the Text Editor, open Select Test Device, and choose the target device.

To switch devices, choose another device. When you no longer need the connection, click Disconnect Test from the same place.

Run Online​

Open a development project or a file in it, click Run, and view the output in the log area below.

Runnable content is usually a script file inside a development project, or a .lua file that can run directly. Plain text files, unrecognized projects, or projects without an entry show Current file cannot run.

Click Stop to terminate the script.

Debug Online​

Click Debug to start the project in debug mode. This is useful for inspecting variables, stack frames, and branches while the script is running.

Common actions:

  • Set or remove breakpoints in the line-number area.
  • Use Continue, Step Over, Step Into, and Step Out to control execution.
  • Use the call stack to see which function level the script is paused in. Selecting a frame jumps the editor to that location.
  • Inspect variables visible at the current paused location in the variables panel. Right-click to copy or edit a value.
  • Enter a single Lua expression in the debug console. It can be evaluated when the script is paused.
  • Click Disconnect Debug to end the current debug connection.

Project Configuration​

After a project is open, the Text Editor title bar provides Project Configuration. Use it to edit the project name, project ID, version, description, ignored paths, shared libraries, and Sample Workbench configuration.

After changing project configuration, click Save. If you are only editing script content, you do not need to open it each time; use it when project metadata, release information, resource paths, or picker settings need to change.

Project Artifacts​

The Text Editor also provides project artifact actions:

  • Encrypt: creates an encrypted artifact for distribution or deployment. The app shows the saved location after it completes, and you can also reveal or download the result from the project tree or File Manager.
  • Control Center Package: packages the project into a script package that can be installed and managed from the control center. This action is only available for supported project types.

Before generating artifacts, save all open project files and run the project once on the development test device.

AI Autocomplete​

AI Autocomplete is an optional Text Editor capability. When enabled, the editor can show AI-generated ghost completions while you type.

Configure it from global settings first:

  1. Open System Settings → AI Providers.
  2. Click Add Profile, then fill in the profile name, AI service, model, and API Key. Keyless compatible services can leave the API Key empty.
  3. Click Fetch Models if you want to read available model names, or type the model name manually.
  4. Open System Settings → Text Editor.
  5. Choose the profile from AI Profile.
  6. Enable AI Autocomplete, then click Save Settings.

If the service requires a specific client identifier or additional request headers, fill in User-Agent and Custom headers below the API Key when adding or editing an AI profile. Enter one Name: Value per line, for example X-Custom-Header: value. These options also apply when fetching models; leave them blank if no extra configuration is needed.

Session ID header name defaults to session-id. Change it to the name required by the service, such as x-opencode-session for OpenCode Go. Do not enter an ID value; leave the field empty to disable it.

After it is enabled, supported text files show gray inline suggestions while you type. Common actions:

  • Press Tab to accept the current suggestion.
  • Press Esc to dismiss the current suggestion.
  • Press Alt + Backslash to trigger autocomplete manually.
  • If multiple candidates are available, press Alt + [ / Alt + ] to switch between them.

You can tune these options in System Settings → Text Editor:

  • Completion Preferences: describe the code style or project habits you want the AI to follow.
  • Enabled File Extensions: choose which file types can trigger AI autocomplete, or add custom extensions.
  • Completion Context: besides the current file, include XXTouch Docs or Project Files so suggestions better match the script project.

If autocomplete does not appear, check that an AI provider profile exists, AI Autocomplete is enabled, the current file extension is allowed, and the model/API Key is usable. After opening a project, if project files changed significantly, click Refresh AI completion context so autocomplete rereads the current project content.