Mini Micro code editor

From MiniScript Wiki
Jump to navigation Jump to search

Mini Micro comes with a built-in code editor, accessed with the edit command.

General Usage

The code editor is invoked with the edit command. This replaces the standard Mini Micro display with a graphical (GUI) code editor, as shown below.

Screen shot of the Mini Micro code editor.

At the top of the screen is the toolbar, containing various buttons and menus as follows:

Code editor toolbar, with widgets labeled.
  • Close (keyboard shortcut: Control-W): closes the code editor, returning you to the MiniScript prompt. If Auto-Save is checked, and there is a File path shown, the contents of the editor will also be saved to that file.
  • Save (control-S): saves the contents of the editor to the path shown in File path. If there currently is no path set, or if you hold the Alt or Option key while clicking this button or pressing control-S, then you will be prompted for a path (relative to the current directory) in which to save.
  • Revert: replaces the contents of the editor with a fresh reload of the file shown in File path.
  • Run (control-R or F5): closes the editor and executes the run command to run the edited source code. If Auto-Save is checked, and there is a File path shown, the contents of the editor will also be saved to that file.
  • Undo (control-Z) and Redo (shift-control-Z): undoes and redoes the last editing action.
  • Cut (control-X), Copy (control-C), Paste (control-V): standard text cut/copy/paste operations common to all text editors.
  • Find/Replace (control-F): opens/closes the Find/Replace dialog on the bottom portion of the screen.
  • Navigate: a menu containing a "Jump to line..." command, as well as any functions found in your source file; selecting any function name jumps to the start of that function in the code.
  • Code: a menu containing Comment/Uncomment Line, Insert Color, and a variety of code snippets (for loops, etc.). Code snippets are loaded from /sys/data/codeSnippets.txt, and /usr/data/codeSnippets.txt (if that exists).
  • File path: shows the path of the file currently being edited, if any. This area is blank if you are editing a program in memory that is not yet associated with any disk file.
  • Auto-save checkbox: if checked, then the contents of the editor are automatically saved whenever the editor is closed. If not, then any code changes are in memory only; you may run and test them, but they will not be written to disk unless you manually do a save.
  • Help: opens the web browser on your host machine to the Mini Micro section of this wiki.

Toolbar Buttons

Search & Replace

Customization

As of Mini Micro version 1.2, you can customize the colors used by the code editor by creating a map of color names to colors, and assigning this to env.editorColors. The following example shows how to use this to create a "dark mode" color theme.

// Set up a dark theme for the editor.
m = {}
m.codeBackground = "#333333"
m.noCodeBackground = "#000000"
m.lineNumber = "#666666"
m.caret = "#CCCCCCCC"
m.toolbarTint = "#CCCCFF"  // (keep light for best results)

m.text = {}
m.text.default = "#BBBBBB"
m.text.operator = "#AAAADD"
m.text.string = "#DDAAAA"
m.text.openString = "#FF0000"
m.text.identifier = "#BBBBBB"
m.text.comment = "#FFFFCC"
m.text.number = "#88FF88"
m.text.keyword = "#FF99FF"
m.text.colon = color.fuchsia
m.text.paren = ["#00FFFF", "#FF8800", "#CC44FF", "#00FF00"]
m.text.bracket = m.text.paren

env.editorColors = m

The above example shows all the supported color keys. Note that text.paren and text.bracket are lists of colors, rotated through to indicate deeper levels of nested parentheses or square brackets. These lists may be as long or short as you like.


This article is a stub. You can help the MiniScript Wiki by expanding it.