Skip to content

Commit

Permalink
added missing plugin commands + code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chromoxdor committed Aug 15, 2022
1 parent 68b8a68 commit 4201595
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 68 deletions.
4 changes: 0 additions & 4 deletions static/anyword-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"use strict";

var WORD = /[\w$]+/, RANGE = 500;
var EXTRAWORDS = commonAtoms.concat(commonKeywords, commonCommands, commonString2, commonPlugins, commonTag, commonNumber, commonMath, commonWarning, AnythingElse);

CodeMirror.registerHelper("hint", "anyword", function (editor, options) {
var word = options && options.word || WORD;
var range = options && options.range || RANGE;
Expand Down Expand Up @@ -46,8 +44,6 @@
});
});



// This is from the file show-hint.js-------------------------------------------------------------------------
(function (showHint) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
Expand Down
2 changes: 1 addition & 1 deletion static/anyword-hint.min.js

Large diffs are not rendered by default.

128 changes: 66 additions & 62 deletions static/espeasy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,87 @@
var commonAtoms = ["And", "Or"];
var commonKeywords = ["If", "Else", "Elseif", "Endif"];
var commonCommands = ["AccessInfo", "Background", "Build", "ClearAccessBlock", "ClearRTCam", "Config", "ControllerDisable",
"ControllerEnable", "DateTime", "Debug", "DeepSleep", "DNS", "DST", "EraseSDKwifi", "ExecuteRules", "Gateway", "I2Cscanner",
"ControllerEnable", "DateTime", "Debug", "DeepSleep", "DNS", "DST", "EraseSDKWiFi", "ExecuteRules", "Gateway", "I2Cscanner",
"IP", "Let", "Load", "LogEntry", "LogPortStatus", "LoopTimerSet", "LoopTimerSet_ms", "MemInfo", "MemInfoDetail", "Name", "Password", "Publish",
"Reboot", "Reset", "ResetFlashWriteCounter", "Save", "SendTo", "SendToHTTP", "SendToUDP", "Settings", "Subnet", "Subscribe", "TaskClear", "TaskClearAll",
"TaskDisable", "TaskEnable", "TaskRun", "TaskValueSet", "TaskValueSetAndRun", "TimerPause", "TimerResume", "TimerSet", "TimerSet_ms", "TimeZone",
"UdpPort", "UdpTest", "Unit", "UseNTP", "WdConfig", "WdRead", "WifiAPkey", "WifiAllowAP", "WifiAPMode", "WifiConnect", "WifiDisconnect", "WifiKey",
"WifiKey", "WifiScan", "WifiSSID", "WifiSSID2", "WifiSTAMode",
"Event", "AsyncEvent", "/control?cmd",
"UdpPort", "UdpTest", "Unit", "UseNTP", "WdConfig", "WdRead", "WiFiAPkey", "WiFiAllowAP", "WiFiAPMode", "WiFiConnect", "WiFiDisconnect", "WiFiKey",
"WiFiKey2", "WiFiScan", "WiFiSSID", "WiFiSSID2", "WiFiSTAMode", "WiFi#Disconnected",
"Event", "AsyncEvent",
"GPIO", "GPIOToggle", "LongPulse", "LongPulse_mS", "Monitor", "Pulse", "PWM", "Servo", "Status", "Tone", "RTTTL", "UnMonitor",];
var commonString2 = ["Clock#Time", "Login#Failed", "MQTT#Connected", "MQTT#Disconnected", "MQTTimport#Connected", "MQTTimport#Disconnected", "Rules#Timer", "System#Boot",
"System#BootMode", "System#Sleep", "System#Wake", "TaskExit#", "TaskInit#", "Time#Initialized", "Time#Set", "WiFi#APmodeDisabled", "WiFi#APmodeEnabled",
"WiFi#ChangedAccesspoint", "WiFi#ChangedWiFichannel", "WiFi#Connected"];
var commonPlugins = [
//P003
"ResetPulseCounter", "SetPulseCounterTotal", "LogPulseStatistic",
"ResetPulseCounter", "SetPulseCounterTotal", "LogPulseStatistic",
//P007
"analogout",
//P009
"MCPGPIO", "MCPGPIOToggle", "MCPLongPulse","MCPLongPulse_ms", "MCPPulse", "Status,MCP", "Monitor,MCP", "UnMonitor,MCP", "MonitorRange,MCP", "UnMonitorRange,MCP", "MCPGPIORange", "MCPGPIOPattern", "MCPMode", "MCPModeRange",
"MCPGPIO", "MCPGPIOToggle", "MCPLongPulse", "MCPLongPulse_ms", "MCPPulse", "Status,MCP", "Monitor,MCP", "MonitorRange,MCP", "UnMonitorRange,MCP", "UnMonitor,MCP", "MCPGPIORange", "MCPGPIOPattern", "MCPMode", "MCPModeRange",
//P012
"LCDCmd", "LCD",
"LCDCmd", "LCD",
//P019
"PCFGPIO", "PCFGPIOToggle", "PCFLongPulse", "PCFLongPulse_ms", "PCFPulse", "Status,PCF", "Monitor,PCF", "UnMonitor,PCF",
"MonitorRange,PCF", "UnMonitorRange,PCF", "PCFGPIORange", "PCFGPIOpattern", "PCFMode", "PCFmodeRange",
"PCFGPIO", "PCFGPIOToggle", "PCFLongPulse", "PCFLongPulse_ms", "PCFPulse", "Status,PCF", "Monitor,PCF",
"MonitorRange,PCF", "UnMonitorRange,PCF", "UnMonitor,PCF", "PCFGPIORange", "PCFGPIOpattern", "PCFMode", "PCFmodeRange",
//P036
"OledFramedCmd", "OledFramedCmd,Display", "OledFramedCmd,Frame", "OledFramedCmd,linecount", "OledFramedCmd,leftalign",
//P038
"NeoPixel", "NeoPixelAll", "NeoPixelLine", "NeoPixelHSV", "NeoPixelAllHSV", "NeoPixelLineHSV",
//P048
"MotorShieldCmd,DCMotor", "MotorShieldCmd,Stepper",
//P052
"Sensair_SetRelay",
"Sensair_SetRelay",
//P053
"PMSX003,Wake", "PMSX003,Sleep", "PMSX003,Reset",
"PMSX003,Wake", "PMSX003,Sleep", "PMSX003,Reset",
//P065
"Play", "Vol", "Eq", "Mode", "Repeat",
//
//P073
"7dn", "7dst", "7dsd", "7dtext", "7dtt", "7dt", "7dtfont", "7dtbin", "7don", "7doff", "7output",
//P076
"HLWCalibrate", "HLWReset",
//P079
"WemosMotorShieldCMD", "LolinMotorShieldCMD",
//P073
"7dn", "7dt", "7dtt", "7dst", "7dsd", "7dtext",
//
"HeatPumpir",
"WemosMotorShieldCMD", "LolinMotorShieldCMD",
//P082
"GPS,Sleep", "GPS,Wake", "GPS#GotFix", "GPS#LostFix", "GPS#Travelled",
//P086
"homieValueSet",
//P088
"HeatPumpir",
//P093
"MitsubishiHP,temperature", "MitsubishiHP,power", "MitsubishiHP,mode","MitsubishiHP,fan", "MitsubishiHP,vane", "MitsubishiHP,widevane",
//
"Culreader_write",
//
"TFTcmd", "TFT&", "Touch,Rot",
//
"WakeOnLan",
//
"Max1704xclearalert"
"MitsubishiHP,temperature", "MitsubishiHP,power", "MitsubishiHP,mode", "MitsubishiHP,fan", "MitsubishiHP,vane", "MitsubishiHP,widevane",
//P094
"Culreader_Write",
//P095
"TFTCMD", "TFT",
//P099
"Touch,Rot", "Touch,Flip", "Touch,Enable", "Touch,Disable",
//P101
"WakeOnLan",
//P104
"DotMatrix,clear", "DotMatrix,update", "DotMatrix,size", "DotMatrix,txt", "DotMatrix,settxt", "DotMatrix,content", "DotMatrix,alignment", "DotMatrix,anim.in", "DotMatrix,anim.out", "DotMatrix,speed", "DotMatrix,pause", "DotMatrix,font", "DotMatrix,layout", "DotMatrix,inverted", "DotMatrix,specialeffect", "DotMatrix,offset", "DotMatrix,brightness", "DotMatrix,repeat", "DotMatrix,bar", "DotMatrix,bar",
//P115
"Max1704xclearalert",
//P116
//P117
"scdgetabc", "scdgetalt", "scdgettmp", "scdsetcalibration", "scdsetfrc", "scdgetinterval",
//P124
"multirelay,on", "multirelay,off", "multirelay,set", "multirelay,get", "multirelay,loop",
//P126
"ShiftOut,Set", "ShiftOut,SetNoUpdate", "ShiftOut,Update", "ShiftOut,SetAll", "ShiftOut,SetAllNoUpdate", "ShiftOut,SetAllLow", "ShiftOut,SetChipCount", "ShiftOut,SetHexBin",
//P127
"cdmrst"
];
var commonTag = ["On", "Do", "Endon"];
var commonNumber = ["toBin", "toHex", "Constrain", "XOR", "AND:", "OR:", "Ord", "bitRead", "bitSet", "bitClear", "bitWrite", "urlencode"];
var commonMath = ["Log", "Ln", "Abs", "Exp", "Sqrt", "Sq", "Round", "Sin", "Cos", "Tan", "aSin", "aCos", "aTan", "Sind_d", "Cos_d", "Tan_d", "aSin_d", "aCos_d", "sTan_d"];
var commonWarning = ["delay", "Delay"];
var AnythingElse = [];

var EXTRAWORDS = commonAtoms.concat(commonPlugins, commonKeywords, commonCommands, commonString2, commonTag, commonNumber, commonMath, commonWarning, AnythingElse);

function initCM() {
CodeMirror.commands.autocomplete = function (cm) { cm.showHint({ hint: CodeMirror.hint.anyword}); }
CodeMirror.commands.autocomplete = function (cm) { cm.showHint({ hint: CodeMirror.hint.anyword }); }
var rEdit = CodeMirror.fromTextArea(document.getElementById('rules'), { lineNumbers: true, extraKeys: { 'Alt-Space': 'autocomplete' } });
rEdit.on('change', function () { rEdit.save() });
}
Expand All @@ -83,7 +101,6 @@ function initCM() {
"use strict";

CodeMirror.defineMode('espeasy', function () {

var words = {};
function define(style, dict) {
for (var i = 0; i < dict.length; i++) {
Expand Down Expand Up @@ -114,31 +131,48 @@ function initCM() {
var lCcommonMath = commonMath.map(name => name.toLowerCase());
commonMath = commonMath.concat(lCcommonMath);

CodeMirror.registerHelper("hintWords", "shell", commonAtoms.concat(commonKeywords, commonCommands));

define('atom', commonAtoms);
define('keyword', commonKeywords);
define('builtin', commonCommands);
define('hr', commonString2);
define('string-2', commonString2);
define('def', commonPlugins);
define('tag', commonTag);
define('number', commonNumber);
define('bracket', commonMath);
define('warning', commonWarning);

function tokenBase(stream, state) {
if (stream.eatSpace()) return null;

var sol = stream.sol();
var ch = stream.next();

if (/\d/.test(ch)) {
//if (!/d|o/.test(stream.peek())) {
stream.eatWhile(/\d|\./);
if (!stream.match("dt") && !stream.match("output")) {
if (stream.eol() || /\D/.test(stream.peek())) {
return 'number';
}
}
}

if (/\w/.test(ch)) {
for (const element of EXTRAWORDS) {
let WinDB = element.substring(1);
if (stream.match(WinDB)) void (0)
}
}

if (ch === '\\') {
stream.next();
return null;
}

if (ch === '(' || ch === ')') {
return "bracket";
}

if (ch === '{' || ch === '}' || ch === ':') {
return "number";
}
Expand All @@ -160,13 +194,6 @@ function initCM() {
return 'qualifier'
}

if (/\d/.test(ch)) {
stream.eatWhile(/\d|\./);
if (stream.eol() || !/\d/.test(stream.peek())) {
return 'number';
}
}

if (ch == "%") {
stream.eatWhile(/[^\s\%]/);
if (stream.match("%")) return 'hr';
Expand All @@ -177,29 +204,6 @@ function initCM() {
if (stream.eat("]")) return 'string-2';
}

if (/\w|\//.test(ch)) {
for (const element of commonCommands) {
let klausi = element.substring(1);
if (stream.match(klausi)) void (0)
}
for (const element of commonString2) {
let klausi = element.substring(1);
if (stream.match(klausi)) void (0)
}
for (const element of commonPlugins) {
let klausi = element.substring(1);
if (stream.match(klausi)) void (0)
}
for (const element of commonNumber) {
let klausi = element.substring(1);
if (stream.match(klausi)) void (0)
}
for (const element of commonMath) {
let klausi = element.substring(1);
if (stream.match(klausi)) void (0)
}
}

stream.eatWhile(/\w/);
var cur = stream.current();
if (stream.peek() === '#' && /\w/.test(cur)) return 'hr';
Expand Down
Loading

0 comments on commit 4201595

Please sign in to comment.