Skip to content

Commit dff16e9

Browse files
committed
8 new languages added
C, C++, C#, Go, Lua, Perl, Rust and Sass added Perl has # comments (single & block) Lua has --[[xyz]] for block, and -- for single lines
1 parent 7264dee commit dff16e9

1 file changed

Lines changed: 42 additions & 17 deletions

File tree

processes/on-editor-load.php

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,27 @@
2020
if (cM && mode) {
2121
cM.setOption("mode",mode);
2222
} else if (cM && fileName) {
23-
fileName.indexOf('.js')>0 ? cM.setOption("mode","javascript")
24-
: fileName.indexOf('.coffee')>0 ? cM.setOption("mode","coffeescript")
25-
: fileName.indexOf('.rb')>0 ? cM.setOption("mode","ruby")
26-
: fileName.indexOf('.py')>0 ? cM.setOption("mode","python")
27-
: fileName.indexOf('.css')>0 ? cM.setOption("mode","css")
28-
: fileName.indexOf('.less')>0 ? cM.setOption("mode","less")
29-
: fileName.indexOf('.md')>0 ? cM.setOption("mode","markdown")
30-
: fileName.indexOf('.xml')>0 ? cM.setOption("mode","xml")
23+
fileName.indexOf('.js')>0 ? cM.setOption("mode","text/javascript")
24+
: fileName.indexOf('.coffee')>0 ? cM.setOption("mode","text/x-coffeescript")
25+
: fileName.indexOf('.rb')>0 ? cM.setOption("mode","text/x-ruby")
26+
: fileName.indexOf('.py')>0 ? cM.setOption("mode","text/x-python")
27+
: fileName.indexOf('.css')>0 ? cM.setOption("mode","text/css")
28+
: fileName.indexOf('.less')>0 ? cM.setOption("mode","text/x-less")
29+
: fileName.indexOf('.md')>0 ? cM.setOption("mode","text/x-markdown")
30+
: fileName.indexOf('.xml')>0 ? cM.setOption("mode","application/xml")
3131
: fileName.indexOf('.sql')>0 ? cM.setOption("mode","text/x-mysql") // also text/x-sql, text/x-mariadb, text/x-cassandra or text/x-plsql
32-
: fileName.indexOf('.erl')>0 ? cM.setOption("mode","erlang")
33-
: fileName.indexOf('.yaml')>0 ? cM.setOption("mode","yaml")
32+
: fileName.indexOf('.erl')>0 ? cM.setOption("mode","text/x-erlang")
33+
: fileName.indexOf('.yaml')>0 ? cM.setOption("mode","text/x-yaml")
3434
: fileName.indexOf('.java')>0 ? cM.setOption("mode","text/x-java")
35-
: fileName.indexOf('.jl')>0 ? cM.setOption("mode","julia")
35+
: fileName.indexOf('.jl')>0 ? cM.setOption("mode","text/x-julia")
36+
: fileName.indexOf('.c')>0 ? cM.setOption("mode","text/x-csrc")
37+
: fileName.indexOf('.cpp')>0 ? cM.setOption("mode","text/x-c++src")
38+
: fileName.indexOf('.cs')>0 ? cM.setOption("mode","text/x-csharp")
39+
: fileName.indexOf('.go')>0 ? cM.setOption("mode","text/x-go")
40+
: fileName.indexOf('.lua')>0 ? cM.setOption("mode","text/x-lua")
41+
: fileName.indexOf('.pl')>0 ? cM.setOption("mode","text/x-perl")
42+
: fileName.indexOf('.rs')>0 ? cM.setOption("mode","text/x-rustsrc")
43+
: fileName.indexOf('.scss')>0 ? cM.setOption("mode","text/x-sass")
3644
: cM.setOption("mode","application/x-httpd-php");
3745
}
3846
}
@@ -41,9 +49,9 @@
4149
top.ICEcoder.lineCommentToggleSub = function(cM, cursorPos, linePos, lineContent, lCLen, adjustCursor) {
4250
var startLine, endLine, commentChar;
4351

44-
if (["JavaScript","CoffeeScript","PHP","Python","Ruby","CSS","SQL","Erlang","Julia","Java","YAML"].indexOf(top.ICEcoder.caretLocType)>-1) {
52+
if (["JavaScript","CoffeeScript","PHP","Python","Ruby","CSS","SQL","Erlang","Julia","Java","YAML","C","C++","C#","Go","Lua","Perl","Rust","Sass"].indexOf(top.ICEcoder.caretLocType)>-1) {
4553
if (cM.somethingSelected()) {
46-
if (["Ruby","Python","Erlang","Julia","YAML"].indexOf(top.ICEcoder.caretLocType)>-1) {
54+
if (["Ruby","Python","Erlang","Julia","YAML","Perl"].indexOf(top.ICEcoder.caretLocType)>-1) {
4755
commentChar = top.ICEcoder.caretLocType == "Erlang" ? "%" : "#";
4856
startLine = cM.getCursor(true).line;
4957
endLine = cM.getCursor().line;
@@ -52,6 +60,10 @@
5260
? commentChar + cM.getLine(i)
5361
: cM.getLine(i).slice(1,cM.getLine(i).length));
5462
}
63+
} else if (["Lua"].indexOf(top.ICEcoder.caretLocType)>-1) {
64+
cM.replaceSelection(cM.getSelection().slice(0,4)!="--[["
65+
? "--[[" + cM.getSelection() + "]]"
66+
: cM.getSelection().slice(4,cM.getSelection().length-2));
5567
} else {
5668
cM.replaceSelection(cM.getSelection().slice(0,2)!="/*"
5769
? "/*" + cM.getSelection() + "*/"
@@ -63,13 +75,18 @@
6375
? "/*" + lineContent + "*/"
6476
: lineContent.slice(2,lCLen).slice(0,lCLen-4));
6577
if (lineContent.slice(0,2)=="/*") {adjustCursor = -adjustCursor};
66-
} else if (["Ruby","Python","Erlang","Julia","YAML"].indexOf(top.ICEcoder.caretLocType)>-1) {
78+
} else if (["Ruby","Python","Erlang","Julia","YAML","Perl"].indexOf(top.ICEcoder.caretLocType)>-1) {
6779
commentChar = top.ICEcoder.caretLocType == "Erlang" ? "%" : "#";
6880
cM.setLine(linePos, lineContent.slice(0,1)!=commentChar
6981
? commentChar + lineContent
7082
: lineContent.slice(1,lCLen));
7183
adjustCursor = 1;
7284
if (lineContent.slice(0,1)==commentChar) {adjustCursor = -adjustCursor};
85+
} else if (["Lua"].indexOf(top.ICEcoder.caretLocType)>-1) {
86+
cM.setLine(linePos, lineContent.slice(0,2)!="--"
87+
? "--" + lineContent
88+
: lineContent.slice(2,lCLen));
89+
if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor};
7390
} else {
7491
cM.setLine(linePos, lineContent.slice(0,2)!="//"
7592
? "//" + lineContent
@@ -97,7 +114,7 @@
97114
top.ICEcoder.getNestLocationSub = function(nestCheck, fileName) {
98115
var events;
99116

100-
if (["js","coffee","css","less","sql","erl","yaml","java","jl"].indexOf(fileName.split(".")[1])<0 &&
117+
if (["js","coffee","css","less","sql","erl","yaml","java","jl","c","cpp","cs","go","lua","pl","rs","scss"].indexOf(fileName.split(".")[1])<0 &&
101118
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)) {
102119

103120
// Then for all the array items, output as the nest display
@@ -122,7 +139,7 @@
122139
cM = top.ICEcoder.getcMInstance();
123140
nestOK = true;
124141
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
125-
if (cM && fileName && ["js","coffee","css","less","sql","erl","yaml","java","jl"].indexOf(fileName.split(".")[1])==-1) {
142+
if (cM && fileName && ["js","coffee","css","less","sql","erl","yaml","java","jl","c","cpp","cs","go","lua","pl","rs","scss"].indexOf(fileName.split(".")[1])==-1) {
126143
nestOK = cM.getTokenAt({line:cM.lineCount(),ch:cM.lineInfo(cM.lineCount()-1).text.length}).className != "error" ? true : false;
127144
}
128145
top.ICEcoder.nestValid.style.background = nestOK ? "#0b0" : "#f00";
@@ -157,7 +174,15 @@
157174
else if (fileName.indexOf(".yaml")>0) {caretLocType="YAML"}
158175
else if (fileName.indexOf(".java")>0) {caretLocType="Java"}
159176
else if (fileName.indexOf(".erl")>0) {caretLocType="Erlang"}
160-
else if (fileName.indexOf(".jl")>0) {caretLocType="Julia"};
177+
else if (fileName.indexOf(".jl")>0) {caretLocType="Julia"}
178+
else if (fileName.indexOf(".c")>0 && fileName.indexOf(".cpp")<0 && fileName.indexOf(".cs")<0) {caretLocType="C"}
179+
else if (fileName.indexOf(".cpp")>0) {caretLocType="C++"}
180+
else if (fileName.indexOf(".cs")>0) {caretLocType="C#"}
181+
else if (fileName.indexOf(".go")>0) {caretLocType="Go"}
182+
else if (fileName.indexOf(".lua")>0) {caretLocType="Lua"}
183+
else if (fileName.indexOf(".pl")>0) {caretLocType="Perl"}
184+
else if (fileName.indexOf(".rs")>0) {caretLocType="Rust"}
185+
else if (fileName.indexOf(".scss")>0) {caretLocType="Sass"};
161186
}
162187

163188
top.ICEcoder.caretLocType = caretLocType;

0 commit comments

Comments
 (0)