diff options
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/keyboard.c | 121 |
1 files changed, 42 insertions, 79 deletions
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 47deb3a5b9..100d5cc319 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c | |||
@@ -630,11 +630,8 @@ int kbd_input(char* text, int buflen) | |||
630 | #ifdef KBD_MODES | 630 | #ifdef KBD_MODES |
631 | if (line_edit) /* right doubles as cursor_right in line_edit */ | 631 | if (line_edit) /* right doubles as cursor_right in line_edit */ |
632 | { | 632 | { |
633 | if (hangul) { | 633 | if (hangul) |
634 | hangul = false; | 634 | hangul = false; |
635 | hlead=hvowel=htail=0; | ||
636 | break; | ||
637 | } | ||
638 | if (editpos < len_utf8) | 635 | if (editpos < len_utf8) |
639 | { | 636 | { |
640 | editpos++; | 637 | editpos++; |
@@ -667,11 +664,8 @@ int kbd_input(char* text, int buflen) | |||
667 | #ifdef KBD_MODES | 664 | #ifdef KBD_MODES |
668 | if (line_edit) /* left doubles as cursor_left in line_edit */ | 665 | if (line_edit) /* left doubles as cursor_left in line_edit */ |
669 | { | 666 | { |
670 | if (hangul) { | 667 | if (hangul) |
671 | hangul = false; | 668 | hangul = false; |
672 | hlead=hvowel=htail=0; | ||
673 | break; | ||
674 | } | ||
675 | if (editpos) | 669 | if (editpos) |
676 | { | 670 | { |
677 | editpos--; | 671 | editpos--; |
@@ -803,18 +797,16 @@ int kbd_input(char* text, int buflen) | |||
803 | #ifdef KBD_MODES | 797 | #ifdef KBD_MODES |
804 | if (line_edit) { /* select doubles as backspace in line_edit */ | 798 | if (line_edit) { /* select doubles as backspace in line_edit */ |
805 | if (hangul) { | 799 | if (hangul) { |
806 | if (htail != 0) | 800 | if (htail) |
807 | htail = 0; | 801 | htail = 0; |
808 | else if (hvowel != 0) | 802 | else if (hvowel) |
809 | hvowel = 0; | 803 | hvowel = 0; |
810 | else { | 804 | else |
811 | hlead = 0; | ||
812 | hangul = false; | 805 | hangul = false; |
813 | } | ||
814 | } | 806 | } |
815 | kbd_delchar(text, &editpos); | 807 | kbd_delchar(text, &editpos); |
816 | if (hangul) { | 808 | if (hangul) { |
817 | if (hvowel != 0) | 809 | if (hvowel) |
818 | ch = hangul_join(hlead, hvowel, htail); | 810 | ch = hangul_join(hlead, hvowel, htail); |
819 | else | 811 | else |
820 | ch = hlead; | 812 | ch = hlead; |
@@ -833,59 +825,40 @@ int kbd_input(char* text, int buflen) | |||
833 | 825 | ||
834 | /* check for hangul input */ | 826 | /* check for hangul input */ |
835 | if (ch >= 0x3131 && ch <= 0x3163) { | 827 | if (ch >= 0x3131 && ch <= 0x3163) { |
836 | if (hangul) { | 828 | if (!hangul) { |
837 | if ((hvowel == 0) && (jamo_table[ch-0x3131][1] != 0)) { | 829 | hlead=hvowel=htail=0; |
838 | hvowel = ch; | 830 | hangul = true; |
839 | ch = hangul_join(hlead, hvowel, htail); | 831 | } |
840 | kbd_delchar(text, &editpos); | 832 | if (!hvowel) |
841 | } | 833 | hvowel = ch; |
842 | else if ((htail == 0) && (hvowel != 0) && (jamo_table[ch-0x3131][2] != 0)) { | 834 | else if (!htail) |
843 | htail = ch; | 835 | htail = ch; |
844 | /* combine into hangul */ | 836 | else { /* previous hangul complete */ |
845 | ch = hangul_join(hlead, hvowel, htail); | 837 | /* check whether tail is actually lead of next char */ |
838 | if ((tmp = hangul_join(htail, ch, 0)) != 0xfffd) { | ||
839 | tmp = hangul_join(hlead, hvowel, 0); | ||
846 | kbd_delchar(text, &editpos); | 840 | kbd_delchar(text, &editpos); |
841 | kbd_inschar(text, buflen, &editpos, tmp); | ||
842 | /* insert dummy char */ | ||
843 | kbd_inschar(text, buflen, &editpos, ' '); | ||
844 | hlead = htail; | ||
845 | hvowel = ch; | ||
846 | htail = 0; | ||
847 | } else { | ||
848 | hvowel=htail=0; | ||
849 | hlead = ch; | ||
847 | } | 850 | } |
848 | else { /* invalid following char or hangul complete */ | ||
849 | /* check whether tail is actually lead of next char */ | ||
850 | if (htail != 0 && (jamo_table[htail-0x3131][0] != 0) | ||
851 | && (jamo_table[ch-0x3131][1] != 0)) { | ||
852 | tmp = hangul_join(hlead, hvowel, 0); | ||
853 | kbd_delchar(text, &editpos); | ||
854 | kbd_inschar(text, buflen, &editpos, tmp); | ||
855 | hlead = htail; | ||
856 | hvowel = ch; | ||
857 | htail = 0; | ||
858 | ch = hangul_join(hlead, hvowel, htail); | ||
859 | } | ||
860 | else if (hlead != 0 && hvowel != 0) { | ||
861 | /* finish previous hangul */ | ||
862 | tmp = hangul_join(hlead, hvowel, htail); | ||
863 | kbd_delchar(text, &editpos); | ||
864 | kbd_inschar(text, buflen, &editpos, tmp); | ||
865 | hlead=hvowel=htail=0; | ||
866 | /* start of new hangul? */ | ||
867 | if (jamo_table[ch-0x3131][0] != 0) { | ||
868 | hlead = ch; | ||
869 | } | ||
870 | else | ||
871 | hangul = false; | ||
872 | } | ||
873 | } | ||
874 | } | ||
875 | else if (jamo_table[ch-0x3131][0] != 0) { | ||
876 | hlead = ch; | ||
877 | hangul = true; | ||
878 | } | 851 | } |
879 | } | 852 | /* combine into hangul */ |
880 | else if (hangul) { | 853 | if ((tmp = hangul_join(hlead, hvowel, htail)) != 0xfffd) { |
881 | /* finish previous hangul */ | ||
882 | if (hlead != 0 && hvowel != 0) { | ||
883 | tmp = hangul_join(hlead, hvowel, htail); | ||
884 | kbd_delchar(text, &editpos); | 854 | kbd_delchar(text, &editpos); |
885 | kbd_inschar(text, buflen, &editpos, tmp); | 855 | ch = tmp; |
856 | } else { | ||
857 | hvowel=htail=0; | ||
858 | hlead = ch; | ||
886 | } | 859 | } |
860 | } else { | ||
887 | hangul = false; | 861 | hangul = false; |
888 | hlead=hvowel=htail=0; | ||
889 | } | 862 | } |
890 | /* insert char */ | 863 | /* insert char */ |
891 | kbd_inschar(text, buflen, &editpos, ch); | 864 | kbd_inschar(text, buflen, &editpos, ch); |
@@ -898,18 +871,16 @@ int kbd_input(char* text, int buflen) | |||
898 | case KBD_BACKSPACE: | 871 | case KBD_BACKSPACE: |
899 | case KBD_BACKSPACE | BUTTON_REPEAT: | 872 | case KBD_BACKSPACE | BUTTON_REPEAT: |
900 | if (hangul) { | 873 | if (hangul) { |
901 | if (htail != 0) | 874 | if (htail) |
902 | htail = 0; | 875 | htail = 0; |
903 | else if (hvowel != 0) | 876 | else if (hvowel) |
904 | hvowel = 0; | 877 | hvowel = 0; |
905 | else { | 878 | else |
906 | hlead = 0; | ||
907 | hangul = false; | 879 | hangul = false; |
908 | } | ||
909 | } | 880 | } |
910 | kbd_delchar(text, &editpos); | 881 | kbd_delchar(text, &editpos); |
911 | if (hangul) { | 882 | if (hangul) { |
912 | if (hvowel != 0) | 883 | if (hvowel) |
913 | ch = hangul_join(hlead, hvowel, htail); | 884 | ch = hangul_join(hlead, hvowel, htail); |
914 | else | 885 | else |
915 | ch = hlead; | 886 | ch = hlead; |
@@ -921,11 +892,8 @@ int kbd_input(char* text, int buflen) | |||
921 | 892 | ||
922 | case KBD_CURSOR_RIGHT: | 893 | case KBD_CURSOR_RIGHT: |
923 | case KBD_CURSOR_RIGHT | BUTTON_REPEAT: | 894 | case KBD_CURSOR_RIGHT | BUTTON_REPEAT: |
924 | if (hangul) { | 895 | if (hangul) |
925 | hangul = false; | 896 | hangul = false; |
926 | hlead=hvowel=htail=0; | ||
927 | break; | ||
928 | } | ||
929 | if (editpos < len_utf8) | 897 | if (editpos < len_utf8) |
930 | { | 898 | { |
931 | editpos++; | 899 | editpos++; |
@@ -936,11 +904,8 @@ int kbd_input(char* text, int buflen) | |||
936 | 904 | ||
937 | case KBD_CURSOR_LEFT: | 905 | case KBD_CURSOR_LEFT: |
938 | case KBD_CURSOR_LEFT | BUTTON_REPEAT: | 906 | case KBD_CURSOR_LEFT | BUTTON_REPEAT: |
939 | if (hangul) { | 907 | if (hangul) |
940 | hangul = false; | 908 | hangul = false; |
941 | hlead=hvowel=htail=0; | ||
942 | break; | ||
943 | } | ||
944 | if (editpos) | 909 | if (editpos) |
945 | { | 910 | { |
946 | editpos--; | 911 | editpos--; |
@@ -971,11 +936,9 @@ int kbd_input(char* text, int buflen) | |||
971 | break ; | 936 | break ; |
972 | } | 937 | } |
973 | 938 | ||
974 | /* finish hangul char if necessary */ | 939 | /* turn off hangul input */ |
975 | if (hangul) { | 940 | if (hangul) |
976 | hangul = false; | 941 | hangul = false; |
977 | hlead=hvowel=htail=0; | ||
978 | } | ||
979 | 942 | ||
980 | kbd_inschar(text, buflen, &editpos, morse_alphabets[j]); | 943 | kbd_inschar(text, buflen, &editpos, morse_alphabets[j]); |
981 | 944 | ||