︙ | | |
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-
+
-
+
|
}
proc DoClipDiff {} {
set f1 [tmpFile]
set f2 [tmpFile]
set ch [open $f1 w]
set data1 [$::diff(wClip1) get 1.0 end]
set data1 [$::eskil(wClip1) get 1.0 end]
set data1 [ClipClean $data1]
puts $ch $data1
close $ch
set ch [open $f2 w]
set data2 [$::diff(wClip2) get 1.0 end]
set data2 [$::eskil(wClip2) get 1.0 end]
set data2 [ClipClean $data2]
puts $ch $data2
close $ch
#set line1 [split $data1 \n]
#set len1 [llength $line1]
#set line2 [split $data2 \n]
|
︙ | | |
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
|
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
|
-
+
-
+
|
$::widgets($top,wLine1) configure -height 1
$t2 configure -height $lines2
$::widgets($top,wLine2) configure -height 1
}
}
proc ArmCatch {} {
if {$::diff(armcatch)} {
if {$::eskil(armcatch)} {
bind .clipdiff <FocusOut> {
if {[string equal %W .clipdiff]} {
after 50 CatchFromWin
}
}
} else {
bind .clipdiff <FocusOut> {}
}
}
proc CatchFromWin {} {
set ::diff(armcatch) 0
set ::eskil(armcatch) 0
ArmCatch
set win [twapi::get_foreground_window]
if {$win eq ""} {
#puts "No fg window"
return
}
#puts "Locating windows"
|
︙ | | |
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
-
-
+
+
-
+
-
+
|
twapi::send_keys ^(ac)
after 50 "set ::CatchFromWinWait 1" ; vwait ::CatchFromWinWait
lassign [twapi::get_window_coordinates $win] x1 y1 x2 y2
if {[catch {clipboard get} text]} continue
if {$text eq ""} continue
lappend capturedData [list $x1 $text]
}
$::diff(wClip1) delete 1.0 end
$::diff(wClip2) delete 1.0 end
$::eskil(wClip1) delete 1.0 end
$::eskil(wClip2) delete 1.0 end
if {[llength $capturedData] == 0} return
# Set it up left-to-right
set capturedData [lsort -index 0 -integer $capturedData]
if {[llength $capturedData] >= 1} {
set text [lindex $capturedData 0 1]
$::diff(wClip1) insert end $text
$::eskil(wClip1) insert end $text
}
if {[llength $capturedData] >= 2} {
set text [lindex $capturedData 1 1]
$::diff(wClip2) insert end $text
$::eskil(wClip2) insert end $text
after idle DoClipDiff
}
}
proc makeClipDiffWin {} {
set top .clipdiff
if {[winfo exists $top] && [winfo toplevel $top] eq $top} {
|
︙ | | |
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
-
-
+
+
|
wm title $top "Clip Diff"
wm protocol $top WM_DELETE_WINDOW "cleanupAndExit $top"
set t1 [Scroll both \
text $top.t1 -width 60 -height 35 -font myfont]
set t2 [Scroll both \
text $top.t2 -width 60 -height 35 -font myfont]
set ::diff(wClip1) $t1
set ::diff(wClip2) $t2
set ::eskil(wClip1) $t1
set ::eskil(wClip2) $t2
bind $t1 <Control-o> [list focus $t2]
bind $t2 <Control-o> [list focus $t1]
ttk::frame $top.f
menubutton $top.f.mf -menu $top.f.mf.m -text "File" -underline 0
menu $top.f.mf.m
|
︙ | | |
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
-
+
|
-padx 4 -pady 2 -sticky "w"
grid $top.f.mf -sticky nw -pady 0 -padx 0
grid columnconfigure $top.f {0 3 5 8} -weight 1
grid columnconfigure $top.f 8 -minsize [winfo reqwidth $top.f.mf]
if {![catch {package require twapi}]} {
ttk::checkbutton $top.f.b6 -text "Capture" -command ArmCatch \
-underline 0 -variable ::diff(armcatch)
-underline 0 -variable ::eskil(armcatch)
bind $top <Alt-c> [list $top.f.b6 invoke]
#raise $top.f.b6
place $top.f.b6 -anchor e -relx 1.0 -rely 0.5
}
grid $top.f - -sticky we
grid $top.t1 $top.t2 -sticky news
grid $top.t2 -padx {2 0}
grid rowconfigure $top 1 -weight 1
grid columnconfigure $top {0 1} -weight 1
return $top
}
|