Twiddle?

New Message Reply Date view Thread view Subject view Author view

From: Masatsugu Nagata (nagata@kurims.kyoto-u.ac.jp)
Date: 8 Mar 01, 01:25 EST


From: Masatsugu Nagata <nagata@kurims.kyoto-u.ac.jp>
Subject: Twiddle?

David Craig wrote on the "twiddling" features:

> (i) twiddling the characters which straddle the cursor, and
> (ii) not ignoring spaces
> [snip]
> it would be preferable for twiddle to return with the cursor where it
> was to begin with: in between the twiddled characters, nothing selected.

I prefer all of the above three points.  That is, I dislike the current
7.4.1 implememtation of 'twiddle' in that it is against the points
(i) and (ii).  I'd also dislike it if Mr. Noyb's proc is against the
third point.

Among the three, I agree with David that the point (ii) is by far the
most impoirtant.  David wrote:
> (If I want to ignore spaces, I can do so by my cursor
> placement.  I have never encountered a situation where the current
> default behaviour seemed to me to be desirable -- I'd be curious if
> anyone has counterexamples.)
I wholeheartedly agree with you on this point, David.

Now, here is the proc 'transposeChars' (originally written by Pete, I 
think), which satisfies all of the above three points.  I have been
happily using this proc for a long time.

proc transposeChars {} {
	set pos [getPos]
	if {!$pos || ($pos == [maxPos])} return;
	if {[string length [set text [getSelect]]]} {
		if {[string length $text] == 1} {
			return
		} else {
			set sel [expr [selEnd] - 1]
			set one [lookAt $sel]
			set two [lookAt $pos]
			replaceText $pos [expr $sel + 1] \
"$one[getText [expr $pos+1] $sel]$two"
			select $pos [expr $sel+1]
			return
		}
	}
	set one [lookAt $pos]
	set two [lookAt [expr $pos-1]]
	replaceText [expr $pos-1] [expr $pos + 1] "$one$two"
	goto $pos
}


You can add this proc definition into your 'prefs.tcl' file,
maybe after renaming the above "transposeChars" name to "twiddle"
and the line:

auto_load twiddle

added outside of the "proc twiddle" definition (inside 'prefs.tcl')
so that the (evil) "twiddle" proc definition (in 'textManip.tcl')
will not get loaded.

Hope this helps.

Mark
-- 
Mark Nagata
mailto:nagata@kurims.kyoto-u.ac.jp


P.S.  No, I don't (mean to) do "one-sided conversation".
All of the messages that I've mentioned there were messages I've
received from either one of the "ALPHA-D"/"alphatcl-developers"/
"alphatcl-users" mailing lists.  It seems that some messages have
trouble propagating to all subscribers...?

_______________________________________________
AlphaTcl-developers mailing list
AlphaTcl-developers@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/alphatcl-developers


New Message Reply Date view Thread view Subject view Author view

This archive was generated by das@users.sourceforge.net with hypermail 2b29 on 31 Mar 01, 11:51 EST