Patch - moving cursor using PgUp/PgDown

From: Krzysztof Strasburger (
Date: Tue Jun 11 2002 - 09:34:54 CEST

I'm coming from another world ;) ie. i never had to use a WYSIWYG word
processor, after i learned LaTeX. But now i have to set up a computer
for my mother. Linux was the obvious choice, as i know it, but a WP
with the possibility of exchanging documents with the, eh, "real world"
was needed. I looked at Abiword, but it is a memory hog (yes, it is).
I tried also Ted. It was good with its RTF support and small memory footprint.
It compiled with LessTif, but then - unfortunately - crashed while doing
something very obvious. Siag office was my last chance ;). I tried it it
out and it does its job nicely, while the memory requirements are still

This was my story, now the concretes follow. The first annoying feature
i experienced was that PgUp/PgDown did not move the cursor. Ulrich, maybe
you find it useful. This is your program, but believe me - many people
use PgUp/PgDown to browse the document. Below is attached the patch, which
changes this behavior to move the cursor. The old code in xpw.c is commented
out. If you decide still to use it, maybe bind it with another keys?
The patch changes also the safe-position function in pw.scm.
My code doesn't work as expected with zoomed text. I tried to scale height
by the zoom variable, but it resulted in weird jumps of the cursor. The final
cursor position was very dependent on its starting position, so the scaling
is removed.

I have also following ideas, but still not enough knowledge to implement them.
Maybe in the near future? Or maybe somebody works on somenthing similar?
1. Deleting of characters is painfully slow, and the blinking of the whole
image is annoying.
Solution of this problems should be easy (i hope...). First, check the
length of first word in the next line. If it is longer than the free space
in the current line, don't call rebreak-line. Only update the current row.
2. Deleting "end of line". The first word from the next line is concatenated
with the last one in the current line, which typically becomes too long.
Then the whole cluster-of-both-words is moved to the next line. No easy
solution here. Maybe allow the current line to be longer and let the user
calls the adjusting explicite?

And some other ideas, unfortunately without suggestions about implementation.
1. Visible page boundaries.
2. Hard newlines, like in TeX.
3. Native tables, maybe using MwTable?

Krzysztof Strasburger

--- siag-3.5.2.orig/pw/pw.scm Fri Feb 1 18:43:12 2002
+++ siag-3.5.2/pw/pw.scm Mon Jun 3 16:07:07 2002
@@ -38,6 +38,7 @@
         (set! col COLS-MIN))))
   (if (< row ROWS-MIN) (set! row ROWS-MIN))
   (if (> row (max-lines)) (set! row (max-lines)))
+ (set! col (min col (col-last-used row)))
   (make-position row col))
 (define (at-beginning-of-line p)
@@ -98,21 +99,25 @@
 (define (forward-char)
   (set-point (next-col (get-point))))
-(define (previous-line)
+(define (scroll-lines l)
   (let* ((p (get-point))
- (r (- (position-row p) 1))
- (lc (col-last-used r))
- (c (position-col p)))
- (if (>= c lc) (set! c lc))
- (set-point (make-position r c))))
+ (c (position-col p))
+ (r (+ l (position-row p))))
+ (if (< r ROWS-MIN) (set! r ROWS-MIN))
+ (if (> r (line-last-used)) (set! r (line-last-used)))
+ (set-point (make-position r (min c (col-last-used r))))))
+(define (previous-line)
+ (scroll-lines -1))
 (define (next-line)
- (let* ((p (get-point))
- (r (+ (position-row p) 1))
- (lc (col-last-used r))
- (c (position-col p)))
- (if (>= c lc) (set! c lc))
- (set-point (make-position r c))))
+ (scroll-lines 1))
+(define (scroll-up)
+ (scroll-lines (- (get-scroll-lines -1))))
+(define (scroll-down)
+ (scroll-lines (get-scroll-lines 1)))
 (define (beginning-of-line)
   (set-point (find-beginning-of-line (get-point))))
--- siag-3.5.2.orig/xpw/xpw.c Sun Jan 20 20:23:20 2002
+++ siag-3.5.2/xpw/xpw.c Tue Jun 4 16:03:14 2002
@@ -406,7 +406,29 @@
         return NIL;
-static LISP lscroll_up(void)
+static LISP get_scroll_lines(LISP lstep)
+ int step = get_c_long(lstep);
+ int lines = -2;
+ int used = 0;
+ Dimension height;
+ int s = w_list->sht;
+ sheet *st = w_list->buf->sht;
+ int r = st[s].point_pos.row;
+ int last = line_last_used(w_list->buf, w_list->sht);
+ XtVaGetValues(w_list->ui->grid,
+ XtNheight, &height,
+ (char *)0);
+ while (used < height && r >= 0 && r <= last) {
+ used += w_list->buf->sht[s].text[r].height;
+ r += step;
+ lines++;
+ }
+ if (lines < 1) lines = 1;
+ return flocons((double) lines);
+/* static LISP lscroll_up(void)
         int top_row, th;
         Dimension height;
@@ -444,7 +466,7 @@
                 (char *)0);
         XawScrollbarSetThumb(w_list->ui->vscroll, (double)top_row/th, 0.0);
         return NIL;
+} */
 static LISP lselect_theme(void)
@@ -500,8 +522,9 @@
         init_subr_0("embed-remove", lembed_remove);
         init_subr_0("embed-open", lembed_open);
         init_subr_0("embed-save", lembed_save);
- init_subr_0("scroll-up", lscroll_up);
- init_subr_0("scroll-down", lscroll_down);
+/* init_subr_0("scroll-up", lscroll_up);
+ init_subr_0("scroll-down", lscroll_down); */
+ init_subr_1("get-scroll-lines", get_scroll_lines);
         init_subr_0("edit_tabs", ledit_tabs);
         init_subr_0("select_theme", lselect_theme);
         init_subr_0("edit_theme", ledit_theme);

This archive was generated by hypermail 2.1.2 : Tue Jun 11 2002 - 09:42:39 CEST