|
39 | 39 |
|
40 | 40 | // Comment/uncomment line or selected range on keypress |
41 | 41 | top.ICEcoder.lineCommentToggleSub = function(cM, cursorPos, linePos, lineContent, lCLen, adjustCursor) { |
42 | | - var startLine, endLine; |
| 42 | + var startLine, endLine, commentChar; |
43 | 43 |
|
44 | | - if (["JavaScript","CoffeeScript","PHP","Python","Ruby","CSS","SQL"].indexOf(top.ICEcoder.caretLocType)>-1) { |
| 44 | + if (["JavaScript","CoffeeScript","PHP","Python","Ruby","CSS","SQL","Erlang","Julia","Java","YAML"].indexOf(top.ICEcoder.caretLocType)>-1) { |
45 | 45 | if (cM.somethingSelected()) { |
46 | | - if (top.ICEcoder.caretLocType=="Ruby"||top.ICEcoder.caretLocType=="Python") { |
| 46 | + if (["Ruby","Python","Erlang","Julia","YAML"].indexOf(top.ICEcoder.caretLocType)>-1) { |
| 47 | + commentChar = top.ICEcoder.caretLocType == "Erlang" ? "%" : "#"; |
47 | 48 | startLine = cM.getCursor(true).line; |
48 | 49 | endLine = cM.getCursor().line; |
49 | 50 | for (var i=startLine; i<=endLine; i++) { |
50 | | - cM.setLine(i, cM.getLine(i).slice(0,1)!="#" |
51 | | - ? "#" + cM.getLine(i) |
| 51 | + cM.setLine(i, cM.getLine(i).slice(0,1)!=commentChar |
| 52 | + ? commentChar + cM.getLine(i) |
52 | 53 | : cM.getLine(i).slice(1,cM.getLine(i).length)); |
53 | 54 | } |
54 | 55 | } else { |
|
62 | 63 | ? "/*" + lineContent + "*/" |
63 | 64 | : lineContent.slice(2,lCLen).slice(0,lCLen-4)); |
64 | 65 | if (lineContent.slice(0,2)=="/*") {adjustCursor = -adjustCursor}; |
65 | | - } else if (top.ICEcoder.caretLocType=="Ruby") { |
66 | | - cM.setLine(linePos, lineContent.slice(0,1)!="#" |
67 | | - ? "#" + lineContent |
| 66 | + } else if (["Ruby","Python","Erlang","Julia","YAML"].indexOf(top.ICEcoder.caretLocType)>-1) { |
| 67 | + commentChar = top.ICEcoder.caretLocType == "Erlang" ? "%" : "#"; |
| 68 | + cM.setLine(linePos, lineContent.slice(0,1)!=commentChar |
| 69 | + ? commentChar + lineContent |
68 | 70 | : lineContent.slice(1,lCLen)); |
69 | | - if (lineContent.slice(0,1)=="#") {adjustCursor = -adjustCursor}; |
| 71 | + adjustCursor = 1; |
| 72 | + if (lineContent.slice(0,1)==commentChar) {adjustCursor = -adjustCursor}; |
70 | 73 | } else { |
71 | 74 | cM.setLine(linePos, lineContent.slice(0,2)!="//" |
72 | 75 | ? "//" + lineContent |
|
86 | 89 | adjustCursor = lineContent.slice(0,4)=="<\!--" ? -4 : 4; |
87 | 90 | } |
88 | 91 | } |
| 92 | + |
| 93 | + if (!cM.somethingSelected()) {cM.setCursor(linePos, cursorPos+adjustCursor)}; |
89 | 94 | } |
90 | 95 |
|
91 | 96 | // Work out the nesting depth location on demand and update our display if required |
|
0 commit comments