ISEEditorオブジェクトは、Microsoft.PowerShell.Host.ISE.ISEEditorクラスのインスタンスです。 コンソールペインは ISEEditor オブジェクトです。 各 ISEFile オブジェクトには対応する ISEEditor オブジェクトがあります。 以下のセクションでは 、ISEEditor オブジェクトのメソッドとプロパティを一覧にしています。
Methods
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()
プロパティ
CanGoToMatch(キャンゴートゥマッチ)
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
CaretColumn
Windows PowerShell ISE 2.0以降でサポートされています。
読み取り専用の性質で、キャレットの位置に対応する列番号を得ます。
# Get the CaretColumn.
$psISE.CurrentFile.Editor.CaretColumn
ケアレットライン
Windows PowerShell ISE 2.0以降でサポートされています。
キャレットを含む行番号を取得する読み取り専用の性質です。
# Get the CaretLine.
$psISE.CurrentFile.Editor.CaretLine
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())