Eskil

Check-in [2e8c70e978]
Login

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

Overview
Comment:Improved incremental search. Added status indicator. Improved search to work in both windows.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2e8c70e9785dd9e47726cc58016493703d3f599b
User & Date: spjutp 2001-11-05 15:18:03.000
Context
2001-11-05
15:26
Release 1.9. check-in: 0f7a4d40e6 user: spjutp tags: trunk
15:18
Improved incremental search. Added status indicator. Improved search to work in both windows. check-in: 2e8c70e978 user: spjutp tags: trunk
2001-11-02
19:00
Added context around a 'diffs only' output. Improved printing with headers and syntax printing. Printing now doesn't use mpage and does all job with enscript. check-in: 661551c44a user: spjutp tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/eskil.tcl.
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#-----------------------------------------------
# $Revision$
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"

set debug 1
set diffver "Version 1.8.7  2001-11-02"
set tmpcnt 0
set tmpfiles {}
set thisscript [file join [pwd] [info script]]
set thisdir [file dirname $thisscript]

if {$tcl_platform(platform) == "windows"} {
    cd $thisdir







|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#-----------------------------------------------
# $Revision$
#-----------------------------------------------
# the next line restarts using wish \
exec wish "$0" "$@"

set debug 1
set diffver "Version 1.8.8  2001-11-05"
set tmpcnt 0
set tmpfiles {}
set thisscript [file join [pwd] [info script]]
set thisdir [file dirname $thisscript]

if {$tcl_platform(platform) == "windows"} {
    cd $thisdir
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
    set Pref(dopt) $Pref(old_dopt)
    unset Pref(old_dopt)
}

# Main diff function.
proc doDiff {} {
    global diff Pref
    global eqLabel doingLine1 doingLine2
    global mapMax changesList

    if {$diff(mode) == "" && ($diff(leftOK) == 0 || $diff(rightOK) == 0)} {
        disableRedo
        return
    } else {
        enableRedo







|







1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
    set Pref(dopt) $Pref(old_dopt)
    unset Pref(old_dopt)
}

# Main diff function.
proc doDiff {} {
    global diff Pref
    global doingLine1 doingLine2
    global mapMax changesList

    if {$diff(mode) == "" && ($diff(leftOK) == 0 || $diff(rightOK) == 0)} {
        disableRedo
        return
    } else {
        enableRedo
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294

    if {[llength $result] == 0} {
        if {$differr == 1} {
            .ft1.tt insert end $diffres
            normalCursor
            return
        } else {
            set eqLabel "="
        }
    } else {
        set eqLabel " "
    }
    update idletasks

    set ch1 [open $diff(leftFile)]
    set ch2 [open $diff(rightFile)]
    if {$::tcl_platform(platform) == "windows" && $Pref(crlf)} {
        fconfigure $ch1 -translation crlf







|


|







1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294

    if {[llength $result] == 0} {
        if {$differr == 1} {
            .ft1.tt insert end $diffres
            normalCursor
            return
        } else {
            set ::diff(eqLabel) "="
        }
    } else {
        set ::diff(eqLabel) " "
    }
    update idletasks

    set ch1 [open $diff(leftFile)]
    set ch2 [open $diff(rightFile)]
    if {$::tcl_platform(platform) == "windows" && $Pref(crlf)} {
        fconfigure $ch1 -translation crlf
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
    normalCursor
    showDiff 0

    if {$diff(mode) == "RCS" || $diff(mode) == "CVS"} {
        cleanupRCS
    } elseif {[string match "conflict*" $diff(mode)]} {
        cleanupConflict
        if {$eqLabel != "="} {
            after idle makeMergeWin
        }
    }
    if {$diff(printFile) != ""} {
        after idle {doPrint 1 ; exit}
    }
}







|







1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
    normalCursor
    showDiff 0

    if {$diff(mode) == "RCS" || $diff(mode) == "CVS"} {
        cleanupRCS
    } elseif {[string match "conflict*" $diff(mode)]} {
        cleanupConflict
        if {$::diff(eqLabel) != "="} {
            after idle makeMergeWin
        }
    }
    if {$diff(printFile) != ""} {
        after idle {doPrint 1 ; exit}
    }
}
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938









1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961




1962
1963






1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981

1982
1983
1984
1985
1986
1987
1988
        endIncrementalSearch $w
    }

    set ::diff(isearch) $w
    
    bind MyText <Control-Key-s> "isearchAgain %W ; break"
    bind MyText <FocusOut> "endIncrementalSearch %W"
    bind MyText <Key> "isearchKey %W %A ; break"
    bind MyText <Key-Escape> "endIncrementalSearch %W ; break"
    bind MyText <Control-Key-g> "endIncrementalSearch %W ; break"
    bind MyText <Key-Delete> "isearchBack %W ; break"
    bind MyText <Key-BackSpace> "isearchBack %W ; break"
    
    set ::diff(isearchstring) ""
    set ::diff(isearchhistory) {}
    set ::diff(isearchindex) [$w index insert]

}

proc isearchShow {w index string} {
    if {$index != $::diff(isearchindex)} {
        $w tag remove sel 1.0 end
    }
    $w tag add sel $index "$index + [string length $string] chars"
    $w mark set insert $index
    $w see $index

    set ::diff(isearchindex) $index
    set ::diff(isearchstring) $string
    set ::diff(isearchlast) $string
}










proc isearchAgain {w} {
    if {$w != $::diff(isearch)} {
        bell
        endIncrementalSearch $::diff(isearch)
        return
    }

    set str $::diff(isearchstring)
    if {$str == ""} {
        set str $::diff(isearchlast)
    }
    set found [$w search $str "$::diff(isearchindex) + 1 char"]
    if {$found == ""} {
        bell
        return
    }
    lappend ::diff(isearchhistory) $::diff(isearchindex) \
            $::diff(isearchstring)
    isearchShow $w $found $str
}

proc isearchKey {w key} {





    if {$w != $::diff(isearch)} {






        bell
        endIncrementalSearch $::diff(isearch)
        return
    }

    if {$key == ""} return

    set str $::diff(isearchstring)
    append str $key

    set found [$w search $str $::diff(isearchindex)]
    if {$found == ""} {
        bell
        return
    }
    lappend ::diff(isearchhistory) $::diff(isearchindex) \
            $::diff(isearchstring)
    isearchShow $w $found $str

}

proc isearchBack {w} {
    if {$w != $::diff(isearch)} {
        bell
        endIncrementalSearch $::diff(isearch)
        return







|








|



<
|
<








>
>
>
>
>
>
>
>
>












|









|
>
>
>
>
|
|
>
>
>
>
>
>





<
<



|


|




>







1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927

1928

1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985


1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
        endIncrementalSearch $w
    }

    set ::diff(isearch) $w
    
    bind MyText <Control-Key-s> "isearchAgain %W ; break"
    bind MyText <FocusOut> "endIncrementalSearch %W"
    bind MyText <Key> "isearchKey %W %A %s %K"
    bind MyText <Key-Escape> "endIncrementalSearch %W ; break"
    bind MyText <Control-Key-g> "endIncrementalSearch %W ; break"
    bind MyText <Key-Delete> "isearchBack %W ; break"
    bind MyText <Key-BackSpace> "isearchBack %W ; break"
    
    set ::diff(isearchstring) ""
    set ::diff(isearchhistory) {}
    set ::diff(isearchindex) [$w index insert]
    set ::diff(statusLabel) "i"
}

proc isearchShow {w index string} {

    $w tag remove sel 1.0 end

    $w tag add sel $index "$index + [string length $string] chars"
    $w mark set insert $index
    $w see $index

    set ::diff(isearchindex) $index
    set ::diff(isearchstring) $string
    set ::diff(isearchlast) $string
}

proc isearchSearch {w str ix} {
    if {[string equal [string tolower $str] $str]} {
        set found [$w search -nocase $str $ix]
    } else {
        set found [$w search $str $ix]
    }
    return $found
}

proc isearchAgain {w} {
    if {$w != $::diff(isearch)} {
        bell
        endIncrementalSearch $::diff(isearch)
        return
    }

    set str $::diff(isearchstring)
    if {$str == ""} {
        set str $::diff(isearchlast)
    }
    set found [isearchSearch $w $str "$::diff(isearchindex) + 1 char"]
    if {$found == ""} {
        bell
        return
    }
    lappend ::diff(isearchhistory) $::diff(isearchindex) \
            $::diff(isearchstring)
    isearchShow $w $found $str
}

proc isearchKey {w key state sym} {
    if {$w != $::diff(isearch)} {
        bell
        endIncrementalSearch $::diff(isearch)
        return -code break
    }

    if {$key == ""} {
        # Ignore the Control key
        if {[string match Contr* $sym]} {return -code break}
        # Ignore any Control-ed key
        if {$state == 4} {return -code break}
        # Break isearch on other non-ascii keys, and let it through
        bell
        endIncrementalSearch $::diff(isearch)
        return
    }



    set str $::diff(isearchstring)
    append str $key

    set found [isearchSearch $w $str $::diff(isearchindex)]
    if {$found == ""} {
        bell
        return -code break
    }
    lappend ::diff(isearchhistory) $::diff(isearchindex) \
            $::diff(isearchstring)
    isearchShow $w $found $str
    return -code break
}

proc isearchBack {w} {
    if {$w != $::diff(isearch)} {
        bell
        endIncrementalSearch $::diff(isearch)
        return
1998
1999
2000
2001
2002
2003
2004

2005
2006
2007
2008
2009
2010
2011
    
    isearchShow $w $found $str
}

proc endIncrementalSearch {w} {

    set ::diff(isearch) ""


    # Remove all bindings from MyText
    foreach b [bind MyText] {
        bind MyText $b ""
    }
    
    bind MyText <Control-Key-s> "startIncrementalSearch %W"







>







2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
    
    isearchShow $w $found $str
}

proc endIncrementalSearch {w} {

    set ::diff(isearch) ""
    set ::diff(statusLabel) ""

    # Remove all bindings from MyText
    foreach b [bind MyText] {
        bind MyText $b ""
    }
    
    bind MyText <Control-Key-s> "startIncrementalSearch %W"
2537
2538
2539
2540
2541
2542
2543








2544
2545
2546
2547
2548
2549
2550
            -value "0"
    .mo.mp add radiobutton -label "Words" -variable Pref(lineparsewords) \
            -value "1"
    .mo.mp add separator
    .mo.mp add checkbutton -label "Use 2nd stage" \
            -variable Pref(extralineparse)
    .mo.mp add checkbutton -label "Mark last" -variable Pref(marklast)









    menubutton .mh -text Help -underline 0 -menu .mh.m
    menu .mh.m
    .mh.m add command -label "Help" -command makeHelpWin
    .mh.m add command -label "About" -command makeAboutWin

    button .bfn -text "Next Diff" -relief raised -command {findDiff 1}







>
>
>
>
>
>
>
>







2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
            -value "0"
    .mo.mp add radiobutton -label "Words" -variable Pref(lineparsewords) \
            -value "1"
    .mo.mp add separator
    .mo.mp add checkbutton -label "Use 2nd stage" \
            -variable Pref(extralineparse)
    .mo.mp add checkbutton -label "Mark last" -variable Pref(marklast)

    menubutton .ms -text Search -underline 0 -menu .ms.m 
    menu .ms.m
    .ms.m add command -label "Find"      -accelerator "Ctrl+f" -command Search
    .ms.m add command -label "Find Next" -accelerator "F3" \
            -command SearchNext
    .ms.m add command -label "Find Prev" -accelerator "Ctrl+F3" \
            -command SearchPrev

    menubutton .mh -text Help -underline 0 -menu .mh.m
    menu .mh.m
    .mh.m add command -label "Help" -command makeHelpWin
    .mh.m add command -label "About" -command makeAboutWin

    button .bfn -text "Next Diff" -relief raised -command {findDiff 1}
2579
2580
2581
2582
2583
2584
2585
2586

2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
    pack .ft2.tt -side right -fill both -expand 1
    scrollbar .sbx2 -orient horizontal -command ".ft2.tt xview"

    bind MyText <Control-Key-s> "startIncrementalSearch %W"
    bindtags .ft1.tt "MyText [bindtags .ft1.tt]"
    bindtags .ft2.tt "MyText [bindtags .ft2.tt]"

    label .le -textvariable eqLabel -width 1

    canvas .c -width 6 -bd 0 -selectborderwidth 0 -highlightthickness 0

    applyColor
    .ft1.tt tag configure last -underline 1
    .ft2.tt tag configure last -underline 1
    foreach w {.ft1.tt .ft1.tl .ft2.tt .ft2.tl} {
        bind $w <ButtonPress-3> "zoomRow %W %X %Y %x %y"
        bind $w <ButtonRelease-3> "unzoomRow"
    }

    grid .l1 .le - .l2 -row 1 -sticky news
    grid .ft1 .c .sby .ft2 -row 2 -sticky news
    grid .sbx1 x x .sbx2 -row 3 -sticky news
    grid columnconfigure . {0 3} -weight 1
    grid rowconfigure . 2 -weight 1
    grid .c -pady [expr {[.sby cget -width] + 2}]

    image create photo map
    .c create image 0 0 -anchor nw -image map
    bind .c <Configure> {drawMap %h}

    bind . <Key-Up> {scroll -1 u}
    bind . <Key-Down> {scroll 1 u}
    bind . <Key-Prior> {scroll -1 p}
    bind . <Key-Next> {scroll 1 p}
    bind . <Key-Escape> {focus .}
    bind . <Control-Key-f> {Search}
    bind . <Key-F3> {SearchNext}
    bind . <Control-Key-F3> {SearchPrev}

    menubutton .mg -text Search -underline 0 -menu .mg.m 
    menu .mg.m
    .mg.m add command -label "Find"      -accelerator "Ctrl+f" -command Search
    .mg.m add command -label "Find Next" -accelerator "F3" \
            -command SearchNext
    .mg.m add command -label "Find Prev" -accelerator "Ctrl+F3" \
            -command SearchPrev

    if {$debug == 1} {
        menubutton .md -text Debug -menu .md.m -relief ridge
        menu .md.m
        if {$tcl_platform(platform) == "windows"} {
            .md.m add checkbutton -label Console -variable consolestate \
                    -onvalue show -offvalue hide \
                    -command {console $consolestate}







|
>










|
|
|

















<
|
<
<
<
<
<
|







2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642

2643





2644
2645
2646
2647
2648
2649
2650
2651
    pack .ft2.tt -side right -fill both -expand 1
    scrollbar .sbx2 -orient horizontal -command ".ft2.tt xview"

    bind MyText <Control-Key-s> "startIncrementalSearch %W"
    bindtags .ft1.tt "MyText [bindtags .ft1.tt]"
    bindtags .ft2.tt "MyText [bindtags .ft2.tt]"

    label .le -textvariable ::diff(eqLabel) -width 1
    label .ls -textvariable ::diff(statusLabel) -width 1 -pady 0 -padx 0
    canvas .c -width 6 -bd 0 -selectborderwidth 0 -highlightthickness 0

    applyColor
    .ft1.tt tag configure last -underline 1
    .ft2.tt tag configure last -underline 1
    foreach w {.ft1.tt .ft1.tl .ft2.tt .ft2.tl} {
        bind $w <ButtonPress-3> "zoomRow %W %X %Y %x %y"
        bind $w <ButtonRelease-3> "unzoomRow"
    }

    grid .l1   .le -    .l2   -row 1 -sticky news
    grid .ft1  .c  .sby .ft2  -row 2 -sticky news
    grid .sbx1 .ls -    .sbx2 -row 3 -sticky news
    grid columnconfigure . {0 3} -weight 1
    grid rowconfigure . 2 -weight 1
    grid .c -pady [expr {[.sby cget -width] + 2}]

    image create photo map
    .c create image 0 0 -anchor nw -image map
    bind .c <Configure> {drawMap %h}

    bind . <Key-Up> {scroll -1 u}
    bind . <Key-Down> {scroll 1 u}
    bind . <Key-Prior> {scroll -1 p}
    bind . <Key-Next> {scroll 1 p}
    bind . <Key-Escape> {focus .}
    bind . <Control-Key-f> {Search}
    bind . <Key-F3> {SearchNext}
    bind . <Control-Key-F3> {SearchPrev}


    pack .mf .mo .ms .mh -in .f -side left





    pack .bfn .bfp .eo .lo -in .f -side right
    if {$debug == 1} {
        menubutton .md -text Debug -menu .md.m -relief ridge
        menu .md.m
        if {$tcl_platform(platform) == "windows"} {
            .md.m add checkbutton -label Console -variable consolestate \
                    -onvalue show -offvalue hide \
                    -command {console $consolestate}
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
        .md.m add separator
        .md.m add command -label "Normal Cursor" -command {normalCursor}
        .md.m add separator
        .md.m add command -label "Evalstats" -command {evalstats}
        .md.m add command -label "_stats" -command {parray _stats}
        .md.m add command -label "Nuisance" -command {makeNuisance \
                "It looks like you are trying out the debug menu."}
        pack .mf .mo .mh .mg .md -in .f -side left
    } else {
        pack .mf .mo .mh .mg -in .f -side left
    }
    pack .bfn .bfp .eo .lo -in .f -side right
}

# Set new preferences.
proc applyPref {} {
    global Pref TmpPref

    array set Pref [array get TmpPref]







|
<
<

<







2663
2664
2665
2666
2667
2668
2669
2670


2671

2672
2673
2674
2675
2676
2677
2678
        .md.m add separator
        .md.m add command -label "Normal Cursor" -command {normalCursor}
        .md.m add separator
        .md.m add command -label "Evalstats" -command {evalstats}
        .md.m add command -label "_stats" -command {parray _stats}
        .md.m add command -label "Nuisance" -command {makeNuisance \
                "It looks like you are trying out the debug menu."}
        pack .md -in .f -side left -padx 20


    }

}

# Set new preferences.
proc applyPref {} {
    global Pref TmpPref

    array set Pref [array get TmpPref]
3331
3332
3333
3334
3335
3336
3337

3338

3339
3340
3341
3342
3343
3344
3345
    getOptions
    makeDiffWin
    update idletasks
    parseCommandLine
}

## FIXA, ga igenom Ulfs kod



proc Dialog_Create {top title args} {
    global dialog
    if {[winfo exists $top]} {
        switch -- [wm state $top] {
            normal {
                # Raise a buried window
                raise $top







>

>







3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
    getOptions
    makeDiffWin
    update idletasks
    parseCommandLine
}

## FIXA, ga igenom Ulfs kod
# Searching contributed by Ulf Nilsson

# Dialog functions from "Practical Programming in Tcl And Tk" by Welch.
proc Dialog_Create {top title args} {
    global dialog
    if {[winfo exists $top]} {
        switch -- [wm state $top] {
            normal {
                # Raise a buried window
                raise $top
3427
3428
3429
3430
3431
3432
3433




3434
3435
3436

3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478

3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
proc Search {} {
    if {![info exists diff(searchcase)]} {
        set ::diff(searchcase) 0
        set ::diff(searchindex) 1.0
        set ::diff(searchstring) ""
    }





    set ::diff(searchstring) [Find_Dialog "Please enter string to find"]

    if {$::diff(searchcase)} {

        set searchpos [.ft1.tt search -count cnt $::diff(searchstring) @0,0]
    } else {
        set searchpos [.ft1.tt search -count cnt -nocase \
                $::diff(searchstring) @0,0]
    }
    if {$searchpos == ""} {
        tk_messageBox -message "Search string not found!" -type ok -title Diff
        return
    }

    .ft1.tt see $searchpos
    .ft1.tt tag remove sel 1.0 end
    .ft1.tt tag add sel $searchpos "$searchpos + $cnt chars"
    set ::diff(searchindex) $searchpos
}      

proc SearchNext {} {
    if {$::diff(searchcase)} {
        set searchpos [.ft1.tt search -count cnt $::diff(searchstring) \
                "$::diff(searchindex) + 1 chars"]
    } else {
        set searchpos [.ft1.tt search -count cnt -nocase  $::diff(searchstring) \
                "$::diff(searchindex) + 1 chars"]
    }
    
    if {$searchpos == "" || $searchpos == $::diff(searchindex)} {
        tk_messageBox -message "String not found!" -type ok -title Diff
        return
    }

    .ft1.tt see $searchpos
    .ft1.tt tag remove sel 1.0 end
    .ft1.tt tag add sel $searchpos "$searchpos + $cnt chars"
    set ::diff(searchindex) $searchpos
}

proc SearchPrev {} {
    if {$::diff(searchcase)} {
        set searchpos [.ft1.tt search -count cnt -backwards \
                $::diff(searchstring) "$::diff(searchindex) - 1 chars"]
    } else {
        set searchpos [.ft1.tt search -count cnt -nocase  -backwards \

                $::diff(searchstring) "$::diff(searchindex) - 1 chars"]
    }
    
    if {$searchpos == "" || $searchpos == $::diff(searchindex)} {
        tk_messageBox -message "String not found!" -type ok -title Diff
        return
    }

    .ft1.tt see $searchpos
    .ft1.tt tag remove sel 1.0 end
    .ft1.tt tag add sel $searchpos "$searchpos + $cnt chars"
    set ::diff(searchindex) $searchpos
}







>
>
>
>



>
|

|







|
|
|





|
|

|
|







|
|
|





|


|
>








|
|
|


3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
proc Search {} {
    if {![info exists diff(searchcase)]} {
        set ::diff(searchcase) 0
        set ::diff(searchindex) 1.0
        set ::diff(searchstring) ""
    }

    set ::diff(searchwin) .ft1.tt
    if {[focus -displayof .] == ".ft2.tt"} {
        set ::diff(searchwin) .ft2.tt
    }
    set ::diff(searchstring) [Find_Dialog "Please enter string to find"]

    if {$::diff(searchcase)} {
        set searchpos [$::diff(searchwin) search -count cnt \
                $::diff(searchstring) @0,0]
    } else {
        set searchpos [$::diff(searchwin) search -count cnt -nocase \
                $::diff(searchstring) @0,0]
    }
    if {$searchpos == ""} {
        tk_messageBox -message "Search string not found!" -type ok -title Diff
        return
    }

    $::diff(searchwin) see $searchpos
    $::diff(searchwin) tag remove sel 1.0 end
    $::diff(searchwin) tag add sel $searchpos "$searchpos + $cnt chars"
    set ::diff(searchindex) $searchpos
}      

proc SearchNext {} {
    if {$::diff(searchcase)} {
        set searchpos [$::diff(searchwin) search -count cnt \
                $::diff(searchstring) "$::diff(searchindex) + 1 chars"]
    } else {
        set searchpos [$::diff(searchwin) search -count cnt -nocase \
                $::diff(searchstring) "$::diff(searchindex) + 1 chars"]
    }
    
    if {$searchpos == "" || $searchpos == $::diff(searchindex)} {
        tk_messageBox -message "String not found!" -type ok -title Diff
        return
    }

    $::diff(searchwin) see $searchpos
    $::diff(searchwin) tag remove sel 1.0 end
    $::diff(searchwin) tag add sel $searchpos "$searchpos + $cnt chars"
    set ::diff(searchindex) $searchpos
}

proc SearchPrev {} {
    if {$::diff(searchcase)} {
        set searchpos [$::diff(searchwin) search -count cnt -backwards \
                $::diff(searchstring) "$::diff(searchindex) - 1 chars"]
    } else {
        set searchpos [$::diff(searchwin) search -count cnt -backwards \
                -nocase \
                $::diff(searchstring) "$::diff(searchindex) - 1 chars"]
    }
    
    if {$searchpos == "" || $searchpos == $::diff(searchindex)} {
        tk_messageBox -message "String not found!" -type ok -title Diff
        return
    }

    $::diff(searchwin) see $searchpos
    $::diff(searchwin) tag remove sel 1.0 end
    $::diff(searchwin) tag add sel $searchpos "$searchpos + $cnt chars"
    set ::diff(searchindex) $searchpos
}