[62] in bug-owl
another edge case in transpose-chars
daemon@ATHENA.MIT.EDU (Jeremy Daniel)
Mon Jul 22 10:55:17 2002
To: bug-owl@MIT.EDU
From: Jeremy Daniel <jdaniel@MIT.EDU>
Date: 22 Jul 2002 10:47:52 -0400
Message-ID: <skefzybg6p3.fsf@multics.mit.edu>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
This time I missed the edge case of only one character in buffer and
cursor after it. I don't see how I could still be missing anything,
so hopefully this is the last of it.
/mit/jdaniel/project/owl/build-cvs/patches/transpose-chars.patch
----------
Index: commands.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/commands.c,v
retrieving revision 1.12
diff -r1.12 commands.c
573a574,578
> OWLCMD_VOID_CTX("edit:transpose-chars", owl_editwin_transpose_chars,
> OWL_CTX_EDIT,
> "Interchange characters around point, moving forward one character.",
> "", ""),
>
Index: editwin.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/editwin.c,v
retrieving revision 1.6
diff -r1.6 editwin.c
369a370,400
> void owl_editwin_transpose_chars(owl_editwin *e) {
> /* Swap the character at point with the character at point-1 and
> * advance the pointer. If point is at beginning of buffer do
> * nothing. If point is after the last character swap point-1 with
> * point-2. (Behaves as observed in tcsh and emacs).
> */
>
> int z;
> char tmp;
>
> if (e->bufflen==0) return;
>
> /* get the cursor point */
> z=_owl_editwin_get_index_from_xy(e);
>
> if (z==e->bufflen) {
> /* point is after last character */
> z--;
> }
>
> if (z-1 < e->lock) {
> /* point is at beginning of buffer, do nothing */
> return;
> }
>
> tmp=e->buff[z];
> e->buff[z]=e->buff[z-1];
> e->buff[z-1]=tmp;
> owl_editwin_key_right(e);
> }
>
Index: keys.c
===================================================================
RCS file: /mit/ktools/src/owl/repository/owl/keys.c,v
retrieving revision 1.10
diff -r1.10 keys.c
71a72,73
> BIND_CMD("C-t", "edit:transpose-chars", "");
>
----------
Jer
------------------------------------------------------------------
Tulgey Wood - tulgeywood@attbi.com Cell Phone: 617-429-8573 /
4 Farragut Ave (617-629-3983) jdaniel-phone@mit.edu
Somerville, MA 02144-1709 AIM: jdanielmit
Zephyr athena users over the web: http://webzephyr.mit.edu/