From mboxrd@z Thu Jan 1 00:00:00 1970 From: marian To: "sourcenav@sources.redhat.com" Subject: Editor startup HELP!!!!!!!!!!!!! Date: Mon, 07 May 2001 07:15:00 -0000 Message-id: <3AF6ACF0.1C474C82@mail.jozep.com.au> X-SW-Source: 2001-q2/msg00138.html The manual says that if I want to override behaviour in the editor I need to put code in .sn/rc.tcl. I have done this and find I have odd behaviour in all versions of sourcenav 4.2, 99r1, and 5.0. If I exit from sn with an editor window open, when I restart the same project in sn the previous editor window opens, but the behaviour I have placed in the rc.tcl does not work for this window. If I open a new editor window then the behaviour is there. The code will complete braces, type for{ and it will put for ( ; ; ) { } I like this style. But it only does this in newly opened editor windows. Desperately need help!!!!!!!!!!!!!!!!!!!!!!! This is the source put it in .sn/rc.tcl proc sn_rc_editor {view text} { global auto_brace global sn_text_highlight_group puts stdout $view puts stdout $text puts stdout $sn_text_highlight_group($text) set cpp "c++" set auto_brace(${cpp},for) {" \( ; ; \) \{\n\t" "\n\}"} set auto_brace(${cpp},if) {" \( FALSE \) \{\n\t" "\n\}"} set auto_brace(${cpp},else) {" \{\n\t" "\n\}"} set auto_brace(${cpp},switch) {" \( \) \{\n\tcase " ":\n\tdefault:\n\}"} set auto_brace(${cpp},while) {" \( \) \{\n\t" "\n\}"} set auto_brace(${cpp},do) {" \{\n\t" "\n\} while \( FALSE \);"} bind $text { auto_brace %W break } proc auto_brace {w} { global auto_brace global sn_text_highlight_group set word $sn_text_highlight_group($w) set word ${word},[$w get "insert -1 chars wordstart" insert] if { [info exists auto_brace($word)] == 1 } { $w insert insert [lindex $auto_brace($word) 0] set index [$w index insert] $w insert insert [lindex $auto_brace($word) 1] # Crunch out any trailing elements to make it all a bit tidier set tlist [lrange $auto_brace($word) 2 end] foreach element $tlist { $w insert insert $element } $w mark set insert $index } } }