ISEEditor 객체는 Microsoft.PowerShell.Host.ISE.ISEEditor 클래스의 인스턴스입니다. 콘솔 창은 ISEEditor 객체입니다. 각 ISEFile 객체는 연관된 ISEEditor 객체를 가지고 있습니다. 다음 섹션에서는 ISEEditor 객체의 메서드와 속성을 나열합니다.
메서드
Clear()
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
편집기에서 텍스트를 지우는 거죠.
# Clears the text in the Console pane.
$psISE.CurrentPowerShellTab.ConsolePane.Clear()
EnsureVisible(int lineNumber)
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
에디터를 스크롤하여 지정된 lineNumber 매개변수 값에 해당하는 줄이 보이도록 합니다. 지정된 줄 번호가 유효한 줄 번호를 정의하는 1,마지막 줄 번호 범위를 벗어나면 예외를 던집니다.
- lineNumber - 가시화될 줄 번호.
# Scrolls the text in the Script pane so that the fifth line is in view.
$psISE.CurrentFile.Editor.EnsureVisible(5)
Focus()
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
에디터에게 초점을 맞춥니다.
# Sets focus to the Console pane.
$psISE.CurrentPowerShellTab.ConsolePane.Focus()
GetLineLength(int lineNumber )
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
줄 길이를 줄 번호로 지정한 줄의 정수로 받습니다.
- lineNumber - 길이를 얻을 수 있는 선의 번호.
- 반환 - 지정된 줄 번호에 해당하는 줄의 줄 길이입니다.
# Gets the length of the first line in the text of the Command pane.
$psISE.CurrentPowerShellTab.ConsolePane.GetLineLength(1)
GoToMatch()
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다.
에디터 객체의 CanGoToMatch 속성이 가 될 $true경우, 캐럿이 바로 앞에 있는 괄호, 괄호, 또는 대괄호 바로 앞에 있을 때 캐럿을 해당 문자로 이동시킵니다
-
([,,{- 또는 닫는 괄호, 괄호 또는 중개 바로 뒤에 -),],.}캐럿은 오프닝 문자 앞이나 닫는 문자 후에 배치됩니다. CanGoToMatch 속성이 이라$false면 이 메서드는 아무런 효과가 없습니다.
# Goes to the matching character if CanGoToMatch() is $true
$psISE.CurrentPowerShellTab.ConsolePane.GoToMatch()
InsertText( text )
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
선택 영역을 텍스트로 대체하거나 현재 캐럿 위치에 텍스트를 삽입합니다.
- 텍스트 - 문자열 - 삽입할 텍스트.
이 주제의 후반부에서 스크 립팅 예제 를 참고하세요.
Select( startLine, startColumn, endLine, endColumn )
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
startLine, startColumn, endLine, endColumn 매개변수에서 텍스트를 선택합니다.
- startLine - 정수 - 선택이 시작되는 선.
- startColumn - 정수 - 시작 라인 내에서 선택이 시작되는 열.
- endLine - 정수 - 선택이 끝나는 선.
- endColumn - 정수 - 선택 영역이 끝나는 끝 줄 내의 열.
이 주제의 후반부에서 스크 립팅 예제 를 참고하세요.
SelectCaretLine()
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
현재 캐럿이 포함된 전체 텍스트 라인을 선택합니다.
# First, set the caret position on line 5.
$psISE.CurrentFile.Editor.SetCaretPosition(5,1)
# Now select that entire line of text
$psISE.CurrentFile.Editor.SelectCaretLine()
SetCaretPosition( lineNumber, columnNumber )
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
캐럿 위치를 줄 번호와 열 번호에 설정합니다. 캐럿 라인 번호나 캐럿 열 번호가 각각의 유효 범위를 벗어나면 예외를 던집니다.
- lineNumber - 정수 - 캐럿 라인 번호.
- columnNumber - 정수 - 캐럿 열 번호.
# Set the CaretPosition.
$psISE.CurrentFile.Editor.SetCaretPosition(5,1)
ToggleOutliningExpansion()
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다.
모든 윤곽선 구간이 팽창하거나 무너지게 만듭니다.
# Toggle the outlining expansion
$psISE.CurrentFile.Editor.ToggleOutliningExpansion()
속성
캔고투매치
Windows PowerShell ISE 3.0 이후 버전에서 지원되며, 이전 버전에는 포함되지 않습니다.
캐럿이 괄호, 괄호, 혹은 브레이스 옆에 있는지 나타내는 읽기 전용 불리언 속성 - (), , []{}. 캐럿이 쌍의 시작 문자 바로 앞이나 닫는 문자 바로 뒤에 있다면, 이 속성 값은 입니다 $true. 아니면 $false입니다.
# Test to see if the caret is next to a parenthesis, bracket, or brace
$psISE.CurrentFile.Editor.CanGoToMatch
캐럿 칼럼
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
읽기 전용 속성으로, 캐럿의 위치에 대응하는 열 번호를 얻습니다.
# Get the CaretColumn.
$psISE.CurrentFile.Editor.CaretColumn
캐럿라인
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
캐럿을 포함하는 줄 번호를 받는 읽기 전용 속성입니다.
# Get the CaretLine.
$psISE.CurrentFile.Editor.CaretLine
캐럿라인 텍스트
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
읽기 전용 속성으로, 캐릿을 포함하는 전체 텍스트 줄을 가져옵니다.
# Get all of the text on the line that contains the caret.
$psISE.CurrentFile.Editor.CaretLineText
LineCount
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
에디터로부터 줄 수를 가져오는 읽기 전용 속성입니다.
# Get the LineCount.
$psISE.CurrentFile.Editor.LineCount
SelectedText
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
에디터에서 선택한 텍스트를 가져오는 읽기 전용 속성입니다.
이 주제의 후반부에서 스크 립팅 예제 를 참고하세요.
문자 메시지
Windows PowerShell ISE 2.0 이후 버전에서 지원됩니다.
에디터에서 텍스트를 받거나 설정하는 읽기/쓰기 속성입니다.
이 주제의 후반부에서 스크 립팅 예제 를 참고하세요.
스크립팅 예시
# This illustrates how you can use the length of a line to
# select the entire line and shows how you can make it lowercase.
# You must run this in the Console pane. It will not run in the Script pane.
# Begin by getting a variable that points to the editor.
$myEditor = $psISE.CurrentFile.Editor
# Clear the text in the current file editor.
$myEditor.Clear()
# Make sure the file has five lines of text.
$myEditor.InsertText("LINE1 `n")
$myEditor.InsertText("LINE2 `n")
$myEditor.InsertText("LINE3 `n")
$myEditor.InsertText("LINE4 `n")
$myEditor.InsertText("LINE5 `n")
# Use the GetLineLength method to get the length of the third line.
$endColumn = $myEditor.GetLineLength(3)
# Select the text in the first three lines.
$myEditor.Select(1, 1, 3, $endColumn + 1)
$selection = $myEditor.SelectedText
# Clear all the text in the editor.
$myEditor.Clear()
# Add the selected text back, but in lower case.
$myEditor.InsertText($selection.ToLower())