public inbox for
 help / color / mirror / Atom feed
* Editor startup HELP!!!!!!!!!!!!!
@ 2001-05-07  7:15 marian
  0 siblings, 0 replies; only message in thread
From: marian @ 2001-05-07  7:15 UTC (permalink / raw)
  To: sourcenav

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 "
    set auto_brace(${cpp},while)  {" \(  \) \{\n\t" "\n\}"}
    set auto_brace(${cpp},do)     {" \{\n\t" "\n\} while \( FALSE \);"}

    bind  $text <braceleft> {
        auto_brace %W

    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
            set tlist [lrange $auto_brace($word) 2 end]
            foreach element $tlist {
                $w insert insert $element
            $w mark set insert $index

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-07  7:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-07  7:15 Editor startup HELP!!!!!!!!!!!!! marian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).