Author Topic: Powershell escape char  (Read 8316 times)

cb831

  • Community Member
  • Posts: 16
  • Hero Points: 0
Powershell escape char
« on: October 22, 2006, 01:01:04 am »
Hi

Is there anyway I can configure VS to behave correctly on Powershell's excape char which is accent-grave (backtick).
Basically the editor should behave the same way as with \ in .c files.

Claus

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2367
  • Hero Points: 132
Re: Powershell escape char
« Reply #1 on: October 24, 2006, 11:35:58 am »
Do you have an extension set up for these files yet?

Is this primarily a color coding issue?

Thanks,

Dan

cb831

  • Community Member
  • Posts: 16
  • Hero Points: 0
Re: Powershell escape char
« Reply #2 on: October 24, 2006, 09:07:11 pm »
Yes, I have set up a .ps1 extension refering to lexer "Powershell" defined in user.vlx

Yes, it is a color issue e.g. the below fails at the line following Get-Content line because of the line continuation `

function Get-HexDump ($path = $(throw "path must be specified"),$width=16, $total=-1)
{
    $OFS=""
    Get-Content -Encoding byte $path -ReadCount $width `
        -totalcount $total | %{
        $record = $_
        if (($record -eq 0).count -ne $width)
        {
            $hex = $record | %{
                " " + ("{0:x}" -f $_).PadLeft(2,"0")}
            $char = $record | %{
                if ([char]::IsLetterOrDigit($_))
                    { [char] $_ } else { "." }}
            "$hex $char"
        }
    }
}

cb831

  • Community Member
  • Posts: 16
  • Hero Points: 0
Re: Powershell escape char
« Reply #3 on: November 02, 2006, 05:26:06 pm »
Any comments ?

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Powershell escape char
« Reply #4 on: November 02, 2006, 07:26:10 pm »
It's hard to say what the "correct" behavior should be since Powershell syntax is going to be user-defined anyway. I'd like to see how you have your lexer defined. Please post your definition from user.vlx.
I played around with this a few months ago. I'll attach the lexer I defined, wps.vlx. It's a little stale since I haven't updated it since the Monad Beta 2 days. I'm also attaching my ps1.e file, which I threw together just to get support for function, filter, and alias listings in the Defs tool window.