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.

After a device is selected, the Text Editor shows the current test device and actions such as Browse Device Files, Open Picker Workbench, Run, Stop, and Debug.

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

Run Online

After opening a development project or a file inside it, click Run. The editor saves required changes, sends the current project to the test device, and starts it. Logs appear in the lower panel while the script runs.

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.

Common states:

  • Running: the script has started or is waiting for the device to execute it.
  • Stopping: a stop request is being sent to the device.
  • No logs: the log connection is open, but the device has not produced output yet.
  • Please choose a development device: no test device is selected.
  • Current file cannot run: the current tab is not part of a runnable project or no entry was found.
  • Save failed, stopped running: the file was not saved successfully, so the run does not continue.

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.

The debug panel shows states such as Idle, Running, Paused, and Debug Ended. Only supported projects and devices can start a debug session. If the app reports that the project cannot be debugged, run it normally first and confirm that the project entry is correct.

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 Picker 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.

If an artifact button is unavailable, the current tab may not belong to a project, the project type may not support that action, or the project may not be in a saved state yet.

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.

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.