head 1.4; access; symbols; locks mys:1.4; strict; comment @# @; 1.4 date 2000.11.26.18.20.03; author mys; state Exp; branches; next 1.3; 1.3 date 2000.08.15.22.34.13; author mys; state Exp; branches; next 1.2; 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.4 log @*** empty log message *** @ text @# Copyright (C) 1999 - Martin Strauss - under terms of GPL proc NewFile {} { global FocusEditor global FilenameArray UpToDateArray global EDITORNUMMER global etcpath set E [EDITOR] $E.te.edit1 delete 1.0 end set FilenameArray($E) "" set UpToDateArray($E) 0 wm title $E "no name $EDITORNUMMER" if [file exists "$etcpath/default.tex"] then { set f [open "$etcpath/default.tex" r] set x [read $f] $E.te.edit1 insert 1.0 $x set t [close $f] } else { $E.te.edit1 insert end "\\documentclass\[12pt,a4paper\]{report}\n" # $E.te.edit1 insert end "\\usepackage\[german\]{babel}\n" # $E.te.edit1 insert end "\\usepackage{umlaut}\n" $E.te.edit1 insert end "\\begin{document}\n\n" $E.te.edit1 insert end "\\end{document}\n" } Syntax $E.te.edit1 1.0 end set ksp [$E.te.edit1 search "\\begin{document}" 1.0] $E.te.edit1 mark set insert "$ksp + 1 lines" update event generate $E.te.edit1 <> -when tail # after 250 "event generate $E.te.edit1 <> -when tail" } proc NewFileArg {} { global FocusEditor global FilenameArray UpToDateArray global EDITORNUMMER global etcpath set E [EDITOR] $E.te.edit1 delete 1.0 end set FilenameArray($E) "" set UpToDateArray($E) 0 wm title $E "no name $EDITORNUMMER" if [file exists "$etcpath/default.tex"] then { set f [open "$etcpath/default.tex" r] set x [read $f] $E.te.edit1 insert 1.0 $x set t [close $f] } else { $E.te.edit1 insert end "\\documentclass\[12pt,a4paper\]{report}\n" # $E.te.edit1 insert end "\\usepackage\[german\]{babel}\n" # $E.te.edit1 insert end "\\usepackage{umlaut}\n" $E.te.edit1 insert end "\\begin{document}\n\n" $E.te.edit1 insert end "\\end{document}\n" } Syntax $E.te.edit1 1.0 end set ksp [$E.te.edit1 search "\\begin{document}" 1.0] $E.te.edit1 mark set insert "$ksp + 1 lines" update event generate $E.te.edit1 <> -when tail # after 250 "event generate $E.te.edit1 <> -when tail" } proc LoadFile {} { global FilenameArray ModifiedArray directory set types { {{latex Files} {.tex} } {{plain Text} {.txt}} {{All Files} *} } set filename [tk_getOpenFile -filetypes $types -initialdir $directory] LoadFileArg $filename 0 } proc LoadFileArg {filename line} { global FilenameArray UpToDateArray ModifiedArray directory if {[file exists $filename]} then { set directory [file dirname $filename] set E [EDITOR] set f [open $filename r] set x [read $f] $E.te.edit1 insert 1.0 $x set t [close $f] #Set global filename set FilenameArray($E) $filename set UpToDateArray($E) [file mtime "$filename"] wm title $E "$filename" Syntax $E.te.edit1 1.0 end $E.te.edit1 mark set insert "1.0 + $line lines" event generate $E.te.edit1 <> update event generate $E.te.edit1 <> -when tail update focus $E.te.edit1 # after 500 "event generate $E.te.edit1 <> -when tail" # after 500 "focus $E.te.edit1" } } proc ReLoadFileArg {E filename} { global FilenameArray UpToDateArray ModifiedArray directory if {[file exists $filename]} then { set directory [file dirname $filename] set f [open $filename r] set x [read $f] set pos [$E.te.edit1 index insert] $E.te.edit1 delete 1.0 end $E.te.edit1 insert 1.0 $x $E.te.edit1 mark set insert $pos set t [close $f] #Set global filename set FilenameArray($E) $filename set UpToDateArray($E) [file mtime "$filename"] Syntax $E.te.edit1 1.0 end focus $E.te.edit1 # after 500 "event generate $E.te.edit1 <> -when tail" # after 500 "focus $E.te.edit1" } } proc AppendFile {E} { global directory set types { {{latex Files} {.tex} } {{plain Text} {.txt}} {{All Files} *} } set filename [tk_getOpenFile -filetypes $types -initialdir $directory] if {$filename != ""} then { set directory [file dirname $filename] set f [open $filename r] set x [read $f] #Append file at end of text $E.te.edit1 insert insert $x #Close source file set t [close $f] Syntax $E.te.edit1 1.0 end event generate $E.te.edit1 <> }} proc UpToDateFile {E} { global FilenameArray UpToDateArray T if [file exists $FilenameArray($E)] { if { [file mtime $FilenameArray($E)] > $UpToDateArray($E) } { switch [tk_messageBox -parent $E -icon warning -message $T(FileUpToDate) -default yes -type yesno] yes { ReLoadFileArg $E $FilenameArray($E) } no { set UpToDateArray($E) [file mtime $FilenameArray($E)] } } } } proc SaveFile {E} { global FilenameArray UpToDateArray ModifiedArray if {$FilenameArray($E)!= ""} then { UpToDateFile $E if { ![file exists $FilenameArray($E)] || [file mtime $FilenameArray($E)] <= $UpToDateArray($E) } { set f [open $FilenameArray($E) w] #Get text to save set x [$E.te.edit1 get 1.0 end] #Save it puts $f $x #and close file set t [close $f] set ModifiedArray($E.te.edit1) 0 set ModifiedArrayl($E.te.edit1) [string length $x] set UpToDateArray($E) [file mtime $FilenameArray($E)] } } else {SaveAsFile $E} } proc SaveAsFile {E} { global FilenameArray UpToDateArray ModifiedArray directory set types { {{latex Files} {.tex} } {{plain Text} {.txt}} {{All Files} *} } set filename [tk_getSaveFile -filetypes $types -initialfile $FilenameArray($E) -defaultextension ".tex" -initialdir $directory] if {$filename != ""} then { set directory [file dirname $filename] set f [open $filename w] #Get text to save set x [$E.te.edit1 get 1.0 end] #Save it puts $f $x #and close file set t [close $f] set FilenameArray($E) $filename wm title $E "$FilenameArray($E)" set ModifiedArray($E.te.edit1) 0 set UpToDateArray($E) [file mtime $FilenameArray($E)] }} @ 1.3 log @*** empty log message *** @ text @d4 1 a4 1 global FilenameArray d10 1 d33 1 a33 1 global FilenameArray d39 1 d70 1 a70 1 LoadFileArg $filename d73 2 a74 2 proc LoadFileArg {filename} { global FilenameArray ModifiedArray directory d84 1 d87 1 d98 1 a98 1 global FilenameArray ModifiedArray directory d110 1 d138 13 d152 1 a152 1 global FilenameArray ModifiedArray d154 13 a166 9 set f [open $FilenameArray($E) w] #Get text to save set x [$E.te.edit1 get 1.0 end] #Save it puts $f $x #and close file set t [close $f] set ModifiedArray($E.te.edit1) 0 set ModifiedArrayl($E.te.edit1) [string length $x] d171 1 a171 1 global FilenameArray ModifiedArray directory d190 1 @ 1.2 log @*** empty log message *** @ text @d93 19 @ 1.1 log @Initial revision @ text @d1 151 a151 151 # Copyright (C) 1999 - Martin Strauss - under terms of GPL proc NewFile {} { global FocusEditor global FilenameArray global EDITORNUMMER global etcpath set E [EDITOR] $E.te.edit1 delete 1.0 end set FilenameArray($E) "" wm title $E "no name $EDITORNUMMER" if [file exists "$etcpath/default.tex"] then { set f [open "$etcpath/default.tex" r] set x [read $f] $E.te.edit1 insert 1.0 $x set t [close $f] } else { $E.te.edit1 insert end "\\documentclass\[12pt,a4paper\]{report}\n" # $E.te.edit1 insert end "\\usepackage\[german\]{babel}\n" # $E.te.edit1 insert end "\\usepackage{umlaut}\n" $E.te.edit1 insert end "\\begin{document}\n\n" $E.te.edit1 insert end "\\end{document}\n" } Syntax $E.te.edit1 1.0 end set ksp [$E.te.edit1 search "\\begin{document}" 1.0] $E.te.edit1 mark set insert "$ksp + 1 lines" update event generate $E.te.edit1 <> -when tail # after 250 "event generate $E.te.edit1 <> -when tail" } proc NewFileArg {} { global FocusEditor global FilenameArray global EDITORNUMMER global etcpath set E [EDITOR] $E.te.edit1 delete 1.0 end set FilenameArray($E) "" wm title $E "no name $EDITORNUMMER" if [file exists "$etcpath/default.tex"] then { set f [open "$etcpath/default.tex" r] set x [read $f] $E.te.edit1 insert 1.0 $x set t [close $f] } else { $E.te.edit1 insert end "\\documentclass\[12pt,a4paper\]{report}\n" # $E.te.edit1 insert end "\\usepackage\[german\]{babel}\n" # $E.te.edit1 insert end "\\usepackage{umlaut}\n" $E.te.edit1 insert end "\\begin{document}\n\n" $E.te.edit1 insert end "\\end{document}\n" } Syntax $E.te.edit1 1.0 end set ksp [$E.te.edit1 search "\\begin{document}" 1.0] $E.te.edit1 mark set insert "$ksp + 1 lines" update event generate $E.te.edit1 <> -when tail # after 250 "event generate $E.te.edit1 <> -when tail" } proc LoadFile {} { global FilenameArray ModifiedArray directory set types { {{latex Files} {.tex} } {{plain Text} {.txt}} {{All Files} *} } set filename [tk_getOpenFile -filetypes $types -initialdir $directory] LoadFileArg $filename } proc LoadFileArg {filename} { global FilenameArray ModifiedArray directory if {[file exists $filename]} then { set directory [file dirname $filename] set E [EDITOR] set f [open $filename r] set x [read $f] $E.te.edit1 insert 1.0 $x set t [close $f] #Set global filename set FilenameArray($E) $filename wm title $E "$filename" Syntax $E.te.edit1 1.0 end event generate $E.te.edit1 <> update event generate $E.te.edit1 <> -when tail update focus $E.te.edit1 # after 500 "event generate $E.te.edit1 <> -when tail" # after 500 "focus $E.te.edit1" } } proc AppendFile {E} { global directory set types { {{latex Files} {.tex} } {{plain Text} {.txt}} {{All Files} *} } set filename [tk_getOpenFile -filetypes $types -initialdir $directory] if {$filename != ""} then { set directory [file dirname $filename] set f [open $filename r] set x [read $f] #Append file at end of text $E.te.edit1 insert insert $x #Close source file set t [close $f] Syntax $E.te.edit1 1.0 end event generate $E.te.edit1 <> }} proc SaveFile {E} { global FilenameArray ModifiedArray if {$FilenameArray($E)!= ""} then { set f [open $FilenameArray($E) w] #Get text to save set x [$E.te.edit1 get 1.0 end] #Save it puts $f $x #and close file set t [close $f] set ModifiedArray($E.te.edit1) 0 set ModifiedArrayl($E.te.edit1) [string length $x] } else {SaveAsFile $E} } proc SaveAsFile {E} { global FilenameArray ModifiedArray directory set types { {{latex Files} {.tex} } {{plain Text} {.txt}} {{All Files} *} } set filename [tk_getSaveFile -filetypes $types -initialfile $FilenameArray($E) -defaultextension ".tex" -initialdir $directory] if {$filename != ""} then { set directory [file dirname $filename] set f [open $filename w] #Get text to save set x [$E.te.edit1 get 1.0 end] #Save it puts $f $x #and close file set t [close $f] set FilenameArray($E) $filename wm title $E "$FilenameArray($E)" set ModifiedArray($E.te.edit1) 0 }} @