2004/12/04 - [CB] This was a little piece of fun I had playing with code for my new editor project in progress [viTHE]. I have backported it to Richard Suchenwirth's [A minimal editor]. It is a little fragile in this form (You probably don't want to click the right mouse button if the first line of the file you are editing starts with " .."). Adding a tcl command line allows an increase in the potential abilities of this editor out of all proportion to it's size. (Although one would have to come up with some utility procs for it to be really useful). # Minimally extended Minimal editor # set about "minEd - a minimally extended minimal editor Richard Suchenwirth 2003 -- Modified 2004 Connor Berry F1: help F2: load F3: save F4: navigate filesystem " pack [entry .cline] -side bottom -fill x ;# ADDED pack [scrollbar .y -command ".t yview"] -side right -fill y pack [text .t -wrap word -yscrollc ".y set"] -side right -fill both -expand 1 bind . {tk_messageBox -message $about} bind . {loadText .t [tk_getOpenFile]} bind . {saveText .t [tk_getSaveFile]} bind .cline {process_cline} ;# ADDED bind . {showDir} ;# ADDED bind .t {view} ;# ADDED # Modified if {$argv != ""} { loadText .t [lindex $argv 0] } else { append instructions "F1 for minimal help\n" append instructions "F2 for load dialog\n" append instructions "F3 for save dialog\n" append instructions "F4 for interactive filesystem navigation --\n" append instructions " Click left button to select and right button to view\n\n" append instructions "Tcl commands can be run from command line at bottom" .t insert end $instructions } proc loadText {w fn} { if {$fn==""} return wm title . [file tail $fn] set fp [open $fn] $w delete 1.0 end $w insert end [read $fp] close $fp } proc saveText {w fn} { if {$fn==""} return set fp [open $fn w] puts -nonewline $fp [$w get 1.0 "end - 1 c"] close $fp } # ADDED proc process_cline {} { set my_cmd [.cline get] uplevel #0 $my_cmd .cline delete 0 end } # ADDED proc showDir {} { .t delete 1.0 end .t insert 1.0 [list_dir] .t mark set insert 1.end } # ADDED proc list_dir {} { append output " ..\n" foreach item [glob -nocomplain *] { if {[file isdirectory $item]} { append output " $item\n" } else { append output " $item\n" } } return $output } # ADDED proc view {} { if {[string match " .." [.t get 1.0 1.end]]} { set cursor_pos [.t index insert] set line [expr int($cursor_pos)] set line_text [.t get ${line}.0 ${line}.end] if {[string first "" $line_text] == -1} { set filename [string trimleft $line_text] .t delete 1.0 end loadText .t $filename } else { set dirname [string trimleft [string replace $line_text 0 5]] puts $dirname cd $dirname showDir } } }