summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-07-11 22:39:13 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-07-11 22:39:13 +0800
commitf0d2f053520e63153fc57ffb409b1889a80a428b (patch)
tree923a2062288a345bc30d3eb1cebcc5b71b578310
parent5c74ded7dc2bca3726e274bfb5172a9108204e45 (diff)
downloadpttbbs-f0d2f053520e63153fc57ffb409b1889a80a428b.tar
pttbbs-f0d2f053520e63153fc57ffb409b1889a80a428b.tar.gz
pttbbs-f0d2f053520e63153fc57ffb409b1889a80a428b.tar.bz2
pttbbs-f0d2f053520e63153fc57ffb409b1889a80a428b.tar.lz
pttbbs-f0d2f053520e63153fc57ffb409b1889a80a428b.tar.xz
pttbbs-f0d2f053520e63153fc57ffb409b1889a80a428b.tar.zst
pttbbs-f0d2f053520e63153fc57ffb409b1889a80a428b.zip
enable the editor with symbol bar.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2130 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/edit.c241
1 files changed, 229 insertions, 12 deletions
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index a1e2a2a8..aa08e7c7 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("\033[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("\033[37m%c\033[34m%2.2s",
+ i + 'A', BIG5[phone_mode - 1] + i * 2);
+ else
+ outs(" ");
+ outs("\033[37m `-=¤Á´« Zªí®æ \033[m");
+ }
+ else
+ {
+ prints("\033[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("\033[37m%c\033[34m%2.2s", i ? i + '/' : '.',
+ table[phone_mode - 20] + i * 2);
+ outs("\033[37m Z¤º½X \033[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(^P)\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",
+ "\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,98 @@ 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 '2':
+ 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 +2236,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 +2291,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 +2306,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);
@@ -2289,13 +2498,21 @@ vedit(char *fpath, int saveheader, int *islocal)
rscroll();
}
}
- if (curr_window_line == b_lines) {
- curr_window_line = t_lines - 2;
+ if (curr_window_line == b_lines ||
+ (phone_mode && curr_window_line == b_lines - 1)) {
+ if(phone_mode)
+ curr_window_line = t_lines - 3;
+ else
+ curr_window_line = t_lines - 2;
+
if (!top_of_win->next)
indigestion(7);
else {
top_of_win = top_of_win->next;
- move(b_lines, 0);
+ if(phone_mode)
+ move(b_lines-1, 0);
+ else
+ move(b_lines, 0);
clrtoeol();
scroll();
}