What's wrong with this ?...

Ian Gilmour ian.gilmour@ffei.co.uk
Tue Sep 26 09:36:00 GMT 2000

OK - first off I admit I'm no tcl or tk expert. So apologies if this is
obvious to some of you.

Basically all I'm trying to do is add an "Extras" menu to the editor window
with an option to run XEmacs, vi, or indent on the currently edited file. I
know I probably need some more checks in all of this but I'm just trying to
get the basics working for now.

So I've got the following in my rc.tcl file...

It basically works, except that if I edit the file in snavigator I need to
explicitely save it (via "File"->"Save" menu option or ^S) for it to
autoupdate the editor window when I run the indent option. i.e. It saves the
file correctly for indent to work on it, but doesn't reload the indented
file and refresh the display.

What am I doing wrong ? What do I need to do to remove the need to perform
an explicit Save file ?

How do it I tell it I've already performed the save and force the editor
window to be updated ?

Is there more detailed documentation than the programmer''s ref. for all of

Is there a library of typical rc.tcl, etc. config files anywhere ?

Anyone interfaced PVCS and willing to share there
sn_add_version_control_system() config ?

Any help much appreciated. 

(PS. I'm running snavigator 4.5.1 under solaris)



-------- snippet from rc.tcl --------------------------------

proc editor_extras {symboltype view} {
    global sn_options

    set e [$view editor]
    set f [$view getfilename]
    # Select local option
    switch -- $symboltype {
	"Xemacs" {
	    if {[sn_save_file $e $f] == 1} {
		exec xemacs $f +1 &
	"vi" {
	    if {[sn_save_file $e $f] == 1} {
		exec xterm -T $f -e vi $f &
	"Reload" {
	    sn_parse_uptodate $f
	"Indent" {
	    if {[sn_save_file $e $f] == 1} {
		exec indent -npro -ts0 -l120 -lc120 -c40 -bli0 -ncs -bl
-npsl -nhnl -ncs -i2 $f
	    sn_parse_uptodate $f
	default {
	    sn_error_dialog \
		"$symboltype on $f not implemented yet."

proc sn_rc_editor {view text} {
    global tcl_platform

    set topw [winfo toplevel $view]
    set tool_frame $topw.exp
    set menu_frame $topw.menu
    set extras $menu_frame.extras

    # Create a new menu called "Extras".
    menu $extras -tearoff 0
    # Add a menu item to the menu. The second character is
    # the designated hot key. Place this menu fourth in
    # the menu bar.
    $menu_frame insert 3 cascade -label Extras -underline 1 \
	-menu $extras
    # Add items to the menu.
    $extras add command -label "Xemacs" -command \
	"editor_extras Xemacs $view" -underline 0
    $extras add command -label "vi"  -command \
	"editor_extras vi $view" -underline 0
    $extras add command -label "C-Indent" -command \
	"editor_extras Indent $view" -underline 0
    $extras add command -label "Reload file"  -command \
	"editor_extras Reload $view" -underline 0

More information about the Sourcenav mailing list