head 1.2; access; symbols; locks mys:1.2; strict; comment @# @; 1.2 date 2000.04.11.21.41.24; author mys; state Exp; branches; next 1.1; 1.1 date 99.11.09.21.32.05; author mys; state Exp; branches; next ; desc @@ 1.2 log @*** empty log message *** @ text @# Copyright (C) 1999 - Martin Strauss - under terms of GPL ################################ # auto complition # ok ! proc ergaenzung {E} { global I_befehl I_back I_state global BeginFlag global erg_flag erg_back set ksp [$E get {insert-1c wordstart-1c} {insert-1c wordstart}] if ![string compare "\\" $ksp] then { set TEXT [$E get {insert-1c wordstart} insert] set LISTE [array names I_state "$TEXT*"] if {1 == [llength $LISTE]} then { set sp1 [string length $LISTE] set sp2 [string length $TEXT] if {$sp1 > $sp2} then { erg_insert $E $LISTE [$E index insert] } elseif {$sp1 == $sp2} { Syntax $E {insert-1c wordstart-1c} insert }}}} ############################################# # complition per mouse : the start # ok ! menu .pop_menu -tearoff 0 COLOR .pop_menu proc ergaenzung2 {E} { global I_state set ksp [$E get {insert-1c wordstart-1c} {insert-1c wordstart}] if ![string compare "\\" $ksp] then { set TEXT [$E get {insert-1c wordstart} insert] set sp1 [string length $TEXT] set LISTE [lsort [array names I_state "$TEXT*"]] if {0 < [llength $LISTE]} then { erg2_weiter $E $LISTE $sp1 [$E index insert] }}} ############################################## # complition per mouse : construction proc erg2_weiter {E LISTE laenge index} { global erg2_max T .pop_menu delete 0 end .pop_menu add command -label $T(cancel) if {[llength $LISTE] > $erg2_max} { .pop_menu add command -label $T(more) -command "erg2_weiter $E {[lrange $LISTE $erg2_max end]} $laenge $index" } .pop_menu add separator foreach i [lrange $LISTE 0 [expr $erg2_max - 1]] { if {$laenge == [string length $i]} { .pop_menu add command -label $i } { .pop_menu add command -label $i -command "erg_insert $E $i $index" } } tk_popup .pop_menu [expr [winfo rootx $E] + [lindex [$E bbox insert] 0]] [expr [winfo rooty $E] + [lindex [$E bbox insert] 1]] } ################################### # functions for complitions in general # ok ? proc erg_insert {E T index} { global I_befehl I_back global BeginFlag global erg_flag erg_back $E mark set insert $index set erg_flag($E) 1 undo_switch $E {Save {{insert-1c wordstart-1c} insert} Delete UndoBegin} $E mark set erg_begin insert $E mark gravity erg_begin left $E insert insert $I_befehl($T) $E mark set erg_end insert undo_switch $E {UndoEnd Save UndoMax UndoMul} switch $T begin { $E mark set BeginMark insert-2c set BeginFlag($E) 1 } $E tag add erg_tag erg_begin erg_end $E mark set insert $index set erg_back($E) $I_back($T) } proc erg_proc {E} { global erg_flag global erg_back if $erg_flag($E) then { Syntax $E erg_begin erg_end $E mark set insert "erg_end - $erg_back($E) chars" $E tag remove erg_tag 1.0 end set erg_flag($E) 0 } } @ 1.1 log @Initial revision @ text @d1 90 a90 90 # Copyright (C) 1999 - Martin Strauss - under terms of GPL ################################ # auto complition # ok ! proc ergaenzung {E} { global I_befehl I_back I_state global BeginFlag global erg_flag erg_back set ksp [$E get {insert-1c wordstart-1c} {insert-1c wordstart}] if ![string compare "\\" $ksp] then { set TEXT [$E get {insert-1c wordstart} insert] set LISTE [array names I_state "$TEXT*"] if {1 == [llength $LISTE]} then { set sp1 [string length $LISTE] set sp2 [string length $TEXT] if {$sp1 > $sp2} then { erg_insert $E $LISTE [$E index insert] } elseif {$sp1 == $sp2} { Syntax $E {insert-1c wordstart-1c} insert }}}} ############################################# # complition per mouse : the start # ok ! menu .pop_menu -tearoff 0 COLOR .pop_menu proc ergaenzung2 {E} { global I_state set ksp [$E get {insert-1c wordstart-1c} {insert-1c wordstart}] if ![string compare "\\" $ksp] then { set TEXT [$E get {insert-1c wordstart} insert] set sp1 [string length $TEXT] set LISTE [lsort [array names I_state "$TEXT*"]] if {0 < [llength $LISTE]} then { erg2_weiter $E $LISTE $sp1 [$E index insert] }}} ############################################## # complition per mouse : construction proc erg2_weiter {E LISTE laenge index} { global erg2_max T .pop_menu delete 0 end .pop_menu add command -label $T(cancel) if {[llength $LISTE] > $erg2_max} { .pop_menu add command -label $T(more) -command "erg2_weiter $E {[lrange $LISTE $erg2_max end]} $laenge $index" } .pop_menu add separator foreach i [lrange $LISTE 0 [expr $erg2_max - 1]] { if {$laenge == [string length $i]} { .pop_menu add command -label $i } { .pop_menu add command -label $i -command "erg_insert $E $i $index" } } tk_popup .pop_menu [expr [winfo rootx $E] + [lindex [$E bbox insert] 0]] [expr [winfo rooty $E] + [lindex [$E bbox insert] 1]] } ################################### # functions for complitions in general # ok ? proc erg_insert {E T index} { global I_befehl I_back global BeginFlag global erg_flag erg_back $E mark set insert $index set erg_flag($E) 1 undo_switch $E {Save {{insert-1c wordstart-1c} insert} Delete UndoBegin} $E mark set erg_begin insert $E mark gravity erg_begin left $E insert insert $I_befehl($T) $E mark set erg_end insert undo_switch $E {UndoEnd Save UndoMax UndoMul} switch $T begin { $E mark set BeginMark insert-2c set BeginFlag($E) 1 } $E tag add erg_tag erg_begin erg_end $E mark set insert $index set erg_back($E) $I_back($T) } proc erg_proc {E} { global erg_flag global erg_back if $erg_flag($E) then { Syntax $E erg_begin erg_end $E mark set insert "erg_end - $erg_back($E) chars" $E tag remove erg_tag 1.0 end set erg_flag($E) 0 } } @