?? vfsview.cc
字號:
} } return false;}char *VfsListbox::translateProp(char *fmt, int *type){ for (int i=0; i<VFSV_FORMAT_PROPERTIES; i++) { int l = strlen(format_property[i]); if (ht_strncmp(fmt, format_property[i], l)==0) { *type = i; return fmt+l; } } return 0;}void VfsListbox::reread(){#define VFSV_FORMAT_MAX_LENGTH 256 if (!cvfs) return; clearAll(); char *strs[VFSV_FORMAT_MAX_COLS]; for (int i=0; i<dfmt_cols; i++) { strs[i] = ht_malloc(VFSV_FORMAT_MAX_LENGTH); } pfind_t f; int k = 0; if (cvfs->findFirst(cdir, &f)) { do { if (strcmp(f.name, ".") != 0) { for (int i=0; i<dfmt_cols; i++) { *(strs[i]) = 0; } for (int i=0; i<dfmt_props; i++) { int z = dfmt_prop2colidx[i]; int l = strlen(strs[z]); renderEntry(strs[z]+l, VFSV_FORMAT_MAX_LENGTH-l, dfmt_prop[i], f.name, f.stat); } insert_str_extra(k++, make_vfs_extra(f.name, f.stat), (const char**)strs); } } while (cvfs->findNext(&f)); } cvfs->findClose(&f); for (int i=0; i<dfmt_cols; i++) { free(strs[i]); }}void *VfsListbox::quickfind(const char *s){ ht_text_listbox_item *item = (ht_text_listbox_item *)e_cursor; for (int j=0; j<2; j++) { int slen = strlen(s); char *i = NULL; if (item) { i = item->data[keycol]; i = (i && *i) ? i+1 : i; } while (item && (compare_strn(i, s, slen)!=0)) { item = item->next; if (item) { i = item->data[keycol]; i = (i && *i) ? i+1 : i; } } if (item) return item; item = first; } return NULL;}char *VfsListbox::quickfindCompletition(const char *s){ ht_text_listbox_item *item = first; char *res = NULL; int slen = strlen(s); char *i = NULL; if (item) { i = item->data[keycol]; i = (i && *i) ? i+1 : i; } while (item) { if (compare_strn(i, s, slen)==0) { if (!res) { res = ht_strdup(item->data[keycol]+1); } else { int a = compare_ccomm(item->data[keycol]+1, res); res[a] = 0; } } item = item->next; if (item) { i = item->data[keycol]; i = (i && *i) ? i+1 : i; } } return res;}void VfsListbox::update(){ if (show_pos) { char curl[VFS_URL_MAX]; ht_snprintf(curl, sizeof curl, "%s:%s", cproto, cdir); show_pos->settext(curl); } ht_text_listbox::update();}void VfsListbox::renderEntry(char *buf, int bufsize, int dfmt, const char *filename, pstat_t stat){ buf[0] = 0; int timei = 0; switch (GET_DISPLAY_FORMAT_TYPE(dfmt)) { case VFSV_FORMAT_NAME: { ht_snprintf(buf, bufsize, "%s", filename); break; } case VFSV_FORMAT_SIZE: if (stat.caps & pstat_size) { ht_snprintf(buf, bufsize, "%qu", stat.size); } break; case VFSV_FORMAT_BSIZE: if (HT_S_ISDIR(stat.mode)) { if (strcmp(filename, "..")==0) { ht_snprintf(buf, bufsize,"<UP-DIR>", stat.size); } else { ht_snprintf(buf, bufsize,"<SUB-DIR>", stat.size); } } else if (stat.caps & pstat_size) { ht_snprintf(buf, bufsize, "%qu", stat.size); } break; case VFSV_FORMAT_TYPE: if (bufsize > 1) { if (stat.caps & pstat_mode_type) { if (HT_S_ISDIR(stat.mode)) { buf[0] = '/'; } else if (HT_S_ISBLK(stat.mode)) { buf[0] = '+'; } else if (HT_S_ISCHR(stat.mode)) { buf[0] = '#'; } else if (HT_S_ISFIFO(stat.mode)) { buf[0] = '|'; } else if (HT_S_ISLNK(stat.mode)) { buf[0] = '@'; } else if (HT_S_ISSOCK(stat.mode)) { buf[0] = '='; } else if (stat.mode & HT_S_IXUSR) { buf[0] = '*'; } else { buf[0] = ' '; } buf[1] = 0; } } break; case VFSV_FORMAT_MTIME: timei++; case VFSV_FORMAT_ATIME: timei++; case VFSV_FORMAT_CTIME: timei++; case VFSV_FORMAT_RMTIME: timei++; case VFSV_FORMAT_RATIME: timei++; case VFSV_FORMAT_RCTIME: { time_t q; bool avail = false; bool reltime = false; switch (timei) { case 2: reltime = true; case 5: if (stat.caps & pstat_mtime) { q = stat.mtime; avail = true; } break; case 1: reltime = true; case 4: if (stat.caps & pstat_atime) { q = stat.atime; avail = true; } break; case 0: reltime = true; case 3: if (stat.caps & pstat_ctime) { q = stat.ctime; avail = true; } break; } if (avail) { tm *pt = gmtime(&q); if (!pt) { q = 0; pt = gmtime(&q); } tm t = *pt; time_t ct; time(&ct); tm *pc = gmtime(&ct); if (!pc) { ct = 0; pc = gmtime(&ct); } tm c = *pc; char *line = buf; const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; if ((reltime) && ((uint)ct-q<=60*60*24*28)) { if ((uint)ct-q<=60*60*24) { line += ht_snprintf(line, bufsize-(line-buf), "now "); } else if ((uint)ct-q<=60*60*24*2) { line += ht_snprintf(line, bufsize-(line-buf), "now "); } else { line += ht_snprintf(line, bufsize-(line-buf), "%s-%uday", ((uint)(ct-q)/(60*60*24)>10) ? "" : " ", (uint)(ct-q)/(60*60*24)); } } else { line += ht_snprintf(line, bufsize-(line-buf), "%s %02d", months[t.tm_mon], t.tm_mday); } if (t.tm_year==c.tm_year) { if ((reltime) && ((uint)ct-q<=60*60*24)) { if ((uint)ct-q<=60*60) { line += ht_snprintf(line, bufsize-(line-buf), "-%umin", (uint)(ct-q)/60); } else { line += ht_snprintf(line, bufsize-(line-buf), "-%um:%u", (uint)(ct-q)/60/60, (uint)(ct-q)/60%60); } } else { line += ht_snprintf(line, bufsize-(line-buf), " %02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec); } } else { line += ht_snprintf(line, bufsize-(line-buf), " %04d", t.tm_year+1900); line += ht_snprintf(line, bufsize-(line-buf), " %02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec); } } break; } case VFSV_FORMAT_PERM: { if (bufsize>3) { char *line = buf; if (stat.caps & pstat_mode_type) { *(line++)=HT_S_ISDIR(stat.mode) ? 'd' : '-'; } if (stat.caps & pstat_mode_oth) { *(line++)=(stat.mode & HT_S_IROTH) ? 'r' : '-'; *(line++)=(stat.mode & HT_S_IWOTH) ? 'w' : '-'; *(line++)=(stat.mode & HT_S_IXOTH) ? 'x' : '-'; } if (stat.caps & pstat_mode_grp) { *(line++)=(stat.mode & HT_S_IRGRP) ? 'r' : '-'; *(line++)=(stat.mode & HT_S_IWGRP) ? 'w' : '-'; *(line++)=(stat.mode & HT_S_IXGRP) ? 'x' : '-'; } if (stat.caps & pstat_mode_usr) { *(line++)=(stat.mode & HT_S_IRUSR) ? 'r' : '-'; *(line++)=(stat.mode & HT_S_IWUSR) ? 'w' : '-'; *(line++)=(stat.mode & HT_S_IXUSR) ? 'x' : '-'; } *line = 0; } break; } case VFSV_FORMAT_MODE: if (stat.caps & pstat_mode_all) { ht_snprintf(buf, bufsize, "%o", stat.mode & ((1<<9)-1)); } break; case VFSV_FORMAT_NLINK: break; case VFSV_FORMAT_NGID: if (stat.caps & pstat_gid) { ht_snprintf(buf, bufsize, "%u", stat.gid); } break; case VFSV_FORMAT_NUID: if (stat.caps & pstat_uid) { ht_snprintf(buf, bufsize, "%u", stat.uid); } break; case VFSV_FORMAT_OWNER: break; case VFSV_FORMAT_GROUP: break; case VFSV_FORMAT_INODE: if (stat.caps & pstat_inode) { ht_snprintf(buf, bufsize, "%u", stat.inode); } break; case VFSV_FORMAT_SPACE: if (bufsize>1) { buf[0] = ' '; buf[1] = 0; } break; case VFSV_FORMAT_MARK: break; case VFSV_FORMAT_DESC: if (stat.caps & pstat_desc) {/* tag_strcpy(line, stat.desc); line+=tag_strlen(line); alignright=0;*/ } break; }}/* * class VfsListbox2 */bool VfsListbox2::selectEntry(void *entry){ if (VfsListbox::selectEntry(entry)) return true; ht_text_listbox_item *i = (ht_text_listbox_item*)entry; if (i->extra_data) { vfs_extra *e = (vfs_extra*)i->extra_data; char path[VFS_URL_MAX]; ht_snprintf(path, sizeof path, "%s%s", cdir, e->name); cvfs->open(path, 1); return true; } return false;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -