TabFileTools

Title TabFileTools
File Name TabFileTools.txt
Description
Author Vochomurka
Parameters -
Plugins Called win, file, ini
Icon
Version 1.1
Updated on 15.11.2017
local hh = win.handle("c=TTOTAL_CMD")
static Path = file.folder(win.exepath(hh))
local List = file.listfiles(Path ++ "\Tabs\*.tab")
local Elem, Str, Temp, Count

static T = cl.Create("Tabs", 1)
static Width = 150

T.Insert(0)
T.SetLabel(0, "Close")
T.AddLeft(0, "*Bar close Tabs")
T.SetTooltip(0, "Close bar")
T.SetHeight(0, 30)

T.Insert(0)
T.SetLabel(0, "Delete")
T.AddLeft(0, cb("@Delete"))
T.SetTooltip(0, "Delete selected tab file")
T.SetHeight(0, 30)

T.Insert(0)
T.SetLabel(0, "View")
T.AddLeft(0, cb("@View"))
T.SetTooltip(0, "View selected tab file")
T.SetHeight(0, 30)

T.Insert(0)
T.SetLabel(0, "Add / Replace")
T.SetTooltip(0, "Left: Add tabs/Right: Replace tabs")
T.SetHeight(0, 30)
T.AddLeft(0, cb("@UseTabs", 1))
T.AddRight(0, cb("@UseTabs", 0))

T.Insert(0)
T.SetLabel(0, ?+*control combobox dropdownlist scroll border+)
T.SetWidth(0, Width)
T.SetTooltip(0, "Choose tab file")
T.SetHeight(0, 25)

T.SetProperties("Format=barsize samesize position: FixedTopLeft vertical tooltips border topmost textcenter")

Temp = T.length

for each line Elem in List
	Str = file.name(Elem)
	T.Insert(Temp)
	T.AddLeft(Temp, cb("@View", Elem))
	T.SetLabel(Temp, Str)

	Count = 0
	for(ini.check_exists(Elem, "activetabs", Count ++ "_path") == 3)
		Count++
	endfor

	T.SetTooltip(Temp, Count ++ " tabs")
	Temp++
endfor

T.show

for each line Elem in List
	Str = file.name(Elem)
	T.AddCtrlListItem(0, Str)
endfor

quit
//===================================================
Function View(TabFile)

if(!TabFile) do
	if(T.GetCtrlValue(0)) do
		TabFile = Path ++ "\Tabs\" ++ T.GetCtrlValue(0) ++ ".tab"
	else
		messagebox("ok error", "First select tab file from dropdown list", "TabFileTools Script")
		quit
	endif
endif

local ATs = "activetabs"
local Active = ini.get(TabFile, ATs, "activetab")
local Keys = ini.enum_keys(TabFile, ATs)
local Values = line(Keys, 0)
local TabChar = esc(?+\t+, ?+\+)
static CR = esc(?+\n+, ?+\+)
local OpQuote = esc(?+\d171+, ?+\+)
local ClQuote = esc(?+\d187+, ?+\+)
local i, Temp

local Message = "File size:" ++ TabChar ++ file.size(TabFile) ++ " bytes" ++ CR
Message ++= "Created:" ++ TabChar ++ TimeDate(file.getdate(TabFile, "c"))
Message ++= "Modified:" ++ TabChar ++ TimeDate(file.getdate(TabFile, "m")) ++ CR

local Keys = ini.enum_keys(TabFile, ATs)
local Values = line(Keys, 0)

for(i = Values/3; i <= Values/2; i++)
	if(ini.check_exists(TabFile, ATs, i ++ "_path") != 3) do
		Temp = i - 1
		break
	endif
endfor

for(i = 0; i <= Temp; i++)
	Values = ini.get(TabFile, ATs, i ++ "_path")
	Message ++= i ++ ifelse(i == Active, "*:", ":") ++ TabChar ++ Values

	if(ini.check_exists(TabFile, ATs, i ++ "_caption") == 3) do
		Values = ini.get(TabFile, ATs, i ++ "_caption")
		Message ++= TabChar ++ OpQuote ++ Values ++ ClQuote
	endif

	Message ++= CR
endfor

messagebox("ok info", Message, "Tab file: " ++ TabFile)

quit
//===================================================
Function TimeDate(Str)
local Result = formatdate("longdate", select(Str, 8)) ++ ", " ++ formattime("HH:mm:ss", select(Str, -6)) ++ CR
quit(Result)
//===================================================
Function UseTabs(Key)
if(T.GetCtrlValue(0)) do
	.OpenTabs(Path ++ "\Tabs\" ++ T.GetCtrlValue(0) ++ ".tab", Key)
else
	messagebox("ok error", "First select tab file from dropdown list", "TabFileTools Script")
endif

quit
//===================================================
Function Delete
if(T.GetCtrlValue(0)) do
	file.delete(Path ++ "\Tabs\" ++ T.GetCtrlValue(0) ++ ".tab")
	T.close
else
	messagebox("ok error", "First select tab file from dropdown list", "TabFileTools Script")
endif

quit

Comments:

After the script execution the panel consisting of two separate panels appears.

Lower panel contains buttons one per each tab-file. At left-clicking such button the corresponding file is viewed. Paths to tabs and tab names (if any) are shown. Active tab s marked with asterisk. User can't add, replace tabs, and delete tab file.

To do so, user should first open the topmost dropdown list in the upper panel. This list contains the same tab-files as in buttons below. After one of files is chosen, one of three buttons can be pressed.

First one Add/Replace pressed by left (Add) or right (Replace) mouse button opens tabs from file chosen on the active panel keeping current tabs or not.

Second button View acts exactly like the corresponding button in the lower panel. Third Delete button removes the tab-file from disk. The last Close button hides the panel.

These upper panel buttons differ from lower panel tab-file buttons: the former are higher, and button text is centered.


All Scripts Total Commander TotalCmd.net PowerPro