char *usr_cmd(int fd, t_history *histo, t_options options) { struct termios set; struct termios unset; char *str; char *cmd; int rev_c; int histo_pl; (void)options; if (init_termios(&set, &unset) == -1 || init_values(&histo_pl, &rev_c, &str, &cmd) == -1) return (unset_termios(&unset)); show_cmd(str[0], fd, cmd, rev_c); while (str[0] != 10 || str[1] != 0 || str[2] != 0) { if (read_cmd(fd, &str, &cmd, &rev_c) == -1) return (unset_termios(&unset)); if (histo_pl < length_of_history(histo) && chk_str(str, 27, 91, 65) == 0) if (take_cmd_from_history(++histo_pl, &rev_c, &cmd, histo) == -1) return (unset_termios(&unset)); if (histo_pl > 0 && chk_str(str, 27, 91, 66) == 0) if (take_cmd_from_history(--histo_pl, &rev_c, &cmd, histo) == -1) return (unset_termios(&unset)); show_cmd(str[0], fd, cmd, rev_c); } return (finish_usr_cmd(cmd, str, unset)); }
/* * 列印? Index List Lines */ void read_entry(int x, void *ent, int idx, int top, int last, int rows) { register int num, len; int score; unsigned char *str; static char chdate[9]; time_t date; struct tm *tm; register unsigned char type; FILEHEADER *fhr = &(((FILEHEADER *) ent)[top - idx]); for (num = top; num <= last && (num - top) < rows; num++, fhr++) { chk_str(fhr->title); chk_str(fhr->owner); /* by lmj */ date = atol((fhr->filename) + 2); if (!date) sprintf(chdate, "%-8.8s", "unknown"); else { tm = localtime(&date); sprintf(chdate, "%02d.%02d.%02d", tm->tm_year - 11, tm->tm_mon + 1, tm->tm_mday); } type = fhr->accessed; if (in_mail) { if (type & FILE_RESV) type = (type & FILE_READ) ? 'g' : 'G'; else if (type & FILE_DELE) type = (type & FILE_READ) ? 'd' : 'D'; else if (type & FILE_REPD) type = 'r'; else type = (type & FILE_READ) ? ' ' : 'N'; } else if (in_board) { if (type & FILE_RESV) type = (ReadRC_UnRead(fhr)) ? 'G' : 'g'; else if (type & FILE_DELE) type = (ReadRC_UnRead(fhr)) ? 'D' : 'd'; else { switch (ReadRC_UnRead(fhr)) { case UNREAD_NEW: type = 'N'; break; case UNREAD_MOD: type = 'M'; break; default: type = ' '; } } } else { /* 若為精華區, 則皆視為已讀過 */ type = ' '; } /* 顯示指標區域 */ outs(" "); if (cmp_wlist(artwtop, fhr->filename, strcmp)) prints("%4d*%c", num, type); else prints("%4d %c", num, type); #if USE_THREAD if (thr_mode && !art_mode) { if (fhr->unused_int2 > 1 && fhr->unused_int2 < 10) prints(" %d ", fhr->unused_int2); else if (fhr->unused_int2 >= 10) prints(" %d", fhr->unused_int2); else outs(" "); } else outs(" "); #else score = get_pushcnt(fhr); if (score != PUSH_FIRST) { if (score == SCORE_MAX) prints("\033[1;31m\xA1\xDB\033[m"); else if (score > 0) prints("\033[1;31m%2.2X\033[m", score); else if (score == SCORE_MIN) prints("\033[32m\xA3\x58\033[m"); else if (score < 0) prints("\033[32m%2.2X\033[m", 0 - score); else prints("\033[1;33m 0\033[m"); } else { outs(" "); } #endif /* if treausure sub-folder */ if (fhr->accessed & FILE_TREA) prints("[1;36m %-11.11s[m", _msg_read_4); else { len = 11; if (curuser.ident == 7 && fhr->ident == 7) { outs(_str_marker); } else if (fhr->owner[0] == '#') { len = 12; outs(" "); } else { outs(" "); } str = (unsigned char *)fhr->owner; while (len > 0 && *str && *str != '@' && *str != '.') { outc(*str++); len--; } while (len-- > 0) outc(' '); } outs(" "); outs(chdate); outs(" "); if (type == 'd' || type == 'D') prints(_msg_read_7, fhr->delby); else { if (memtitle[0] && !strcmp(fhr->title, memtitle)) outs("[1;33m#"); else if (memtitle[0] && !strcmp(fhr->title, memtitle + REPLY_LEN)) outs("[1;32m#"); else outs(" "); #if USE_THREAD len = 40; #else len = 42; #endif str = (unsigned char *)fhr->title; while (len-- > 0 && *str) outc(*str++); /* if (len == -1 && *(str - 1) > 0x80) outc(*str); */ outs("[0m"); } outs("\n"); } }
bool wxKeyTextCtrl::ParseString(const wxChar* s, int len, int &mod, int &key) { mod = key = 0; if (!s || !len) return false; wxString a = wxT('\t'); a.append(s, len); wxAcceleratorEntry ae; #ifndef __WXMAC__ #define check_meta(str) do { \ wxString meta = str; \ for(int ml = 0; (ml = a.find(meta, ml)) != wxString::npos; ml++) { \ if(!ml || a[ml-1] == wxT('-') || a[ml-1] == wxT('+')) { \ mod |= wxMOD_META; \ a.erase(ml, meta.size()); \ ml = -1; \ } \ } \ } while(0) check_meta(wxT("Meta-")); check_meta(wxT("Meta+")); check_meta(_("Meta-")); check_meta(_("Meta+")); #endif // wx disallows standalone modifiers // unlike ToString(), this generates a debug message rather than // an assertion error, so it's easy to ignore and expensive to avoid // beforehand. Instead, check for them on failure if (!ae.FromString(a)) { a.MakeUpper(); #define chk_str(n, k) do { \ wxString t = n; \ if(a.size() > t.size() && a.substr(a.size() - t.size()) == t) { \ a.replace(a.size() - t.size(), t.size(), wxT("F1")); \ wxString ss(s); \ if(ae.FromString(a)) { \ mod |= ae.GetFlags(); \ key = k; \ return true; \ } \ a.replace(a.size() - 2, 2, n); \ } \ } while(0) chk_str(wxT("ALT"), WXK_ALT); chk_str(wxT("SHIFT"), WXK_SHIFT); chk_str(wxT("CTRL"), WXK_CONTROL); chk_str(wxT("CONTROL"), WXK_CONTROL); chk_str(_("ALT"), WXK_ALT); chk_str(_("SHIFT"), WXK_SHIFT); chk_str(_("CTRL"), WXK_CONTROL); chk_str(_("CONTROL"), WXK_CONTROL); return false; } mod |= ae.GetFlags(); key = ae.GetKeyCode(); // wx makes key lower-case, but key events return upper case if (key < WXK_START && wxIslower(key)) key = wxToupper(key); return true; }