<commit_before>$ProfileDir = (split-path $MyInvocation.MyCommand.Path -Parent)

Push-Location $ProfileDir
	. ./PowerShell.ps1
	. ./Themes/blackboard.ps1
Pop-Location

function prompt {
	Write-Host ' '
	Write-Host "$([Environment]::UserName)@$([Environment]::MachineName) " -foregroundColor Green -noNewLine
	Write-Host $(Shorten-Path) -foregroundColor Yellow

	Write-Host "$([char]0xBB)" -foregroundColor Green -noNewline
	' '

	Update-HostTitle
}

function ISE-CommentSelectedText {
    $text = $psISE.CurrentOpenedFile.Editor.SelectedText
    $lines = $text.Split("`n") | %{
        $_ -replace "^", "# "
    }
    if ($lines[$lines.count -1] -eq "# ") {
        $lines[$lines.count -1] = ""
    }
    $text = [string]::Join("`n", $lines)
    $psISE.CurrentOpenedFile.Editor.InsertText($text)
}

function ISE-UncommentSelectedText {
    $text = $psISE.CurrentOpenedFile.Editor.SelectedText
    $lines = $text.Split("`n") | %{
        $_ -replace "^ *# *", ""
    }
    $text = [string]::Join("`n", $lines)
    $psISE.CurrentOpenedFile.Editor.InsertText($text)
}

function ISE-ToggleCommenting {
    if ($psISE.CurrentOpenedFile.Editor.SelectedText.StartsWith('#')) {
        ISE-UncommentSelectedText       
    }
    else {
        ISE-CommentSelectedText
    }
}

$psISE.CustomMenu.Submenus.Add('Toggle Commenting', {ISE-ToggleCommenting}, "Ctrl+Oem2")
$psISE.CustomMenu.Submenus.Add("C_lear", {clear}, "Ctrl+L")<commit_msg>Added some ISE editor specific functions.<commit_after>$ProfileDir = (split-path $MyInvocation.MyCommand.Path -Parent)

Push-Location $ProfileDir
	. ./PowerShell.ps1
	. ./Themes/blackboard.ps1
Pop-Location

function prompt {
	Write-Host ' '
	Write-Host "$([Environment]::UserName)@$([Environment]::MachineName) " -foregroundColor Green -noNewLine
	Write-Host $(Shorten-Path) -foregroundColor Yellow

	Write-Host "$([char]0xBB)" -foregroundColor Green -noNewline
	' '

	Update-HostTitle
}

function ISE-CommentSelectedText {
    $text = $psISE.CurrentOpenedFile.Editor.SelectedText
    $lines = $text.Split("`n") | %{
        $_ -replace "^", "# "
    }
    if ($lines[$lines.count -1] -eq "# ") {
        $lines[$lines.count -1] = ""
    }
    $text = [string]::Join("`n", $lines)
    $psISE.CurrentOpenedFile.Editor.InsertText($text)
}

function ISE-UncommentSelectedText {
    $text = $psISE.CurrentOpenedFile.Editor.SelectedText
    $lines = $text.Split("`n") | %{
        $_ -replace "^ *# *", ""
    }
    $text = [string]::Join("`n", $lines)
    $psISE.CurrentOpenedFile.Editor.InsertText($text)
}

function ISE-ToggleCommenting {
    if ($psISE.CurrentOpenedFile.Editor.SelectedText.StartsWith('#')) {
        ISE-UncommentSelectedText       
    }
    else {
        ISE-CommentSelectedText
    }
}

function Set-File {
    param
    (
        [parameter(Mandatory=$true,ValueFromPipeline=$true)]
        [string]
        $file
    )

    $psise.CurrentOpenedRunspace.OpenedFiles.Add($file)
}

function Insert-Text{
    param
    (
        [parameter(Mandatory=$true, ValueFromPipeline=$true)]
        [string]
        $text
    )
    
    $currentFilePath = $psise.CurrentOpenedFile.FullPath
    $currentFile = $psIse.CurrentOpenedRunspace.OpenedFiles | where {$_.FullPath -eq $currentFilePath}
    $currentFile.Editor.InsertText($text)
}

function Invoke-CaretLine
{
    Invoke-Expression $([Regex]::Split($psISE.CurrentOpenedFile.Editor.text,"`r`n" )[$psISE.CurrentOpenedFile.Editor.caretline-1])
}

[void]$psISE.CustomMenu.Submenus.Add("Current Line", {Invoke-CaretLine},'F7')
[void]$psISE.CustomMenu.Submenus.Add('Toggle Commenting', {ISE-ToggleCommenting}, "Ctrl+Oem2")
[void]$psISE.CustomMenu.Submenus.Add("C_lear", {clear}, "Ctrl+L")
{'fraction_non_alphanumeric': 0.16562415012238238, 'fraction_numerical': 0.003807451726951319, 'mean_word_length': 3.673443456162643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5034441', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1262, 'n_words': 173}