Page 1 of 1
Visually highlight favs
Posted: 06 Mar 2017 10:07
by rclkrtrzckr
Hi all
It all started with a single file I marked as favorite. I noticed that there's no visual indication in the file list whether a file/directory is fav'ed or not. First, I thought that color filters would help; then I tried adding a new column, but as "I'm a fav" is not an attribute, that didn't work either. So I started to think about labeling favourites.
Would something like Set/unset Favorite => set/unset label work? If yes, how? I am sure that scripting can solve it. I tried that:
but I don't really like it, because it's not really toggling the label. Any help highly appreciated.
Cheers
André
PS: Is it just me or is the scripting language closer related to
brainfuck than to, say, perl?
PPS: A real IDE would help scripting, or at least a real editor. How are you guys scripting/debugging anyway?
Re: Visually highlight favs
Posted: 06 Mar 2017 10:50
by highend
You need at least v17.60.0002 for this to work!
Code: Select all
$isFav = formatlist(favs("f"), "F", <crlf>, <curitem>);
if ($isFav) { tag 0; }
else { tag "Fav"; }
#565;
How are you guys scripting/debugging anyway?
<- Sublime Text
Other users have written syntax-highlighting files for iirc Notepad++, Akelpad,...
Debugging:
Code: Select all
step;
unstep;
A leading ? in front of a command
Or e.g.:
Code: Select all
function debug($str, $mode="a", $repeat=2, $sep=<crlf>) {
$editor = "D:\Tools\Sublime Text\sublime_text.exe";
$debugFile = "R:\~XYDebug.log";
if (exists("R:\") != 2) { echo "Ramdrive 'R:\' does not exist, no logging possible!"; }
if !(regexmatches($mode, "^(b|begin|a|append|e|end)$")) {
$message = <<<>>>
ERROR: The debug function knows only three modes:
01. b[egin]
02. a[ppend] -> Default
03. e[nd]
But it received: "$mode" instead!
>>>;
echo formatlist($message, "t", <crlf>);
end 1==1;
}
// Start mode
if (regexmatches($mode, "^(b|begin)$")) {
$message = "Start of debug log:";
$time = formatdate();
$div = strrepeat("=", strlen($message) + strlen($time) + 1);
$header = <<<>>>
$message $time
$div<crlf 2>
>>>;
writefile($debugFile, <crlf> . regexreplace($header, "^[ \t]+") . , "o", "tu");
// Append mode
} elseif (regexmatches($mode, "^(a|append)$")) {
writefile($debugFile, $str . strrepeat($sep, $repeat), "a", "tu");
// Stop mode
} elseif (regexmatches($mode, "^(e|end)$")) {
$message = "End of debug log:";
$time = formatdate();
$div = strrepeat("=", strlen($message) + strlen($time) + 1);
$footer = <<<>>>
$div
$message $time<crlf>
>>>;
writefile($debugFile, <crlf> . regexreplace($footer, "^[ \t]+") . , "a", "tu");
run """$editor"" ""$debugFile""", <xypath>;
}
return;
}
Which can help to gather larger amounts of data from a script and display it in your favorite text editor
(which hopefully autoreloads that file once it's updated)
Re: Visually highlight favs
Posted: 06 Mar 2017 12:56
by rclkrtrzckr
Salü highend
Somehow I knew you'd write
highend wrote:You need at least v17.60.0002 for this to work!
Code: Select all
$isFav = formatlist(favs("f"), "F", <crlf>, <curitem>);
if ($isFav) { tag 0; }
else { tag "Fav"; }
#565;
Thanks, but it doesn't work here. Somehow my favs only keep portions of the filename, not the fully qualified one (like stored in <curitem>).
Favs:
Code: Select all
b\Userlocal\Speedy\Dropbox\01\Documents\B\2017\B\B.xlsx
Curitem:
Code: Select all
C:\Users\b\Userlocal\Speedy\Dropbox\01\Documents\B\2017\B\B.xlsx
Cheers
André
Re: Visually highlight favs
Posted: 06 Mar 2017 13:26
by highend
Seen this for folders as well. Don't know if this is really by design or a setting that is responsible for this behavior (this
can lead to favorites that you can't be distinguished by path). No time to check this right now
Try this:
Code: Select all
$isFav = false;
foreach($fav, favs("f"), <crlf>) {
if (strpos(<curitem>, $fav) != -1) { $isFav = true; break; }
}
if ($isFav) { tag 0; }
else { tag "Fav"; }
#565;
Re: Visually highlight favs
Posted: 06 Mar 2017 13:34
by rclkrtrzckr
highend wrote:Seen this for folders as well. Don't know if this is really by design or a setting that is responsible for this behavior (this
can lead to favorites that you can't distinguish by path). No time to check this right now
Try this:
Code: Select all
$isFav = false;
foreach($fav, favs("f"), <crlf>) {
if (strpos(<curitem>, $fav) != -1) { $isFav = true; break; }
}
if ($isFav) { tag 0; }
else { tag "Fav"; }
#565;
Works perfectly, thanks!
When I have more time, I'll check out your hints regarding scripting.
Cheers
André
Re: Visually highlight favs
Posted: 06 Mar 2017 13:58
by rclkrtrzckr
Found and hopefully fixed a tiny bug with empty favlist.
Code: Select all
$list=favs("f");
$isFav = false;
if($list!="") {
foreach($fav, favs("f"), <crlf>) {
if (strpos(<curitem>, $fav) != -1) { $isFav = true; break; }
}
}
if ($isFav) { tag 0; favs("f","<curitem>",,"d"); }
else { tag "Fav"; favs("f","<curitem>",,"a"); }
Re: Visually highlight favs
Posted: 06 Mar 2017 14:01
by highend
Which bug?
Re: Visually highlight favs
Posted: 06 Mar 2017 14:05
by rclkrtrzckr
Somehow the script didn't work on an empty favlist. Now that I'm checking for the non-empty list, it seems to work
(maybe I did something wrong, but hey, I'm a noob!)

Re: Visually highlight favs
Posted: 06 Mar 2017 14:06
by highend
Probably because of the check if nothing ($fav = empty) is in <curitem> which is always true -> $isFav = true
To get this right it would be enough to do this:
Code: Select all
foreach($fav, favs("f"), <crlf>, "e") {
Re: Visually highlight favs
Posted: 06 Mar 2017 14:17
by rclkrtrzckr
Did I mention "cryptic"?
Found something else:
seems to work differently than
Code: Select all
if ($isFav) { tag 0; favs("f","<curitem>",,"d"); }
else { tag "Fav"; favs("f","<curitem>",,"a"); }
The latter adds a blank line to the favs if they're empty.
Anyway, I'm wasting our time

Thanks!
Re: Visually highlight favs
Posted: 06 Mar 2017 14:29
by highend
Different commands, different behaviors. But the empty line in the gui (manage favorite files). I'd call that a bug...
viewtopic.php?f=2&t=17138