SQF Highlighter – Extension

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fix description)
(Add CSS classes and Known Issues)
Line 61: Line 61:
| <pre><sqf>
| <pre><sqf>
#define fadeInDuration 3
#define fadeInDuration 3
#define end_duration 10


waitUntil { not alive player };
waitUntil { not alive player };
Line 79: Line 78:


// after 10s, end the mission
// after 10s, end the mission
sleep end_duration;
sleep 10;
[] call BIS_fnc_endMission;
[] call BIS_fnc_endMission;
</sqf></pre>
</sqf></pre>
| <sqf>
| <sqf>
#define fadeInDuration 3
#define fadeInDuration 3
#define end_duration 10


waitUntil { not alive player };
waitUntil { not alive player };
Line 102: Line 100:


// after 10s, end the mission
// after 10s, end the mission
sleep end_duration;
sleep 10;
[] call BIS_fnc_endMission;
[] call BIS_fnc_endMission;
</sqf>
</sqf>
|}
== CSS Classes ==
All elements are {{hl|<nowiki><span></nowiki>}}.
{| class="wikitable"
! Element
! CSS class
! Overview
|-
| parent block
| sqfhighlighter-'''block'''
| <sqf>&nbsp;</sqf>
|-
| error message
| sqfhighlighter-'''error'''
| <sqf></sqf>
|-
| comment
| sqfhighlighter-'''comment'''
| <sqf>// comment
/*
this is
a multiline
comment
*/</sqf>
|-
| string
| sqfhighlighter-'''string'''
| <sqf>"string"</sqf>
|-
| number
| sqfhighlighter-'''number'''
| <sqf>42
-6.9
10e10</sqf>
|-
| operator
| sqfhighlighter-'''operator'''
| <sqf>a + b</sqf>
|-
| keyword ({{hl|if}}, {{hl|then}}, {{hl|waitUntil}}, etc)
| sqfhighlighter-'''keyword'''
| <sqf>if</sqf>
|-
| command
| sqfhighlighter-'''command'''
| <sqf>setDir</sqf>
|-
| function
| sqfhighlighter-'''function'''
| <sqf>BIS_fnc_spawnGroup</sqf>
|-
| external function
| sqfhighlighter-'''function-ext'''
| <sqf>// not just considering BIS_ or BIN_
BIS_fnc_unknownFunction
TAG_fnc_spawnGroup</sqf>
|-
| local variable
| sqfhighlighter-'''localvar'''
| <sqf>_localVar</sqf>
|-
| global variable
| sqfhighlighter-'''globalvar'''
| <sqf>// anything will go but UNDERSCORED_ALL_CAPS
GlobalVar = 1;</sqf>
|-
| constant ({{hl|#define}}d value)
| sqfhighlighter-'''const'''
| <sqf>// anything #defined or anything UNDERSCORED_ALL_CAPS
#define testVar
testVar;
MY_CONSTANT;</sqf>
|-
| macro
| sqfhighlighter-'''macro'''
| <sqf>#define</sqf>
|-
| array start ({{hl|[}})
| sqfhighlighter-'''arraystart'''
| <sqf>[...</sqf>
|-
| array end ({{hl|]}})
| sqfhighlighter-'''arrayend'''
| <sqf>...]</sqf>
|-
| code start ({{hl|{<nowiki/>}})
| sqfhighlighter-'''codestart'''
| <sqf>{...</sqf>
|-
| code end ({{hl|}<nowiki/>}})
| sqfhighlighter-'''codeend'''
| <sqf>...}</sqf>
|-
| parenthese start ({{hl|{<nowiki/>}})
| sqfhighlighter-'''parenthesestart'''
| <sqf>(...</sqf>
|-
| parenthese end ({{hl|}<nowiki/>}})
| sqfhighlighter-'''parentheseend'''
| <sqf>...)</sqf>
|}
|}


Line 111: Line 215:


* comment blocks still highlight words as global variables for now
* comment blocks still highlight words as global variables for now
* single-quote strings have issues with other formatting between quotes
* report other issues on [https://discord.gg/arma Discord]
* report other issues on [https://discord.gg/arma Discord]

Revision as of 02:58, 15 March 2022

SQF Highlighter
Description Highlights and links SQF commands and functions
Author Lou Montana
Version 0.5b
(version is not incremented for now
due to continuous updates as of 2022-03-14)
Release Date 2022-03-12: First upload
Project Start 2022-03-08: Project start

This extension highlights and automatically links SQF commands and functions.


Installation

  • Unzip the directory to wiki/extensions/SQFHighlighter
  • Add wfLoadExtension('SQFHighlighter'); to LocalSettings.php
  • There are no settings - the extension creates full path links unless the host is one of the following (then relative links are created):
    • community.bistudio.com
    • community.bohemia.net


Usage

Using <sqf> tags will auto-generate syntax highlighting and links to the pages.

Examples
Code Result
<sqf/>
-no SQF code provided-
<sqf></sqf>
-no SQF code provided-
<sqf> </sqf>
-no SQF code provided-
<sqf>hint "It Works!";</sqf>
hint "It Works!";
<sqf>
// your code here
hint "good!";
</sqf>
// your code here hint "good!";
<sqf>
#define fadeInDuration 3

waitUntil { not alive player };
hint DEATH_MESSAGE;
cutText ["", "Black", playerRespawnTime];

private _deathTime = time;
Deaths = Deaths + 1;

/*
	wait for resurrection
*/
waitUntil { alive player && { preloadCamera getPosATL player } };

sleep 3;
cutText ["Welcome!", "Black in", fadeInDuration];

// after 10s, end the mission
sleep 10;
[] call BIS_fnc_endMission;
</sqf>
#define fadeInDuration 3 waitUntil { not alive player }; hint DEATH_MESSAGE; cutText ["", "Black", playerRespawnTime]; private _deathTime = time; Deaths = Deaths + 1; /* wait for resurrection */ waitUntil { alive player && { preloadCamera getPosATL player } }; sleep 3; cutText ["Welcome!", "Black in", fadeInDuration]; // after 10s, end the mission sleep 10; [] call BIS_fnc_endMission;


CSS Classes

All elements are <span>.

Element CSS class Overview
parent block sqfhighlighter-block
&nbsp;
error message sqfhighlighter-error
-no SQF code provided-
comment sqfhighlighter-comment
// comment /* this is a multiline comment */
string sqfhighlighter-string
"string"
number sqfhighlighter-number
42 -6.9 10e10
operator sqfhighlighter-operator
a + b
keyword (if, then, waitUntil, etc) sqfhighlighter-keyword
command sqfhighlighter-command
function sqfhighlighter-function
external function sqfhighlighter-function-ext
// not just considering BIS_ or BIN_ BIS_fnc_unknownFunction TAG_fnc_spawnGroup
local variable sqfhighlighter-localvar
_localVar
global variable sqfhighlighter-globalvar
// anything will go but UNDERSCORED_ALL_CAPS GlobalVar = 1;
constant (#defined value) sqfhighlighter-const
// anything #defined or anything UNDERSCORED_ALL_CAPS #define testVar testVar; MY_CONSTANT;
macro sqfhighlighter-macro
#define
array start ([) sqfhighlighter-arraystart
[...
array end (]) sqfhighlighter-arrayend
...]
code start ({) sqfhighlighter-codestart
{...
code end (}) sqfhighlighter-codeend
...}
parenthese start ({) sqfhighlighter-parenthesestart
(...
parenthese end (}) sqfhighlighter-parentheseend
...)


Known Issues

  • comment blocks still highlight words as global variables for now
  • single-quote strings have issues with other formatting between quotes
  • report other issues on Discord