SaveTabs

Title SaveTabs
File Name SaveTabs.txt
Description Save tabs in the current panel
Author Vochomurka
Parameters -
Plugin called win, tc, ini, file, miscplugin
Icons
Version 2.1
Updated on 18.08.2013
local hh = win.handle("c=TTOTAL_CMD")
win.sendmessage(hh, 0x400+51, 580, 0)
static Tube = "|"
static ATS = "activetabs"
static AT = "activetab"
static AL = "activelocked"
static AC = "activecaption"
local Config = env("WINDIR") ++ "\wincmd.ini"
local Panel = tc.active(hh)
local Sec = Panel ++ "tabs"
local Keys = ini.enum_keys(Config, Sec)
local Tabs = line(Keys, 0)
local Opts, Counter, Lock, Path

local Num = ini.check_exists(Config, "Configuration", "TabDir")

if(Val == 3) do
	Path = ini.get(Config, "Configuration", "TabDir") ++ "1.tab"
else
	Path = file.folder(win.exepath(hh)) ++ "\Tabs\1.tab"
endif

local Val = ini.check_exists(Path) 
if(not Val) do
	i = file.open(Path, "w")
	file.close(i)
endif

ini.delete_section(Path, ATS)

if(ini.check_exists(Config, Sec, AL) == 3) do
	Lock = ini.get(Config, Sec, AL)
else
	Lock = 0
endif

local Str = ini.get(Config, Panel, "ShowAllDetails") ++ Tube ++ ini.get(Config, Panel, "sortorder")
Str ++= Tube ++ ini.get(Config, Panel, "negative Sortorder") ++ Tube ++ ini.get(Config, Panel, "show")
Str ++= "|0|" ++ Lock ++ Tube ++ ini.get(Config, Panel, "SpecialView")

local Num = ini.get(Config, Sec, AT)

ini.set(Path, ATS, Num ++ "_path", ini.get(Config, Panel, "path"))
ini.set(Path, ATS, Num ++ "_options", Str)

for(i = 1; i <= Tabs; i++)
	Str = line(Keys, i)
	Val = nextword(Str, "Opts", "_")
	if(not miscplugin.is_int(Val))
		break

	if(Val >= Num) do
		Counter = Val + 1
		Val = Counter ++ Opts
	else
		Val = Str
	endif

	ini.set(Path, ATS, Val, ini.get(Config, Sec, Str))

endfor

ini.set(Path, ATS, AT, Num)

if(Lock)
	ini.set(Path, ATS, AL, Lock)

if(ini.check_exists(Config, Sec, AC) == 3)
	ini.set(Path, ATS, AC, ini.get(Config, Sec, AC))

Comments:

Sometimes it happens that you temporarily need some specific tab set either stored in the *.tab file or created manually. But in this case the current tab set will be lost. To save it, you should do the following:

To prevent yourself from losing your time it's convenient to do it with one mouse click or one hotkey.

If file 1.tab exists, it will be rewritten, otherwise created. To restore tabs, give the OPENTABS 1.tab command.


Main Page Total Commander PowerPro