More from me...

  • From: Sam Holden <sholden@xxxxxxxxxxxxxx>
  • To: wilyfans@xxxxxxxxxxxxx
  • Date: Thu, 15 Jul 2004 23:57:28 +1000

I'll just keep talking to myself (is it obvious my work profile this week
changed from writing code to writing a tech report :).

When implementing win in python I noticed a section in win.c which is
'#if 0'ed out with the following comment.

                        /*
             * This doesn't work. It's an idea for implementing scrolling
             * on output. What we need is msg.c to execute view_show()
             * but not view_select() or view_warp(). However, making that
             * modification would case view_show() to happen even if you
             * are not setting dot. What we need to do is separate the
             * functions show, select, and warp.
                         */

The behaviour in win is easy enough to 'cat large_file' and the window
doesn't scroll to show it. Sometimes that behaviour is what is wanted but
most of the time (at least for me) the window scrolling so that the
insertion point is visible would be prefered.

The comment above gives a solution, which I hacked up, the diff is:

---diff---
diff -c -r1.1.1.1 msg.c
*** wily/msg.c  13 Jul 2004 00:22:08 -0000      1.1.1.1
--- wily/msg.c  15 Jul 2004 13:37:37 -0000
***************
*** 280,287 ****
        if(view_goto(&v, &r, m->s)){
                if (show) {
                        view_show(v, r);
!                       view_select(v, r);
!                       view_warp(v, r);
                }
                m->r = r;
                m->w = text_data(view_text(v))->id;
--- 280,289 ----
        if(view_goto(&v, &r, m->s)){
                if (show) {
                        view_show(v, r);
!                       if (m->t == WEgoto || m->flag == 1) {
!                               view_select(v, r);
!                               view_warp(v, r);
!                       }
                }
                m->r = r;
                m->w = text_data(view_text(v))->id;
---diff---

It's an ugly hack, taking advantage of the fact that m->flag is
16 bits but is being used as boolean. Since the libmsg interface
has rpc_goto(...) taking a Bool for setdot which is assigned
to the flag, and the only valid Bool values are 0 and 1 
flag with a value that is not 0 or 1 is taken to mean do the
show but not the select and warp. Existing C code shouldn't
care since it *should* have been using the Bool enum.

So in my python win code I can do:

        self.w.goto((0,0), ':#'+str(self.output_point), 2)

To get the window to scroll to the end of the output. With the
annoying side effect of showing the window if it is hidden. But
without the show stopping side effect or warping the cursor.

I don't like the hack, so does anyone have a better idea or do
I live with a non-auto-scrolling terminal?

Damn you gary for sending an initial WEConnected message at
connection time so I could do backward compatible
versioning... :)

-- 
Sam



Other related posts: