# encoding: ascii
# api: powershell
# title: Move-ISETAB
# description: A function to be called by ISE AddOnMenu to move files to other tabs (runspaces)
# version: 0.1
# type: function
# author: Bernd Kriszio
# license: CC0
# function: Move-ISETab
# x-poshcode-id: 3455
# x-archived: 2012-06-22T05:44:46
# x-published: 2012-06-16T03:13:00
#
#
function Move-ISETab
{
param(
$offset = 1
)
$curFile = $psISE.CurrentFile
if ($curFile.IsSaved)
{
$curTabFiles = $psISE.CurrentPowerShellTab.Files
$tabs = $psISE.PowerShellTabs
$Fileindex = $null
foreach ($i in 0..($curTabFiles.count -1))
{
if ($curTabFiles[$i].displayname -eq $curFile.DisplayName)
{
$Fileindex = $i
break
}
}
$file = $curFile.FullPath
$Tabindex = $null
foreach ($i in 0..($tabs.count -1))
{
if ($tabs[$i].displayname -eq $psISE.CurrentPowerShellTab.DisplayName)
{
$Tabindex = $i
break
}
}
$newTabIndex = ($TabIndex + $offset) % $tabs.count
$curTabFiles.removeAt($Fileindex)
$newtab = $tabs[$newTabIndex]
$psise.PowerShellTabs.SetSelectedPowerShellTab($newTab)
$newObj = $tabs[$newTabIndex].files.add($file)
}
else
{
"You must save the file bevore moving it."
}
}
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Move-ToNextPowerShellTab",{Move-ISETab}, "Ctrl+Alt+Shift+RIGHT") | out-null
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Move-ToLastPowerShellTab",{Move-ISETab -1}, "Ctrl+Alt+Shift+LEFT") | out-null