-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommentsAdd2.js
More file actions
44 lines (40 loc) · 1.39 KB
/
CommentsAdd2.js
File metadata and controls
44 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//CommentsAdd2.js
with (AkelPad){
// include("log.js")
Include("Coder.js")
var hMainWnd = GetMainWnd()
var hWndEdit = GetEditWnd()
var selStart = GetSelStart()
var selEnd = GetSelEnd()
var selText = GetSelText()
var lineStart = getLineStartPos(selStart)
var comms = GetSyntaxComments()
if (comms === null || comms.length === 0){
WScript.Echo("В синтаксической теме текущей вкладки отсутствуют обозначения комментариев!")
WScript.Quit()
}
if (lineStart !== selStart){
if(selStart !== selEnd && comms.length === 3){
selText = comms[1] + selText + comms[2]
ReplaceSel(selText)
SetSel(selStart, selStart+selText.length)
} else {
SetSel(lineStart, lineStart)
ReplaceSel(comms[0])
sleStart+=2
var commLen = comms[0].length
SetSel(selStart + commLen, selEnd + commLen)
}
}else{
var lines = selText.split("\r")
var n = 0
if(lines[lines.length-1].length === 0){
lines.pop()
SetSel(selStart, selEnd-1)
n = 1
}
selText = comms[0]+lines.join("\n"+comms[0])
ReplaceSel(selText)
SetSel(selStart, selStart + selText.length + n)
}
}