blob: 64268794224f9688841ff19beabc2fe73710c0f0 (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
function newWindowCallBack(mainwindow) {
var ac=mainwindow.actionCollection();
action = new TDEAction( ac, 'kjsselect_select_action' );
action.text = 'Select enclosing block';
//action.icon = 'konsole';
mainwindow.selectIt = function()
{
endChars=Array();
endChars['\"']="\"";
endChars['(']=")";
endChars['[']="]";
endChars['\'']="'";
endChars['{']="}";
endChar="";
av=this.viewManager().activeView();
d=KATE.DocumentManager.activeDocument();
lineCnt=d.numLines();
x=av.cursorColumn();
y=av.cursorLine();
line=d.textLine(y);
sy=y;
sx=x-1;
while (true) {
if (sx<0) {
sy=sy-1;
if (sy<0) {
d.selectAll();
return;
}
line=d.textLine(sy);
while (line.length==0) {
sy=sy-1;
if (sy<0) {
d.selectAll();
return;
}
line=d.textLine(sy);
}
sx=line.length-1;
}
if (
(line[sx]=="\"") ||
(line[sx]=="'") ||
(line[sx]=="(") ||
(line[sx]=="[") ||
(line[sx]=="{")
) {
endChar=endChars[line[sx]];
break;
}else sx--;
}
alert("Searching end");
ex=x;
ey=y;
line=d.textLine(y);
while (true) {
if (ex>=(line.length-1)) {
ey=ey+1;
if (ey>=lineCnt) {
d.selectAll();
return;
}
line=d.textLine(ey);
while (line.length==0) {
ey=ey+1;
if (ey>=lineCnt) {
d.selectAll();
return;
}
line=d.textLine(ey);
}
ex=0;
}
if (line[ex]==endChar)
break; else ex++;
}
d.setSelection(sy,sx,ey,ex);
}
action.connect( action, 'activated()', mainwindow, 'selectIt' );
}
setWindowConfiguration(null,newWindowCallBack,null);
|