Changeset 801b7ac for functions.c


Ignore:
Timestamp:
Feb 6, 2007, 6:05:13 PM (14 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
7a20e4c
Parents:
2566560
Message:
functions.c: tweak owl_function_calculate_topmsg_normal to not suck as
much. This resolves the delay in jumping from the first message to the
last message.

fmtext.c: get rid of a debug message and an unused variable.

view.c: Convert another linear search to binary search.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r29ebcea r801b7ac  
    12731273int owl_function_calculate_topmsg_normal(int direction, owl_view *v, int curmsg, int topmsg, int recwinlines)
    12741274{
    1275   int savey, j, i, foo, y;
     1275  int savey, i, foo, y;
    12761276
    12771277  if (curmsg<0) return(topmsg);
     
    12821282  }
    12831283
    1284   /* Find number of lines from top to bottom of curmsg (store in savey) */
    1285   savey=0;
    1286   for (i=topmsg; i<=curmsg; i++) {
    1287     savey+=owl_message_get_numlines(owl_view_get_element(v, i));
     1284  /* If curmsg is so far past topmsg that there are more messages than
     1285     lines, skip the line counting that follows because we're
     1286     certainly off screen.  */
     1287  savey=curmsg-topmsg;
     1288  if (savey <= recwinlines) {
     1289    /* Find number of lines from top to bottom of curmsg (store in savey) */
     1290    savey = 0;
     1291    for (i=topmsg; i<=curmsg; i++) {
     1292      savey+=owl_message_get_numlines(owl_view_get_element(v, i));
     1293    }
    12881294  }
    12891295
     
    12921298  if (savey > recwinlines) {
    12931299    topmsg=curmsg;
    1294     savey=owl_message_get_numlines(owl_view_get_element(v, i));
     1300    savey=owl_message_get_numlines(owl_view_get_element(v, curmsg));
    12951301    direction=OWL_DIRECTION_UPWARDS;
    12961302  }
     
    13001306    if (savey < (recwinlines / 4)) {
    13011307      y=0;
    1302       for (j=curmsg; j>=0; j--) {
    1303         foo=owl_message_get_numlines(owl_view_get_element(v, j));
     1308      for (i=curmsg; i>=0; i--) {
     1309        foo=owl_message_get_numlines(owl_view_get_element(v, i));
    13041310        /* will we run the curmsg off the screen? */
    13051311        if ((foo+y) >= recwinlines) {
    1306           j++;
    1307           if (j>curmsg) j=curmsg;
     1312          i++;
     1313          if (i>curmsg) i=curmsg;
    13081314          break;
    13091315        }
     
    13121318        if (y > (recwinlines / 2)) break;
    13131319      }
    1314       if (j<0) j=0;
    1315       return(j);
     1320      if (i<0) i=0;
     1321      return(i);
    13161322    }
    13171323  }
     
    13221328      y=0;
    13231329      /* count lines from the top until we can save 1/2 the screen size */
    1324       for (j=topmsg; j<curmsg; j++) {
    1325         y+=owl_message_get_numlines(owl_view_get_element(v, j));
     1330      for (i=topmsg; i<curmsg; i++) {
     1331        y+=owl_message_get_numlines(owl_view_get_element(v, i));
    13261332        if (y > (recwinlines / 2)) break;
    13271333      }
    1328       if (j==curmsg) {
    1329         j--;
     1334      if (i==curmsg) {
     1335        i--;
    13301336      }
    1331       return(j+1);
     1337      return(i+1);
    13321338    }
    13331339  }
Note: See TracChangeset for help on using the changeset viewer.