diff options
author | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-07-11 02:25:23 +0800 |
---|---|---|
committer | ptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-07-11 02:25:23 +0800 |
commit | 58f062b86a68180206992ea6a7769f99c52e30d0 (patch) | |
tree | 32f3a2f2072b00c5505fb5dcc0283e5f0ffe6759 | |
parent | 36736d45a8f624bc68831035e65fac5e0bfa54ed (diff) | |
download | pttbbs-58f062b86a68180206992ea6a7769f99c52e30d0.tar pttbbs-58f062b86a68180206992ea6a7769f99c52e30d0.tar.gz pttbbs-58f062b86a68180206992ea6a7769f99c52e30d0.tar.bz2 pttbbs-58f062b86a68180206992ea6a7769f99c52e30d0.tar.lz pttbbs-58f062b86a68180206992ea6a7769f99c52e30d0.tar.xz pttbbs-58f062b86a68180206992ea6a7769f99c52e30d0.tar.zst pttbbs-58f062b86a68180206992ea6a7769f99c52e30d0.zip |
editor Ctrl('P') function
git-svn-id: http://opensvn.csie.org/pttbbs/branches/ptt.fpg@2123 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/edit.c | 224 |
1 files changed, 216 insertions, 8 deletions
diff --git a/mbbsd/edit.c b/mbbsd/edit.c index a1e2a2a8..4df1d958 100644 --- a/mbbsd/edit.c +++ b/mbbsd/edit.c @@ -56,9 +56,64 @@ static int blockpnt; static int line_dirty; static int indent_mode; static int insert_c = ' '; +static int phone_mode = 0; static char fp_bak[] = "bak"; + +static char *BIG5[13] = { + "¡A¡F¡G¡B¡N¡C¡H¡I¡E¡T¡]¡^¡©¡ª¡«¡¬", + "¢b¢c¢d¢e¢f¢g¢h¢i¢j¢k¢l¢m¢n¢o¢pùþ ", + "¡³¡ó¡·¡´¡¸¡¹¡¼¡½¡¿¡¶¡¾¡µ¡º¡»¡ð¡ñ", + "¡Ë¡\\¡[¡Â¡Ä¡X¡ü¡ý¢y¡þ¢@¢®¢¬¢¢A¢B", + "¡Ï¡Ð¡Ñ¡Ò¡Ô¡Ó¡×¡Ý¡Ú¡Ü¡Ø¡Ù¡Õ¡Ö¡î¡ï", + "¡Û¡ã¡ä¡å¡ì¡í¡®¡æ¡ç¡è¡é¡Þ¡ß¡à¡á¡â", + "¡ô¡õ¡ö¡÷¡ø¡ù¡ú¡û", + "¡i¡j¡u¡v¡y¡z¡q¡r¡m¡n¡e¡f¡a¡b¡_¡`", + "¡g¡h¡c¡d¡k¡l¡s¡t¡o¡p¡w¡x¡{¡|", + "¢¨¢©¢ª¢«¡Î¡¯¡°¡±¢I¡ò¡À¡K¡L¡Æ¡È", + "£\\£]£^£_£`£a£b£c£d£e£f£g£h£i£j£k", + "£l£m£n£o£p£q£r£s£G£K£N£S£U£X£Z£[", + "¢¹¢º¢»¢¼¢½¢¾¢¿¢À¢Á¢Â" +}; + +static char *BIG_mode[13] = { + "¼ÐÂI", + "¹Ï¶ô", + "¼Ð°O", + "¼Ð½u", + "¼Æ¤@", + "¼Æ¤G", + "½bÀY", + "¬A¤@", + "¬A¤G", + "¨ä¥L", + "§Æ¤@", + "§Æ¤G", + "¼Æ¦r" +}; + +static char *table[8] = { + "¢x¢w¢|¢r¢}¢u¢q¢t¢z¢s¢{", + "ùøùùùãùäùåùàùáùâùÝùÞùß", + "ùø¢wùõùöù÷ùòùóùôùïùðùñ", + "¢xùùùìùíùîùéùêùëùæùçùè", + "¢x¢w¢¢¢r¢£¢u¢q¢t¢~¢s¢¡", + "ùøùù¢¢ù䢣ùàùáùâ¢~ùÞ¢¡", + "ùø¢wùõùöù÷ùòùóùôùïùðùñ", + "¢xùùùìùíùîùéùêùëùæùçùè" +}; + +static char *table_mode[6] = { + "ª½¨¤", + "Ås©·", + "¢q", + "ùá", + "ùó", + "ùê" +}; + + /* °O¾ÐÅéºÞ²z»P½s¿è³B²z */ static void indigestion(int i) @@ -123,19 +178,47 @@ edit_msg() { char *edit_mode[2] = {"¨ú¥N", "´¡¤J"}; register int n = currpnt; + int i; if (my_ansimode) /* Thor: §@ ansi ½s¿è */ n = n2ansi(n, currline); n++; + if(phone_mode) + { + move(b_lines - 1, 0); + clrtoeol(); + if(phone_mode<20) + { + prints("\033m[1;46m¡i%s¿é¤J¡j ", BIG_mode[phone_mode - 1]); + for (i = 0;i < 16;i++) + if (i < strlen(BIG5[phone_mode - 1]) / 2) + prints("\033m[37m%c\033m[34m%2.2s", + i + 'A', BIG5[phone_mode - 1] + i * 2); + else + outs(" "); + outs("\033m[37m `-=¤Á´« Zªí®æ \033m[m"); + } + else + { + prints("\033m[1;46m¡iªí®æø»s¡j /=%s *=%s§Î ", + table_mode[(phone_mode - 20) / 4], + table_mode[(phone_mode - 20) % 4 + 2]); + for (i = 0;i < 11;i++) + prints("\033m[37m%c\033m[34m%2.2s", i ? i + '/' : '.', + table[phone_mode - 20] + i * 2); + outs("\033m[37m Z¤º½X \033m[m"); + } + } move(b_lines, 0); clrtoeol(); - prints("\033[%sm ½s¿è¤å³¹ \033[31;47m (Ctrl-Z)\033[30m»²§U»¡©ú " + prints("\033[%sm ½s¿è¤å³¹ \033[31;47m (^Z)\033[30m»¡©ú " + "\033[31;47m(^R)\033[30m²Å¸¹" "\033[31;47m(^G)\033[30m´¡¤J¹Ï¤å®w \033[31m(^X,^Q)" "\033[30mÂ÷¶}ùø%s¢x%c%c%c%cùø %3d:%3d \033[m", "37;44", edit_mode[insert_character], my_ansimode ? 'A' : 'a', indent_mode ? 'I' : 'i', - 'P', raw_mode ? 'R' : 'r', + phone_mode ? 'P' : 'p', raw_mode ? 'R' : 'r', currln + 1, n); } @@ -394,6 +477,12 @@ insert_char(int ch) } } } +static void +insert_dchar(const char *dchar) +{ + insert_char(*dchar); + insert_char(*(dchar+1)); +} static void insert_string(const char *str) @@ -1592,12 +1681,36 @@ block_color() block_del(1); } +static char* +phone_char(c) + char c; +{ + + if (phone_mode > 0 && phone_mode < 20) + { + if (tolower(c)<'a'||(tolower(c)-'a') >= strlen(BIG5[phone_mode - 1]) / 2) + return 0; + return BIG5[phone_mode - 1] + (tolower(c) - 'a') * 2; + } + else if (phone_mode >= 20) + { + if (c == '.') c = '/'; + + if (c < '/' || c > '9') + return 0; + + return table[phone_mode - 20] + (c - '/') * 2; + } + return 0; +} + + /* ½s¿è³B²z¡G¥Dµ{¦¡¡BÁä½L³B²z */ int vedit(char *fpath, int saveheader, int *islocal) { FILE *fp1; - char last = 0; /* the last key you press */ + char last = 0, *pstr; /* the last key you press */ int ch, foo; int lastindent = -1; int last_margin; @@ -1622,6 +1735,7 @@ vedit(char *fpath, int saveheader, int *islocal) int my_ansimode0 = my_ansimode; int edit_margin0 = edit_margin; int blockln0 = blockln, count = 0, tin = 0; + int phone_mode0=0; currutmp->mode = EDITING; currutmp->destuid = currstat; @@ -1694,13 +1808,97 @@ vedit(char *fpath, int saveheader, int *islocal) continue; break; } + if (phone_mode) + { + switch (ch) + { + case 'z': + case 'Z': + if (phone_mode < 20) + phone_mode = phone_mode0 = 20; + else + phone_mode = phone_mode0 = 2; + line_dirty = 1; + redraw_everything = YEA; + continue; + case '0': + case '1': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (phone_mode < 20) + { + phone_mode = phone_mode0 = ch - '0' + 1; + line_dirty = 1; + redraw_everything = YEA; + continue; + } + break; + case '-': + if (phone_mode < 20) + { + phone_mode = phone_mode0 = 11; + line_dirty = 1; + redraw_everything = YEA; + continue; + } + break; + case '=': + if (phone_mode < 20) + { + phone_mode = phone_mode0 = 12; + line_dirty = 1; + redraw_everything = YEA; + continue; + } + break; + case '`': + if (phone_mode < 20) + { + phone_mode = phone_mode0 = 13; + line_dirty = 1; + redraw_everything = YEA; + continue; + } + break; + case '/': + if (phone_mode >= 20) + { + phone_mode += 4; + if (phone_mode > 27) phone_mode -= 8; + line_dirty = 1; + redraw_everything = YEA; + continue; + } + break; + case '*': + if (phone_mode >= 20) + { + phone_mode++; + if ((phone_mode - 21) % 4 == 3) + phone_mode -= 4; + line_dirty = 1; + redraw_everything = YEA; + continue; + } + break; + } + } + if (ch < 0x100 && isprint2(ch)) { - insert_char(ch); + if(phone_mode && (pstr=phone_char(ch))) + { + insert_dchar(pstr); + } + else insert_char(ch); lastindent = -1; line_dirty = 1; } else { - if (ch == Ctrl('P') || ch == KEY_UP || ch == KEY_DOWN || - ch == Ctrl('N')) { + if (ch == KEY_UP || ch == KEY_DOWN ){ if (lastindent == -1) lastindent = currpnt; } else @@ -2037,6 +2235,18 @@ vedit(char *fpath, int saveheader, int *islocal) redraw_everything = YEA; line_dirty = 1; break; + case Ctrl('P'): + if (phone_mode) + phone_mode = 0; + else + if (phone_mode0) + phone_mode = phone_mode0; + else + phone_mode = phone_mode0 = 2; + redraw_everything = YEA; + line_dirty = 1; + break; + case Ctrl('Z'): /* Help */ more("etc/ve.hlp", YEA); redraw_everything = YEA; @@ -2080,7 +2290,6 @@ vedit(char *fpath, int saveheader, int *islocal) } break; case KEY_UP: - case Ctrl('P'): if (currline->prev) { if (my_ansimode) ch = n2ansi(currpnt, currline); @@ -2096,7 +2305,6 @@ vedit(char *fpath, int saveheader, int *islocal) } break; case KEY_DOWN: - case Ctrl('N'): if (currline->next) { if (my_ansimode) ch = n2ansi(currpnt, currline); |