GP Software • Twitter
Opus FAQs • Manual • Commands • Objects

Acecool Proper Tabs - Prevent closing locked tabs

Tabs don't behave the way I expect them to behave so I'm writing a script to correct this. There are a few issues I've run into but I am working on resolving them. I am also looking into a way to add configuration to the scripts without requiring users to edit the files directly.

First script: Prevent locked tab from being closed ( unless you use the menu / right click > close to close it - There is no way to detect if the menu was used, or if middle click was used so I am adding a modifier + middle-click / menu option [ ie if modifiers { qualifiers } not "none" then allow, otherwise prevent... ] )

Acecool - Prevent Locked Tabs from being Closed without Modifier.js ( Will either be 1 file or a collection, although the process of renaming a zip file is stupid, of files with configuration options )

//
// Acecool™ - Prevent Locked Tabs From Being Closed Without Confirmation
// Josh 'Acecool™' Moser - 1985-Indefinitely - Released under the Acecool™ Company License ( ACL )
//
// This is a script for Directory Opus.
// See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
//


//
// Called by Directory Opus to initialize the script
//
function OnInit( _data )
{
	_data.name = "Acecool™ - Prevent Locked Tabs From Being Closed Without Confirmation";
	_data.version = "1.0";
	_data.copyright = "Josh 'Acecool™' Moser - 1985-Indefinitely - Released under the Acecool™ Company License ( ACL )";
//	_data.url = "https://resource.dopus.com/viewforum.php?f=35";
	_data.desc = "Prevents you from being closed without confirming it first...";
	_data.default_enable = true;
	_data.min_version = "12.0";
}


//
// Prevent closing tabs when the tab is locked unless holding Ctrl / Alt / Shift ??....
// Called when a tab is closed - closeTabData - https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/CloseTabData.htm
//
function OnCloseTab( _data )
{
	// Tab Object
	var _tab	= _data.tab;

	// Lock State of Tab Object - Can be: "off", "on", "changes", "reuse"
	var _state	= _tab.lock;

	// Is the tab locked ( any state )
	var _locked = ( _state != "off" ) ? true : false;

	// Key Modifiers held while trying to close tab... - Can be: "none", "shift", "ctrl", "alt", "shift,ctrl", "shift,alt", "shift,ctrl,alt", "ctrl,alt"
	var _mods	= _data.qualifiers;
	var _modded	= ( _mods != "none" ) ? true : false;

	// Prevent closing the tab if the tab is locked and no mods are pressed...
	if ( _locked && !_modded )
		return true;
}

Planned: If you have a tab / path opened ( I may require it to be locked, or not ; depending on settings but by default it will do this regardless of lock status ) and you switch another tab to said path, then instead of that tab switching paths it remains the same and focuses the tab that is already opened.. Likewise, when going back ( and I hope we can alter the history system ) it will re-focus the other tab instead of switching the path since the path is already open...

On top of this, I may add config because multiple listers can be opened... that this switching will only occur for the current lister with an option to allow it to switch to other listers or dual panes... By default, as I only use 1 lister, it will allow hopping...

Could you adjust the subject of your thread to something like "Prevent locked tabs from being closed"?
Username and unknown abbreviations have not been used in thread subjects until now. Subjects already got kind of chaotic in the script addins area recently and maybe its a good idea to return to something which is more easy on the eyes (look at page 2 to get some examples).

Thank you! o))

I can add that to the subject to add a bit of clarity for the currently released script, but the package name is Proper Tabs because of all the changes planned.

Nothing against "Proper Tabs", but consider to remove "[ WIP ] Acecool Script Package" since it does not add any useful information. "Script packages" is what this forum is about (although your post does not contain one), "Acecool" is your nick and can be seen in the "First Post" column of the thread index and "[ WIP ]" - if it is really necessary, might be better placed at the end or ommitted completely, since you specifiy your script to be version 1.0, which does not imply work in progress.

Also consider to not use "_" as prefix for every variable you use or create, it's against all common practices in the world of scripting unless you like to mark private variables or function parameters, both of which is not the case here.

If you release script snippets under a specific license ("Released under the Acecool™ Company License (ACL)"), please put the full license here as well. I searched the interweb and could not find something like an Acecool Company License, so generic usage of this and wether this belongs here at all, is totally unclear. The same applies to the Acecool (TM) Trademark, I could not find an "Acecool" brand in the US or european union.

After all, a very bold initial post for an effective 6 lines of code.

Thanks. o)

Default script version ( I need to look into changing it as I use a different versioning system.. .. ) and having to change it every time I start a new script is annoying...

It will be a script package ( WIP == Work In Progress ) after I am done adding all of the features; I am still looking into the scripting system and am making a master-script-copy which basically is one file with all of the functions properly commented containing argument data and possibly with other documentation...

I am working on the final License; Acecool is my trademark since 1985 and I own Acecoolco.com/net ( acecool.com/net was registered by me in the 90s and was somehow stolen by "Ace Kool" big wave surfer who is now deceased so I am working on reobtaining my domain names - Per trademark law since I coined the term first and have been operating under it the longest all other users of it are in violation - It is registered in the United States as a Business ). - In short, the license allows for being able to use, modify and redistribute with my copyright in addition to learning from it in order to build your own systems, but you may not sell it without express written consent.

If you learn from it and write your own system without using any of my code then you can do with it as you please; with some of these scripts though they are so basic that there are very few ways to write them for the same functionality therefore I am staking no claim ( and others may freely use my coding standards ) in it.

I will hopefully release the next part of it today but I am still reading up on tab manipulation, etc... and I am going to add the config system too..

So the license does not exist and neither does a trademark or domain. You obviously lack on DO scripting knowlegde too for now. Consider to take yourself some time to get into the things first and come here and present your results afterwards. Proper coding also means looking at what other people do in that domain and listening to what the community around it suggests. I don't think there's something wrong with posting snippets, but the ratio between blabla and result is nowhere near sensible right now. Since you also did not react to suggestions regarding the threads subject I must assume all you intend to create is noise.

EDIT: Oh the subject did change actually, maybe this is a starting point. o)

Legally a TradeMark doesn't need to be registered according to trademark government website - it acts similarly to copyright - as soon as something is created, it is copyright to the author.

When a new word used for business, etc.. is created ( Mine being Acecool meaning A School to revolve around my philosophy ) it is automatically TradeMarked and protected by Law... Should there be a lawsuit, the person with the earliest record of use of the name ( and the name can't simply be Toys Are Us - they used backwards R to create a new logo - my word combines two existing to make and mean something entirely new ) wins.... Take a look at the government site - I have records dating as early as 1989 showing my use of the word, and I registered the site in the early 90s ( which was stolen by my registrar who didn't honor the 10 year contract and I've been fighting to take the stolen site down - it is now down and I'm working on recovering my domain names )...

Hi, I'm using your script, and it's working well thank you.

But I usually use the ctrl + w hotkey to close tabs,
and it seems that your script currently doesn't prevent this.
Can you add this function?? It would be really appreciated.

That's because the script checks if Ctrl (or Shift or Alt) is held down and reverts to normal behavior if it is:

// Prevent closing tabs when the tab is locked unless holding Ctrl / Alt / Shift ??....

To remove that, change this part:

	// Key Modifiers held while trying to close tab... - Can be: "none", "shift", "ctrl", "alt", "shift,ctrl", "shift,alt", "shift,ctrl,alt", "ctrl,alt"
	var _mods	= _data.qualifiers;
	var _modded	= ( _mods != "none" ) ? true : false;

To this:

	var _modded	= false;
1 Like

That was quick.
I really appreciate your help.
This was just what I needed. Thank you so much.

1 Like