Author Topic: MultiCommander v3.1 BETA - Rule Based Coloring  (Read 14524 times)

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4409
    • View Profile
    • Multi Commander
MultiCommander v3.1 BETA - Rule Based Coloring
« on: March 31, 2013, 15:48:04 »
MultiCommander v3.1 (1385) BETA Contains support for rule based coloring of file items.
However this feature is still under development and not everything with it works yet.
For example there is no user interface yet for configure the rules and it will not load/save the rules between restarts.

However. You can setup the rule based coloring using Multi-Script.  And you can then load that script automatic during startup, or button or hotkey or whatever you want, Since it is script based you can have different color setup and change between then with a command that you call.

All the rule based file coloring is done with 4 Multi-Script functions

FileColoringClear();
FileColoringAddRule(...);
FileColoringSetColor(...);
FileColoringRefresh(...);

You can combine multiple rules and only if all of the nested rules are true, then the color is set.

All the rule are matches from the first to the last inserted rule. If a match is found for a file it will then
stop searching for another rule to match. So if you having trouble getting the correct color it might be because of the order
the rules are setup.

You first create a rule using FileColoringAddRule(...) and it will return a "rule handle" you then use that rule handle to set a color.

Code: [Select]
FileColoringAddRule(<parent rule if any, else 0> , <field> , <match type> , <value> );
When settings the color to a rule, you can specify both a text and background color. However the background color is only shown IF the options
"Use file specified background color" / "Use folder specified background colors" are enabled.
And to use use the default set background color use an empty string as background color.
eg.
Code: [Select]
FileColoringSetColor(  $rule , "#FF0000" , "" ); // Use the default specified background color.

Example.
Code: [Select]
// First we need to remove all existing rules. DO NOT FORGET TO DO THIS.
FileColoringClear();

@var $rule = 0;

// if file extension is jpg, bmp, png, or gif
$rule = FileColoringAddRule(0, "Ext" , "Is", "jpg|bmp|png|gif" );
FileColoringSetColor( $rule , "#FF0000" , "#00FF00" );

$rule = FileColoringAddRule(0, "Ext" , "Is", "zip|rar|7z" );
FileColoringSetColor( $rule , "#FF9954" , "#00FF00" );

// wildcard march the namepart of the filename
$rule = FileColoringAddRule(0, "namepart" , "wildcard", "*-Invoice-201?-*" );
FileColoringSetColor( $rule , "#4455FF" , "#00FF00" );

// match substring from the full filename  will match "MyFile_abcdef.txt" and "myFile.edf"
$rule = FileColoringAddRule(0, "Fullname" , "contains", "edf" );
FileColoringSetColor( $rule , "#44FFFF" , "#00FF00" );

// If file size is more then 10.000.000 bytes
$rule = FileColoringAddRule(0, "Size" , "MoreThen", "10000000" );
FileColoringSetColor( $rule , "#BB9988" , "#00FF00" );

// If date is before 2013-01-01 00:00:00 (Date MUST be ISO formatted.)
$rule = FileColoringAddRule(0, "Date" , "Before", "2013-01-01 00:00:00" );
FileColoringSetColor( $rule , "#444433" , "#00FF00" );

// Combine two rules.  if Size is MoreThen 10.000 bytes AND file extension is "txt"
$rule = FileColoringAddRule(0, "Size" , "MoreThen", "10000" );
$rule = FileColoringAddRule($rule, "Ext" , "Is", "txt" );
FileColoringSetColor( $rule , "#FF3299" , "#00FF00" );

// Revalidate all file coloring.
FileColoringRefresh();

Current supported Field

Fullname
Namepart
Ext
Size
Date
= More to be added, for example File Attributes, and any properties provided by extension. (Like MultiRename )


Match Type

Is        - If a string or numeric values matches exactly (String match is not case sensative) (Fullname,namepart,ext,size)
Wildcard  - If a wildcard value matches (Fullname,namepart,ext)
RegExp    - If regular expression matches ( Fullname,namepart,ext) (Not Implemented yet)
Contains  - If a substring exists  (Fullname,namepart,ext)
Beginwith - Not implemented. Use wildcard for now (using wildcard for this is slower, but works)
Endswith  - Not implemented. Use wildcard for now (using wildcard for this is slower, but works)
LessThen  - If a numeric value is less then specified value (Like size)
MoreThen  - If a numeric value is more then specified value (Like size)
Before    - If a date value is before specifed value
After     - If a date value is after specifed value
Has       - If any of the specified flags are set. (used for attribute, Not implementet yet)

= More matching type will be added. Specially for date/time matching.