精華區beta SetupBBS 關於我們 聯絡資訊
雖然sob本來就強調這樣的功能 但事實上是每個不同的程式裡面各自家各自的 除了有些地方不能用之外,也比較浪費空間、記憶體 so...直接找到最早I/O的地方,把他們寫進去,就可以省下不少資源 :) 以下為參照Ptt的寫法.... io.c:把原本的igetch()拿掉,換成如下 /* writen by Ptt */ /* modified by wildcat */ char watermode = -1; /* Ptt 水球回顧用的參數 */ extern char no_oldmsg,oldmsg_count; int dogetch() /* 原本的 igetch */ { int ch; if(currutmp) time(&currutmp->lastact); for (;;) { if (ibufsize == icurrchar) { fd_set readfds; struct timeval to; to.tv_sec = to.tv_usec = 0; FD_ZERO(&readfds); FD_SET(0, &readfds); if (i_newfd) FD_SET(i_newfd, &readfds); if ((ch = select(FD_SETSIZE, &readfds, NULL, NULL, &to)) <= 0) { if (flushf) (*flushf) (); if (dumb_term) oflush(); else refresh(); FD_ZERO(&readfds); FD_SET(0, &readfds); if (i_newfd) FD_SET(i_newfd, &readfds); while ((ch = select(FD_SETSIZE, &readfds, NULL, NULL, i_top)) < 0) { if (errno == EINTR) continue; else { perror("select"); return -1; } } if (ch == 0) return I_TIMEOUT; } if (i_newfd && FD_ISSET(i_newfd, &readfds)) return I_OTHERDATA; while ((ibufsize = read(0, inbuf, IBUFSIZE)) <= 0) { if (ibufsize == 0) longjmp(byebye, -1); if (ibufsize < 0 && errno != EINTR) longjmp(byebye, -1); } icurrchar = 0; } i_mode = INPUT_ACTIVE; ch = inbuf[icurrchar++]; return (ch); } } int igetch() { register int ch; while(ch = dogetch()) { switch (ch) { case Ctrl('L'): /* 螢幕 ReDraw */ redoscr(); continue; case Ctrl('U'): /* 呼叫使用者名單 */ if(currutmp != NULL && currutmp->mode != EDITING && currutmp->mode && LUSERS && currutmp->mode) { extern screenline* big_picture; screenline* screen0 = calloc(t_lines, sizeof(screenline)); int y, x, my_newfd; getyx(&y, &x); memcpy(screen0, big_picture, t_lines * sizeof(screenline)); my_newfd = i_newfd; i_newfd = 0; t_users(); i_newfd = my_newfd; memcpy(big_picture, screen0, t_lines * sizeof(screenline)); move(y, x); free(screen0); redoscr(); continue; } else return (ch); case Ctrl('R'): /* 回水球... */ if(currutmp == NULL) return (ch); else if(watermode > 0) /* 多水球回顧 (一顆而已時) */ { watermode = (watermode + oldmsg_count)% oldmsg_count + 1; t_display_new(); continue; } else if (!currutmp->mode && (currutmp->chatid[0] == 2 || currutmp->chatid[0] == 3) && oldmsg_count && !watermode) { /* 多水球回顧 (很多顆) */ watermode=1; t_display_new(); continue; } else if (currutmp->msgs[0].last_pid) /* 一般回水球 */ { extern screenline* big_picture; screenline* screen0 = calloc(t_lines, sizeof(screenline)); int y, x, my_newfd; getyx(&y, &x); memcpy(screen0, big_picture, t_lines * sizeof(screenline)); my_newfd = i_newfd; i_newfd = 0; show_last_call_in(); watermode = 0; my_write(currutmp->msgs[0].last_pid, "水球丟回去:"); i_newfd = my_newfd; memcpy(big_picture, screen0, t_lines * sizeof(screenline)); move(y, x); free(screen0); redoscr(); continue; } else return (ch); case '\n': /* Ptt把 \n拿掉 */ continue; case KEY_TAB: /* 水球回顧 往下捲動 */ if(watermode > 0 ) { watermode = (watermode + oldmsg_count)% oldmsg_count + 1; t_display_new(); continue; } else return (ch); case Ctrl('T'): /* 水球回顧 往上捲動 */ if(watermode > 0 ) { watermode = (watermode + oldmsg_count - 2 )% oldmsg_count + 1; t_display_new(); continue; } default: return (ch); } } } 作者 wildcat.bbs@wdbbs.ml.org (瘋狂考試二日遊), 看板 WDbbsmaker 標題 Re: Ctrl+U and Ctrl+R every where 時間 風與塵埃的對話 (Wed Jul 29 16:43:51 1998) ─────────────────────────────────────── 然後,就可以把其他地方的 Ctrl('R') Ctrl('U') Ctrl('L') 拿掉了... (一個也不用留) 注意!edit.c的case Ctrl('U') 是控制碼的,不用拿掉 現在用起來很不錯,連pressanykey都可以看使用者名單跟回水球、getdata也可 所以....原本pip.c寫了一堆Ctrl('R')....知道了吧 :p 如果有遇到問題,請回報給我 :p 作者 wildcat.bbs@wdbbs.ml.org (瘋狂考試二日遊), 看板 WDbbsmaker 標題 Re: Ctrl+U and Ctrl+R every where 時間 風與塵埃的對話 (Wed Jul 29 17:03:29 1998) ──────────────────────────────────── ※ 引述《wildcat (瘋狂考試二日遊)》之銘言: : case Ctrl('U'): /* 呼叫使用者名單 */ : if(currutmp != NULL && currutmp->mode != EDITING : && currutmp->mode != LUSERS && currutmp->mode) 原本寫錯