次の方法で共有


ISEEditor オブジェクト

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 - Integer - 選択範囲を開始する行を します。
  • 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 - Integer - キャレット列番号。
# 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

CaretLine

Windows PowerShell ISE 2.0 以降でサポートされています。

キャレットを含む行の数を取得する読み取り専用プロパティ。

# Get the CaretLine.
$psISE.CurrentFile.Editor.CaretLine

CaretLineText

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())

関連項目

  • ISEFile オブジェクト する
  • PowerShellTab オブジェクト する
  • Windows PowerShell ISE スクリプト オブジェクト モデル の目的
  • ISE オブジェクト モデル階層 する