Page 1 of 1

[share] 2 custom columns: SelByExt & R-Toggle

Posted: 02 Sep 2015 14:03
by autocart
Hi all, I was looking for a thread like "Custom Column Exchange". Thought I had seen one a while ago but couldn't find it anymore.

Therefore, here I am sharing on my own 2 custom columns with trigger-scripts which I am quite happy with:
USAGE AT OWN RISK.

Example:
cc SelByExt & R-Toggle.JPG
1) SelByExt (Select by extension):
Very simple, pretty self-explainatory, more a proof of concept (more flexibility would be cool regarding what to select - maybe if it could be dynamicly connected to the current sort order somehow)

(Paste the snippet in the "Configure Custom Column" dialog by right-click on the "Clear"-button.)

Code: Select all

Snip: CustomColumn SelByExt
  XYplorer 15.70.0003, 02.09.2015 13:36:56
Action
  ConfigureColumn
Caption
  SelByExt
Type
  3
Definition
  goto ">>>*.<cc_ext>";
Format
  0
Trigger
  2
Item Type
  2
Item Filter
  
2) R-Toggle (Toggles the write-protection attribute  and  potentially opens the item(s))
Actually 2 separate columns, since one shows the attribute state.
a) When the column-"button" clicked belongs to an item in a selection then the whole selection is R-toggled. Else only the current item is R-toggled, leaving any selection untouched.
b) If the same column-"button" (belonging to the same item) is clicked a 2nd time within about 1/2 second (after the toggle is complete) then the item is opened (and if it belongs to a selection all selected items are opened).

Bullet (b) is important because otherwise I might toggle a whole selection for edit but then would have to move from mouse to keyboard (or right-click... or whatever) to open. Even "open on icon-click" mode does not help because that would unselect all other items and open only this one item.

(Paste the snippet in the "Configure Custom Column" dialog by right-click on the "Clear"-button.)

Code: Select all

Snip: CustomColumn Shows-Write-Protect-State
  XYplorer 15.70.0003, 02.09.2015 13:52:30
Action
  ConfigureColumn
Caption
  R?
Type
  3
Definition
  $attrInt = attrstamp("r", 0, <cc_item>);
    if ($attrInt % 2 == 1) {
      return "R"
    }
    else {
      return "-"
    }
Format
  0
Trigger
  0
Item Type
  2
Item Filter
  
(Paste the snippet in the "Configure Custom Column" dialog by right-click on the "Clear"-button.)

Code: Select all

Snip: CustomColumn Toggle-Write-Protection
  XYplorer 15.70.0003, 02.09.2015 13:52:54
Action
  ConfigureColumn
Caption
  R%
Type
  3
Definition
  $selectedItems = get("SelectedItemsPathNames", "|") . "|";
    perm $openInsteadOfToggleR_prevCCItem;
    perm $openInsteadOfToggleR_timestamp;
    if ($openInsteadOfToggleR_timestamp == "") {
      $openInsteadOfToggleR_timestamp = "2015-01-01 00:00:00.00";
    }
    if (datediff($openInsteadOfToggleR_timestamp, , ms) < 500 AND <cc_item> == $openInsteadOfToggleR_prevCCItem) {
      //ca. under 0.5 secs
      $openInsteadOfToggleR = 1;
    }
    else {
      $openInsteadOfToggleR = 0;
    }
  
    if (strpos($selectedItems, <cc_item> . "|") >= 0) {
      //if ccItem (the clicked item) is part of selection
      $selectedItems = trim($selectedItems, "|", "R");
      if ($openInsteadOfToggleR == 1) {
        foreach($item, $selectedItems) {
          open $item;
        }
      }
      else {
        attrstamp("r", 3, $selectedItems);
      }
    }
    else {
      //if the clicked item is not selected
      if ($openInsteadOfToggleR == 1) {
        open <cc_item>;
      }
      else {
        attrstamp("r", 3, <cc_item>);
      }
    }
    $openInsteadOfToggleR_prevCCItem = <cc_item>;
    $openInsteadOfToggleR_timestamp = <date YYYY-MM-DD hh:nn:ss.ff>;
Format
  0
Trigger
  2
Item Type
  2
Item Filter