Exemplo n.º 1
0
void reset_gtab_all()
{
  if (!cur_inmd)
    return;

  ClrIn();
  ClrSelArea();
}
Exemplo n.º 2
0
void
putstr (int tty_fd, const char *p)
{
  int len = strlen (p);

  if (len != 0)
    write (tty_fd, p, len);

  ClrSelArea ();
  ClrRootArea ();

  RootEmpty ();
  DispRootArea ();
}
Exemplo n.º 3
0
static void putstr_inp(char *p)
{
  clear_page_label();

//  dbg("gtab_hide_row2 %d\n", gtab_hide_row2);
  hide_row2_if_necessary();

  char_play(p);

  int to_tsin = (cur_inmd->flag & FLAG_GTAB_SYM_KBM) && inmd[default_input_method].method_type==method_type_TSIN && tss.c_len;

  if (utf8_str_N(p) > 1  || !(p[0]&128)) {
    if ((gtab_disp_key_codes && !gtab_hide_row2) || ggg.wild_mode)
      lookup_gtabn(p, NULL);
    if (to_tsin) {
      add_to_tsin_buf_str(p);
    }
    else
      send_text(p);
  }
  else {
    if (poo.same_pho_query_state == SAME_PHO_QUERY_gtab_input) {
      poo.same_pho_query_state = SAME_PHO_QUERY_pho_select;
      start_gtab_pho_query(p);

      ClrIn();
      ClrSelArea();
      return;
    }

    if ((gtab_disp_key_codes && !gtab_hide_row2) || ggg.wild_mode)
      lookup_gtab(p);

    if (to_tsin)
      add_to_tsin_buf_str(p);
    else
      send_utf8_ch(p);
  }

  clear_after_put();

  if ((cur_inmd->flag & FLAG_GTAB_SYM_KBM)) {
    extern int win_kbm_inited, b_show_win_kbm;
    init_in_method(default_input_method);
    if (win_kbm_inited && !b_show_win_kbm)
      hide_win_kbm();
  }
}
Exemplo n.º 4
0
void
DispSelection ()
{

  int i, pos = 1, len;



  ClrSelArea ();

  if (gMultiPageMode && gCurrentPageIndex != StartKey) {
    input_print_string (pos, 1, "< ", INPUT_FGCOLOR, INPUT_BGCOLOR);

    pos += 2;
  }

  for (i = 0; i < CurSelNum; i++) {
    if (!seltab[i][0]) {
      if (gsCurrent_method == 0 && i == 0)
	continue;
      else
	break;
    }

    input_draw_ascii (pos++, 1,
		      gsInput_table_array[gsCurrent_method]->selkey[i],
		      INPUT_FGCOLOR, INPUT_BGCOLOR);

    len = strlen (seltab[i]);
    input_print_string (pos, 1, seltab[i], INPUT_FGCOLOR, INPUT_BGCOLOR);
    pos += len + 1;
  }

  if (gMultiPageMode && gNextPageIndex != StartKey) {
    input_print_string (pos, 1, "> ", INPUT_FGCOLOR, INPUT_BGCOLOR);
  }
}
Exemplo n.º 5
0
void
hz_filter1 (int tty_fd, unsigned char key)
{
  int inkey = 0, vv;
  char *is_sel_key = (char *) 0;

  if (!IsHanziInput)
    return outchar (tty_fd, key);

  if (gsCurrent_method == 0)
    return intcode_hz_filter (tty_fd, key);

  switch (key) {
  case '\010':			/* BackSpace Ctrl+H */
  case '\177':			/* BackSpace */
    if (gInputCount > 0) {
      InpKey[--gInputCount] = 0;
      if (gInputCount == 0) {
	RootEmpty ();
	ClrSelArea ();
      } else if (gInputCount < InputMatch) {
	FindMatchKey ();
	gMultiPageMode = 0;
	gCurrentPageIndex = StartKey;
	FillMatchChars (StartKey);
	DispSelection ();
      }
      DispRootArea ();
    } else
      outchar (tty_fd, key);
    break;

  case '\033':			/* ESCAPE */
    if (gInputCount > 0) {
      ClrSelArea ();
      ClrRootArea ();

      RootEmpty ();
      DispRootArea ();

    } else
      outchar (tty_fd, key);
    break;

  case '<':
  case '-':
  case ',':
  case '[':
    if (gMultiPageMode) {
      if (gCurrentPageIndex > StartKey)
	gCurrentPageIndex = gCurrentPageIndex - cur_table->MaxDupSel;
      else
	gCurrentPageIndex = StartKey;
      if (IsAssociateMode)
	FillAssociateChars (gCurrentPageIndex);
      else
	FillMatchChars (gCurrentPageIndex);
      DispSelection ();
    } else
      outchar (tty_fd, key);
    break;

  case '>':
  case ']':
  case '.':
  case '=':
    if (gMultiPageMode) {
      gCurrentPageIndex = gNextPageIndex;
      if (IsAssociateMode)
	FillAssociateChars (gCurrentPageIndex);
      else
	FillMatchChars (gCurrentPageIndex);
      DispSelection ();
    } else
      outchar (tty_fd, key);
    break;

  case ' ':
    if (CurSelNum == 0)
      outchar (tty_fd, key);
    if (seltab[0][0])
      putstr (tty_fd, seltab[0]);
    break;

  default:

    inkey = cur_table->KeyMap[key];
    is_sel_key = strchr (cur_table->selkey, key);
    vv = is_sel_key - cur_table->selkey;

    if ((!inkey && !is_sel_key) ||
	(!inkey && is_sel_key && (CurSelNum == 0 || seltab[vv][0] == 0))) {
      IsAssociateMode = 0;

      RootEmpty ();
      ClrSelArea ();
      ClrRootArea ();
      outchar (tty_fd, key);
      return;
    }

    if (is_sel_key && CurSelNum > 0 && seltab[vv][0]) {
      putstr (tty_fd, seltab[vv]);
      return;
    }

    /* now it must be inkey? */
    IsAssociateMode = 0;
    if (inkey >= 1 && gInputCount < MAX_INPUT_LENGTH)
      InpKey[gInputCount++] = inkey;

    if (gInputCount <= InputMatch + 1) {
      FindMatchKey ();
      gCurrentPageIndex = StartKey;
      gMultiPageMode = 0;
      FillMatchChars (StartKey);
      if (gInputCount >= cur_table->MaxPress && CurSelNum == 1 && cur_table->last_full) {	// left only one selection
	return putstr (tty_fd, seltab[0]);
      }
      DispSelection ();
    }
    DispRootArea ();
    break;

  }				/* switch */
}
Exemplo n.º 6
0
void
intcode_hz_filter (int tty_fd, unsigned char key)
{
  int inkey = 0;
  char buf[30];

  if (gsCurrent_input_table->CaseTransPolicy == 1)
    key = toupper (key);

  if (gsCurrent_input_table->CaseTransPolicy == 2)
    key = tolower (key);


  switch (key) {
  case '\010':			/* BackSpace Ctrl+H */
  case '\177':			/* BackSpace */
    if (gInputCount > 0) {
      InpKey[--gInputCount] = 0;

      if (gInputCount == 2)
	ClrSelArea ();

      if (gInputCount == 0)
	RootEmpty ();

      DispRootArea ();
    } else
      outchar (tty_fd, key);
    break;

  case '\033':			/* ESCAPE */
    if (gInputCount > 0) {
      ClrSelArea ();
      ClrRootArea ();

      RootEmpty ();
      DispRootArea ();
    } else
      outchar (tty_fd, key);
    break;

  default:

    inkey = gsCurrent_input_table->KeyMap[key];


    switch (gInputCount) {
    case 0:
    case 1:
    case 2:
      if (inkey >= 0) {
	InpKey[gInputCount++] = inkey;
	DispRootArea ();

	InpKey2intcode ();

	if (gInputCount == 3) {
	  gMultiPageMode = 0;
	  IntCode_FillMatchChars (intcode * 16);
	  DispSelection ();
	}

      } else {

	RootEmpty ();
	ClrSelArea ();
	ClrRootArea ();
	outchar (tty_fd, key);
	return;
      }

      break;

    case 3:
      if (seltab[inkey][0] != '\0')
	putstr (tty_fd, seltab[inkey]);
      else {
	RootEmpty ();
	ClrSelArea ();
#if 0
	ClrRootArea ();
#else
	DispRootArea ();
#endif
	outchar (tty_fd, key);
	return;
      }

      break;

    }				/* default */
  }				/* switch */
}
Exemplo n.º 7
0
void
BarMenu (int xmax, int ymax, int leftmar, int stepwidth)
{

  int ii, jj;
  int lastx, lasty;
  int key1, key2;
  int i;
  int ok_flag = 0;



  ClrSelArea ();

  if (gEncode == BIG5) {
    input_print_string (0, 1, "請選擇->", LIGHTBAR_MESSAGE, INPUT_BGCOLOR);
  }

  if (gEncode == GB) {
    input_print_string (0, 1, string_BIG5toGB ("請選擇->"), LIGHTBAR_MESSAGE,
			INPUT_BGCOLOR);
  }

  for (jj = 1; jj <= xmax; jj++)
    for (ii = 1; ii <= ymax; ii++) {
      chinese_bar (jj, ii, leftmar, stepwidth,
		   Item_attr[jj] == 1 ? NORMAL : NORMALDISABLE,
		   Item_str[jj][ii]);
    }

  chinese_bar (mx, my, leftmar, stepwidth,
	       Item_attr[mx] == 1 ? REVERSE : REVERSEDISABLE,
	       Item_str[mx][my]);

  #ifdef VGALIB
  gl_copyscreen(physical_screen);
  #endif

  initscr ();
  noecho ();
  keypad (stdscr, TRUE);


  while (ok_flag == 0) {

    key2 = getch ();
    lastx = mx;
    lasty = my;
    switch (key2) {

    case KEY_HOME:
      mx = 1;
      my = 1;
      break;
    case KEY_END:
      mx = xmax;
      my = ymax;
      break;
    case KEY_UP:
      Up (xmax, ymax);
      break;
    case KEY_LEFT:
      BarLeft (xmax, ymax, leftmar, stepwidth);
      break;
    case KEY_RIGHT:
      BarRight (xmax, ymax, leftmar, stepwidth);
      break;
    case KEY_DOWN:
      Dn (xmax, ymax);
      break;
    case 10:
    case 13:
    case KEY_ENTER:
      ok_flag = 1;
      ClrSelArea ();
      if (mx == 10 && gItem_disp_off == 0) {
	set_active_input_method (0);
      } else {
	set_active_input_method (mx + gItem_disp_off);
      }
      break;
    case 200:
    case 201:
    case 202:
    case 203:
    case 204:
    case 205:
    case 206:
    case 207:
    case 208:
    case 209:
      ok_flag = 1;
      ClrSelArea ();
      if (key2 - 200 == 0) {
	mx = 10;
	my = 1;
	set_active_input_method (0);
      } else {
	mx = key2 - 200;
	my = 1;
	set_active_input_method (mx);
      }
      BarMenuInit (10, 1);
      BarMenu (10, 1, 8, 6);
      break;
    default:
      ok_flag = 1;
      ClrSelArea ();
      if (mx == 10 && gItem_disp_off == 0) {
	set_active_input_method (0);
      } else {
	set_active_input_method (mx + gItem_disp_off);
      }

      hz_filter (hztty_list->tty_fd, key2);
      break;
    }

    if (ok_flag == 1) {
      break;
    }



    chinese_bar (mx, my, leftmar, stepwidth,
		 Item_attr[mx] == 1 ? REVERSE : REVERSEDISABLE,
		 Item_str[mx][my]);

    if (!(lasty == my && lastx == mx)) {
      chinese_bar (lastx, lasty, leftmar, stepwidth,
		   Item_attr[lastx] == 1 ? NORMAL : NORMALDISABLE,
		   Item_str[lastx][lasty]);
    }
    #ifdef VGALIB
    gl_copyscreen(physical_screen);
    #endif


  }

  keypad (stdscr, FALSE);

}
Exemplo n.º 8
0
/* before call this function, must lock the console */
void
refresh_input_method_area (void)
{
  char str[25];

  int tTopY;
  int tLeftX;
  int ii, jj;

  tTopY = 458;
  tLeftX = 540;

  NEWRootEmpty ();
//NEWDispRootArea();
  input_clear_line (2, INPUT_BGCOLOR);
  gInputCount = 0;
  ClrSelArea ();
  gSelectingMode_flag = 0;


  input_clear_area (INPUT_BGCOLOR);

  if (use_fb) {
    fb_setfgcolor (15);
    fb_drawline (0, INPUT_AREAY - 7, 639, INPUT_AREAY - 7);
    fb_drawline (0, INPUT_AREAY - 4, 639, INPUT_AREAY - 4);
    for (ii = 0; ii < 100; ii++)
      fb_setfgcolor (12);
  } else {

  #ifdef VGALIB
    gl_hline(0, INPUT_AREAY - 7, WIDTH-1, GRAY);
    gl_hline(0, INPUT_AREAY - 4, WIDTH-1, GRAY);
  #endif

#ifdef VGA__
    vga_setcolor (15);
    vga_drawline (0, INPUT_AREAY - 7, 639, INPUT_AREAY - 7);
    vga_drawline (0, INPUT_AREAY - 4, 639, INPUT_AREAY - 4);
    for (ii = 0; ii < 100; ii++)
      vga_setcolor (12);
#endif
  }


  if (!IsHanziInput) {
    if (gEncode == BIG5) {
      input_print_string (POS_OF_VERSIONSTRING, 0, VERSION_STRING,
			  INPUT_FGCOLOR, INPUT_BGCOLOR);
      input_print_string (POS_OF_INPUTNAME, 0, "【英數】", INPUT_FGCOLOR,
			  INPUT_BGCOLOR);
    }
    if (gEncode == GB) {
      input_print_string (POS_OF_VERSIONSTRING, 0,
			  string_BIG5toGB (VERSION_STRING), INPUT_FGCOLOR,
			  INPUT_BGCOLOR);
      input_print_string (POS_OF_INPUTNAME, 0, string_BIG5toGB ("【英數】"),
			  INPUT_FGCOLOR, INPUT_BGCOLOR);
    }
  } else {

    if ((gsCurrent_input_table->IsExtInpMethod) == 1) {
      if (gEncode == BIG5) {
	input_print_string (POS_OF_INPUTNAME, 0,
			    gsInput_table_array[gsCurrent_method]->cname,
			    INPUT_FGCOLOR, INPUT_BGCOLOR);
      }
      if (gEncode == GB) {
	input_print_string (POS_OF_INPUTNAME, 0,
			    gsInput_table_array[gsCurrent_method]->cname,
			    INPUT_FGCOLOR, INPUT_BGCOLOR);
      }
    } else {
      fprintf (stderr, "%c", 0x7);
      if (gEncode == BIG5) {
        #ifdef NEW_CHEWING
        if (gsCurrent_method == 7) 
	  input_print_string (POS_OF_INPUTNAME, 0, "酷音", INPUT_FGCOLOR, INPUT_BGCOLOR);
        #else
	input_print_string (POS_OF_INPUTNAME, 0, "!無輸入法!", INPUT_FGCOLOR,
			    INPUT_BGCOLOR);
        #endif
      }
      if (gEncode == GB) {
	input_print_string (POS_OF_INPUTNAME, 0,
			    string_BIG5toGB ("!無輸入法!"), INPUT_FGCOLOR,
			    INPUT_BGCOLOR);
      }
    }
  }


  if (gsCurrent_input_table) {
    if (gsCurrent_input_table->CaseTransPolicy == 0) {
      input_print_string (POS_OF_CASEHINT, 0, "A", HINT_CASEHICOLOR,
			  INPUT_BGCOLOR);
      input_print_string (POS_OF_CASEHINT + 1, 0, " ", INPUT_FGCOLOR,
			  INPUT_BGCOLOR);
      input_print_string (POS_OF_CASEHINT + 2, 0, "a", HINT_CASECOLOR,
			  INPUT_BGCOLOR);
    }
    if (gsCurrent_input_table->CaseTransPolicy == 1) {
      input_print_string (POS_OF_CASEHINT, 0, "a", HINT_CASECOLOR,
			  INPUT_BGCOLOR);
      input_print_string (POS_OF_CASEHINT + 1, 0, "=", HINT_CASECOLOR,
			  INPUT_BGCOLOR);
      input_print_string (POS_OF_CASEHINT + 2, 0, "A", HINT_CASECOLOR,
			  INPUT_BGCOLOR);
    }
    if (gsCurrent_input_table->CaseTransPolicy == 2) {
      input_print_string (POS_OF_CASEHINT, 0, "A", HINT_CASECOLOR,
			  INPUT_BGCOLOR);
      input_print_string (POS_OF_CASEHINT + 1, 0, "=", HINT_CASECOLOR,
			  INPUT_BGCOLOR);
      input_print_string (POS_OF_CASEHINT + 2, 0, "a", HINT_CASECOLOR,
			  INPUT_BGCOLOR);
    }
  }


  if (gEncode == BIG5) {
    input_print_string (POS_OF_FULLHALF, 0, half_full_strBIG5[IsFullChar],
			INPUT_FGCOLOR, INPUT_BGCOLOR);
    input_print_string (POS_OF_HISTORYMODE, 0,
			history_normal_strBIG5[console_mode], INPUT_FGCOLOR,
			INPUT_BGCOLOR);
    sprintf (str, "【視窗%1d】", hztty_list->index);
  }
  if (gEncode == GB) {
    input_print_string (POS_OF_FULLHALF, 0, half_full_strGB[IsFullChar],
			INPUT_FGCOLOR, INPUT_BGCOLOR);
    input_print_string (POS_OF_HISTORYMODE, 0,
			history_normal_strGB[console_mode], INPUT_FGCOLOR,
			INPUT_BGCOLOR);
    sprintf (str, "▽敦諳%1d▼", hztty_list->index);
  }
  input_print_string (POS_OF_WINDOWNO, 0, str, INPUT_FGCOLOR, INPUT_BGCOLOR);
  if (IsHanziInput > 0 && gsCurrent_method == 7)
#ifdef CHEWING
    ChewReDrawText ();		/* Chewing */
#else
    ;
#endif
  input_print_string (76, 1, encode_name, RED, INPUT_BGCOLOR); 

}
Exemplo n.º 9
0
gboolean feedkey_gtab(KeySym key, int kbstate)
{
  int i,j=0;
  int inkey=0;
  char *pselkey= NULL;
  gboolean phrase_selected = FALSE;
  char seltab_phrase[MAX_SELKEY];
  gboolean is_keypad = FALSE;
  gboolean shift_m = (kbstate & ShiftMask) > 0;
//  gboolean ctrl_m = (kbstate & ControlMask) > 0;
  gboolean capslock_on = (kbstate & LockMask);

  bzero(seltab_phrase, sizeof(seltab_phrase));

//  dbg("uuuuu %x %x   shift,ctrl:%d,%d\n", key, kbstate, shift_m, ctrl_m);

  if (!cur_inmd)
    return 0;

  gboolean is_dayi = !strncmp(cur_inmd->filename, "dayi", 4);

  if ((tsin_chinese_english_toggle_key == TSIN_CHINESE_ENGLISH_TOGGLE_KEY_CapsLock) &&
      (key == XK_Caps_Lock)){
    // The CapLock status may be incorrect when XK_Caps_Lock is pressed.
    gboolean new_tsin_pho_mode = ! gdk_keymap_get_caps_lock_state(gdk_keymap_get_default());
    if (current_CS->tsin_pho_mode != new_tsin_pho_mode) {
      current_CS->tsin_pho_mode = new_tsin_pho_mode;
      save_CS_current_to_temp();
      tsin_set_eng_ch(new_tsin_pho_mode);
    }
  }

  if ((kbstate & (Mod1Mask|Mod4Mask|Mod5Mask|ControlMask))==ControlMask
     && key>='1' && key<='9' && ggg.gbufN) {
    save_gtab_buf_phrase(key);
    return 1;
  }

  if (ggg.gbufN && key==XK_Tab)
    return 1;

   if ((key==XK_Shift_L||key==XK_Shift_R) && !key_press_time) {
     key_press_time = current_time();
     key_press_time_ctrl = 0;
   } else
  if ((key==XK_Control_L||key==XK_Control_R) && !key_press_time_ctrl && tss.pre_selN) {
    key_press_time_ctrl = current_time();
    return TRUE;
  } else {
    key_press_time_ctrl = 0;
    key_press_time = 0;
  }

  if (kbstate & (Mod1Mask|Mod4Mask|Mod5Mask|ControlMask)) {
    return 0;
  }

  if (poo.same_pho_query_state == SAME_PHO_QUERY_pho_select)
    return feedkey_pho(key, 0);

  if (poo.same_pho_query_state == SAME_PHO_QUERY_none && gwin_pho &&
    GTK_WIDGET_VISIBLE(gwin_pho))
     hide_win_pho();

  if (!tsin_pho_mode()) {
    if (key < 0x20 || key>=0x7f)
      goto shift_proc;

    if (capslock_on && hime_capslock_lower)
      case_inverse((KeySym *)&key, shift_m);

    if (ggg.gbufN)
      insert_gbuf_cursor_char(key);
    else
      send_ascii(key);

    return 1;
  }


  int lcase;
  lcase = tolower(key);
  int ucase;
  ucase = toupper(key);
  if (key < 127 && cur_inmd->keymap[key]) {
     if (key < 'A' || key > 'z' || (key > 'Z'  && key < 'a') )
       goto shift_proc;
     if (cur_inmd->keymap[lcase] != cur_inmd->keymap[ucase])
       goto next;

  }


shift_proc:
  if (shift_m && !strchr(cur_inmd->selkey, key) && !ggg.more_pg && key>=' ' && key < 0x7e &&
       key!='*' && (key!='?' || (gtab_shift_phrase_key && !ggg.ci))) {
    if (gtab_shift_phrase_key) {
      if (tss.pre_selN && shift_char_proc(key, kbstate))
        return TRUE;
      if (feed_phrase(key, kbstate))
        return TRUE;
    } else {
      if (!cur_inmd->keymap[key] || (lcase != ucase &&
           cur_inmd->keymap[lcase]==cur_inmd->keymap[ucase]))
        return shift_char_proc(key, kbstate);
    }
  }

  gboolean has_wild;
  has_wild = FALSE;

  switch (key) {
    case XK_BackSpace:
      ggg.last_idx=0;
      ggg.spc_pressed=0;
      ggg.sel1st_i=MAX_SELKEY-1;
      clear_gtab_input_error_color();
      hide_gtab_pre_sel();

      if (ggg.ci==0) {
        if (AUTO_SELECT_BY_PHRASE)
          return gtab_buf_backspace();
        else
          return 0;
      }

      if (ggg.ci>0)
        ggg.inch[--ggg.ci]=0;

      if (has_wild_card()) {
        proc_wild_disp();
        return 1;
      }


      ggg.wild_mode=0;
      ggg.invalid_spc = FALSE;
      if (ggg.ci==1 && cur_inmd->use_quick) {
        int i;
        clr_seltab();
        for(i=0;i<cur_inmd->M_DUP_SEL;i++)
          utf8cpy(seltab[i], (char *)cur_inmd->qkeys->quick1[ggg.inch[0]-1][i]);

        ggg.defselN=cur_inmd->M_DUP_SEL;
        DispInArea();
        goto Disp_opt;
      } else
      if (ggg.ci==2 && cur_inmd->use_quick) {
        int i;
        clr_seltab();
        for(i=0;i<cur_inmd->M_DUP_SEL;i++)
          utf8cpy(seltab[i], (char *)cur_inmd->qkeys->quick2[ggg.inch[0]-1][ggg.inch[1]-1][i]);

        ggg.defselN=cur_inmd->M_DUP_SEL;
        DispInArea();
        goto Disp_opt;
      }

      break;
    case XK_KP_Enter:
    case XK_Return:
      if (AUTO_SELECT_BY_PHRASE) {
        hide_gtab_pre_sel();
        if (shift_m) {
          return save_gtab_buf_shift_enter();
        } else
          return output_gbuf();
      }
      else
        return 0;
    case XK_Up:
      if (gtab_has_input())
        return TRUE;
      return FALSE;
    case XK_Down:
    case XK_KP_Down:
      if (AUTO_SELECT_BY_PHRASE)
        return show_buf_select();
      else
        return 0;
    case XK_Escape:
      hide_gtab_pre_sel();
      if (ggg.gtab_buf_select) {
        ggg.gtab_buf_select = 0;
        reset_gtab_all();
        ClrSelArea();
        if (hime_pop_up_win && !gtab_has_input())
          hide_win_gtab();
        return 1;
      }
      ClrSelArea();
      close_gtab_pho_win();
      if (ggg.ci) {
        reset_gtab_all();
        return 1;
      } else {
        if (ggg.gbufN) {
          set_gtab_user_head();
          return 1;
        }
        ClrIn();
        return 0;
      }
    case XK_Prior:
    case XK_KP_Prior:
    case XK_KP_Subtract:
      if (ggg.wild_mode) {
        if (ggg.wild_page >= cur_inmd->M_DUP_SEL) ggg.wild_page-=cur_inmd->M_DUP_SEL;
        wildcard();
        return 1;
      } else
      if (ggg.more_pg) {
        if (ggg.gtab_buf_select) {
          gbuf_prev_pg();
          return 1;
        }

        ggg.pg_idx -= page_len();
        if (ggg.pg_idx < ggg.S1)
          ggg.pg_idx = ggg.S1;

        goto next_pg;
      }

      if (key==XK_KP_Subtract)
        goto keypad_proc;

      return win_sym_page_up();
    case XK_Next:
    case XK_KP_Next:
    case XK_KP_Add:
      if (ggg.more_pg) {
        if (ggg.gtab_buf_select) {
          gbuf_next_pg();
          return 1;
        }
next_page:
//        dbg("more...\n");
        ggg.pg_idx += page_len();
        if (ggg.pg_idx >=ggg.E1)
          ggg.pg_idx = ggg.S1;
        goto next_pg;
      } else {
        if (key==XK_KP_Add)
          goto keypad_proc;
        if (win_sym_page_down())
          return TRUE;
        if (!ggg.gtab_buf_select && ggg.gbufN && AUTO_SELECT_BY_PHRASE)
          return show_buf_select();
        return FALSE;
      }
    case ' ':
      hide_gtab_pre_sel();

      if (ggg.invalid_spc && gtab_invalid_key_in)
        ClrIn();

      if (!gtab_invalid_key_in && ggg.spc_pressed && ggg.invalid_spc) {
        ClrIn();
        return 1;
      }

      has_wild = has_wild_card();

//      dbg("ggg.wild_mode:%d ggg.more_pg:%d ggg.ci:%d  has_wild:%d\n", ggg.wild_mode, ggg.more_pg, ggg.ci, has_wild);

      if (ggg.wild_mode) {
        // request from tetralet
        if (!ggg.wild_page && ggg.total_matchN < cur_inmd->M_DUP_SEL) {
          ggg.sel1st_i = 0;
          goto direct_select;
        }

        ggg.wild_page += cur_inmd->M_DUP_SEL;
        if (ggg.wild_page >= ggg.total_matchN)
          ggg.wild_page=0;

        wildcard();
        ggg.spc_pressed = TRUE;
        return 1;
      } else
      if (ggg.more_pg && !(_gtab_space_auto_first & GTAB_space_auto_first_any)) {
        if (ggg.gtab_buf_select) {
          gbuf_next_pg();
          return 1;
        }
        else
          goto next_page;
      } else
      if (ggg.ci==0) {
        if (current_CS->b_half_full_char)
          return full_char_proc(key);

        if (ggg.gbufN) {
          output_gbuf();
        } else
          return 0;
      } else
      if (!has_wild) {
//        dbg("iii %d  ggg.defselN:%d   %d\n", ggg.sel1st_i, ggg.defselN, cur_inmd->M_DUP_SEL);
        if (_gtab_space_auto_first == GTAB_space_auto_first_any && seltab[0][0] &&
            ggg.sel1st_i==MAX_SELKEY-1) {
          ggg.sel1st_i = 0;
        }

        if (_gtab_space_auto_first == GTAB_space_auto_first_nofull && ggg.exa_match > 1
            && !AUTO_SELECT_BY_PHRASE && gtab_dup_select_bell)
          bell();

        if (seltab[ggg.sel1st_i][0]) {
//          dbg("ggg.last_full %d %d\n", ggg.last_full,ggg.spc_pressed);
          if (gtab_full_space_auto_first || ggg.spc_pressed) {
direct_select:
            if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) {
//              dbg("ins ggg.kval %x\n", ggg.kval);
              insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match);
            }
            else
              putstr_inp(seltab[ggg.sel1st_i]);  /* select 1st */
            return 1;
          }
        }
      }

      ggg.last_full=0;
      ggg.spc_pressed=1;
//      dbg("spc_pressed=1\n");

      if (has_wild) {
        ggg.wild_page=0;
        ggg.wild_mode=1;
        wildcard();
        return 1;
      }

      break;
    case '?':
    case '*':
      if ((!gtab_que_wild_card && key == '?') || (!gtab_que_wild_card_asterisk && key == '*')) {
        inkey=cur_inmd->keymap[key];
        if ((inkey && (inkey!=cur_inmd->WILD_QUES && inkey!=cur_inmd->WILD_STAR)) || ptr_selkey(key))
          goto next;
        if (AUTO_SELECT_BY_PHRASE && ggg.gbufN) {
          insert_gbuf_cursor_char(key);
          return 1;
        } else {
          if (current_CS->b_half_full_char)
            return full_char_proc(key);
		  else
            return 0;
		}
      }
      if (tss.pre_selN && shift_char_proc(key, kbstate))
        return TRUE;

      if (current_CS->b_half_full_char)
        return full_char_proc(key);

      inkey=cur_inmd->keymap[key];
      if ((inkey && (inkey!=cur_inmd->WILD_STAR && inkey!=cur_inmd->WILD_QUES)) || ptr_selkey(key)) {
//        dbg("%d %d\n", inkey, cur_inmd->WILD_STAR);
        goto next;
      }
      if (ggg.ci< cur_inmd->MaxPress) {
        ggg.inch[ggg.ci++]=inkey;
        DispInArea();

        if (hime_pop_up_win)
          show_win_gtab();

        ggg.total_matchN = 0;
        ggg.wild_page=0;
        ggg.wild_mode=1;
        wildcard();
        return 1;
      }
      return 0;
    case XK_Left:
    case XK_KP_Left:
      return gbuf_cursor_left();
    case XK_Right:
    case XK_KP_Right:
      return gbuf_cursor_right();
    case XK_Home:
    case XK_KP_Home:
      return gbuf_cursor_home();
    case XK_End:
    case XK_KP_End:
      return gbuf_cursor_end();
    case XK_Delete:
    case XK_KP_Delete:
      return gtab_buf_delete();
    case XK_Shift_L:
    case XK_Shift_R:
    case XK_Control_R:
    case XK_Control_L:
    case XK_Alt_L:
    case XK_Alt_R:
    case XK_Caps_Lock:
      return 0;
    case '`':
      if (gtab_pho_query && !cur_inmd->keymap[key]) {
        poo.same_pho_query_state = SAME_PHO_QUERY_gtab_input;
        reset_gtab_all();
        disp_gtab_sel(_("輸入要查的同音字,接著在注音視窗選字"));
        if (hime_pop_up_win)
          show_win_gtab();
        disp_pho_sel("");
        init_gtab_pho_query_win();
        return 1;
      }
    default:
next:

      if (key < 0x7f)
        inkey= cur_inmd->keymap[key];
      else
        inkey = 0;

      if (shift_m && !inkey && !tss.ctrl_pre_sel &&
        tss.pre_selN && shift_char_proc(key, kbstate))
        return TRUE;

      clear_gtab_input_error_color();

      if (ggg.invalid_spc && gtab_invalid_key_in) {
        ClrIn();
      }
      if (key>=XK_KP_0 && key<=XK_KP_9) {
        if (!ggg.ci) {
          if (ggg.gbufN) {
            insert_gbuf_cursor_char(key - XK_KP_0 + '0');
            return 1;
          } else
            return 0;
        }
        if (is_dayi) {
          key = key - XK_KP_0 + '0';
          is_keypad = TRUE;
        }
      }

      int keypad;
keypad_proc:
      keypad = keypad_proc(key);
      if (keypad) {
        if (!ggg.ci) {
          if (ggg.gbufN) {
            insert_gbuf_cursor_char(keypad);
            return 1;
          } else
            return 0;
        }
      }
      char *pendkey = strchr(cur_inmd->endkey, key);

      pselkey=ptr_selkey(key);

      if (!pselkey && (key < 32 || key > 0x7e) && (gtab_full_space_auto_first || ggg.spc_pressed)) {
//        dbg("%x %x ggg.sel1st_i:%d  '%c'\n", pselkey, key, ggg.sel1st_i, seltab[ggg.sel1st_i][0]);
        if (seltab[ggg.sel1st_i][0]) {
          if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
            insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match);
          else
            putstr_inp(seltab[ggg.sel1st_i]);  /* select 1st */
        }

        return 0;
      }



//        dbg("ggg.spc_pressed %d %d %d is_keypad:%d\n", ggg.spc_pressed, ggg.last_full, cur_inmd->MaxPress, is_keypad);

#if 1 // for dayi, testcase :  6 space keypad6
      int vv = pselkey - cur_inmd->selkey;
      if (pselkey && tss.pre_selN && !ggg.gtab_buf_select && (tss.ctrl_pre_sel||
          ((!inkey||ggg.spc_pressed||is_keypad)&&! gtab_disp_partial_match_on() && !gtab_pre_select_on()))) {
        if (gtab_pre_select_idx(vv))
          return TRUE;
      } else
      if (( (ggg.spc_pressed||ggg.last_full||is_keypad) ||(ggg.wild_mode && (!inkey ||pendkey)) || ggg.gtab_buf_select) && pselkey) {
        if ((_gtab_space_auto_first & GTAB_space_auto_first_any) && !ggg.wild_mode)
          vv++;

        if (vv<0)
          vv=9;

        if (seltab[vv][0]) {
          if (AUTO_SELECT_BY_PHRASE && !same_query_show_pho_win()) {
            if (ggg.gtab_buf_select && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
              set_gbuf_c_sel(vv);
            else
              insert_gbuf_cursor1_cond(seltab[vv], ggg.kval, ggg.exa_match);
          }
          else {
            putstr_inp(seltab[vv]);
          }

          if (hime_pop_up_win && !gtab_has_input())
            hide_win_gtab();

          return 1;
        }
      }
#endif

//      dbg("iii %x sel1st_i:%d auto:%d\n", pselkey, ggg.sel1st_i, AUTO_SELECT_BY_PHRASE);
      if (seltab[ggg.sel1st_i][0] && !ggg.wild_mode &&
           (gtab_full_space_auto_first||ggg.spc_pressed||ggg.last_full) ) {
        if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
          insert_gbuf_cursor1_cond(seltab[ggg.sel1st_i], ggg.kval, ggg.exa_match);
        else
          putstr_inp(seltab[ggg.sel1st_i]);  /* select 1st */
      }
#if 0
      if (key > 0x7f) {
        return 0;
      }
#endif

      ggg.spc_pressed=0;

      // for cj & boshiamy to input digits
      if (!ggg.ci && !inkey) {
        if (current_CS->b_half_full_char)
          return full_char_proc(key);
        else {
          if (ggg.gbufN && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input) {
            insert_gbuf_cursor_char(key);
            return 1;
          }
          else
            return 0;
        }
      }

      if (ggg.wild_mode && inkey>=1 && ggg.ci< cur_inmd->MaxPress) {
        ggg.inch[ggg.ci++]=inkey;
        if (hime_pop_up_win)
          show_win_gtab();
        proc_wild_disp();
        return 1;
      }

      if (inkey>=1 && ggg.ci< cur_inmd->MaxPress) {
        ggg.inch[ggg.ci++]=inkey;
        hide_gtab_pre_sel();

        if (hime_pop_up_win)
          show_win_gtab();
        ggg.last_full=0;

        if (cur_inmd->use_quick && !pendkey) {
          if (ggg.ci==1) {
            int i;
            for(i=0;i < cur_inmd->M_DUP_SEL; i++) {
              utf8cpy(seltab[i], (char *)&cur_inmd->qkeys->quick1[inkey-1][i]);
            }

            ggg.defselN=cur_inmd->M_DUP_SEL;
            DispInArea();
            goto Disp_opt;
          } else
          if (ggg.ci==2 && !pselkey) {
            int i;
            for(i=0;i < cur_inmd->M_DUP_SEL; i++) {
              utf8cpy(seltab[i], (char *)&cur_inmd->qkeys->quick2[ggg.inch[0]-1][inkey-1][i]);
            }

            ggg.defselN=cur_inmd->M_DUP_SEL;
            DispInArea();
            goto Disp_opt;
          }
        }
      } else
      if (ggg.ci == cur_inmd->MaxPress && !pselkey) {
        bell();
        return 1;
      }


      if (inkey) {
        for(i=0; i < MAX_TAB_KEY_NUM64_6; i++)
          if (ggg.inch[i]>=cur_inmd->WILD_QUES) {
            DispInArea();
            if (ggg.ci==cur_inmd->MaxPress) {
              ggg.wild_mode=1;
              ggg.wild_page=0;
              wildcard();
            }

            return 1;
          }
      } else {
        if (!pselkey) {
          if (current_CS->b_half_full_char)
            return full_char_proc(key);
          else {
            if (key>=' ' && key<0x7f && AUTO_SELECT_BY_PHRASE && ggg.gbufN)
              insert_gbuf_cursor_char(key);
            else
              return 0;
          }
        }

        if (ggg.defselN) {
          goto YYYY;
        }
     }
  } /* switch */


  if (ggg.ci==0) {
    ClrSelArea();
    ClrIn();
    return 1;
  }

  ggg.invalid_spc = FALSE;
  char *pendkey = NULL;
  pendkey = strchr(cur_inmd->endkey, key);

  DispInArea();

  ggg.kval=0;

  for(i=0; i < Max_tab_key_num; i++) {
    ggg.kval|= (u_int64_t)ggg.inch[i] << (KeyBits * (Max_tab_key_num - 1 - i));
  }

#if 1
  if (ggg.last_idx)
    ggg.S1=ggg.last_idx;
  else
#endif
    ggg.S1=cur_inmd->idx1[ggg.inch[0]];

//  dbg("--------- ch:%d %d val %llx  ggg.S1:%d\n", ggg.inch[0], Max_tab_key_num, ggg.kval, ggg.S1);

  int oE1;
  oE1=cur_inmd->idx1[ggg.inch[0]+1];
  if (cur_inmd->keybits==6)
    vmaskci = cur_inmd->key64 ? vmask64[ggg.ci]:vmask[ggg.ci];
  else
    vmaskci = cur_inmd->key64 ? vmask64_7[ggg.ci]:vmask_7[ggg.ci];

  gtab_scan_pre_select(TRUE);

  while ((CONVT2(cur_inmd, ggg.S1) & vmaskci) != ggg.kval &&
          CONVT2(cur_inmd, ggg.S1) < ggg.kval &&  ggg.S1<oE1)
    ggg.S1++;

  ggg.pg_idx=ggg.last_idx=ggg.S1;


#if 0
  dbg("MaxPress:%d vmaskci:%llx kval:%llx ggg.ci:%d  !=%d  S1:%d  kval:%x\n", cur_inmd->MaxPress,
  vmaskci, ggg.kval, ggg.ci,
  ((CONVT2(cur_inmd, ggg.S1) & vmaskci)!=ggg.kval), ggg.S1);
#endif

  if ((CONVT2(cur_inmd, ggg.S1) & vmaskci)!=ggg.kval || (ggg.wild_mode && ggg.defselN) ||
                  ((/* ggg.ci==cur_inmd->MaxPress|| */ ggg.spc_pressed) && ggg.defselN &&
      (pselkey && ( pendkey || ggg.spc_pressed)) ) ) {
YYYY:

    if ((pselkey || ggg.wild_mode) && ggg.defselN) {
      int vv = pselkey - cur_inmd->selkey;

      if ((_gtab_space_auto_first & GTAB_space_auto_first_any) && !ggg.wild_mode
          && ggg.exa_match && (!cur_inmd->use_quick || ggg.ci!=2))
        vv++;

      if (vv<0)
        vv=9;

      if (seltab[vv][0]) {
        if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
          insert_gbuf_cursor1_cond(seltab[vv], ggg.kval, ggg.exa_match);
        else
          putstr_inp(seltab[vv]);
        return 1;
      }
    }

    if (pselkey && !ggg.defselN)
      return 0;

    if (gtab_invalid_key_in) {
      if (ggg.spc_pressed) {
        bell_err();
        ggg.invalid_spc = TRUE;
//        dbg("ggg.invalid_spc\n");
      } else {
        seltab[0][0]=0;
        ClrSelArea();
      }
    } else {
      if (gtab_dup_select_bell)
        bell();

      if (ggg.ci>0)
        ggg.inch[--ggg.ci]=0;
    }

    ggg.last_idx=0;
    DispInArea();
    return 1;
  }

//refill:

  j=ggg.S1;
  while(CONVT2(cur_inmd, j)==ggg.kval && j<oE1)
    j++;

  ggg.E1 = j;
  ggg.total_matchN = ggg.E1 - ggg.S1;
  ggg.pg_idx = ggg.S1;

  ggg.more_pg = 0;
  if (ggg.total_matchN > page_len()) {
    if ((_gtab_space_auto_first & GTAB_space_auto_first_any) || ggg.spc_pressed || pendkey ||
      (ggg.ci==cur_inmd->MaxPress && (_gtab_space_auto_first & GTAB_space_auto_first_full)))
      ggg.more_pg = 1;
  }

  if (ggg.ci < cur_inmd->MaxPress && !ggg.spc_pressed && !pendkey && !ggg.more_pg) {
    j = ggg.S1;
    ggg.exa_match=0;
    clr_seltab();
    int match_cnt=0;

    while (CONVT2(cur_inmd, j)==ggg.kval && ggg.exa_match <= page_len()) {
      seltab_phrase[ggg.exa_match] = load_seltab(j, ggg.exa_match);
      match_cnt++;
      ggg.exa_match++;
      j++;
    }

    ggg.defselN=ggg.exa_match;
//    dbg("--- ggg.exa_match %d\n", ggg.exa_match);

    if (ggg.defselN > page_len())
      ggg.defselN--;

    int shiftb=(KEY_N - 1 -ggg.ci) * KeyBits;

//    if (gtab_disp_partial_match_on)
    while((CONVT2(cur_inmd, j) & vmaskci)==ggg.kval && j<oE1) {
      int fff=cur_inmd->keycol[(CONVT2(cur_inmd, j)>>shiftb) & cur_inmd->kmask];
      u_char *tbl_ch = tblch(j);

      if (gtab_disp_partial_match_on() && (!seltab[fff][0] || seltab_phrase[fff] ||
           (bchcmp(seltab[fff], tbl_ch)>0 && fff > ggg.exa_match))) {
        seltab_phrase[fff] = load_seltab(j, fff);
        ggg.defselN++;
      }

      match_cnt++;
#if 0
      dbg("jj %d", fff); utf8_putchar(seltab[fff]); dbg("\n");
#endif
      j++;
    }

    if (gtab_unique_auto_send_on()) {
      char *first_str=NULL;
      for(i=0; i < page_len(); i++) {
        if (!seltab[i][0])
          continue;
        if (!first_str)
          first_str = seltab[i];
      }

      if (match_cnt==1 && first_str) {
        if (AUTO_SELECT_BY_PHRASE && poo.same_pho_query_state != SAME_PHO_QUERY_gtab_input)
          insert_gbuf_nokey(first_str);
        else
          putstr_inp(first_str);
        return 1;
      }
    }
  } else {
Exemplo n.º 10
0
void wildcard()
{
  int i,t, wild_ofs=0;
  int found=0;
  regex_t reg;

  ClrSelArea();
  clr_seltab();
  /* printf("wild %d %d %d %d\n", ggg.inch[0], ggg.inch[1], ggg.inch[2], ggg.inch[3]); */
  ggg.defselN=0;
  char regstr[32];
  int regstrN=0;

  regstr[regstrN++]=' ';

  for(i=0; i < KEY_N; i++) {
    if (!ggg.inch[i])
      break;
    if (ggg.inch[i] == cur_inmd->WILD_STAR) {
      regstr[regstrN++]='.';
      regstr[regstrN++]='*';
    } else
    if (ggg.inch[i] == cur_inmd->WILD_QUES) {
      regstr[regstrN++]='.';
    } else {
      char c = ggg.inch[i] + '0';         // start from '0'
      if (strchr("*.\\()[]", c))
      regstr[regstrN++] = '\\';
      regstr[regstrN++]=c;
    }
  }

  regstr[regstrN++]=' ';
  regstr[regstrN]=0;

//  dbg("regstr %s\n", regstr);

  if (regcomp(&reg, regstr, 0)) {
    dbg("regcomp failed\n");
    return;
  }

  for(t=0; t< cur_inmd->DefChars && ggg.defselN < cur_inmd->M_DUP_SEL; t++) {
    if (cmp_inmd_idx(&reg, t))
      continue;

    if (wild_ofs >= ggg.wild_page) {
      load_seltab(t, ggg.defselN);
      ggg.defselN++;
    } else
      wild_ofs++;

    found=1;
  } /* for t */


  if (!found) {
    bell_err();
  } else
  if (!ggg.wild_page) {
    ggg.total_matchN = 0;

    for(t=0; t< cur_inmd->DefChars; t++)
      if (!cmp_inmd_idx(&reg, t))
        ggg.total_matchN++;

  }

  if (ggg.total_matchN > cur_inmd->M_DUP_SEL)
    ggg.more_pg = 1;

  regfree(&reg);
  disp_selection(FALSE);
}
Exemplo n.º 11
0
void clear_after_put()
{
  ClrIn();
  ClrSelArea();
}