Changeset ab31454


Ignore:
Timestamp:
Jun 25, 2003, 9:34:51 AM (17 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
ceb8cfb
Parents:
ae0a5fc
Message:
Wordwrap incoming AIM messages
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rae0a5fc rab31454  
    2323        Removed libfaim/config.log from CVS
    2424        Fixed some easy fixed-length buffers
     25        Wordwrap incoming AIM messages.
    2526
    26272.0.4-pre-1
  • aim.c

    rb2b0773 rab31454  
    11971197  int clienttype = AIM_CLIENTTYPE_UNKNOWN;
    11981198  owl_message *m;
    1199   char *stripmsg, *nz_screenname;
     1199  char *stripmsg, *nz_screenname, *wrapmsg;
    12001200  char realmsg[8192+1] = {""};
    12011201  clienttype = aim_fingerprintclient(args->features, args->featureslen);
     
    12731273  /* create a message, and put it on the message queue */
    12741274  stripmsg=owl_text_htmlstrip(realmsg);
     1275  wrapmsg=owl_text_wordwrap(stripmsg, 70);
    12751276  nz_screenname=owl_aim_normalize_screenname(userinfo->sn);
    12761277  m=owl_malloc(sizeof(owl_message));
     
    12781279                         nz_screenname,
    12791280                         owl_global_get_aim_screenname(&g),
    1280                          stripmsg,
     1281                         wrapmsg,
    12811282                         OWL_MESSAGE_DIRECTION_IN,
    12821283                         0);
    12831284  owl_global_messagequeue_addmsg(&g, m);
    12841285  owl_free(stripmsg);
     1286  owl_free(wrapmsg);
    12851287  owl_free(nz_screenname);
    12861288
  • text.c

    rdafd919 rab31454  
    66static const char fileIdent[] = "$Id$";
    77
    8 int owl_text_truncate_lines(char *out, char *in, int aline, int lines) {
     8int owl_text_truncate_lines(char *out, char *in, int aline, int lines)
     9{
    910  /* start with line aline (where the first line is 1) and print
    1011   *  'lines' lines
     
    4344}
    4445
    45 void owl_text_truncate_cols(char *out, char *in, int acol, int bcol) {
     46void owl_text_truncate_cols(char *out, char *in, int acol, int bcol)
     47{
    4648  char *ptr1, *ptr2, *tmpbuff, *last;
    4749  int len;
     
    8991
    9092
    91 void owl_text_indent(char *out, char *in, int n) {
     93void owl_text_indent(char *out, char *in, int n)
     94{
    9295  char *ptr1, *ptr2, *last;
    9396  int i;
     
    113116
    114117
    115 int owl_text_num_lines(char *in) {
     118int owl_text_num_lines(char *in)
     119{
    116120  int lines, i;
    117121
     
    129133
    130134/* caller must free the return */
    131 char *owl_text_htmlstrip(char *in) {
     135char *owl_text_htmlstrip(char *in)
     136{
    132137  char *ptr1, *end, *ptr2, *ptr3, *out;
    133138
     
    186191  return(out);
    187192}
     193
     194/* caller must free the return */
     195char *owl_text_wordwrap(char *in, int col)
     196{
     197  char *out;
     198  int cur, lastspace, len, lastnewline;
     199
     200  out=owl_strdup(in);
     201  len=strlen(in);
     202  cur=0;
     203  lastspace=-1;
     204  lastnewline=-1;
     205
     206  while (cur<(len-1)) {
     207    if (out[cur]==' ') {
     208      lastspace=cur;
     209      cur++;
     210      continue;
     211    } else if (out[cur]=='\n') {
     212      lastnewline=cur;
     213      cur++;
     214      continue;
     215    }
     216
     217    /* do we need to wrap? */
     218    if ( (cur-(lastnewline+1)) > col ) {
     219      if (lastspace==-1 ||
     220          (lastnewline>0 && (lastspace<=lastnewline))) {
     221        /* we can't help, sorry */
     222        cur++;
     223        continue;
     224      }
     225
     226      /* turn the last space into a newline */
     227      out[lastspace]='\n';
     228      lastnewline=lastspace;
     229      lastspace=-1;
     230      cur++;
     231      continue;
     232    }
     233
     234    cur++;
     235    continue;
     236  }
     237  return(out);
     238}
Note: See TracChangeset for help on using the changeset viewer.