head 1.3; access; symbols; locks mys:1.3; strict; comment @# @; 1.3 date 2000.04.11.21.41.24; author mys; state Exp; branches; next 1.2; 1.2 date 99.11.22.14.31.17; 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.3 log @*** empty log message *** @ text @# Copyright (C) 1999 - Martin Strauss - under terms of GPL ############################################################################## # Umdefinition des Defaultverhaltens fuer Text-variablen bind Text {} bind Text {} # Block Anfang bind Text { set BlockBeginFlag 1 %W mark set BlockBegin insert if {[string compare %W $BlockEditor] == 0} then { if $BlockEndFlag then { %W tag remove BlockTag 1.0 end %W tag add BlockTag BlockBegin BlockEnd }} else { if {$BlockBeginFlag && $BlockEndFlag} then { $BlockEditor tag remove BlockTag 1.0 end } set BlockEndFlag 0 set BlockEditor %W } } # Block Ende bind Text { set BlockEndFlag 1 %W mark set BlockEnd insert %W mark gravity BlockEnd left if {[string compare %W $BlockEditor] == 0} then { if $BlockBeginFlag then { %W tag remove BlockTag 1.0 end %W tag add BlockTag BlockBegin BlockEnd }} else { if {$BlockBeginFlag && $BlockEndFlag} then { $Blockeditor tag remove BlockTag 1.0 end } set BlockBeginFlag 0 set BlockEditor %W } } # Block kopieren bind Text { if {$BlockBeginFlag && $BlockEndFlag} then { set ksp [%W index {insert linestart}] undo_switch %W {Save UndoBegin} %W insert insert [$BlockEditor get BlockBegin BlockEnd] undo_switch %W {UndoEnd Save UndoMax} Syntax %W $ksp "insert lineend" } } # Block verschieben bind Text { if {$BlockBeginFlag && $BlockEndFlag} then { set ksp [%W index "insert linestart"] undo_switch %W {Save UndoBegin} %W insert insert [$BlockEditor get BlockBegin BlockEnd] undo_switch %W {UndoEnd Save} undo_switch $BlockEditor {{BlockBegin BlockEnd} Delete UndoMax} if {[string compare %W $BlockEditor] == 0} then { undo_switch %W UndoMul } Syntax %W $ksp "insert lineend" Syntax $BlockEditor "BlockBegin linestart" "BlockEnd lineend" } } bind Text { event generate %W event generate %W } # Block loeschen bind Text { if {$BlockBeginFlag && $BlockEndFlag} then { undo_switch $BlockEditor {Save {BlockBegin BlockEnd} Delete UndoMax} } } # Block auskommentieren proc AusKomm {E A B} { set i [lindex "[split [$E index $A] .]" 0] set i_max [lindex "[split [$E index $B] .]" 0] incr i_max set ksp $i.0 while {$i < $i_max} { if [expr [string compare [$E get "$i.0 linestart" "$i.0 linestart+1c"] "%"] != 0] { $E insert "$i.0 linestart" "%" } incr i } Syntax $E $ksp $i_max.0 event generate $E <> } # Block auskommentieren rueckgaengig proc AusKommRueck {E A B} { set i [lindex "[split [$E index $A] .]" 0] set i_max [lindex "[split [$E index $B] .]" 0] incr i_max set ksp $i.0 while {$i < $i_max} { if [expr [string compare [$E get "$i.0 linestart" "$i.0 linestart+1c"] "%"] == 0] { $E delete "$i.0 linestart" "$i.0 linestart+1c" } incr i } Syntax $E $ksp $i_max.0 event generate $E <> } switch $tcl_platform(platform) windows { # Auf jedenfall fuer Windows !!! bind Text <%> { if { $BlockBeginFlag && $BlockEndFlag} then { AusKomm %W BlockBegin BlockEnd } } } unix { # fuer linux ??? bind Text { if { $BlockBeginFlag && $BlockEndFlag} then { AusKomm %W BlockBegin BlockEnd } } } bind Text { if { $BlockBeginFlag && $BlockEndFlag} then { AusKommRueck %W BlockBegin BlockEnd } } # Block in Clipboard kopieren bind Text { if { $BlockBeginFlag && $BlockEndFlag} then { clipboard clear -displayof %W catch {clipboard append -displayof %W [$BlockEditor get BlockBegin BlockEnd]} } } # aus Clipboard kopieren bind Text

{ set ksp [%W index {insert linestart}] undo_switch %W {Save UndoBegin} tk_textPaste %W undo_switch %W {UndoEnd Save UndoMax} Syntax %W $ksp "insert lineend" } bind Text {break} bind Text { undo_switch %W {Save UndoBegin} catch {tkTextInsert %W [selection get -displayof %W]} undo_switch %W {UndoEnd Save} } # Block eliminieren bind Text { set BlockBeginFlag 0 set BlockEndFlag 0 if {[lsearch [array names ModifiedArray] %W] != -1} { unset ModifiedArray(%W) } if {[lsearch [array names UndoArray] %W] != -1} { unset UndoArray(%W) } if {[lsearch [array names FilenameArray] %W] != -1} { unset FilenameArray(%W) } } # Zeile aus Text loeschen bind Text { undo_switch %W {{"insert linestart" "insert lineend+1c"} Delete} } bind Text { if $FocusEditorFlag { focus $FocusEditor.te.edit1 set ksp [$FocusEditor.te.edit1 get {insert wordstart-1c} {insert wordstart}] if ![string compare "\\" $ksp] then { set Text [$FocusEditor.te.edit1 get {insert wordstart} {insert wordend}] if {[llength [array names I_befehl $Text]] != 1} {set Text "\\section"} else {set Text "\\$Text"} } {set Text "\\section"} set ksp [$FocusEditor.te.edit1 search -- $Text {insert wordend} end] if {$ksp != ""} then { $FocusEditor.te.edit1 mark set insert "$ksp + 1 chars" $FocusEditor.te.edit1 see insert event generate $FocusEditor.te.edit1 <> -when tail }}} bind Text { if $FocusEditorFlag { focus $FocusEditor.te.edit1 set ksp [$FocusEditor.te.edit1 get {insert wordstart-1c} {insert wordstart}] if ![string compare "\\" $ksp] then { set Text [$FocusEditor.te.edit1 get {insert wordstart} {insert wordend}] if {[llength [array names I_befehl $Text]] != 1} {set Text "\\section"} else {set Text "\\$Text"} } {set Text "\\section"} set ksp [$FocusEditor.te.edit1 search -backwards -- $Text {insert wordstart-1c} 1.0] if {$ksp != ""} then { $FocusEditor.te.edit1 mark set insert "$ksp + 1 chars" $FocusEditor.te.edit1 see insert event generate $FocusEditor.te.edit1 <> -when tail }}} bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 section } } bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 unsection } } bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 line } } bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 unline } } # Was passiert wenn man ein Fenster vernichtet bind Toplevel { # Fenster war Master dann Master loeschen if $MasterFlag then {if {[string compare $Master %W] == 0} then {set MasterFlag 0}} if $FocusEditorFlag then {if {[string compare $FocusEditor %W] == 0} then {set FocusEditorFlag 0}} } bind Text { if $erg_flag(%W) then { if {[%W get insert insert+1c] == "%A"} then { %W mark set insert insert+1c continue } else { erg_proc %W } } if {"%A" != "{}"} then { undo_switch %W {SelSave UndoBegin} tkTextInsert %W %A undo_switch %W {UndoEnd SelMul} if $BeginFlag(%W) then { %W insert BeginMark %A undo_switch %W BeginMark } event generate %W <> event generate %W <> if $KlammerFlag then { switch -- "%A" "(" { tkTextInsert %W ")" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c } "\{" { if {[string compare [%W get insert-2c] "\\"] == 0} { tkTextInsert %W "\\\}" undo_switch %W UndoEnd tkTextSetCursor %W insert-2c } { tkTextInsert %W "\}" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c } } "\[" { if {[string compare [%W get insert-2c] "\\"] == 0} { tkTextInsert %W "\\\]" undo_switch %W UndoEnd tkTextSetCursor %W insert-2c } { tkTextInsert %W "\]" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c } } "$" { tkTextInsert %W "$" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c }}}} @ 1.2 log @+ \{ wird automatisch mit \{ ergaenzt, analog \[ mit \] bisher wurde nur die Klammer selbst ergaenzt @ text @d1 273 a273 273 # Copyright (C) 1999 - Martin Strauss - under terms of GPL ############################################################################## # Umdefinition des Defaultverhaltens fuer Text-variablen bind Text {} bind Text {} # Block Anfang bind Text { set BlockBeginFlag 1 %W mark set BlockBegin insert if {[string compare %W $BlockEditor] == 0} then { if $BlockEndFlag then { %W tag remove BlockTag 1.0 end %W tag add BlockTag BlockBegin BlockEnd }} else { if {$BlockBeginFlag && $BlockEndFlag} then { $BlockEditor tag remove BlockTag 1.0 end } set BlockEndFlag 0 set BlockEditor %W } } # Block Ende bind Text { set BlockEndFlag 1 %W mark set BlockEnd insert %W mark gravity BlockEnd left if {[string compare %W $BlockEditor] == 0} then { if $BlockBeginFlag then { %W tag remove BlockTag 1.0 end %W tag add BlockTag BlockBegin BlockEnd }} else { if {$BlockBeginFlag && $BlockEndFlag} then { $Blockeditor tag remove BlockTag 1.0 end } set BlockBeginFlag 0 set BlockEditor %W } } # Block kopieren bind Text { if {$BlockBeginFlag && $BlockEndFlag} then { set ksp [%W index {insert linestart}] undo_switch %W {Save UndoBegin} %W insert insert [$BlockEditor get BlockBegin BlockEnd] undo_switch %W {UndoEnd Save UndoMax} Syntax %W $ksp "insert lineend" } } # Block verschieben bind Text { if {$BlockBeginFlag && $BlockEndFlag} then { set ksp [%W index "insert linestart"] undo_switch %W {Save UndoBegin} %W insert insert [$BlockEditor get BlockBegin BlockEnd] undo_switch %W {UndoEnd Save} undo_switch $BlockEditor {{BlockBegin BlockEnd} Delete UndoMax} if {[string compare %W $BlockEditor] == 0} then { undo_switch %W UndoMul } Syntax %W $ksp "insert lineend" Syntax $BlockEditor "BlockBegin linestart" "BlockEnd lineend" } } bind Text { event generate %W event generate %W } # Block loeschen bind Text { if {$BlockBeginFlag && $BlockEndFlag} then { undo_switch $BlockEditor {Save {BlockBegin BlockEnd} Delete UndoMax} } } # Block auskommentieren proc AusKomm {E A B} { set i [lindex "[split [$E index $A] .]" 0] set i_max [lindex "[split [$E index $B] .]" 0] incr i_max set ksp $i.0 while {$i < $i_max} { if [expr [string compare [$E get "$i.0 linestart" "$i.0 linestart+1c"] "%"] != 0] { $E insert "$i.0 linestart" "%" } incr i } Syntax $E $ksp $i_max.0 event generate $E <> } # Block auskommentieren rueckgaengig proc AusKommRueck {E A B} { set i [lindex "[split [$E index $A] .]" 0] set i_max [lindex "[split [$E index $B] .]" 0] incr i_max set ksp $i.0 while {$i < $i_max} { if [expr [string compare [$E get "$i.0 linestart" "$i.0 linestart+1c"] "%"] == 0] { $E delete "$i.0 linestart" "$i.0 linestart+1c" } incr i } Syntax $E $ksp $i_max.0 event generate $E <> } switch $tcl_platform(platform) windows { # Auf jedenfall fuer Windows !!! bind Text <%> { if { $BlockBeginFlag && $BlockEndFlag} then { AusKomm %W BlockBegin BlockEnd } } } unix { # fuer linux ??? bind Text { if { $BlockBeginFlag && $BlockEndFlag} then { AusKomm %W BlockBegin BlockEnd } } } bind Text { if { $BlockBeginFlag && $BlockEndFlag} then { AusKommRueck %W BlockBegin BlockEnd } } # Block in Clipboard kopieren bind Text { if { $BlockBeginFlag && $BlockEndFlag} then { clipboard clear -displayof %W catch {clipboard append -displayof %W [$BlockEditor get BlockBegin BlockEnd]} } } # aus Clipboard kopieren bind Text

{ set ksp [%W index {insert linestart}] undo_switch %W {Save UndoBegin} tk_textPaste %W undo_switch %W {UndoEnd Save UndoMax} Syntax %W $ksp "insert lineend" } bind Text {break} bind Text { undo_switch %W {Save UndoBegin} catch {tkTextInsert %W [selection get -displayof %W]} undo_switch %W {UndoEnd Save} } # Block eliminieren bind Text { set BlockBeginFlag 0 set BlockEndFlag 0 if {[lsearch [array names ModifiedArray] %W] != -1} { unset ModifiedArray(%W) } if {[lsearch [array names UndoArray] %W] != -1} { unset UndoArray(%W) } if {[lsearch [array names FilenameArray] %W] != -1} { unset FilenameArray(%W) } } # Zeile aus Text loeschen bind Text { undo_switch %W {{"insert linestart" "insert lineend+1c"} Delete} } bind Text { if $FocusEditorFlag { focus $FocusEditor.te.edit1 set ksp [$FocusEditor.te.edit1 get {insert wordstart-1c} {insert wordstart}] if ![string compare "\\" $ksp] then { set Text [$FocusEditor.te.edit1 get {insert wordstart} {insert wordend}] if {[llength [array names I_befehl $Text]] != 1} {set Text "\\section"} else {set Text "\\$Text"} } {set Text "\\section"} set ksp [$FocusEditor.te.edit1 search -- $Text {insert wordend} end] if {$ksp != ""} then { $FocusEditor.te.edit1 mark set insert "$ksp + 1 chars" $FocusEditor.te.edit1 see insert event generate $FocusEditor.te.edit1 <> -when tail }}} bind Text { if $FocusEditorFlag { focus $FocusEditor.te.edit1 set ksp [$FocusEditor.te.edit1 get {insert wordstart-1c} {insert wordstart}] if ![string compare "\\" $ksp] then { set Text [$FocusEditor.te.edit1 get {insert wordstart} {insert wordend}] if {[llength [array names I_befehl $Text]] != 1} {set Text "\\section"} else {set Text "\\$Text"} } {set Text "\\section"} set ksp [$FocusEditor.te.edit1 search -backwards -- $Text {insert wordstart-1c} 1.0] if {$ksp != ""} then { $FocusEditor.te.edit1 mark set insert "$ksp + 1 chars" $FocusEditor.te.edit1 see insert event generate $FocusEditor.te.edit1 <> -when tail }}} bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 section } } bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 unsection } } bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 line } } bind Text { if $FocusEditorFlag { Line_breaking_switch $FocusEditor.te.edit1 unline } } # Was passiert wenn man ein Fenster vernichtet bind Toplevel { # Fenster war Master dann Master loeschen if $MasterFlag then {if {[string compare $Master %W] == 0} then {set MasterFlag 0}} if $FocusEditorFlag then {if {[string compare $FocusEditor %W] == 0} then {set FocusEditorFlag 0}} } bind Text { if $erg_flag(%W) then { if {[%W get insert insert+1c] == "%A"} then { %W mark set insert insert+1c continue } else { erg_proc %W } } if {"%A" != "{}"} then { undo_switch %W {SelSave UndoBegin} tkTextInsert %W %A undo_switch %W {UndoEnd SelMul} if $BeginFlag(%W) then { %W insert BeginMark %A undo_switch %W BeginMark } event generate %W <> event generate %W <> if $KlammerFlag then { switch -- "%A" "(" { tkTextInsert %W ")" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c } "\{" { if {[string compare [%W get insert-2c] "\\"] == 0} { tkTextInsert %W "\\\}" undo_switch %W UndoEnd tkTextSetCursor %W insert-2c } { tkTextInsert %W "\}" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c } } "\[" { if {[string compare [%W get insert-2c] "\\"] == 0} { tkTextInsert %W "\\\]" undo_switch %W UndoEnd tkTextSetCursor %W insert-2c } { tkTextInsert %W "\]" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c } } "$" { tkTextInsert %W "$" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c }}}} @ 1.1 log @Initial revision @ text @d250 9 a258 3 tkTextInsert %W "\}" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c d260 9 a268 3 tkTextInsert %W "\]" undo_switch %W UndoEnd tkTextSetCursor %W insert-1c @