* Colored completion listings @ 2008-05-12 12:13 sergio 2008-05-12 16:04 ` Peter Stephenson 0 siblings, 1 reply; 6+ messages in thread From: sergio @ 2008-05-12 12:13 UTC (permalink / raw) To: Zsh hackers list [-- Attachment #1: Type: text/plain, Size: 1755 bytes --] Hello. I have some troubles with colored completion listing. 1) zsh highlights broken symlinks as unbroken. but mi color is defined and ls highlights it whith correct color. 2) zsh highlights directories like test.jpg as jpeg file color for directories is defined before *.jpg some string from my ~/.zshrc: eval $(dircolors -b ~/.dir_colors) zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} % echo ${(s.:.)LS_COLORS} no=00 fi=00 di=00;34 ln=00;36 or=00;31 mi=00;31 pi=00;33 so=00;35 do=00;35 bd=00;33 cd=00;33 ex=00;32 sg=30;43 su=30;41 st=30;44 ow=31;44 tw=33;44 *.tar=00;31 *.tgz=00;31 *.svgz=00;31 *.arj=00;31 *.taz=00;31 *.lzh=00;31 *.lzma=00;31 *.zip=00;31 *.z=00;31 *.Z=00;31 *.dz=00;31 *.gz=00;31 *.bz2=00;31 *.bz=00;31 *.tbz2=00;31 *.tz=00;31 *.deb=00;31 *.rpm=00;31 *.jar=00;31 *.rar=00;31 *.ace=00;31 *.zoo=00;31 *.cpio=00;31 *.7z=00;31 *.rz=00;31 *.jpg=00;35 *.jpeg=00;35 *.gif=00;35 *.bmp=00;35 *.pbm=00;35 *.pgm=00;35 *.ppm=00;35 *.tga=00;35 *.xbm=00;35 *.xpm=00;35 *.tif=00;35 *.tiff=00;35 *.png=00;35 *.svg=00;35 *.mng=00;35 *.pcx=00;35 *.mov=00;35 *.mpg=00;35 *.mpeg=00;35 *.m2v=00;35 *.mkv=00;35 *.ogm=00;35 *.mp4=00;35 *.m4v=00;35 *.mp4v=00;35 *.vob=00;35 *.qt=00;35 *.nuv=00;35 *.wmv=00;35 *.asf=00;35 *.rm=00;35 *.rmvb=00;35 *.flc=00;35 *.avi=00;35 *.fli=00;35 *.flv=00;35 *.gl=00;35 *.dl=00;35 *.xcf=00;35 *.xwd=00;35 *.yuv=00;35 *.aac=00;36 *.au=00;36 *.flac=00;36 *.mid=00;36 *.midi=00;36 *.mka=00;36 *.mp3=00;36 *.mpc=00;36 *.ogg=00;36 *.ra=00;36 *.wav=00;36 P.S. There are two listers: ls and complist. They are very similar, but have some difference. For example ls can list directories before other files and complist can not. It will be great to use one lister for completion and for command like ls. -- sergio [-- Attachment #2: .dir_colors --] [-- Type: text/plain, Size: 1211 bytes --] COLOR yes EIGHTBIT yes NORMAL 00 FILE 00 DIR 00;34 LINK 00;36 ORPHAN 00;31 MISSING 00;31 FIFO 00;33 SOCK 00;35 DOOR 00;35 BLK 00;33 CHR 00;33 EXEC 00;32 SETGID 30;43 SETUID 30;41 STICKY 30;44 OTHER_WRITABLE 31;44 STICKY_OTHER_WRITABLE 33;44 #OTHER_WRITABLE 34;41 #STICKY_OTHER_WRITABLE 34;43 # archives or compressed .tar 00;31 .tgz 00;31 .svgz 00;31 .arj 00;31 .taz 00;31 .lzh 00;31 .lzma 00;31 .zip 00;31 .z 00;31 .Z 00;31 .dz 00;31 .gz 00;31 .bz2 00;31 .bz 00;31 .tbz2 00;31 .tz 00;31 .deb 00;31 .rpm 00;31 .jar 00;31 .rar 00;31 .ace 00;31 .zoo 00;31 .cpio 00;31 .7z 00;31 .rz 00;31 # image formats .jpg 00;35 .jpeg 00;35 .gif 00;35 .bmp 00;35 .pbm 00;35 .pgm 00;35 .ppm 00;35 .tga 00;35 .xbm 00;35 .xpm 00;35 .tif 00;35 .tiff 00;35 .png 00;35 .svg 00;35 .mng 00;35 .pcx 00;35 .mov 00;35 .mpg 00;35 .mpeg 00;35 .m2v 00;35 .mkv 00;35 .ogm 00;35 .mp4 00;35 .m4v 00;35 .mp4v 00;35 .vob 00;35 .qt 00;35 .nuv 00;35 .wmv 00;35 .asf 00;35 .rm 00;35 .rmvb 00;35 .flc 00;35 .avi 00;35 .fli 00;35 .flv 00;35 .gl 00;35 .dl 00;35 .xcf 00;35 .xwd 00;35 .yuv 00;35 # audio formats .aac 00;36 .au 00;36 .flac 00;36 .mid 00;36 .midi 00;36 .mka 00;36 .mp3 00;36 .mpc 00;36 .ogg 00;36 .ra 00;36 .wav 00;36 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Colored completion listings 2008-05-12 12:13 Colored completion listings sergio @ 2008-05-12 16:04 ` Peter Stephenson 2008-05-12 16:40 ` sergio 0 siblings, 1 reply; 6+ messages in thread From: Peter Stephenson @ 2008-05-12 16:04 UTC (permalink / raw) To: sergio; +Cc: Zsh hackers list On Mon, 12 May 2008 16:13:46 +0400 sergio <zsh@sergio.spb.ru> wrote: > Hello. > > I have some troubles with colored completion listing. > > 1) zsh highlights broken symlinks as unbroken. but mi color is defined > and ls highlights it whith correct color. My understanding of ls, and experiment, suggest you mean "or". In other words, in a broken link like: lrwxrwxrwx 1 pws users 12 2008-05-12 16:15 going-nowhere -> non-existent "going-nowhere" uses "or", while "non-existent" uses "mi". As completion doesn't show the target of the symbolic link, only the original name, "mi" is therefore irrelevant in zsh. However, I've fixed "or". (By luck, this is easy with the fix I've just made for ln=target.) If you think I've got this wrong you'll have to point me at chapter and verse. > 2) zsh highlights directories like test.jpg as jpeg file > color for directories is defined before *.jpg Yes, the logic is the wrong way round. File type tests from stat should come before extension tests. (This can be kind of annoying in files from Windows that leave execute permissions all over the place but being compatible with ls is preferable.) Index: Src/Zle/complist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v retrieving revision 1.114 diff -u -r1.114 complist.c --- Src/Zle/complist.c 6 May 2008 16:01:19 -0000 1.114 +++ Src/Zle/complist.c 12 May 2008 16:00:30 -0000 @@ -533,9 +533,10 @@ lr_caplen = strlen(mcolors.files[COL_LC]->col) + strlen(mcolors.files[COL_RC]->col); - /* Default for orphans and missing files. Currently not used */ + /* Default for orphan is same as link. */ if (!mcolors.files[COL_OR] || !mcolors.files[COL_OR]->col) - mcolors.files[COL_OR] = mcolors.files[COL_FI]; + mcolors.files[COL_OR] = mcolors.files[COL_LN]; + /* Default for missing files: currently not used */ if (!mcolors.files[COL_MI] || !mcolors.files[COL_MI]->col) mcolors.files[COL_MI] = mcolors.files[COL_FI]; @@ -871,36 +872,15 @@ * file modes. */ static int -putfilecol(char *group, char *n, mode_t m) +putfilecol(char *group, char *n, mode_t m, int special) { - int colour; + int colour = -1; Extcol ec; Patcol pc; - for (ec = mcolors.exts; ec; ec = ec->next) - if (strsfx(ec->ext, n) && - (!ec->prog || !group || pattry(ec->prog, group))) { - zlrputs(ec->col); - - return 0; - } - - nrefs = MAX_POS - 1; - - for (pc = mcolors.pats; pc; pc = pc->next) - if ((!pc->prog || !group || pattry(pc->prog, group)) && - pattryrefs(pc->pat, n, -1, -1, 0, &nrefs, begpos, endpos)) { - if (pc->cols[1]) { - patcols = pc->cols; - - return 1; - } - zlrputs(pc->cols[0]); - - return 0; - } - - if (S_ISDIR(m)) { + if (special != -1) { + colour = special; + } else if (S_ISDIR(m)) { if (m & S_IWOTH) if (m & S_ISVTX) colour = COL_TW; @@ -926,10 +906,36 @@ colour = COL_SG; else if (S_ISREG(m) && (m & S_IXUGO)) colour = COL_EX; - else - colour = COL_FI; - zcputs(group, colour); + if (colour != -1) { + zcputs(group, colour); + return 0; + } + + for (ec = mcolors.exts; ec; ec = ec->next) + if (strsfx(ec->ext, n) && + (!ec->prog || !group || pattry(ec->prog, group))) { + zlrputs(ec->col); + + return 0; + } + + nrefs = MAX_POS - 1; + + for (pc = mcolors.pats; pc; pc = pc->next) + if ((!pc->prog || !group || pattry(pc->prog, group)) && + pattryrefs(pc->pat, n, -1, -1, 0, &nrefs, begpos, endpos)) { + if (pc->cols[1]) { + patcols = pc->cols; + + return 1; + } + zlrputs(pc->cols[0]); + + return 0; + } + + zcputs(group, COL_FI); return 0; } @@ -1752,10 +1758,17 @@ else if (mselect >= 0 && (m->flags & (CMF_MULT | CMF_FMULT))) zcputs(g->name, COL_DU); else if (m->mode) { + /* + * Symlink is orphaned if we read the mode with lstat + * but couldn't read one with stat. That's the + * only way they can be different so the following + * test should be enough. + */ + int orphan_colour = (m->mode && !m->fmode) ? COL_OR : -1; if (mcolors.flags & LC_FOLLOW_SYMLINKS) { - subcols = putfilecol(g->name, m->str, m->fmode); + subcols = putfilecol(g->name, m->str, m->fmode, orphan_colour); } else { - subcols = putfilecol(g->name, m->str, m->mode); + subcols = putfilecol(g->name, m->str, m->mode, orphan_colour); } } else ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Colored completion listings 2008-05-12 16:04 ` Peter Stephenson @ 2008-05-12 16:40 ` sergio 2008-05-12 16:46 ` Peter Stephenson 2008-05-12 16:55 ` Andrey Borzenkov 0 siblings, 2 replies; 6+ messages in thread From: sergio @ 2008-05-12 16:40 UTC (permalink / raw) To: Zsh hackers list Peter Stephenson wrote: >> 1) zsh highlights broken symlinks as unbroken. but mi color is defined >> and ls highlights it whith correct color. > > My understanding of ls, and experiment, suggest you mean "or". yes. However, I've fixed "or". Great. I correctly understand, that 'mi' is unused in zsh? (But it described in manpage) >> 2) zsh highlights directories like test.jpg as jpeg file >> color for directories is defined before *.jpg > > Yes, the logic is the wrong way round. File type tests from stat should > come before extension tests. (This can be kind of annoying in files from > Windows that leave execute permissions all over the place but being > compatible with ls is preferable.) find -type f -exec chmod a-x {} \; or chmod a-x **/*(.) (: -- sergio ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Colored completion listings 2008-05-12 16:40 ` sergio @ 2008-05-12 16:46 ` Peter Stephenson 2008-05-12 17:01 ` Andrey Borzenkov 2008-05-12 16:55 ` Andrey Borzenkov 1 sibling, 1 reply; 6+ messages in thread From: Peter Stephenson @ 2008-05-12 16:46 UTC (permalink / raw) To: sergio; +Cc: Zsh hackers list On Mon, 12 May 2008 20:40:49 +0400 sergio <zsh@sergio.spb.ru> wrote: > I correctly understand, that 'mi' is unused in zsh? (But it described in > manpage) Yes, althought it does say it's unused... as it does for "or", which now you've prodded me to look needs changing. Index: Doc/Zsh/mod_complist.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_complist.yo,v retrieving revision 1.20 diff -u -r1.20 mod_complist.yo --- Doc/Zsh/mod_complist.yo 6 May 2008 16:01:18 -0000 1.20 +++ Doc/Zsh/mod_complist.yo 12 May 2008 16:45:17 -0000 @@ -54,8 +54,7 @@ for character devices ) item(tt(or) var(none))( -for a symlink to nonexistent file (default is the value defined for tt(fi)); -this code is currently not used +for a symlink to nonexistent file (default is the value defined for tt(ln)). ) item(tt(mi) var(none))( for a non-existent file (default is the value defined for tt(fi)); this code -- Peter Stephenson <pws@csr.com> Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Colored completion listings 2008-05-12 16:46 ` Peter Stephenson @ 2008-05-12 17:01 ` Andrey Borzenkov 0 siblings, 0 replies; 6+ messages in thread From: Andrey Borzenkov @ 2008-05-12 17:01 UTC (permalink / raw) To: zsh-workers [-- Attachment #1: Type: text/plain, Size: 203 bytes --] On Monday 12 May 2008, Peter Stephenson wrote: > +for a symlink to nonexistent file (default is the value defined for tt(ln)). Sorry for neatpeaking but all other items do not seem to have full stop :) [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Colored completion listings 2008-05-12 16:40 ` sergio 2008-05-12 16:46 ` Peter Stephenson @ 2008-05-12 16:55 ` Andrey Borzenkov 1 sibling, 0 replies; 6+ messages in thread From: Andrey Borzenkov @ 2008-05-12 16:55 UTC (permalink / raw) To: zsh-workers; +Cc: sergio [-- Attachment #1: Type: text/plain, Size: 981 bytes --] On Monday 12 May 2008, sergio wrote: > I correctly understand, that 'mi' is unused in zsh? (But it described in > manpage) > that's correct; in CVS I added notice that these codes are recognized but not used. Also small manual cleanup after Peter's patch. Index: Doc/Zsh/mod_complist.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_complist.yo,v retrieving revision 1.20 diff -u -p -r1.20 mod_complist.yo --- Doc/Zsh/mod_complist.yo 6 May 2008 16:01:18 -0000 1.20 +++ Doc/Zsh/mod_complist.yo 12 May 2008 16:53:15 -0000 @@ -54,8 +54,7 @@ item(tt(cd 44;37))( for character devices ) item(tt(or) var(none))( -for a symlink to nonexistent file (default is the value defined for tt(fi)); -this code is currently not used +for a symlink to nonexistent file (default is the value defined for tt(ln)) ) item(tt(mi) var(none))( for a non-existent file (default is the value defined for tt(fi)); this code [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-05-12 17:02 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-05-12 12:13 Colored completion listings sergio 2008-05-12 16:04 ` Peter Stephenson 2008-05-12 16:40 ` sergio 2008-05-12 16:46 ` Peter Stephenson 2008-05-12 17:01 ` Andrey Borzenkov 2008-05-12 16:55 ` Andrey Borzenkov
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).