From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16652 invoked from network); 17 Jan 1997 14:03:06 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 17 Jan 1997 14:03:06 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id JAA28593; Fri, 17 Jan 1997 09:08:42 -0500 (EST) Resent-Date: Fri, 17 Jan 1997 09:08:42 -0500 (EST) Message-Id: <199701171409.PAA11641@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Tracking emacs mark Date: Fri, 17 Jan 1997 15:09:13 +0100 From: Peter Stephenson Resent-Message-ID: <"RXUPF1.0.i-6.fVuto"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2807 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu This is what I had in mind for managing the emacs mark properly: the way I've written it it scarcely involves any extra code. The may be other places which need altering, but most of the code is careful to use spaceinline() and the kill and del functions. This is for 3.0.3 and may well clash with one or other of Zefram's zle patches. Also, I haven't done anything with the undo mechanism as that's changing, but it would presumably be easy to record the mark before and after (and should be done, for consistency). *** Src/zle_utils.c.mark Fri Jan 17 14:43:32 1997 --- Src/zle_utils.c Fri Jan 17 15:00:08 1997 *************** *** 55,60 **** --- 55,79 ---- line[i + ct] = line[i]; ll += ct; line[ll] = '\0'; + + if (mark >= cs) + mark += ct; + } + + /**/ + void + shiftchars(int to, int cnt) + { + if (mark >= to + cnt) + mark -= cnt; + else if (mark > to) + mark = to; + + while(to + cnt <= ll) { + line[to] = line[to + cnt]; + to++; + } + ll -= cnt; } /**/ *************** *** 64,74 **** int i = (cs -= ct); cut(i, ct, dir); ! while (i + ct < ll) { ! line[i] = line[i + ct]; ! i++; ! } ! ll -= ct; } /**/ --- 83,89 ---- int i = (cs -= ct); cut(i, ct, dir); ! shiftchars(i, ct); } /**/ *************** *** 78,88 **** int i = cs; cut(i, ct, dir); ! while (i + ct < ll) { ! line[i] = line[i + ct]; ! i++; ! } ! ll -= ct; } /**/ --- 93,99 ---- int i = cs; cut(i, ct, dir); ! shiftchars(i, ct); } /**/ *************** *** 157,182 **** void backdel(int ct) { ! int i = (cs -= ct); ! ! while (i + ct <= ll) { ! line[i] = line[i + ct]; ! i++; ! } ! ll -= ct; } /**/ void foredel(int ct) { ! int i = cs; ! ! while (i + ct <= ll) { ! line[i] = line[i + ct]; ! i++; ! } ! ll -= ct; } /**/ --- 168,181 ---- void backdel(int ct) { ! shiftchars(cs -= ct, ct); } /**/ void foredel(int ct) { ! shiftchars(cs, ct); } /**/ -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.