Multi Commander > Support and Feedback
** How to use Rules based file coloring (New in MC v3.1 and MC 3.2 ) **
Mathias (Author):
--- Quote from: Jungle on May 02, 2013, 13:07:04 ---
--- Quote from: ice-man on May 02, 2013, 11:23:43 ---How about a way to set color if a date is less or more then x days.
Then you can show files that are from today in a different color
--- End quote ---
It is possible.
--- Code: ---// First we need to remove all existing rules. DO NOT FORGET TO DO THIS.
FileColoringClear();
// variable to store Rule in
@var $rule = 0;
// Add Rule - If date is within 10 days from now
@var $now = GetTime();
@var $then = $now - 60*60*24*10;
@var $now_str = FormatDate( "yyyy-MM-dd " , $now ) + FormatTime("HH:mm:ss", $now);
@var $then_str = FormatDate( "yyyy-MM-dd 00:00:00" , $then );
$rule = FileColoringAddRule(0, "Date" , "Before", $now_str );
$rule = FileColoringAddRule($rule, "Date" , "After", $then_str );
FileColoringSetColor( $rule , "#444433" , "#00FF00" );
// Revalidate all file coloring.
FileColoringRefresh();
--- End code ---
But there are 2 moments.
1. GetTime() always returns uncorrected time. E.g. if i have GMT+04, at 15:00 GetTime() will return 11:00
2. Last modified datetime is used when checking files.
--- End quote ---
Well Yes, you can do it with script. But configuring using script is only a workaround for now UNTIL the UI has been added.
(Will probably keep the ability to configure using script. Because it make it more powerful and you can switch to new color setups fast.
But it should not be require to do scripting to configure the rules in the future. )
Btw "GetTime(1);" will return UTC time.. and there is also "TimeLocal2UTC(..)" that convert Local > UTC time. and TimeUTC2Local that convert the other way
But someway to set a rule for Today, or if a file is 2 days old or older then 5 weeks might be useful.
Maybe something like.
FileColoringAddRule(0, "Date" , "Is", "today"); // from today.
FileColoringAddRule(0, "Date" , "Is", "thisweek"); // if file is from current week
FileColoringAddRule(0, "Date" , "LessThan", "5d"); // Less than 5 days old
FileColoringAddRule(0, "Date" , "MoreThan", "5w"); // more than 5 weeks old
Mathias (Author):
MC 3.1.1 Beta (Build 1412)
Date and Attributes rule support have been enhanced.
Date now support ranges like Is Today , Is ThisWeek , LessThan 2d old, LessThan 1h hour, MoreThan 2w old
(LessThan 2d old and LessThan 48h old is NOT the same.
day matches do whole days starting with today. so LessThan 1d old is the same as current day only. )
Attributes can not be match using HasNot and also more attributes are supported.
The first post is updated with information on how to use the new date and attribute rules.
Mathias (Author):
MC 3.1.1 Beta (Build 1420)
Load and Save rule from script has been added
--- Code: ---FileColoringLoad( <filename> );
FileColoringSave( <filename> );
--- End code ---
Also FileColoringAddCustomColor and FileColoringSetCustomColor are added.
With them you can set a specific color to a file/files that does not use the normal rules.
--- Code: ---@var $id = FileColoringAddCustomColor( <TextColor> , <Background Color> );
FileColoringSetCustomColor( $id , "D:\MyFile.txt" );
FileColoringSetCustomColor( $id , "D:\MyFolder\Img*.jpg", true ); // set third parameter to 'true' do to wildcard matching
--- End code ---
There is one glitch with the custom file color. It only works if the file have been shown and are in the UI cache. So it might not be so useful.
I might remove this functions in the future. Normal rules can often be used instead.
The idea with this functions was to be able to color just the selected files. for example, Select some file set them to color 1, then select some other files set them to color2 and so on. But I think file tagging will solve that need when that is finished and that will work better.
Navigation
[0] Message Index
[*] Previous page
Go to full version