Пример #1
0
/// Overwrite the current redo and cursor characters + left adjust
///
/// @param c
static void put_curr_and_l_to_X(int c)
{
  int tempc;

  if (curwin->w_p_rl && p_ri) {
    return;
  }

  if ((curwin->w_cursor.col < (colnr_T)STRLEN(ml_get_curline()))) {
    if ((p_ri && curwin->w_cursor.col) || !p_ri) {
      if (p_ri) {
        dec_cursor();
      } else {
        inc_cursor();
      }

      if (F_is_TyC_TyD((tempc = gchar_cursor()))) {
        pchar_cursor(toF_TyB(tempc));
        AppendCharToRedobuff(K_BS);
        AppendCharToRedobuff(tempc);
      }

      if (p_ri) {
        inc_cursor();
      } else {
        dec_cursor();
      }
    }
  }

  put_and_redo(c);
}
Пример #2
0
/// Change the character left to the cursor to a X or _X type
static void chg_l_toXor_X(void)
{
  char_u tempc;

  if ((curwin->w_cursor.col != 0)
      && (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(get_cursor_line_ptr()))) {
    return;
  }

  if (!curwin->w_cursor.col && p_ri) {
    return;
  }

  if (p_ri) {
    dec_cursor();
  } else {
    inc_cursor();
  }

  switch (gchar_cursor()) {
    case ALEF_     : tempc = ALEF     ; break;
    case ALEF_U_H_ : tempc = ALEF_U_H ; break;
    case _AYN_     : tempc = _AYN     ; break;
    case AYN_      : tempc = AYN      ; break;
    case _GHAYN_   : tempc = _GHAYN   ; break;
    case GHAYN_    : tempc = GHAYN    ; break;
    case _HE_      : tempc = _HE      ; break;
    case YE_       : tempc = YE       ; break;
    case IE_       : tempc = IE       ; break;
    case TEE_      : tempc = TEE      ; break;
    case YEE_      : tempc = YEE      ; break;
    default        : tempc = 0        ;
  }

  if (tempc) {
    put_and_redo(tempc);
  }

  if (p_ri) {
    inc_cursor();
  } else {
    dec_cursor();
  }
}
Пример #3
0
/* 
	Our window with cursor has got some input
	
	key_cnt == -1 means no input has been taking place at this cursor position
	key_cnt >= 0 means the same key has been pressed one or more times here
*/
void
win_cursor_input(int new_key){
	char c;
	
	if (new_key == CURSOR_LEFT){
		dec_cursor();
		key_cnt = -1;
		last_key = -1;
		timer_stop(&char_tmr);
		return;
	};
	
	if (new_key == CURSOR_RIGHT){
		advance_cursor();
		key_cnt = -1;
		last_key = -1;
		timer_stop(&char_tmr);
		return;
	};
	
	/* A bit tricky. It makes sense to implement this as a kind of delete, i.e. delete the character 
		under the cursor. This only fails if the cursor is at end of text. Then delete the last character.
	*/
	if (new_key == CURSOR_BACKSPACE){
		key_cnt = -1;
		last_key = -1;
		timer_stop(&char_tmr);
		
		del_char(pcursor_win, cursor_pos);
		cursor_pos = min(cursor_pos, pcursor_win->text_len);
		return;	
	};
	
	timer_set(&char_tmr, WAIT_KEY_TIME, 0);				// start auto advance timer	
	/* This is the first time a key is pressed here */
	if (key_cnt < 0){
		key_cnt = 0;
		c = key2char(new_key, 0);
		store_char(pcursor_win, cursor_pos, c);
	} else {
		/* We already entered text at this cursor position */	
		if (new_key == last_key){			// User pressed the same key twice before a time out occured 
			key_cnt++;
			c = key2char(new_key, key_cnt);
			store_char(pcursor_win, cursor_pos, c);
		} else {
		// User pressed a different key, advance to the next cursor position, store new char
			key_cnt = 0;
			c = key2char(new_key, 0);
			advance_cursor();
			store_char(pcursor_win, cursor_pos, c);
		};
	};
	last_key = new_key;		
};
Пример #4
0
/// Change the char. under the cursor to a _X_ or _X type
static void chg_c_to_X_or_X(void)
{
  int tempc;

  tempc = gchar_cursor();

  if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(get_cursor_line_ptr())) {
    inc_cursor();
    if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) {
      tempc = _HE_;
      dec_cursor();
      put_and_redo((char_u)tempc);
      return;
    }
    dec_cursor();
  }

  if ((tempc = toF_Xor_X_(tempc)) != 0) {
    put_and_redo((char_u)tempc);
  }
}
Пример #5
0
static void chg_r_to_Xor_X_(void)                 {
  int tempc, c;

  if (curwin->w_cursor.col) {
    if (!p_ri)
      dec_cursor();

    tempc = gchar_cursor();

    if ((c = toF_Xor_X_(tempc)) != 0)
      put_and_redo(c);

    if (!p_ri)
      inc_cursor();

  }
}
Пример #6
0
/// Map Farsi keyboard when in fkmap mode.
int fkmap(int c)
{
  int tempc;
  static int revins;

  if (IS_SPECIAL(c)) {
    return c;
  }

  if (VIM_ISDIGIT(c)
      || (((c == '.')
           || (c == '+')
           || (c == '-')
           || (c == '^')
           || (c == '%')
           || (c == '#')
           || (c == '='))
          && revins)) {
    if (!revins) {
      if (curwin->w_cursor.col) {
        if (!p_ri) {
          dec_cursor();
        }

        chg_c_toX_orX();
        chg_l_toXor_X();
        if (!p_ri) {
          inc_cursor();
        }
      }
    }

    arrow_used = TRUE;
    (void)stop_arrow();

    if (!curwin->w_p_rl && revins) {
      inc_cursor();
    }

    revins++;
    p_ri = 1;
  } else {
    if (revins) {
      arrow_used = TRUE;
      (void)stop_arrow();

      revins = 0;
      if (curwin->w_p_rl) {
        while ((F_isdigit(gchar_cursor())
                || (gchar_cursor() == F_PERIOD
                    || gchar_cursor() == F_PLUS
                    || gchar_cursor() == F_MINUS
                    || gchar_cursor() == F_MUL
                    || gchar_cursor() == F_DIVIDE
                    || gchar_cursor() == F_PERCENT
                    || gchar_cursor() == F_EQUALS))
                && gchar_cursor() != '\0') {
          curwin->w_cursor.col++;
        }
      } else {
        if (curwin->w_cursor.col) {
          while ((F_isdigit(gchar_cursor())
                 || (gchar_cursor() == F_PERIOD
                     || gchar_cursor() == F_PLUS
                     || gchar_cursor() == F_MINUS
                     || gchar_cursor() == F_MUL
                     || gchar_cursor() == F_DIVIDE
                     || gchar_cursor() == F_PERCENT
                     || gchar_cursor() == F_EQUALS))
                 && --curwin->w_cursor.col) {
          }
        }

        if (!F_isdigit(gchar_cursor())) {
          ++curwin->w_cursor.col;
        }
      }
    }
  }

  if (!revins) {
    if (curwin->w_p_rl) {
      p_ri = 0;
    }

    if (!curwin->w_p_rl) {
      p_ri = 1;
    }
  }

  if ((c < 0x100) &&
      (isalpha(c) ||
       (c == '&') ||
       (c == '^') ||
       (c == ';') ||
       (c == '\'') ||
       (c == ',') ||
       (c == '[') ||
       (c == ']') ||
       (c == '{') ||
       (c == '}'))) {
    chg_r_to_Xor_X_();
  }

  tempc = 0;
  switch (c) {
    case '`':
    case ' ':
    case '.':
    case '!':
    case '"':
    case '$':
    case '%':
    case '^':
    case '&':
    case '/':
    case '(':
    case ')':
    case '=':
    case '\\':
    case '?':
    case '+':
    case '-':
    case '_':
    case '*':
    case ':':
    case '#':
    case '~':
    case '@':
    case '<':
    case '>':
    case '{':
    case '}':
    case '|':
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
    case 'B':
    case 'E':
    case 'F':
    case 'H':
    case 'I':
    case 'K':
    case 'L':
    case 'M':
    case 'O':
    case 'P':
    case 'Q':
    case 'R':
    case 'T':
    case 'U':
    case 'W':
    case 'Y':
    case  NL:
    case  TAB:
      if (p_ri && (c == NL) && curwin->w_cursor.col) {
        // If the char before the cursor is _X_ or X_ do not change
        // the one under the cursor with X type.

        dec_cursor();
        if (F_isalpha(gchar_cursor())) {
          inc_cursor();
          return NL;
        }
        inc_cursor();
      }

      if (!p_ri) {
        if (!curwin->w_cursor.col) {
          switch (c) {
            case '0':
              return FARSI_0;

            case '1':
              return FARSI_1;

            case '2':
              return FARSI_2;

            case '3':
              return FARSI_3;

            case '4':
              return FARSI_4;

            case '5':
              return FARSI_5;

            case '6':
              return FARSI_6;

            case '7':
              return FARSI_7;

            case '8':
              return FARSI_8;

            case '9':
              return FARSI_9;

            case 'B':
              return F_PSP;

            case 'E':
              return JAZR_N;

            case 'F':
              return ALEF_D_H;

            case 'H':
              return ALEF_A;

            case 'I':
              return TASH;

            case 'K':
              return F_LQUOT;

            case 'L':
              return F_RQUOT;

            case 'M':
              return HAMZE;

            case 'O':
              return '[';

            case 'P':
              return ']';

            case 'Q':
              return OO;

            case 'R':
              return MAD_N;

            case 'T':
              return OW;

            case 'U':
              return MAD;

            case 'W':
              return OW_OW;

            case 'Y':
              return JAZR;

            case '`':
              return F_PCN;

            case '!':
              return F_EXCL;

            case '@':
              return F_COMMA;

            case '#':
              return F_DIVIDE;

            case '$':
              return F_CURRENCY;

            case '%':
              return F_PERCENT;

            case '^':
              return F_MUL;

            case '&':
              return F_BCOMMA;

            case '*':
              return F_STAR;

            case '(':
              return F_LPARENT;

            case ')':
              return F_RPARENT;

            case '-':
              return F_MINUS;

            case '_':
              return F_UNDERLINE;

            case '=':
              return F_EQUALS;

            case '+':
              return F_PLUS;

            case '\\':
              return F_BSLASH;

            case '|':
              return F_PIPE;

            case ':':
              return F_DCOLON;

            case '"':
              return F_SEMICOLON;

            case '.':
              return F_PERIOD;

            case '/':
              return F_SLASH;

            case '<':
              return F_LESS;

            case '>':
              return F_GREATER;

            case '?':
              return F_QUESTION;

            case ' ':
              return F_BLANK;
          }
          break;
        }
      }

      if (!p_ri) {
        dec_cursor();
      }

      switch ((tempc = gchar_cursor())) {
        case _BE:
        case _PE:
        case _TE:
        case _SE:
        case _JIM:
        case _CHE:
        case _HE_J:
        case _XE:
        case _SIN:
        case _SHIN:
        case _SAD:
        case _ZAD:
        case _FE:
        case _GHAF:
        case _KAF:
        case _KAF_H:
        case _GAF:
        case _LAM:
        case _MIM:
        case _NOON:
        case _HE:
        case _HE_:
        case _TA:
        case _ZA:
          put_curr_and_l_to_X(toF_TyA(tempc));
          break;

        case _AYN:
        case _AYN_:
          if (!p_ri) {
            if (!curwin->w_cursor.col) {
              put_curr_and_l_to_X(AYN);
              break;
            }
          }

          if (p_ri) {
            inc_cursor();
          } else {
            dec_cursor();
          }

          if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
            tempc = AYN_;
          } else {
            tempc = AYN;
          }

          if (p_ri) {
            dec_cursor();
          } else {
            inc_cursor();
          }

          put_curr_and_l_to_X(tempc);
          break;

        case _GHAYN:
        case _GHAYN_:

          if (!p_ri) {
            if (!curwin->w_cursor.col) {
              put_curr_and_l_to_X(GHAYN);
              break;
            }
          }

          if (p_ri) {
            inc_cursor();
          } else {
            dec_cursor();
          }

          if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
            tempc = GHAYN_;
          } else {
            tempc = GHAYN;
          }

          if (p_ri) {
            dec_cursor();
          } else {
            inc_cursor();
          }

          put_curr_and_l_to_X(tempc);
          break;

        case _YE:
        case _IE:
        case _YEE:

          if (!p_ri) {
            if (!curwin->w_cursor.col) {
              put_curr_and_l_to_X((tempc == _YE ? YE :
                                   (tempc == _IE ? IE : YEE)));
              break;
            }
          }

          if (p_ri) {
            inc_cursor();
          } else {
            dec_cursor();
          }

          if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
            tempc = (tempc == _YE ? YE_ :
                     (tempc == _IE ? IE_ : YEE_));
          } else {
            tempc = (tempc == _YE ? YE :
                     (tempc == _IE ? IE : YEE));
          }

          if (p_ri) {
            dec_cursor();
          } else {
            inc_cursor();
          }

          put_curr_and_l_to_X(tempc);
          break;
      }

      if (!p_ri) {
        inc_cursor();
      }

      tempc = 0;

      switch (c) {
        case '0':
          return FARSI_0;

        case '1':
          return FARSI_1;

        case '2':
          return FARSI_2;

        case '3':
          return FARSI_3;

        case '4':
          return FARSI_4;

        case '5':
          return FARSI_5;

        case '6':
          return FARSI_6;

        case '7':
          return FARSI_7;

        case '8':
          return FARSI_8;

        case '9':
          return FARSI_9;

        case 'B':
          return F_PSP;

        case 'E':
          return JAZR_N;

        case 'F':
          return ALEF_D_H;

        case 'H':
          return ALEF_A;

        case 'I':
          return TASH;

        case 'K':
          return F_LQUOT;

        case 'L':
          return F_RQUOT;

        case 'M':
          return HAMZE;

        case 'O':
          return '[';

        case 'P':
          return ']';

        case 'Q':
          return OO;

        case 'R':
          return MAD_N;

        case 'T':
          return OW;

        case 'U':
          return MAD;

        case 'W':
          return OW_OW;

        case 'Y':
          return JAZR;

        case '`':
          return F_PCN;

        case '!':
          return F_EXCL;

        case '@':
          return F_COMMA;

        case '#':
          return F_DIVIDE;

        case '$':
          return F_CURRENCY;

        case '%':
          return F_PERCENT;

        case '^':
          return F_MUL;

        case '&':
          return F_BCOMMA;

        case '*':
          return F_STAR;

        case '(':
          return F_LPARENT;

        case ')':
          return F_RPARENT;

        case '-':
          return F_MINUS;

        case '_':
          return F_UNDERLINE;

        case '=':
          return F_EQUALS;

        case '+':
          return F_PLUS;

        case '\\':
          return F_BSLASH;

        case '|':
          return F_PIPE;

        case ':':
          return F_DCOLON;

        case '"':
          return F_SEMICOLON;

        case '.':
          return F_PERIOD;

        case '/':
          return F_SLASH;

        case '<':
          return F_LESS;

        case '>':
          return F_GREATER;

        case '?':
          return F_QUESTION;

        case ' ':
          return F_BLANK;
      }
      break;

    case 'a':
      tempc = _SHIN;
      break;

    case 'A':
      tempc = WAW_H;
      break;

    case 'b':
      tempc = ZAL;
      break;

    case 'c':
      tempc = ZE;
      break;

    case 'C':
      tempc = JE;
      break;

    case 'd':
      tempc = _YE;
      break;

    case 'D':
      tempc = _YEE;
      break;

    case 'e':
      tempc = _SE;
      break;

    case 'f':
      tempc = _BE;
      break;

    case 'g':
      tempc = _LAM;
      break;

    case 'G':
      if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
        if (gchar_cursor() == _LAM) {
          chg_c_toX_orX();
        } else if (p_ri) {
          chg_c_to_X_or_X();
        }
      }

      if (!p_ri) {
        if (!curwin->w_cursor.col) {
          return ALEF_U_H;
        }
      }

      if (!p_ri) {
        dec_cursor();
      }

      if (gchar_cursor() == _LAM) {
        chg_c_toX_orX();
        chg_l_toXor_X();
        tempc = ALEF_U_H;
      } else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
        tempc = ALEF_U_H_;
        chg_l_toXor_X();
      } else {
        tempc = ALEF_U_H;
      }

      if (!p_ri) {
        inc_cursor();
      }

      return tempc;

    case 'h':
      if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
        if (p_ri) {
          chg_c_to_X_or_X();
        }
      }

      if (!p_ri) {
        if (!curwin->w_cursor.col) {
          return ALEF;
        }
      }

      if (!p_ri) {
        dec_cursor();
      }

      if (gchar_cursor() == _LAM) {
        chg_l_toXor_X();
        del_char(FALSE);
        AppendCharToRedobuff(K_BS);

        if (!p_ri) {
          dec_cursor();
        }

        tempc = LA;
      } else {
        if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
          tempc = ALEF_;
          chg_l_toXor_X();
        } else {
          tempc = ALEF;
        }
      }

      if (!p_ri) {
        inc_cursor();
      }

      return tempc;

    case 'i':

      if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
        if (!p_ri && !F_is_TyE(tempc)) {
          chg_c_to_X_orX_();
        }

        if (p_ri) {
          chg_c_to_X_or_X();
        }
      }

      if (!p_ri && !curwin->w_cursor.col) {
        return _HE;
      }

      if (!p_ri) {
        dec_cursor();
      }

      if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
        tempc = _HE_;
      } else {
        tempc = _HE;
      }

      if (!p_ri) {
        inc_cursor();
      }
      break;

    case 'j':
      tempc = _TE;
      break;

    case 'J':

      if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
        if (p_ri) {
          chg_c_to_X_or_X();
        }
      }

      if (!p_ri) {
        if (!curwin->w_cursor.col) {
          return TEE;
        }
      }

      if (!p_ri) {
        dec_cursor();
      }

      if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
        tempc = TEE_;
        chg_l_toXor_X();
      } else {
        tempc = TEE;
      }

      if (!p_ri) {
        inc_cursor();
      }

      return tempc;

    case 'k':
      tempc = _NOON;
      break;

    case 'l':
      tempc = _MIM;
      break;

    case 'm':
      tempc = _PE;
      break;

    case 'n':
    case 'N':
      tempc = DAL;
      break;

    case 'o':
      tempc = _XE;
      break;

    case 'p':
      tempc = _HE_J;
      break;

    case 'q':
      tempc = _ZAD;
      break;

    case 'r':
      tempc = _GHAF;
      break;

    case 's':
      tempc = _SIN;
      break;

    case 'S':
      tempc = _IE;
      break;

    case 't':
      tempc = _FE;
      break;

    case 'u':
      if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
        if (!p_ri && !F_is_TyE(tempc)) {
          chg_c_to_X_orX_();
        }

        if (p_ri) {
          chg_c_to_X_or_X();
        }
      }

      if (!p_ri && !curwin->w_cursor.col) {
        return _AYN;
      }

      if (!p_ri) {
        dec_cursor();
      }

      if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
        tempc = _AYN_;
      } else {
        tempc = _AYN;
      }

      if (!p_ri) {
        inc_cursor();
      }
      break;

    case 'v':
    case 'V':
      tempc = RE;
      break;

    case 'w':
      tempc = _SAD;
      break;

    case 'x':
    case 'X':
      tempc = _TA;
      break;

    case 'y':
      if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
        if (!p_ri && !F_is_TyE(tempc)) {
          chg_c_to_X_orX_();
        }

        if (p_ri) {
          chg_c_to_X_or_X();
        }
      }

      if (!p_ri && !curwin->w_cursor.col) {
        return _GHAYN;
      }

      if (!p_ri) {
        dec_cursor();
      }

      if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
        tempc = _GHAYN_;
      } else {
        tempc = _GHAYN;
      }

      if (!p_ri) {
        inc_cursor();
      }

      break;

    case 'z':
      tempc = _ZA;
      break;

    case 'Z':
      tempc = _KAF_H;
      break;

    case ';':
      tempc = _KAF;
      break;

    case '\'':
      tempc = _GAF;
      break;

    case ',':
      tempc = WAW;
      break;

    case '[':
      tempc = _JIM;
      break;

    case ']':
      tempc = _CHE;
      break;
  }

  if ((F_isalpha(tempc) || F_isdigit(tempc))) {
    if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) {
      if (!p_ri && !F_is_TyE(tempc)) {
        chg_c_to_X_orX_();
      }

      if (p_ri) {
        chg_c_to_X_or_X();
      }
    }

    if (curwin->w_cursor.col) {
      if (!p_ri) {
        dec_cursor();
      }

      if (F_is_TyE(tempc)) {
        chg_l_toXor_X();
      } else {
        chg_l_to_X_orX_();
      }

      if (!p_ri) {
        inc_cursor();
      }
    }
  }

  if (tempc) {
    return tempc;
  }
  return c;
}
Пример #7
0
/// Convert the given Farsi character into a _X or _X_ type
///
/// @param c The character to convert.
///
/// @return Farsi character converted to a _X or _X_ type.
static int toF_Xor_X_(int c)
{
  int tempc;

  switch (c) {
    case BE:
      return _BE;

    case PE:
      return _PE;

    case TE:
      return _TE;

    case SE:
      return _SE;

    case JIM:
      return _JIM;

    case CHE:
      return _CHE;

    case HE_J:
      return _HE_J;

    case XE:
      return _XE;

    case SIN:
      return _SIN;

    case SHIN:
      return _SHIN;

    case SAD:
      return _SAD;

    case ZAD:
      return _ZAD;

    case AYN:
      return _AYN;

    case AYN_:
      return _AYN_;

    case GHAYN:
      return _GHAYN;

    case GHAYN_:
      return _GHAYN_;

    case FE:
      return _FE;

    case GHAF:
      return _GHAF;

    case KAF:
      return _KAF;

    case GAF:
      return _GAF;

    case LAM:
      return _LAM;

    case MIM:
      return _MIM;

    case NOON:
      return _NOON;

    case YE:
    case YE_:
      return _YE;

    case YEE:
    case YEE_:
      return _YEE;

    case IE:
    case IE_:
      return _IE;

    case F_HE:
      tempc = _HE;

      if (p_ri &&
          (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline()))) {
        inc_cursor();
        if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
          tempc = _HE_;
        }
        dec_cursor();
      }

      if (!p_ri && STRLEN(ml_get_curline())) {
        dec_cursor();
        if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
          tempc = _HE_;
        }
        inc_cursor();
      }

      return tempc;
  }
  return 0;
}
Пример #8
0
/// Change the character left to the cursor to a _X_ or X_ type
static void chg_l_to_X_orX_(void)
{
  int tempc;

  if ((curwin->w_cursor.col != 0)
      && (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) {
    return;
  }

  if (!curwin->w_cursor.col && p_ri) {
    return;
  }

  if (p_ri) {
    dec_cursor();
  } else {
    inc_cursor();
  }

  switch (gchar_cursor()) {
    case ALEF:
      tempc = ALEF_;
      break;

    case ALEF_U_H:
      tempc = ALEF_U_H_;
      break;

    case _AYN:
      tempc = _AYN_;
      break;

    case AYN:
      tempc = AYN_;
      break;

    case _GHAYN:
      tempc = _GHAYN_;
      break;

    case GHAYN:
      tempc = GHAYN_;
      break;

    case _HE:
      tempc = _HE_;
      break;

    case YE:
      tempc = YE_;
      break;

    case IE:
      tempc = IE_;
      break;

    case TEE:
      tempc = TEE_;
      break;

    case YEE:
      tempc = YEE_;
      break;

    default:
      tempc = 0;
  }

  if (tempc) {
    put_and_redo(tempc);
  }

  if (p_ri) {
    inc_cursor();
  } else {
    dec_cursor();
  }
}
Пример #9
0
/// Change the char. under the cursor to a X_ or X type
static void chg_c_toX_orX(void)
{
  int tempc, curc;

  switch ((curc = gchar_cursor())) {
    case _BE:
      tempc = BE;
      break;

    case _PE:
      tempc = PE;
      break;

    case _TE:
      tempc = TE;
      break;

    case _SE:
      tempc = SE;
      break;

    case _JIM:
      tempc = JIM;
      break;

    case _CHE:
      tempc = CHE;
      break;

    case _HE_J:
      tempc = HE_J;
      break;

    case _XE:
      tempc = XE;
      break;

    case _SIN:
      tempc = SIN;
      break;

    case _SHIN:
      tempc = SHIN;
      break;

    case _SAD:
      tempc = SAD;
      break;

    case _ZAD:
      tempc = ZAD;
      break;

    case _FE:
      tempc = FE;
      break;

    case _GHAF:
      tempc = GHAF;
      break;

    case _KAF_H:
    case _KAF:
      tempc = KAF;
      break;

    case _GAF:
      tempc = GAF;
      break;

    case _AYN:
      tempc = AYN;
      break;

    case _AYN_:
      tempc = AYN_;
      break;

    case _GHAYN:
      tempc = GHAYN;
      break;

    case _GHAYN_:
      tempc = GHAYN_;
      break;

    case _LAM:
      tempc = LAM;
      break;

    case _MIM:
      tempc = MIM;
      break;

    case _NOON:
      tempc = NOON;
      break;

    case _HE:
    case _HE_:
      tempc = F_HE;
      break;

    case _YE:
    case _IE:
    case _YEE:
      if (p_ri) {
        inc_cursor();

        if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
          tempc = (curc == _YE ? YE_ :
                   (curc == _IE ? IE_ : YEE_));
        } else {
          tempc = (curc == _YE ? YE :
                   (curc == _IE ? IE : YEE));
        }
        dec_cursor();
      } else {
        if (curwin->w_cursor.col) {
          dec_cursor();

          if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
            tempc = (curc == _YE ? YE_ :
                     (curc == _IE ? IE_ : YEE_));
          } else {
            tempc = (curc == _YE ? YE :
                     (curc == _IE ? IE : YEE));
          }
          inc_cursor();
        } else {
          tempc = (curc == _YE ? YE :
                   (curc == _IE ? IE : YEE));
        }
      }
      break;

    default:
      tempc = 0;
  }

  if (tempc) {
    put_and_redo(tempc);
  }
}
Пример #10
0
/// Convert the given Farsi character into a _X or _X_ type
///
/// @param c The character to convert.
///
/// @return Farsi character converted to a _X or _X_ type.
static char_u toF_Xor_X_(int c)
{
  char_u tempc;

  switch (c) {
    case BE     : tempc = _BE     ; break;
    case PE     : tempc = _PE     ; break;
    case TE     : tempc = _TE     ; break;
    case SE     : tempc = _SE     ; break;
    case JIM    : tempc = _JIM    ; break;
    case CHE    : tempc = _CHE    ; break;
    case HE_J   : tempc = _HE_J   ; break;
    case XE     : tempc = _XE     ; break;
    case SIN    : tempc = _SIN    ; break;
    case SHIN   : tempc = _SHIN   ; break;
    case SAD    : tempc = _SAD    ; break;
    case ZAD    : tempc = _ZAD    ; break;
    case AYN    : tempc = _AYN    ; break;
    case AYN_   : tempc = _AYN_   ; break;
    case GHAYN  : tempc = _GHAYN  ; break;
    case GHAYN_ : tempc = _GHAYN_ ; break;
    case FE     : tempc = _FE     ; break;
    case GHAF   : tempc = _GHAF   ; break;
    case KAF    : tempc = _KAF    ; break;
    case GAF    : tempc = _GAF    ; break;
    case LAM    : tempc = _LAM    ; break;
    case MIM    : tempc = _MIM    ; break;
    case NOON   : tempc = _NOON   ; break;
    case YE     :
    case YE_    : tempc = _YE     ; break;
    case YEE    :
    case YEE_   : tempc = _YEE    ; break;
    case IE     :
    case IE_    : tempc = _IE     ; break;
    case F_HE   :
      tempc = _HE;

      if (p_ri
          && (curwin->w_cursor.col + 1
              < (colnr_T)STRLEN(get_cursor_line_ptr()))) {
        inc_cursor();
        if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
          tempc = _HE_;
        }
        dec_cursor();
      }

      if (!p_ri && STRLEN(get_cursor_line_ptr())) {
        dec_cursor();
        if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) {
          tempc = _HE_;
        }
        inc_cursor();
      }

      break;

    default:
      tempc = 0;
  }

  return tempc;
}
Пример #11
0
static void chg_l_toXor_X(void)                 {
  int tempc;

  if (curwin->w_cursor.col != 0 &&
      (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline())))
    return;

  if (!curwin->w_cursor.col && p_ri)
    return;

  if (p_ri)
    dec_cursor();
  else
    inc_cursor();

  switch (gchar_cursor()) {
  case ALEF_:
    tempc = ALEF;
    break;
  case ALEF_U_H_:
    tempc = ALEF_U_H;
    break;
  case _AYN_:
    tempc = _AYN;
    break;
  case AYN_:
    tempc = AYN;
    break;
  case _GHAYN_:
    tempc = _GHAYN;
    break;
  case GHAYN_:
    tempc = GHAYN;
    break;
  case _HE_:
    tempc = _HE;
    break;
  case YE_:
    tempc = YE;
    break;
  case IE_:
    tempc = IE;
    break;
  case TEE_:
    tempc = TEE;
    break;
  case YEE_:
    tempc = YEE;
    break;
  default:
    tempc = 0;
  }

  if (tempc)
    put_and_redo(tempc);

  if (p_ri)
    inc_cursor();
  else
    dec_cursor();
}