static hwnd = win.handle("c=TTOTAL_CMD") global Config = "D:/Winnt/wincmd.ini" global TT = cl.Create("Tabs", 1) global TW = "d:/Utils/PowerPro/scripts/TabTools/TabTools.ini" static Icons = "D:/Graphics/Icons/User/TT.icl" static Quote = esc(?+\"+, ?+\+) static OpQuote = esc(?+\d171+, ?+\+) static ClQuote = esc(?+\d187+, ?+\+) static CR = esc(?+\n+, ?+\+) local LTabs, RTabs, Temp, Number, Stat, Comm, FS, BS, MaxText, i win.sendmessage(hwnd, 0x400+51, 580, 0) if(ini.check_exists(TW, "FontColor", "Source") == 3) FS = ini.get(TW, "FontColor", "Source") if(ini.check_exists(TW, "BackColor", "Source") == 3) BS = ini.get(TW, "BackColor", "Source") Comm = ini.get(TW, "Configuration", "Labels") LTabs = runfile.Subs\Sub_ReadTabs("left") RTabs = runfile.Subs\Sub_ReadTabs("right") if(max(Ltabs, RTabs) > ini.get(TW, "Configuration", "MaxTabs")) TT.AddProperties("Format=IconSize: 16") Number = TT.Length MaxText = ini.get(TW, "Configuration", "MaxText") for(i = 0; i < Number; i++) Temp = TT.GetMiddleCmd(i) if(Temp == 1 && tc.active(hwnd) == "left" && TT.GetLeftOnTop(i)) do TT.SetTextColor(i, FS) TT.SetBackColor(i, BS) endif if(Temp == 2 && tc.active(hwnd) == "right" && TT.GetLeftOnTop(i)) do TT.SetTextColor(i, FS) TT.SetBackColor(i, BS) endif Stat = TT.GetLeftCmd(i) TT.ClearRight(i) TT.AddRight(i, cb("TabTools/TabTools@CloseTab", Stat)) TT.SetHeight(i, Stat) Stat = ifelse(Temp == 1, 5201 + Stat, 5301 + Stat) TT.ClearLeft(i) TT.AddLeft(i, "win.sendmessage(hwnd, 0x400+51, " ++ Stat ++ ", 0)") if(Comm == 0) do Temp = TT.GetToolTip(i) elseif(Comm == 1) Temp = TT.GetId(i) elseif(Comm == 2) Temp = TT.GetId(i) Stat = TT.GetToolTip(i) if(Stat) Stat = " = " ++ OpQuote ++ Stat ++ ClQuote Temp = Temp ++ Stat endif if(length(Temp) > MaxText) Temp = select(Temp, MaxText) ++ "..." TT.SetLabel(i, Temp) Temp = "Path: " ++ OpQuote ++ TT.GetId(i) ++ ClQuote if(TT.GetToolTip(i)) Temp = Temp ++ "/Caption: " ++ OpQuote ++ TT.GetToolTip(i) ++ ClQuote TT.SetTooltip(i, Temp) endfor TT.Insert(LTabs) TT.AddLeft(LTabs, "Format NewColumnLine") TT.SetId(LTabs, "Vertical Separator") TT.AddRight(LTabs, RTabs) TT.AddMiddle(LTabs, LTabs) if(not ini.get(TW, "Configuration", "IncludeCommands")) do *menu show Tabs quit all endif if(LTabs < RTabs) do Temp = LTabs Number = RTabs - LTabs elseif(LTabs > RTabs) Temp = LTabs + RTabs + 1 Number = LTabs - RTabs elseif(LTabs == RTabs) Number = 0 endif for(i = 0; i < Number; i++) TT.Insert(Temp + i) TT.SetIconVisible(Temp + i, 0) TT.SetEnabled(Temp + i, 0) TT.SetTooltip(Temp + i, "TabTools 5.0/(C) Vochomurka/2005-2009") endfor Temp = TT.GetIdIndex("Vertical Separator") TT.Insert(Temp) TT.AddLeft(Temp, "Format Separator") Number = TT.Length TT.Insert(Number) TT.AddLeft(Number, "Format Separator") Comm = 6 Temp++ TT.Insert(Temp) TT.AddLeft(Temp, "Format EndSubMenu") TT.Insert(Temp) TT.AddLeft(Temp, "Format StartSubMenu") TT.SetLabel(Temp, "Left Panel Tabs") Number = TT.Length TT.Insert(Number) TT.AddLeft(Number, "Format EndSubMenu") TT.Insert(Number) TT.AddLeft(Number, "Format StartSubMenu") TT.SetLabel(Number, "Right Panel Tabs") for(i = 1; i <= 2; i++) Stat = i*(Temp + i) + (i - 1)*Comm TT.Insert(Stat) TT.AddLeft(Stat, cb("TabTools/TabTools@PathVal", i, 1)) TT.AddRight(Stat, cb("TabTools/TabTools@PathVal", i, 0)) TT.SetLabel(Stat, "Check Path &Validity") TT.SetIcon(Stat, Icons, 3) TT.SetTooltip(Stat, "Left - Check & ask to close/Right - Close silently") TT.Insert(Stat) TT.AddLeft(Stat, cb("TabTools/TabTools@CloseDups", i)) TT.SetLabel(Stat, "Close Opposite &Dups") TT.SetIcon(Stat, Icons, 4) TT.SetTooltip(Stat, "Close duplicate tabs in opposite panel") TT.Insert(Stat) TT.AddLeft(Stat, cb("TabTools/TabTools@Alias", i)) TT.SetLabel(Stat, "&Alias") TT.SetIcon(Stat, Icons, 5) FS = "Change tab captions according to settings in TabTools.ini, sections [Caption] & [Alias]" TT.SetTooltip(Stat, FS) TT.Insert(Stat) TT.AddLeft(Stat, cb("TabTools/TabTools@HighLight", i, 1)) TT.AddRight(Stat, cb("TabTools/TabTools@HighLight", i, 0)) TT.SetLabel(Stat, "&Highlight Tab(s)") TT.SetIcon(Stat, Icons, 6) TT.SetTooltip(Stat, "Left - highlight tab(s)/Right - clear highlighting") TT.Insert(Stat) TT.AddLeft(Stat, cb("TabTools/TabTools@CloseAllTabs", i)) TT.SetLabel(Stat, "&Close All Tabs") TT.SetIcon(Stat, Icons, 7) TT.SetTooltip(Stat, "Close all tabs, independent of lock status") TT.Insert(Stat) TT.AddLeft(Stat, cb("TabTools/TabTools@MultiFind", i)) TT.SetLabel(Stat, "&Find in All Tabs") TT.SetIcon(Stat, Icons, 8) TT.SetTooltip(Stat, "Open 'Find File' dialog box with 'Search in' field filled with paths of all tabs") endfor if(ini.get(TW, "Configuration", "SmallIcons")) do TT.AddProperties("Format=IconSize: 16") else TT.AddProperties("Format=IconSize: 32") endif TT.AddProperties("Format=tooltips") if(ini.check_exists(TW, "Configuration", "AnyProps") == 3) TT.AddProperties(ini.get(TW, "Configuration", "AnyProps")) TT.showmenu() quit all //****************************************************************** Function Alias(Panel) local Temp = runfile.Subs\Sub_TMTC(hwnd, Panel) if(not Temp) do messagebox("ok stop", "No tabs to rename", "TabTools script") quit all endif local i, j, Comm, Hand, Str, Caption local Delim = ", " static RH = "RightHistory" static LH = "LeftHistory" static C = "Caption" static DM = "DirMenu" static SI = "SearchIn" static PD = "ParentDir" flag clear 1 6 if(ini.check_exists(TW, C, "Alias") == 3) do if(ini.get(TW, C, "Alias")) flag set 1 endif if(ini.check_exists(TW, C, SI) == 3) do if(ini.get(TW, C, SI)) flag set 2 endif if(ini.check_exists(TW, C, DM) == 3) do if(ini.get(TW, C, DM)) flag set 3 endif if(ini.check_exists(TW, C, PD) == 3) flag set 4 if(ini.check_exists(TW, C, LH) == 3) flag set 5 if(ini.check_exists(TW, C, RH) == 3) flag set 6 if(ini.check_exists(TW, C, "Delimiter") == 3) Delim = ini.get(TW, C, "Delimiter") ++ " " if(not pproflag(1) && not pproflag(2) && not pproflag(3) && not pproflag(4) && not pproflag(5) && not pproflag(6)) do messagebox("ok warning", "No alias source specified", "TabTools script") quit all endif for(i = 0; i < TT.Length; i++) Temp = TT.GetMiddleCmd(i) if(Temp == Panel) do Temp = TT.GetId(i) Caption = Temp if(pproflag(4)) Comm = ini.get(TW, C, PD) if(pproflag(4) && miscplugin.is_int(Comm) && Comm > 0) Caption = runfile.Subs\Sub_ParsePath(Temp, Comm) if(pproflag(1) && ini.check_exists(TW, "Alias", Temp) == 3) Caption = ini.get(TW, "Alias", Temp) if(pproflag(2)) do Comm = ini.enum_keys(Config, SI) Hand = line(Comm, 0) for(j = 0; j < Hand; j++) Str = line(Comm, j) Str = ini.get(Config, SI, j) if(Str ++ "\" == Temp) do Caption = Caption ++ Delim ++ ini.get(TW, C, SI) break endif endfor endif if(pproflag(3)) do for(j = 1; j < 200; j++) Str = "menu" ++ j if(ini.check_exists(Config, DM, Str) != 3) break Str = "cmd" ++ j if(ini.check_exists(Config, DM, Str) == 3) do Hand = ini.get(Config, DM, Str) if(index(Hand, "cd ") == 1) do Hand = remove(Hand, 3) if(Hand ++ "\" == Temp) do Temp = ini.get(TW, C, DM) Caption = Caption ++ Delim ++ Temp endif endif endif endfor endif if(pproflag(5)) do Comm = ini.enum_keys(Config, LH) Hand = line(Comm, 0) for(j = 0; j < Hand; j++) if(ini.get(Config, LH, j) == Temp) do Caption = Caption ++ Delim ++ ini.get(TW, C, LH) break endif endfor endif if(pproflag(6)) do Comm = ini.enum_keys(Config, RH) Hand = line(Comm, 0) for(j = 0; j < Hand; j++) if(ini.get(Config, RH, j) == Temp) do Caption = Caption ++ Delim ++ ini.get(TW, C, RH) break endif endfor endif TT.RunLeft(i) win.postmessage(hwnd, 0x400+51, 3009, 0) *keys {down 2}{enter} wait.for(activewindow("c=TCheckEditBox")) Hand = win.getfocus() win.settext(Hand, Caption) *keys {enter} endif endfor messagebox("ok information", "Aliasing complete", "TabTools script") quit //'Alias' function //****************************************************************** Function CloseAllTabs(Panel) local Cur = ifelse(tc.active(hwnd) == "left", 4001, 4002) local Focus = 4000 + Panel win.sendmessage(hwnd, 0x400+51, Focus, 0) runfile.CloseAllTabs quit //'CloseAllTabs' function //****************************************************************** Function CloseDups(Panel) local i, j, k, Side, Path, Temp, Opp, Comm, Number local Counter = 0 local Mess local Cap = "Duplcating tabs in " ++ ifelse(Panel == 2, "left", "right") ++ " panel: " @Start flag clear 1 Temp = TT.GetIdIndex("Vertical Separator") Opp = ifelse(Panel == 1, TT.GetRightCmd(Temp, 1), TT.GetMiddleCmd(Temp, 1)) if(Opp == 1) do messagebox("ok stop", "There is only one tab", "Bad user command") quit all endif Number = TT.Length for(i = 0; i < Number; i++) Side = TT.GetMiddleCmd(i) if(Panel == Side) do Path = TT.GetId(i) for(j = 0; j < Number; j++) Side = TT.GetMiddleCmd(j) if(Panel != Side && Side != "") do Temp = TT.GetId(j) if(Path == Temp) do Counter++ if(Counter != 1) Mess = Mess ++ CR ++ CR Mess = Mess ++ "Tab #" ++ Counter ++ ":" Mess = Mess ++ CR ++ "Path: '" ++ Temp ++ "'" Mess = Mess ++ .TabTools\TabTools@CloseTab(TT.GetMiddleCmd(j), j) flag set 1 break endif endif endfor if(pproflag(1)) break endif endfor if(pproflag(1)) jump Start Cap = Cap ++ Counter if(Mess) do messagebox("ok warning", Mess, Cap) else messagebox("ok information", "No duplicates found", Cap) endif quit //'CloseDups' function //****************************************************************** Function HighLight(Panel, Action) local TMTC = runfile.Subs\Sub_TMTC(hwnd, Panel) if(not TMTC) do messagebox("ok stop", "No tabs to highlight", "TabTools script") quit all endif local i, List, Label, Side local Number = TT.Length local NewLine = esc(?+\r+, ?+\+) for(i = 0; i < Number; i++) if(TT.GetMiddleCmd(i) == Panel) do Label = TT.GetLabel(i) List = List ++ Label ++ NewLine endif endfor NewLine = "Pick tab(s) to " ++ ifelse(Action, "highlight", "clear highlighting") pickstring(List, NewLine, 1) Side = word(_pickedline_, 0) for(i = 1; i <= Side; i++) Number = word(_pickedline_, i) win.sendmessage(TMTC, 4915, Number - 1, Action) endfor quit //'HighLight' function //****************************************************************** Function MultiFind(Num) local i, Target, Str, Panel for(i = 0; i < TT.Length; i++) Target = TT.GetId(i) Panel = TT.GetMiddleCmd(i) if(file.validpath(Target) && Num == Panel) Str = Str ++ Target ++ ";" endfor Str = remove(Str, -1) win.postmessage(hwnd, 0x400+51, 501, 0) wait.for(activewindow("c=TFindFile")) Panel = win.handle("c=TFindFile") Target = childwin.handle(Panel, 22) win.settext(Target, Str) quit //'MultiFind' function //****************************************************************** Function PathVal(Panel, Ask) local Number = runfile.Subs\Sub_TMTC(hwnd, Panel) if(not Number) do messagebox("ok stop", "No tabs to check", "TabTools script") quit all endif Number = TT.Length local i, j, Side, Path, Beg, Mess, Counter, Section, Status local Cap = "Invalid tabs in " local Comm = "/Caption: " if(Panel == 1) do Section = "lefttabs" Cap = Cap ++ "left" else Section = "righttabs" Cap = Cap ++ "right" endif Cap = Cap ++ " panel" local Active = ini.get(Config, Section, "activetab") local Temp = (Number - 1)*3 flag clear 2 3 if(ini.check_exists(TW, "ValidPaths", "Archives") == 3 && ini.get(TW, "ValidPaths", "Archives")) flag set 2 if(ini.check_exists(TW, "ValidPaths") == 2) flag set 3 v = vec.create(Temp) if(v <= 0) do messagebox("ok error", "Vector not created", "VEC plugin error") quit endif for(i = 0; i < Number; i++) flag clear 1 Side = TT.GetMiddleCmd(i) Status = TT.GetIconNumber(i) if(Panel == Side) do Path = TT.GetId(i) if(not validpath(Path)) do if(pproflag(3)) do Temp = ini.enum_keys(TW, "ValidPaths") Side = line(Temp, 0) for(j = 1; j <= Side; j++) Beg = line(Temp, j) if(index(Path, Beg) == 1) do flag set 1 break endif endfor endif if(pproflag(2)) do Temp = remove(Path, -1) if(not file.isfolder(Temp) && length(Temp) > 2) flag set 1 endif if(pproflag(1)) jump NextPath Temp = TT.GetHeight(i) if(Mess) Mess = Mess ++ CR ++ CR Mess = Mess ++ "Invalid path is '" ++ Path ++ "'" ++ CR ++ "Tab #" ++ Temp if(Active > Temp) Active-- Side = "" if(Status == 1 || Status == 4) Side = Side ++ "locked " if(Status == 2 || Status == 5) Side = Side ++ "locked, but directory changes allowed " if(Side != "") Mess = Mess ++ CR ++ "Status: " ++ Side else @NextPath v[Counter*3] = Path v[Counter*3 + 1] = TT.GetToolTip(i) Side = TT.GetHeight(i) if(Side > Active) Side-- Temp = ini.get(Config, Section, Side ++ "_options") v[Counter*3 + 2] = Temp Counter++ endif endif endfor if(not Mess) do messagebox("ok information", "All paths are valid", "TabTools Script") vec.destroy(v) vec.unload quit all endif if(Ask) do Mess = Mess ++ CR ++ CR ++ "Close invalid tabs?" if(messagebox("yesno question", Mess, Cap) == 7) do vec.destroy(v) vec.unload quit all endif endif Cap = "2.tab" Path = ini.get(Config, "Configuration", "TabDir") ++ Cap Beg = file.open(Path, "w") if(Beg <= 0) do messagebox("ok error", "File not opened", "FILE plugin error") quit endif file.writeline(Beg, "[activetabs]") for(i = 0; i < Counter; i++) file.writeline(Beg, i ++ "_path=" ++ v[i*3]) Temp = v[i*3 + 1] if(index(Temp, Comm)) do Status = index(Temp, Comm) Section = slice(Temp, Status + 10, length(Temp) - 2) file.writeline(Beg, i ++ "_caption=" ++ Section) endif file.writeline(Beg, i ++ "_options=" ++ v[i*3 + 2]) endfor vec.destroy(v) vec.unload file.writeline(Beg, "activetab=" ++ Active) file.close(Beg) win.sendmessage(hwnd, 0x400+51, 4000 + Panel, 0) win.postmessage(hwnd, 0x400+51, 3009, 0) *keys {fast}{up 4}{enter} wait.for(activewindow("Open")) wait.for(win.handle("Open")) Side = win.handle("Open") wait.for(childwin.handle(Side, 9)) Temp = childwin.handle(Side, 9) win.settext(Temp, Cap) for(childwin.gettext(Temp) != Cap) endfor *keys ^{enter} quit //'PathVal' function //****************************************************************** Function CloseTab(Number, Item) flag clear 1 if(not miscplugin.is_int(Item)) do flag set 1 Item = cl.GetLastMenuSel() endif local Mess, k local Temp = TT.GetIconNumber(Item) local Panel = TT.GetMiddleCmd(Item) TT.RunLeft(Item) if(Temp == 1) do win.sendmessage(hwnd, 0x400+51, 3010, 0) Mess = CR ++ "Status: locked" elseif(Temp == 2) do win.sendmessage(hwnd, 0x400+51, 3012, 0) Mess = CR ++ "Status: locked, but directory changes allowed" endif win.sendmessage(hwnd, 0x400+51, 3007, 0) TT.Remove(Item) local Result = TT.GetIdIndex("Vertical Separator") local Right = TT.GetRightCmd(Result, 1) local Left = TT.GetMiddleCmd(Result, 1) if(Panel == 2) do TT.ClearRight(Result) Right-- TT.AddRight(Result, Right) else TT.ClearMiddle(Result) Left-- TT.AddMiddle(Result, Left) endif local What = TT.GetLabelIndex("Left Panel Tabs") if(What) do Result = TT.GetLabelIndex("Right Panel Tabs") if(Right > Left) do if(Panel == 1) do TT.Insert(What - 1) TT.SetIconVisible(What - 1, 0) else TT.Remove(What - 2) endif elseif(Left > Right) do if(Panel == 1) do TT.Remove(Result - 2) else TT.Insert(Result - 1) TT.SetIconVisible(Result - 1, 0) endif elseif(Left == Right) do if(Panel == 1) do TT.Remove(Result - 2) else TT.Remove(What - 2) endif endif endif for(k = Item; k < TT.Length(); k++) What = TT.GetLeftCmd(k, 1) Code = select(What, 33, 36) if(miscplugin.is_int(Code)) do Temp = ifelse(Code < 5300, 1, 2) if(Panel == Temp && k >= Number) do What = TT.GetHeight(k) TT.ClearRight(k) TT.AddRight(k, cb("TabTools/TabTools@CloseTab", What)) What-- TT.SetHeight(k, What) Code-- What = "win.sendmessage(hwnd, 0x400+51, " ++ Code ++ ", 0)" TT.ClearLeft(k) TT.AddLeft(k, What) endif endif endfor if(pproflag(1)) TT.showmenu() quit(Mess)