PoshCode Archive  Artifact [5971679143]

Artifact 5971679143cd2c2ea59ebe6fb25eb585f82dfb551905f02e0da481fc02dfa189:

  • File Move-ISETAB.ps1 — part of check-in [8819e7ad33] at 2018-06-10 13:25:59 on branch trunk — A function to be called by ISE AddOnMenu to move files to other tabs (runspaces) (user: Bernd Kriszio size: 1783)

# 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