switch on/off custom column

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

switch on/off custom column

Post 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
To see the attached files, you need to log into the forum.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: switch on/off custome column

Post by highend »

setcolumns()
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: switch on/off custom column

Post 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.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: switch on/off custom column

Post by highend »

As long as the custom column has a unique name, why should this be difficult?

Code: Select all

setcolumns("info", 32);
Hidden...
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: switch on/off custom column

Post by LittleBiG »

highend wrote:As long as the custom column has a unique name, why should this be difficult?

Code: Select all

setcolumns("info", 32);
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.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: switch on/off custom column

Post 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.
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: switch on/off custom column

Post 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.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: switch on/off custom column

Post 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...
One of my scripts helped you out? Please donate via Paypal

LittleBiG
Posts: 1848
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: switch on/off custom column

Post 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!

admin
Site Admin
Posts: 67070
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: switch on/off custom column

Post 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.

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: switch on/off custom column

Post by yusef88 »

thanks for all solution, this menu can be customized?
To see the attached files, you need to log into the forum.

admin
Site Admin
Posts: 67070
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: switch on/off custom column

Post by admin »

Nope.

Post Reply