TextSweep

Check-in [c27e96591e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix bug in file reading
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c27e96591e05e4756fb7382df8301791f2ea6df0
User & Date: kevin 2018-04-24 02:21:54
Context
2018-04-24
02:39
Fix typos in license check-in: 391db8288f user: kevin tags: trunk
02:21
Fix bug in file reading check-in: c27e96591e user: kevin tags: trunk
2018-04-22
22:13
Fix typos in license check-in: 190a4c2edf user: kevin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to buildapp.

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

echo "Uploading DMG..."

upload TextSweep.dmg updates

upload textsweep-changes.tcl

upload texstsweep-version.tcl


cd ../

#create archive of entire source tree
tar cvfz TextSweep-$1.tgz TextSweep



echo "Done."










|













162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

echo "Uploading DMG..."

upload TextSweep.dmg updates

upload textsweep-changes.tcl

upload textsweep-version.tcl


cd ../

#create archive of entire source tree
tar cvfz TextSweep-$1.tgz TextSweep



echo "Done."



Changes to scriptlibs/textsweep/textsweep-main.tcl.

53
54
55
56
57
58
59

60



61
62
63
64
65
66
67
set filelist {}


#handle errors in Tk
proc bgerror {args} {

    global cachedir

    puts "TextSweep: An error occurred: $args\n"



}

#make images for buttons et. al from files
proc makeImage {} {

    global  runsearch 
    global folder_documents 







>
|
>
>
>







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
set filelist {}


#handle errors in Tk
proc bgerror {args} {

    global cachedir
    if {[tk windowingsystem] ne "win32"} {
	puts "TextSweep: An error occurred: $args\n"
    } else {
	tk_messageBox -icon warning -title "Error" -message $args
    }
}

#make images for buttons et. al from files
proc makeImage {} {

    global  runsearch 
    global folder_documents 
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
    set searchterm $searchvar
    highlightText
}

#highlight search text
proc highlightText {} {
    global searchterm 
    global searchvar

    if {$searchterm == ""} {
	set filename [lindex [.f.text.list.listbox get [.f.text.list.listbox curselection]] 0]

	set displayfile [open $filename r]
	set displaytext [read $displayfile]
	close $displayfile
	.f.text.t configure -state normal
	.f.text.t delete 1.0 end
	.f.text.t insert end $displaytext
	.f.text.t configure -state disabled
	return

    }
    
    .f.text.t configure -state normal
    .f.text.t delete 1.0 end
    .f.text.t configure -state disabled
    
    .f.text.t tag configure search -background yellow

    set filename [lindex [.f.text.list.listbox get [.f.text.list.listbox curselection]] 0]

    if [file isdirectory $filename] {
	return
    }

    if {![file owned $filename]} {
	return
    }

    set displayfile [open $filename r]
    set displaytext [read $displayfile]
    close $displayfile


    .f.text.t configure -state normal
    .f.text.t insert end $displaytext
    .f.text.t configure -state disabled

    setHighlight

}


#apply coloring to text
proc setHighlight {} {

    global searchterm
    global searchvar

    if {$searchterm == ""} {
	return
    }

    if {[.f.text.t get 1.0 end] == ""} {
	return
    }

    .f.text.t configure -state normal
    .f.text.t tag remove search 0.0 end
    
    set cur 1.0
    while 1 {
	set cur [.f.text.t search -count length $searchterm $cur end]
	if {$cur == ""} {
	    break
	}
	.f.text.t tag add search $cur "$cur + $length char"
	set cur [.f.text.t index "$cur + $length char"]
    }

    .f.text.t mark set insert 1.0
    .f.text.t configure -state disabled


}

#update the search term if the var changes
proc updateSearchTerm {args} {








|







|
|
|
|




|
|
|

|
















|
|
|
















|



|
|



|



|
|


|
|







450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
    set searchterm $searchvar
    highlightText
}

#highlight search text
proc highlightText {} {
    global searchterm 
    global searchvar 

    if {$searchterm == ""} {
	set filename [lindex [.f.text.list.listbox get [.f.text.list.listbox curselection]] 0]

	set displayfile [open $filename r]
	set displaytext [read $displayfile]
	close $displayfile
	.f.text.frame.t configure -state normal
	.f.text.frame.t delete 1.0 end
	.f.text.frame.t insert end $displaytext
	.f.text.frame.t configure -state disabled
	return

    }
    
    .f.text.frame.t configure -state normal
    .f.text.frame.t delete 1.0 end
    .f.text.frame.t configure -state disabled
    
    .f.text.frame.t tag configure search -background yellow

    set filename [lindex [.f.text.list.listbox get [.f.text.list.listbox curselection]] 0]

    if [file isdirectory $filename] {
	return
    }

    if {![file owned $filename]} {
	return
    }

    set displayfile [open $filename r]
    set displaytext [read $displayfile]
    close $displayfile


    .f.text.frame.t configure -state normal
    .f.text.frame.t insert end $displaytext
    .f.text.frame.t configure -state disabled

    setHighlight

}


#apply coloring to text
proc setHighlight {} {

    global searchterm
    global searchvar

    if {$searchterm == ""} {
	return
    }

    if {[.f.text.frame.t get 1.0 end] == ""} {
	return
    }

    .f.text.frame.t configure -state normal
    .f.text.frame.t tag remove search 0.0 end
    
    set cur 1.0
    while 1 {
	set cur [.f.text.frame.t search -count length $searchterm $cur end]
	if {$cur == ""} {
	    break
	}
	.f.text.frame.t tag add search $cur "$cur + $length char"
	set cur [.f.text.frame.t index "$cur + $length char"]
    }

    .f.text.frame.t mark set insert 1.0
    .f.text.frame.t configure -state disabled


}

#update the search term if the var changes
proc updateSearchTerm {args} {