DIV2 on VS Code
Visual Studio Code extension for programming with DIV Games Studio 2.
(Versión en español más abajo.)
Version 0.1.0: language, built-in help, symbols and formatting. Compiling and the graphic
formats (FPG, MAP, PAL) will come in later versions.
Features
- DIV2 language for
.prg files.
- Syntax highlighting: keywords, types, built-in functions and constants, predefined variables
(globals and process locals), compiler options, decimal and
0x hexadecimal numbers, strings
(with "" escapes) and nestable /* */ comments.
- Folding by blocks:
process/function, begin, loop, if/else, while, for,
from, switch/case, clone, repeat/until, struct, declaration sections
(const/global/local/private), multi-line comments and // region / // endregion.
- Built-in DIV2 help, in English (a translation of the corrected original help) or in the
original Spanish: it follows the VS Code display language, or the
div2.helpLanguage setting
(auto, es, en).
- Completion of functions (with parameter placeholders), constants, predefined variables and
keywords; after
mouse., scroll[0].… only the fields of that structure.
- Hover with signature, value, description, return value and a link to the help page.
- Parameter hints while typing a call.
- Help viewer:
Ctrl+F1 on a word (or the editor context menu) opens its help page, with links
between pages; without a known word, search the help.
- Your program's symbols: outline and breadcrumbs (processes, functions, constants, variables,
structures with their fields, privates), go to definition (
F12), find references
(Shift+F12) and highlighting of occurrences. Names ignore case and accented vowels, as the
DIV2 compiler does.
Completion of your own processes, functions, constants, variables and structure fields, by
scope (a process sees its privates and the globals).
Hover with the declaration and its comment (// at the end of the line, or the // lines
just above), and parameter hints for your own processes and functions.
Functions from DLLs loaded with import, described in a comment the compiler ignores:
import "tad.dll";
//@function tad_value(int index, string name) : int Returns the value
or, to describe a DLL once for every program, in a TAD.div2dll.json file next to the DLL or
to the program:
{ "functions": [ { "name": "tad_value", "params": ["int index", "string name"],
"returns": "int", "description": "Returns the value" } ] }
- Formatting of the document or the selection (
Shift+Alt+F): indentation by blocks and no
trailing spaces; the rest of each line is kept as written (hand-aligned value lists too).
Optionally, keywords in lower or upper case (div2.format.keywordCase).
- Line comments with
Ctrl+/, auto-closing brackets and quotes, block indentation.
- Snippets:
program, process, function, if, ifelse, while, repeat, loop, for,
from, switch, struct.
- DOS file defaults:
.prg files are read and written as CP850 with CRLF line endings, as
the DIV2 compiler expects. If VS Code opens one with another encoding (for example because it
remembered a previous one), the extension reopens it as CP850 (div2.enforceEncoding).
Requires VS Code 1.100 or later.
Planned
Compiling with an external compiler
(local or online, configurable) with errors shown in the editor, and visual editors for FPG,
MAP and PAL files.
If you have another DIV extension installed
This extension registers its own language id (div2). If another extension also claims .prg
files, pick the language from the status bar or with files.associations:
"files.associations": { "*.prg": "div2" }
License
GNU GPL v3 or later (LICENSE file). The built-in help is generated from the DIV Games Studio 2
help, published under the GPL v3; see NOTICE.md.
DIV2 on VS Code (español)
Extensión de Visual Studio Code para programar con DIV Games Studio 2.
Versión 0.1.0: lenguaje, ayuda integrada, símbolos y formato. La compilación y los formatos
gráficos (FPG, MAP, PAL) llegarán en versiones posteriores.
Qué hace
- Lenguaje DIV2 para los ficheros
.prg.
- Coloreado de sintaxis: palabras clave, tipos, funciones y constantes del lenguaje, variables
predefinidas (globales y locales de los procesos), opciones de compilación, números decimales y
hexadecimales (
0x), textos (con "" como escape) y comentarios /* */ anidables.
- Plegado por bloques:
process/function, begin, loop, if/else, while, for,
from, switch/case, clone, repeat/until, struct, secciones de declaraciones
(const/global/local/private), comentarios de varias líneas y // region / // endregion.
- Ayuda de DIV2 integrada, en español (la original) o en inglés (traducción de la ayuda
corregida): sigue el idioma de VS Code o el ajuste
div2.helpLanguage (auto, es, en).
- Autocompletado de funciones (con los parámetros como marcadores), constantes, variables
predefinidas y palabras reservadas; tras
mouse., scroll[0].… solo los campos de esa
estructura.
- Información al pasar el ratón: firma, valor, descripción, qué retorna y enlace a su página.
- Ayuda de parámetros al escribir una llamada.
- Visor de la ayuda:
Ctrl+F1 sobre una palabra (o el menú contextual) abre su página, con
enlaces entre páginas; sin palabra conocida, permite buscar en la ayuda.
- Símbolos del programa: esquema y migas de pan (procesos, funciones, constantes, variables,
estructuras con sus campos, privados), ir a la definición (
F12), buscar referencias
(Mayús+F12) y resaltado de apariciones. Los nombres no distinguen mayúsculas ni vocales
acentuadas, como el compilador de DIV2.
Autocompletado de los procesos, funciones, constantes, variables y campos propios, según el
ámbito (un proceso ve sus privados y lo global).
Hover con la declaración y su comentario (// al final de la línea, o las líneas // justo
encima), y ayuda de parámetros de los procesos y funciones propios.
Funciones de las DLL cargadas con import, descritas en un comentario que el compilador
ignora:
import "tad.dll";
//@function tad_valor(int indice, string nombre) : int Devuelve el valor
o, para describir una DLL una sola vez para todos los programas, en un fichero
TAD.div2dll.json junto a la DLL o al programa:
{ "functions": [ { "name": "tad_valor", "params": ["int indice", "string nombre"],
"returns": "int", "description": "Devuelve el valor" } ] }
- Formato del documento o de la selección (
Mayús+Alt+F): sangrado por bloques y sin
espacios al final; el resto de cada línea queda como se escribió (también las listas de valores
alineadas a mano). Opcionalmente, palabras reservadas en minúsculas o mayúsculas
(div2.format.keywordCase).
- Comentarios con
Ctrl+/, cierre automático de paréntesis y comillas, sangrado por bloques.
- Fragmentos:
program, process, function, if, ifelse, while, repeat, loop, for,
from, switch, struct.
- Ficheros DOS por defecto: los
.prg se abren y guardan en CP850 con saltos de línea CRLF,
como los espera el compilador de DIV2. Si VS Code abre uno con otra codificación (por ejemplo
porque recordaba una anterior), la extensión lo reabre en CP850 (div2.enforceEncoding).
Necesita VS Code 1.100 o posterior.
Previsto
Compilación con un compilador externo (local u online, configurable) con los errores marcados en el editor, y
editores visuales para FPG, MAP y PAL.
Si tienes otra extensión de DIV instalada
Esta extensión registra su propio lenguaje (div2). Si otra extensión también reclama los .prg,
elige el lenguaje con el selector de la barra de estado o con files.associations:
"files.associations": { "*.prg": "div2" }
Licencia
GNU GPL v3 o posterior (fichero LICENSE). La ayuda integrada se genera a partir de la ayuda de
DIV Games Studio 2, publicada bajo la GPL v3; ver NOTICE.md.
| |