Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit fcd032d

Browse files
authored
JS code tidy and put function back in
1 parent a893282 commit fcd032d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

lib/ice-coder.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3115,7 +3115,6 @@ var ICEcoder = {
31153115
if (["object","both"].indexOf(top.ICEcoder.fileDirResOutput) >= 0) {
31163116
console.log(statusObj);
31173117
}
3118-
31193118
// If error, show that, otherwise do whatever we're required to do next
31203119
if (statusObj.status.error) {
31213120
top.ICEcoder.message(statusObj.status.errorMsg);
@@ -3564,7 +3563,7 @@ var ICEcoder = {
35643563
outputMsg: function(msg) {
35653564
top.ICEcoder.output.innerHTML += msg + "<br>";
35663565
},
3567-
3566+
35683567
// Show a message
35693568
message: function(msg) {
35703569
alert(msg);
@@ -4258,7 +4257,6 @@ var ICEcoder = {
42584257
top.ICEcoder.cmdKey = true;
42594258
}
42604259

4261-
42624260
// F1 (zoom code out non declaration lines)
42634261
if (key === 112) {
42644262
if (top.ICEcoder.codeZoomedOut) {
@@ -4283,7 +4281,7 @@ var ICEcoder = {
42834281
cM.refresh();
42844282
return false;
42854283
};
4286-
4284+
42874285
// DEL (Delete file)
42884286
if (key==46 && area == "files") {
42894287
top.ICEcoder.deleteFiles();
@@ -4537,6 +4535,29 @@ var ICEcoder = {
45374535
top.ICEcoder.cmdKey = false;
45384536
},
45394537

4538+
// Add snippet code completion
4539+
addSnippet: function() {
4540+
var cM, cMdiff, thisCM, lineNo, whiteSpace, content;
4541+
4542+
// Get line content after trimming whitespace
4543+
cM = ICEcoder.getcMInstance();
4544+
cMdiff = ICEcoder.getcMdiffInstance();
4545+
thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM;
4546+
lineNo = thisCM.getCursor().line;
4547+
whiteSpace = thisCM.getLine(lineNo).length - thisCM.getLine(lineNo).replace(/^\s\s*/, '').length;
4548+
content = thisCM.getLine(lineNo).slice(whiteSpace);
4549+
// function snippet
4550+
if (content.slice(0,8)=="function") {
4551+
top.ICEcoder.doSnippet('function','function VAR() {\nINDENT\tCURSOR\nINDENT}');
4552+
// if snippet
4553+
} else if (content.slice(0,2)=="if") {
4554+
top.ICEcoder.doSnippet('if','if (CURSOR) {\nINDENT\t\nINDENT}');
4555+
// for snippet
4556+
} else if (content.slice(0,3)=="for") {
4557+
top.ICEcoder.doSnippet('for','for (var i=0; i<CURSOR; i++) {\nINDENT\t\nINDENT}');
4558+
}
4559+
},
4560+
45404561
// Action a snippet
45414562
doSnippet: function(tgtString,replaceString) {
45424563
var cM, cMdiff, thisCM, lineNo, lineContents, remainder, strPos, replacedLine, whiteSpace, curPos, sPos, lineNoCount;

0 commit comments

Comments
 (0)