Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    r6fe806a reebef19  
    4848#include <termios.h>
    4949#include <sys/stat.h>
    50 #include <locale.h>
    5150#include "owl.h"
    5251
     
    7069  owl_editwin *tw;
    7170  owl_popwin *pw;
    72   int ret, initialsubs, debug, argcsave, followlast;
    73   owl_input j;
     71  int j, ret, initialsubs, debug, argcsave, followlast;
    7472  int newmsgs, nexttimediff;
    7573  struct sigaction sigact;
     
    8684  int newstderr;
    8785#endif
    88  
    89   if (!GLIB_CHECK_VERSION (2, 12, 0))
    90     g_error ("GLib version 2.12.0 or above is needed.");
    9186
    9287  argcsave=argc;
     
    9792  debug=0;
    9893  initialsubs=1;
    99 
    100   setlocale(LC_ALL, "");
    101  
    10294  if (argc>0) {
    10395    argv++;
     
    538530     * little bit, but otherwise do not.  This lets input be grabbed
    539531     * as quickly as possbile */
    540     j.ch = wgetch(typwin);
    541     if (j.ch == ERR) {
     532    j=wgetch(typwin);
     533    if (j==ERR) {
    542534      usleep(10000);
    543535    } else {
    544       j.uch = '\0';
    545       if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) {
    546         /* This is a curses control character. */
    547       }
    548       else if (j.ch > 0x7f && j.ch < 0xfe) {
    549         /* Pull in a full utf-8 character. */
    550         int bytes, i;
    551         char utf8buf[7];
    552         memset(utf8buf, '\0', 7);
    553 
    554         utf8buf[0] = j.ch;
    555 
    556         if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2;
    557         else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3;
    558         else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4;
    559         else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5;
    560         else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6;
    561         else bytes = 1;
    562        
    563         for (i = 1; i < bytes; i++) {
    564           int tmp =  wgetch(typwin);
    565           /* If what we got was not a byte, or not a continuation byte */
    566           if (tmp > 0xff || !(tmp & 0x80 && ~tmp & 0x40)) {
    567             /* ill-formed UTF-8 code unit subsequence, put back the
    568                char we just got. */
    569             ungetch(tmp);
    570             j.ch = ERR;
    571             break;
    572           }
    573           utf8buf[i] = tmp;
    574         }
    575        
    576         if (j.ch != ERR) {
    577           if (g_utf8_validate(utf8buf, -1, NULL)) {
    578             j.uch = g_utf8_get_char(utf8buf);
    579           }
    580           else {
    581             j.ch = ERR;
    582           }
    583         }
    584       }
    585       else if (j.ch <= 0x7f) {
    586         j.uch = j.ch;
    587       }
    588      
    589       owl_global_update_lastinputtime(&g);
     536      owl_global_set_lastinputtime(&g, now);
    590537      /* find and activate the current keymap.
    591538       * TODO: this should really get fixed by activating
Note: See TracChangeset for help on using the changeset viewer.