Changeset f9c43ae for functions.c


Ignore:
Timestamp:
Sep 21, 2002, 7:52:22 PM (22 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
bde7714
Parents:
1583c90
Message:
Fixed up the normal scrolling code.  Now it should always
  land on a message, but it's still not optimal.
Added the variable 'smartstrip' which will strip kerberos
  instances out for the 'reply' command.
Added -R/usr/athena/lib to the build for Athena
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r1583c90 rf9c43ae  
    759759  recwinlines=owl_global_get_recwin_lines(&g);
    760760
     761  /*
    761762  if (owl_view_get_size(v) < 1) {
    762763    return;
    763764  }
     765  */
    764766
    765767  switch (owl_global_get_scrollmode(&g)) {
    766768  case OWL_SCROLLMODE_TOP:
    767     topmsg = owl_function_calculate_topmsg_top(direction, v, curmsg,
    768                                                topmsg, recwinlines);
     769    topmsg = owl_function_calculate_topmsg_top(direction, v, curmsg, topmsg, recwinlines);
    769770    break;
    770771  case OWL_SCROLLMODE_NEARTOP:
    771     topmsg = owl_function_calculate_topmsg_neartop(direction, v, curmsg,
    772                                                    topmsg, recwinlines);
     772    topmsg = owl_function_calculate_topmsg_neartop(direction, v, curmsg, topmsg, recwinlines);
    773773    break;
    774774  case OWL_SCROLLMODE_CENTER:
    775     topmsg = owl_function_calculate_topmsg_center(direction, v, curmsg,
    776                                                   topmsg, recwinlines);
     775    topmsg = owl_function_calculate_topmsg_center(direction, v, curmsg, topmsg, recwinlines);
    777776    break;
    778777  case OWL_SCROLLMODE_PAGED:
    779     topmsg = owl_function_calculate_topmsg_paged(direction, v, curmsg,
    780                                                  topmsg, recwinlines, 0);
     778    topmsg = owl_function_calculate_topmsg_paged(direction, v, curmsg, topmsg, recwinlines, 0);
    781779    break;
    782780  case OWL_SCROLLMODE_PAGEDCENTER:
    783     topmsg = owl_function_calculate_topmsg_paged(direction, v, curmsg,
    784                                                  topmsg, recwinlines, 1);
     781    topmsg = owl_function_calculate_topmsg_paged(direction, v, curmsg, topmsg, recwinlines, 1);
    785782    break;
    786783  case OWL_SCROLLMODE_NORMAL:
    787784  default:
    788     topmsg = owl_function_calculate_topmsg_normal(direction, v, curmsg,
    789                                                   topmsg, recwinlines);
     785    topmsg = owl_function_calculate_topmsg_normal(direction, v, curmsg, topmsg, recwinlines);
    790786  }
    791787  owl_function_debugmsg("Calculated a topmsg of %i", topmsg);
     
    801797 */
    802798int owl_function_calculate_topmsg_top(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) {
    803   return curmsg;
     799  return(curmsg);
    804800}
    805801
     
    808804      && (owl_message_get_numlines(owl_view_get_element(v, curmsg-1))
    809805          <  recwinlines/2)) {
    810     return curmsg-1;
     806    return(curmsg-1);
    811807  } else {
    812     return curmsg;
     808    return(curmsg);
    813809  }
    814810}
     
    824820    last = i;
    825821  }
    826   return last;
     822  return(last);
    827823}
    828824 
     
    841837    }
    842838    if (center_on_page) {
    843       return owl_function_calculate_topmsg_center(direction, v, curmsg, 0, recwinlines);
     839      return(owl_function_calculate_topmsg_center(direction, v, curmsg, 0, recwinlines));
    844840    } else {
    845       return last;
     841      return(last);
    846842    }
    847843  }
     
    856852  if (savey > recwinlines) {
    857853    if (center_on_page) {
    858       return owl_function_calculate_topmsg_center(direction, v, curmsg, 0, recwinlines);
     854      return(owl_function_calculate_topmsg_center(direction, v, curmsg, 0, recwinlines));
    859855    } else {
    860       return curmsg;
     856      return(curmsg);
    861857    }
    862858  }
    863859
    864860  /* else just stay as we are... */
    865   return topmsg;
     861  return(topmsg);
    866862}
    867863
     
    869865int owl_function_calculate_topmsg_normal(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines) {
    870866  int savey, j, i, foo, y;
    871  
     867
     868  /* If we're off the top of the screen then center */
     869  if (curmsg<topmsg) {
     870    topmsg=owl_function_calculate_topmsg_center(direction, v, curmsg, 0, recwinlines);
     871  }
     872
    872873  /* Find number of lines from top to bottom of curmsg (store in savey) */
    873874  savey=0;
     
    876877  }
    877878
    878   /* If the direction is DOWNWARDS but we're off the bottom of the
    879    *  screen, then set the topmsg to curmsg and scroll UPWARDS
    880    */
    881   if (direction == OWL_DIRECTION_DOWNWARDS) {
    882     if (savey > recwinlines) {
    883       topmsg=curmsg;
    884       savey=owl_message_get_numlines(owl_view_get_element(v, i));
    885       direction=OWL_DIRECTION_UPWARDS;
    886     }
    887   }
    888 
     879  /* If we're off the bottom of the screen, set the topmsg to curmsg
     880   * and scroll upwards */
     881  if (savey > recwinlines) {
     882    topmsg=curmsg;
     883    savey=owl_message_get_numlines(owl_view_get_element(v, i));
     884    direction=OWL_DIRECTION_UPWARDS;
     885  }
     886 
    889887  /* If our bottom line is less than 1/4 down the screen then scroll up */
    890888  if (direction == OWL_DIRECTION_UPWARDS || direction == OWL_DIRECTION_NONE) {
     
    904902      }
    905903      if (j<0) j=0;
    906       return j;
     904      return(j);
    907905    }
    908906  }
     
    920918        j--;
    921919      }
    922       return j+1;
    923     }
    924   }
    925 
    926   return topmsg;
     920      return(j+1);
     921    }
     922  }
     923
     924  return(topmsg);
    927925}
    928926
     
    15541552    }
    15551553
    1556 
    15571554    /* first check if we catch the reply-lockout filter */
    15581555    f=owl_global_get_filter(&g, "reply-lockout");
     
    15681565      owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m));
    15691566    } else if (owl_message_is_type_admin(m)) {
    1570       owl_function_makemsg("You cannot reply to this admin message");
     1567      owl_function_makemsg("You cannot reply to an admin message");
    15711568    } else {
    15721569      if (owl_message_is_login(m)) {
     
    16031600      }
    16041601      if (*to != '\0') {
    1605         char *tmp, *oldtmp;
    1606         tmp=short_zuser(to);
     1602        char *tmp, *oldtmp, *tmp2;
    16071603        if (cc) {
    16081604          tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
     
    16121608        } else {
    16131609          tmp=short_zuser(to);
     1610          if (owl_global_is_smartstrip(&g)) {
     1611            tmp2=tmp;
     1612            tmp=smartstripped_user(tmp2);
     1613            owl_free(tmp2);
     1614          }
    16141615          buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
    16151616          owl_free(oldbuff);
     
    17481749  owl_view *v;
    17491750  owl_filter *f;
    1750   int curid=-1, newpos;
    1751   owl_message *curm;
     1751  int curid=-1, newpos, curmsg;
     1752  owl_message *curm=NULL;
    17521753
    17531754  v=owl_global_get_current_view(&g);
    1754   curm=owl_view_get_element(v, owl_global_get_curmsg(&g));
    1755   if (curm) {
    1756     curid = owl_message_get_id(curm);
    1757     owl_view_save_curmsgid(v, curid);
    1758   }
    1759 
     1755  curmsg=owl_global_get_curmsg(&g);
     1756  if (curmsg==-1) {
     1757    owl_function_debugmsg("Hit the curmsg==-1 case in change_view");
     1758  } else {
     1759    curm=owl_view_get_element(v, curmsg);
     1760    if (curm) {
     1761      curid=owl_message_get_id(curm);
     1762      owl_view_save_curmsgid(v, curid);
     1763    }
     1764  }
     1765
     1766  /* grab the filter */;
    17601767  f=owl_global_get_filter(&g, filtname);
    17611768  if (!f) {
     
    17641771  }
    17651772
     1773  /* free the existing view and create a new one based on the filter */
    17661774  owl_view_free(v);
    17671775  owl_view_create(v, f);
    17681776
    1769   /* Figure out where to set the current message to.
    1770    * - If the previous view had messages in it, go to the closest message
    1771    *   to the last message in that view.
    1772    * - If the previous view was empty, attempts to restore the position
    1773    *   from the last time we were in that view.  */
     1777  /* Figure out what to set the current message to.
     1778   * - If the view we're leaving has messages in it, go to the closest message
     1779   *   to the last message pointed to in that view.
     1780   * - If the view we're leaving is empty, try to restore the position
     1781   *   from the last time we were in the new view.  */
    17741782  if (curm) {
    17751783    newpos = owl_view_get_nearest_to_msgid(v, curid);
     
    17801788  owl_global_set_curmsg(&g, newpos);
    17811789
    1782   owl_global_set_curmsg_vert_offset(&g, 0);
     1790  owl_function_calculate_topmsg(OWL_DIRECTION_DOWNWARDS);
     1791  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    17831792  owl_global_set_direction_downwards(&g);
    1784   owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
    1785   owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    17861793}
    17871794
Note: See TracChangeset for help on using the changeset viewer.