Page 1 of 1
switch on/off custom column
Posted: 06 Nov 2015 07:57
by yusef88
because scripted column slow down browsing a bit and i need to see its information sometimes not always
can I switch on/off custom column or activating it by a shortcut key
Re: switch on/off custome column
Posted: 06 Nov 2015 09:11
by highend
setcolumns()
Re: switch on/off custom column
Posted: 06 Nov 2015 13:36
by LittleBiG
Not that easy, unfortunately, if you want it to be independent from the exact custom column number and want to refer to it by name. So to create a portable solution is a bit difficult.
Re: switch on/off custom column
Posted: 06 Nov 2015 14:00
by highend
As long as the custom column has a unique name, why should this be difficult?
Hidden...
Re: switch on/off custom column
Posted: 06 Nov 2015 22:58
by LittleBiG
highend wrote:As long as the custom column has a unique name, why should this be difficult?
Hidden...
Difficult, because this command does something only if you are on the tab where you created this column, or if it is placed somewhere to Custom Column 1 - 5. If yusef88 tries it on an other tab (because he wants to switch it on there too), this command does nothing, until he uses the SetColumns(":d-info",8). So first he has to check, if the column exists. If not, he has to use flag 8, if yes, flag 32. The checking of existence is also can be difficult: if the custom column was added manually, the SetColumns(,1) list would contain, say, ":d-10", the NUMBER of the custom column.
Checking the existence by the column name is tricky in this case.
Other problem is that a custom column can be addressed in 3 different ways (:d-10,:d-Info,"LabelOfInfo":d-info) and you have to use exactly the same text to switch on/off the column.
Actually, if I were in Don's shoes, I would give a bit more thinking of this very good feature, and it would deserve being a bit simpler.
Re: switch on/off custom column
Posted: 07 Nov 2015 10:56
by highend
Code: Select all
$columnName = "Info";
if (regexmatches(setcolumns(, 1), "(^|,)\+?:d-$columnName")) { setcolumns(":d-$columnName", 32); }
else { setcolumns(":d-$columnName", 8); }
As long as he only uses a script to add / show / hide the column I don't see any problems using this.
What should be changed: Adding a custom column by hand should return the caption of it (as long as one was used) and only if it doesn't has one, the number to bring it in line with the scripting method.
Re: switch on/off custom column
Posted: 08 Nov 2015 09:10
by LittleBiG
highend wrote:As long as he only uses a script to add / show / hide the column I don't see any problems using this.
So I am right. This relatively simple solution is also not a general one. And think about the situation, when you want to extended this small script with delete function, like keeping the CTRL button pressed would delete the Info column, instead of simply hiding it.
Re: switch on/off custom column
Posted: 08 Nov 2015 10:57
by highend
So I am right.
With what? That the script doesn't include columns that were set manually? Yes, you are. May I ask why a user should set it manually and
then use the script instead of
just using it in the first place?
And it's that hard to code around that limitation (as long Don doesn't implement my suggestion)?
Can't say so...
Code: Select all
$translatedColumns = "";
foreach($column, setcolumns(, 1), ",") {
$columnCaption = "";
if (regexmatches($column, "\+?:d-\d+")) { $columnCaption = getkey("Caption" . regexmatches($column, "\d+"), "CustomColumns"); }
if ($columnCaption) { $translatedColumns = $translatedColumns . ":d-$columnCaption" . ","; }
else { $translatedColumns = $translatedColumns . $column . ","; }
}
And if you want to brag that this won't include columns that were added before the last save settings execution? savesetting 1; will help...
And think about the situation, when you want to extended this small script with delete function, like keeping the CTRL button pressed would delete the Info column, instead of simply hiding it
Extending the script with a column delete function where the delete function hides the column instead of deleting it? Sorry, no time to think about functions that don't do what they are supposed to do...
Re: switch on/off custom column
Posted: 08 Nov 2015 21:01
by LittleBiG
Sorry, I just wanted to say that this simple wish can be not so straightforward to develop.
highend wrote: May I ask why a user should set it manually and then use the script instead of just using it in the first place?
In my case, I added the CC manually on 2 tabs, then I realized, it is so good, that I wrote the script to switch it on/off on other tabs too. (And a script for adding the column to all tabs.) And my fisrt script worked only where I added the columns manually. It took me a while to figure out that I need a flag 8 first.
Extending the script with a column delete function where the delete function hides the column instead of deleting it? Sorry, no time to think about functions that don't do what they are supposed to do...
No need to think about anything more. My intention was to create a "general" script, which is not needed to change later, so I developed the show/hide and the add/delete function as well. I decided that a normal click do the show/hide and add function, and CTRL+click is for delete. (Yes, you are probably right, it is not so meaningful, but I wanted to put it in so I can call the script complete.) Creating the solution was not simple to me, and my code is really ugly compared with yours.
And very big thanks for sharing your thoughts and script on the topic!
Re: switch on/off custom column
Posted: 08 Nov 2015 21:08
by admin
I use a catalog item named "Column Layout" for this:
Code: Select all
$cs = listfolder("<xydata>\Columns", "*.txt", 5);
$cs = replace($cs, ".txt", "");
$c = popupmenu($cs);
if ($c) {columnlayout($c)};
In this folder ("<xydata>\Columns") I have several files that describe column layouts. Examples:
Normal.txt:
Code: Select all
Path.150,+Name.274,+Ext.43,+Size.56,+Modified.115,+Created.115,Type.70,Accessed.111,Attr.55,Len.28,Label.18,Tags.75,Comment.69,Extra 1.64,Extra 2.43,Extra 3.64,Extra 4.64,Extra 5.64,Custom 1.71,Custom 2.93,Custom 3.79,Custom 4.79,Custom 5.79
AudioSpecial.txt
Code: Select all
Path.150,+Name.236,+Ext.43,+Size.62,+Modified.115,+Created.115,Type.70,Accessed.111,Attr.55,Len.28,Label.18,Tags.75,Comment.69,Extra 1.64,Extra 2.43,Extra 3.64,Extra 4.64,Extra 5.64,Custom 1.71,Custom 2.93,Custom 3.79,Custom 4.79,Custom 5.79,Index.64,+:n-27.60,+:s-audio.length.65,+:s-audio.bitdepth.77,+:s-audio.bitrate.68,+:s-audio.samplerate.93
etc.
Re: switch on/off custom column
Posted: 10 Nov 2015 08:36
by yusef88
thanks for all solution, this menu can be customized?
Re: switch on/off custom column
Posted: 10 Nov 2015 09:22
by admin
Nope.