Changeset 428834d for owl.c


Ignore:
Timestamp:
Jan 9, 2008, 2:17:57 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:
369479d
Parents:
c10fef0
Message:
take two for input processing
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    rc10fef0 r428834d  
    7171  owl_popwin *pw;
    7272  int ret, initialsubs, debug, argcsave, followlast;
    73   gunichar j;
     73  owl_input j;
    7474  int newmsgs, nexttimediff;
    7575  struct sigaction sigact;
     
    546546     * little bit, but otherwise do not.  This lets input be grabbed
    547547     * as quickly as possbile */
    548     j=wgetch(typwin);
    549     if (j == ERR
    550 #ifdef KEY_RESIZE
    551         || j == KEY_RESIZE
    552 #endif
    553          ) {
     548    j.ch = wgetch(typwin);
     549    if (j.ch == ERR) {
    554550      usleep(10000);
    555551    } else {
    556       /* Pull in a full utf-8 character. */
    557       if (j & 0x80) {
    558         char utf8buf[7];
     552      j.uch = '\0';
     553      if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) {
     554        /* This is a curses control character. */
     555      }
     556      else if (j.ch > 0x7f && j.ch < 0xfe) {
     557        /* Pull in a full utf-8 character. */
    559558        int bytes, i;
    560         memset(utf8buf,'\0',7);
    561         utf8buf[0] = j;
    562 
    563         if ((j & 0xc0) && (~j & 0x20)) bytes = 2;
    564         else if ((j & 0xe0) && (~j & 0x10)) bytes = 3;
    565         else if ((j & 0xf0) && (~j & 0x08)) bytes = 4;
    566         else if ((j & 0xf8) && (~j & 0x04)) bytes = 5;
    567         else if ((j & 0xfc) && (~j & 0x02)) bytes = 6;
     559        char *utf8buf[7];
     560        memset(utf8buf, '\0', 7);
     561
     562        utf8buf[0] = j.ch;
     563
     564        if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2;
     565        else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3;
     566        else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4;
     567        else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5;
     568        else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6;
    568569        else bytes = 1;
    569570       
     
    572573        }
    573574        if (g_utf8_validate(utf8buf, -1, NULL)) {
    574           j = g_utf8_get_char(utf8buf);
     575          j.uch = g_utf8_get_char(utf8buf);
    575576        }
    576577        else {
    577           j = ERR;
     578          j.ch = ERR;
    578579        }
    579580      }
     581      else if (j.ch <= 0x7f) {
     582        j.uch = j.ch;
     583      }
     584     
    580585      owl_global_update_lastinputtime(&g);
    581586      /* find and activate the current keymap.
Note: See TracChangeset for help on using the changeset viewer.