Changeset 07bfbc2 for owl.c


Ignore:
Timestamp:
Feb 19, 2008, 6:13:25 PM (16 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
c020e73
Parents:
b70d24f (diff), 4cc0ee0b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merged revisions 955-957 via svnmerge from 
file:///afs/sipb.mit.edu/project/barnowl/src/svn/trunk

........
  r956 | geofft | 2008-02-19 04:55:35 -0500 (Tue, 19 Feb 2008) | 4 lines
  
  Fix a bug where an explicit (local) realm foiled
  owl_message_get_cc_without_recipient(). (per quentin)
........
  r957 | asedeno | 2008-02-19 18:10:18 -0500 (Tue, 19 Feb 2008) | 4 lines
  
  owl.c:
  * Input processing - deal with all remaining input before moving on.
  * Change how we get stdin's fileno -- actually grab it from the stdin handle.
........
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    r5f3168a r07bfbc2  
    681681
    682682  typwin = owl_global_get_curs_typwin(&g);
    683   j.ch = wgetch(typwin);
    684   if (j.ch == ERR) return;
    685 
    686   owl_global_set_lastinputtime(&g, time(NULL));
    687   pw=owl_global_get_popwin(&g);
    688   tw=owl_global_get_typwin(&g);
    689 
    690   j.uch = '\0';
    691   if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) {
    692     /* This is a curses control character. */
    693   }
    694   else if (j.ch > 0x7f && j.ch < 0xfe) {
    695     /* Pull in a full utf-8 character. */
    696     int bytes, i;
    697     char utf8buf[7];
    698     memset(utf8buf, '\0', 7);
    699 
    700     utf8buf[0] = j.ch;
    701 
    702     if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2;
    703     else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3;
    704     else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4;
    705     else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5;
    706     else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6;
    707     else bytes = 1;
    708 
    709     for (i = 1; i < bytes; i++) {
    710       int tmp =  wgetch(typwin);
    711       /* If what we got was not a byte, or not a continuation byte */
    712       if (tmp > 0xff || !(tmp & 0x80 && ~tmp & 0x40)) {
    713         /* ill-formed UTF-8 code unit subsequence, put back the
    714            char we just got. */
    715         ungetch(tmp);
    716         j.ch = ERR;
    717         break;
    718       }
    719       utf8buf[i] = tmp;
    720     }
     683  while (1) {
     684    j.ch = wgetch(typwin);
     685    if (j.ch == ERR) return;
    721686   
    722     if (j.ch != ERR) {
    723       if (g_utf8_validate(utf8buf, -1, NULL)) {
    724         j.uch = g_utf8_get_char(utf8buf);
    725       }
    726       else {
    727         j.ch = ERR;
    728       }
    729     }
    730   }
    731   else if (j.ch <= 0x7f) {
    732     j.uch = j.ch;
    733   }
     687    owl_global_set_lastinputtime(&g, time(NULL));
     688    pw=owl_global_get_popwin(&g);
     689    tw=owl_global_get_typwin(&g);
     690
     691    j.uch = '\0';
     692    if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) {
     693      /* This is a curses control character. */
     694    }
     695    else if (j.ch > 0x7f && j.ch < 0xfe) {
     696      /* Pull in a full utf-8 character. */
     697      int bytes, i;
     698      char utf8buf[7];
     699      memset(utf8buf, '\0', 7);
    734700     
    735   owl_global_set_lastinputtime(&g, time(NULL));
    736   /* find and activate the current keymap.
    737    * TODO: this should really get fixed by activating
    738    * keymaps as we switch between windows...
    739    */
    740   if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
    741     owl_context_set_popless(owl_global_get_context(&g),
    742                             owl_global_get_viewwin(&g));
    743     owl_function_activate_keymap("popless");
    744   } else if (owl_global_is_typwin_active(&g)
    745              && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
    746     /*
    747       owl_context_set_editline(owl_global_get_context(&g), tw);
    748       owl_function_activate_keymap("editline");
    749     */
    750   } else if (owl_global_is_typwin_active(&g)
    751              && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
    752     owl_context_set_editmulti(owl_global_get_context(&g), tw);
    753     owl_function_activate_keymap("editmulti");
    754   } else {
    755     owl_context_set_recv(owl_global_get_context(&g));
    756     owl_function_activate_keymap("recv");
    757   }
    758   /* now actually handle the keypress */
    759   ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
    760   if (ret!=0 && ret!=1) {
    761     owl_function_makemsg("Unable to handle keypress");
     701      utf8buf[0] = j.ch;
     702     
     703      if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2;
     704      else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3;
     705      else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4;
     706      else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5;
     707      else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6;
     708      else bytes = 1;
     709     
     710      for (i = 1; i < bytes; i++) {
     711        int tmp =  wgetch(typwin);
     712        /* If what we got was not a byte, or not a continuation byte */
     713        if (tmp > 0xff || !(tmp & 0x80 && ~tmp & 0x40)) {
     714          /* ill-formed UTF-8 code unit subsequence, put back the
     715             char we just got. */
     716          ungetch(tmp);
     717          j.ch = ERR;
     718          break;
     719        }
     720        utf8buf[i] = tmp;
     721      }
     722     
     723      if (j.ch != ERR) {
     724        if (g_utf8_validate(utf8buf, -1, NULL)) {
     725          j.uch = g_utf8_get_char(utf8buf);
     726        }
     727        else {
     728          j.ch = ERR;
     729        }
     730      }
     731    }
     732    else if (j.ch <= 0x7f) {
     733      j.uch = j.ch;
     734    }
     735   
     736    owl_global_set_lastinputtime(&g, time(NULL));
     737    /* find and activate the current keymap.
     738     * TODO: this should really get fixed by activating
     739     * keymaps as we switch between windows...
     740     */
     741    if (pw && owl_popwin_is_active(pw) && owl_global_get_viewwin(&g)) {
     742      owl_context_set_popless(owl_global_get_context(&g),
     743                              owl_global_get_viewwin(&g));
     744      owl_function_activate_keymap("popless");
     745    } else if (owl_global_is_typwin_active(&g)
     746               && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_ONELINE) {
     747      /*
     748        owl_context_set_editline(owl_global_get_context(&g), tw);
     749        owl_function_activate_keymap("editline");
     750      */
     751    } else if (owl_global_is_typwin_active(&g)
     752               && owl_editwin_get_style(tw)==OWL_EDITWIN_STYLE_MULTILINE) {
     753      owl_context_set_editmulti(owl_global_get_context(&g), tw);
     754      owl_function_activate_keymap("editmulti");
     755    } else {
     756      owl_context_set_recv(owl_global_get_context(&g));
     757      owl_function_activate_keymap("recv");
     758    }
     759    /* now actually handle the keypress */
     760    ret = owl_keyhandler_process(owl_global_get_keyhandler(&g), j);
     761    if (ret!=0 && ret!=1) {
     762      owl_function_makemsg("Unable to handle keypress");
     763    }
    762764  }
    763765}
Note: See TracChangeset for help on using the changeset viewer.