From: marian <marian@mail.jozep.com.au>
To: sourcenav@sources.redhat.com
Subject: Help Indented text
Date: Mon, 07 May 2001 04:47:00 -0000 [thread overview]
Message-ID: <3AF68A47.674D2BBE@mail.jozep.com.au> (raw)
I have this little patch to give me auto brace completion, which call
should I use to get proper indenting.
I have used the tkTextInsert but this does not give correct nested
indenting.
proc sn_rc_editor {view text} {
global auto_brace
global sn_text_highlight_group
if {$sn_text_highlight_group($text) == "c++"} {
set auto_brace(for) {" \( ; ; \) \{\n\t" "\n\}"}
set auto_brace(if) {" \( FALSE \) \{\n\t" "\n\}"}
set auto_brace(else) {" \{\n\t" "\n\}"}
set auto_brace(switch) {" \( \) \{\n\tcase "
":\n\tdefault:\n\}"}
set auto_brace(while) {" \( \) \{\n\t" "\n\}"}
set auto_brace(do) {" \{\n\t" "\n\} while \( FALSE \);"}
# Auto build regexp string
set names [array names auto_brace]
set names [ join $names | ]
set auto_brace(names) $names
bind $text <braceleft> {auto_brace %W; break}
}
if {$sn_text_highlight_group($text) == "tcl"} {
}
proc auto_brace {W} {
global auto_brace
global sn_text_highlight_group
set word [$W get "insert -1 chars wordstart" insert]
if { [regexp {[$auto_brace(names)]} $word {}] } {
tkTextInsert $w insert [lindex $auto_brace($word) 0]
set index [$W index insert]
tkTextInsert $w 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 {
ac_paste $W $element
}
$W mark set insert $index
}
}
}
reply other threads:[~2001-05-07 4:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3AF68A47.674D2BBE@mail.jozep.com.au \
--to=marian@mail.jozep.com.au \
--cc=sourcenav@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).