Page 1 of 1

Add profiles functionality to favorites

Posted: 10 Nov 2023 15:34
by mr9bitbyte
I love the favorite folder/files. But I often use them for specific projects and changed them based on a project that I find myself going back to. It'd be nice to have the option to have different "profiles" in which a group of favorite files or folders are loaded depending on the profile used, if you are working on a different project, you can change the favorite files/folders being used depending on the profile selected. I think this would be a very useful functionality.

Re: Add profiles functionality to favorites

Posted: 10 Nov 2023 16:14
by admin
a) Check out the command line switch /ini in the Help file.

OR

b) Check out the scripting command loadsettings.

Re: Add profiles functionality to favorites

Posted: 10 Nov 2023 18:48
by Horst
I support mr9bitbyte's wish.
/ini parameter or scripting makes things too complicated.
1. Different ini-files would mean, all other setting changes must be made in all ini-files.
2. Loadsettings doesn't allow to just load new favorites.

Re: Add profiles functionality to favorites

Posted: 10 Nov 2023 18:50
by jupe

Re: Add profiles functionality to favorites

Posted: 10 Nov 2023 18:52
by admin

Re: Add profiles functionality to favorites

Posted: 10 Nov 2023 20:10
by Horst
The script solution with toggling 2 sets is fine for normal usage
but not applicable for project management related favs.
Who has only 2 projects ?

Re: Add profiles functionality to favorites

Posted: 10 Nov 2023 20:20
by jupe
The link was to a post mentioning that the scripting command is already available, demoing that users can already script XY to load any number of different sets of favorites, no one is forcing you to to use that pre-made script.

Re: Add profiles functionality to favorites

Posted: 10 Nov 2023 21:34
by highend
Unlimited profiles...

Code: Select all

    $dst = "<xydata>\Favorites";
    if (exists($dst) != 2) { new($dst, "dir"); }

    $favFiles = listfolder($dst, "*.txt", 1+4, <crlf>);
    $mouseBtn = <get trigger mousebtn>;

    // Left click (load profile)
    if ($mouseBtn == 1) {
        end ($favFiles == ""), "No profile(s) yet, aborted!";

        $menu = replace($favFiles, ".txt");
        $sel  = popupmenu($menu, 6:=<crlf>);
        if ($sel) {
            $cntFiles   = 0;
            $cntFolders = 0;
            $favFile    = $sel . ".txt";
            $content    = readfile("$dst\$favFile", , , 65001);
            $files      = regexmatches($content, "^\[Files\](\s|\S)+?^\[");
            if ($files) {
                $files    = trim(regexreplace($files, "^\[.*?(\r?\n|$)"), <crlf>);
                $cntFiles = gettoken($files, "count", <crlf>);
                favs("f", $files, , "s");
            }
            $folders = regexmatches($content, "^\[Folders\](\s|\S)+");
            if ($folders) {
                $folders    = trim(regexreplace($folders, "^\[.+?\](\r?\n)"), <crlf>);
                $cntFolders = gettoken($folders, "count", <crlf>);
                favs("d", $folders, , "s");
            }
            if ($files == "" && $folders == "") {
                status "No favorites in profile, aborted!", "8B4513", "stop";
                end true;
            }
            status ($cntFiles + $cntFolders) . " favorites loaded from " . quote($sel);
        }

    // Right click (save profile)
    } elseif ($mouseBtn == 2) {
        // Show all existing profile (files) and one entry to create a new one
        $favFiles = replace($favFiles, ".txt");

        $menu = "Save as a new profile";
        if ($favFiles != "") { $menu .= <crlf> . "-" . <crlf> . $favFiles; }

        $files   = favs("f");
        $folders = favs("d");
        end ($files == "" && $folders == ""), "No favorites defined, aborted!";

        $sel = popupmenu($menu, 6:=<crlf>);
        if ($sel == "Save as a new profile") {
            $fileName = input("Enter filename, WITHOUT extension!", , "Work");
            end ($fileName == ""), "Empty name entered, aborted!";

            $fileName .= ".txt";
            step; // DEBUG
            if (exists("$dst\$fileName") == 1) {
                if !(confirm("Profile already exists, overwrite?", , , 1+32)) { end true; }
            }
            WriteFavFile("$dst\$fileName", $files, $folders);

        } elseif ($sel != "") {
            $fileName = $sel . ".txt";
            WriteFavFile("$dst\$fileName", $files, $folders);
        }
    }

function WriteFavFile($file, $favFiles, $favFolders) {
    $content = "[Files]" . <crlf> . $favFiles . <crlf 2> . "[Folders]" . <crlf> . $favFolders;
    writefile($file, $content, , "utf8");
}

Re: Add profiles functionality to favorites

Posted: 11 Nov 2023 11:39
by Horst
jupe wrote: 10 Nov 2023 20:20 The link was to a post mentioning that the scripting command is already available, demoing that users can already script XY to load any number of different sets of favorites, no one is forcing you to to use that pre-made script.
That's clear, but there are too many basic functions which can only be solved by additional scripting.
For me, this is a typical example where Don should make an integrated solution.

Re: Add profiles functionality to favorites

Posted: 11 Nov 2023 11:46
by Horst
highend wrote: 10 Nov 2023 21:34 Unlimited profiles...
Thanks