diff options
author | Ori Bernstein <ori@eigenstate.org> | 2020-09-22 11:42:15 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2020-09-22 11:42:15 -0700 |
commit | 313aebb96478c37be8f39754875c02dcb3f896cc (patch) | |
tree | 880c9ba449631562b136135e3e9a7e6169d178f6 /sys/src/cmd/acme/addr.c | |
parent | c1c904776c1536e854c5c1717a104353f885c3cd (diff) |
acme: import changes from plan9port (thanks jxy)
Import the following improvements and bugfixes from plan9port:
4650064a acme: scale window bodies on resize, not including tag space
d28913a9 acme: save/restore multiline tags in Dump/Load
d2df5d6c acme: fix crash in X |cat with multiple windows
3d6e5cb5 acme: preserve window position and selection during Get
Diffstat (limited to 'sys/src/cmd/acme/addr.c')
-rw-r--r-- | sys/src/cmd/acme/addr.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/src/cmd/acme/addr.c b/sys/src/cmd/acme/addr.c index 94dd88cde..0637fab64 100644 --- a/sys/src/cmd/acme/addr.c +++ b/sys/src/cmd/acme/addr.c @@ -48,6 +48,27 @@ isregexc(int r) return FALSE; } +// nlcounttopos starts at q0 and advances nl lines, +// being careful not to walk past the end of the text, +// and then nr chars, being careful not to walk past +// the end of the current line. +// It returns the final position. +long +nlcounttopos(Text *t, long q0, long nl, long nr) +{ + while(nl > 0 && q0 < t->file->nc) { + if(textreadc(t, q0++) == '\n') + nl--; + } + if(nl > 0) + return q0; + while(nr > 0 && q0 < t->file->nc && textreadc(t, q0) != '\n') { + q0++; + nr--; + } + return q0; +} + Range number(Mntdir *md, Text *t, Range r, int line, int dir, int size, int *evalp) { |