This is the mail archive of the
sourcenav@sources.redhat.com
mailing list for the Source Navigator.
Editor startup HELP!!!!!!!!!!!!!
- To: "sourcenav at sources dot redhat dot com" <sourcenav at sources dot redhat dot com>
- Subject: Editor startup HELP!!!!!!!!!!!!!
- From: marian <marian at mail dot jozep dot com dot au>
- Date: Tue, 08 May 2001 00:10:56 +1000
- Organization: JOZEP
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 <braceleft> {
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
}
}
}