From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Zle mark code (second posting)
Date: Mon, 20 Jan 1997 09:55:40 +0100 [thread overview]
Message-ID: <199701200855.JAA01379@hydra.ifh.de> (raw)
I posted this on Friday, but it doesn't seem to have arrived back, so
it's possible another version of this will turn up at some point.
This is what I was hoping for to get the Emacs mark to work with
insertions and deletions; it should cope with all the well-behaved
code which calls spaceinline() and the kill and del functions to do
the work, though there may be parts which shift chunks of the line
themselves. As rewritten, it's scarcely longer than the original
code.
This is against zsh-3.0.3-test3 and it's quite liable to clash with
one or other of Zefram's zle patches. For the same reason, I haven't
written anything to handle this in the undo code, although that needs
doing.
*** 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 <pws@ifh.de> 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.
reply other threads:[~1997-01-20 8:56 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=199701200855.JAA01379@hydra.ifh.de \
--to=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).