C# Класс NppSharp.NppScript

Base class for all script objects. Any objects that wish to have their public methods made available as commands must inherit from this class.
Показать файл Открыть проект

Открытые методы

Метод Описание
Append ( string text ) : void

Appends text to the end of the document without affecting the selection.

CancelAutoCompletion ( ) : void

Cancels any active auto-completion.

Clear ( ) : void

Deletes the selected text.

ClearAll ( ) : void

Clears all text out of the document.

Copy ( ) : void

Copies the selected text to the clipboard.

Copy ( TextLocation start, TextLocation end ) : void

Copies the specified text range into the clipboard.

Copy ( TextLocation start, int numChars ) : void

Copies the specified text range into the clipboard.

Copy ( string text ) : void

Copies the provided string into the clipboard.

CopyAllowLine ( ) : void

Copies the selected text to the clipboard. If no text is selected, the current line is copied instead.

Cut ( ) : void

Cuts the selected text to the clipboard.

DockWindow ( IWin32Window window, string title, DockWindowAlignment alignment, int id ) : IDockWindow

Creates a docked window.

This window will not be restored the next time Notepad++ starts. The plugin must recreate the window during the 'Ready' event, if it wishes to have the window visible again.

Notepad++ will use the ID to remember the state for this docked window between sessions. If another docked window with the same ID had been opened previously with a different alignment, or the user had dragged the window to another side of the screen, then the docked window will appear in the previous location rather than the one specified here.

FindColumn ( int line, int column ) : TextLocation

Gets the position that corresponds to a line and column.

FocusEditor ( ) : void

Sets the focus to the current editor window.

GetActiveFileIndex ( EditorView view ) : int

Gets the current document index in the specified view.

GetDockWindow ( int id ) : IDockWindow

Gets the dock window object for the specified ID.

GetFileNames ( EditorView view ) : IEnumerable

Gets a list of open file names in the specified view.

To get a list of all open file names in both views, you can use the 'FileNames' property.

GetLanguageName ( int langId ) : string

Gets the name of a language, given the ID.

GetLineEndPos ( int line ) : TextLocation

Gets the ending position of the specified line, before any line-end characters.

GetLineLength ( int line ) : int

Gets the length of the specified line (excluding line-end characters).

GetLineStartPos ( int line ) : TextLocation

Gets the starting position of the specified line.

GetLineText ( int line ) : string

Gets the text for the specified line.

GetLineText ( int line, bool includeLineEndChars ) : string

Gets the text for the specified line, optionally including line-end characters.

GetText ( TextLocation start, TextLocation end ) : string

Gets the text for the specified range.

GetText ( TextLocation start, int numChars ) : string

Gets the text for the specified range.

GetWordEndPos ( TextLocation pos, bool onlyWordChars ) : TextLocation

Gets the position at the end of the current word.

GetWordStartPos ( TextLocation pos, bool onlyWordChars ) : TextLocation

Gets the position at the start of the current word.

GoTo ( TextLocation pos ) : void

Goes to the specified position and ensures it is visible.

GoToLine ( int line ) : void

Goes to the specified line and ensures it is visible.

Insert ( string text ) : void

Inserts text over the current selection. The caret is placed after the inserted text and scrolled into view.

LaunchFindInFiles ( string dir, string filters ) : void

Launches the 'Find in Files' dialog.

MenuCommand ( MenuCommand command ) : void

Triggers a menu item command.

MenuCommand ( int commandId ) : void

Triggers a menu item command.

MoveCaretInsideView ( ) : void

If the caret is outside the current view, it is moved to the nearest visible line. Any selection is lost.

MoveSelectedLinesDown ( ) : void

Moves the selected lines down one line, shifting the line below the selection.

MoveSelectedLinesUp ( ) : void

Moves the selected lines up one line, shifting the line above the selection.

OpenFile ( string fileName ) : bool

Opens a new file. If the file is already open, it will be made active.

Paste ( ) : void

Pastes the clipboard text over the selection.

PointToPos ( Point pt ) : TextLocation

Finds the position closest to a point on the screen.

PointToPosClose ( Point pt, TextLocation &location ) : bool

Finds the position closest to a point on the screen.

PosToPoint ( TextLocation pos ) : Point

Returns the x and y display location of the position.

RefreshCustomLexers ( ) : void

Refreshes the word-styles and folding on documents that use a custom lexer provided via NppSharp.

This function is useful if your lexers providing highlighting that can change, and need to be refreshed at certain events.

ReloadFile ( bool withAlert ) : void

Reloads the current file.

ReloadFile ( string fileName, bool withAlert ) : void

Reloads a file given the file name. If the file is not already open, then this has no effect.

SaveAllFiles ( ) : bool

Saves all open documents.

SaveFile ( ) : bool

Saves the current document.

SaveFileAs ( string fileName ) : bool

Saves the current document to another file name.

SaveFileCopyAs ( string fileName ) : bool

Saves a copy of the current document to another file name.

SelectAll ( ) : void

Selects all text in the document. (The caret is not scrolled into view)

SetActiveFileIndex ( EditorView view, int index ) : void

Switches to the file in the specified view.

SetEmptySelection ( TextLocation pos ) : void

Removes the selection and sets the caret at pos. (The caret is not scrolled into view)

SetSelection ( TextLocation anchorPos, TextLocation currentPos ) : void

Sets the selection range. (The caret is scrolled into view)

ShowAutoCompletion ( int lengthEntered, IEnumerable list ) : void

Shows the AutoCompletion list.

ShowAutoCompletion ( int lengthEntered, IEnumerable list, bool ignoreCase ) : void

Shows the AutoCompletion list.

ShowError ( Exception ex ) : void

Displays an error message caused by an exception.

ShowError ( Exception ex, string message ) : void

Displays an error message caused by an exception, with additional text.

ShowError ( string message ) : void

Displays an error message.

SwitchToFile ( string fileName ) : bool

Switches to a file given the file name.

Защищенные методы

Метод Описание
OnLoad ( ) : void

Called after the object has been created and initialized, but before the Notepad++ Ready notification.

Приватные методы

Метод Описание
InitEvents ( ) : void
OnCharAdded ( object sender, CharAddedEventArgs e ) : void
OnDoubleClick ( object sender, DoubleClickEventArgs e ) : void
OnFileActivated ( object sender, FileEventArgs e ) : void
OnFileClosed ( object sender, FileEventArgs e ) : void
OnFileClosing ( object sender, FileEventArgs e ) : void
OnFileLoadFailed ( object sender, EventArgs e ) : void
OnFileLoading ( object sender, EventArgs e ) : void
OnFileOpened ( object sender, FileEventArgs e ) : void
OnFileOpening ( object sender, FileEventArgs e ) : void
OnFileOrderChanged ( object sender, FileEventArgs e ) : void
OnFileSaved ( object sender, FileEventArgs e ) : void
OnFileSaving ( object sender, FileEventArgs e ) : void
OnLanguageChanged ( object sender, LanguageTypeEventArgs e ) : void
OnModification ( object sender, ModifiedEventArgs e ) : void
OnReady ( object sender, EventArgs e ) : void
OnShutdown ( object sender, EventArgs e ) : void
OnStyleUpdate ( object sender, FileEventArgs e ) : void

Описание методов

Append() публичный Метод

Appends text to the end of the document without affecting the selection.
public Append ( string text ) : void
text string The text to be appended.
Результат void

CancelAutoCompletion() публичный Метод

Cancels any active auto-completion.
public CancelAutoCompletion ( ) : void
Результат void

Clear() публичный Метод

Deletes the selected text.
public Clear ( ) : void
Результат void

ClearAll() публичный Метод

Clears all text out of the document.
public ClearAll ( ) : void
Результат void

Copy() публичный Метод

Copies the selected text to the clipboard.
public Copy ( ) : void
Результат void

Copy() публичный Метод

Copies the specified text range into the clipboard.
public Copy ( TextLocation start, TextLocation end ) : void
start TextLocation The starting position.
end TextLocation The ending position (exclusive).
Результат void

Copy() публичный Метод

Copies the specified text range into the clipboard.
public Copy ( TextLocation start, int numChars ) : void
start TextLocation The starting position.
numChars int The number of characters to be copied.
Результат void

Copy() публичный Метод

Copies the provided string into the clipboard.
public Copy ( string text ) : void
text string The text to be placed into to the clipboard.
Результат void

CopyAllowLine() публичный Метод

Copies the selected text to the clipboard. If no text is selected, the current line is copied instead.
public CopyAllowLine ( ) : void
Результат void

Cut() публичный Метод

Cuts the selected text to the clipboard.
public Cut ( ) : void
Результат void

DockWindow() публичный Метод

Creates a docked window.

This window will not be restored the next time Notepad++ starts. The plugin must recreate the window during the 'Ready' event, if it wishes to have the window visible again.

Notepad++ will use the ID to remember the state for this docked window between sessions. If another docked window with the same ID had been opened previously with a different alignment, or the user had dragged the window to another side of the screen, then the docked window will appear in the previous location rather than the one specified here.

public DockWindow ( IWin32Window window, string title, DockWindowAlignment alignment, int id ) : IDockWindow
window IWin32Window The form window that is to be docked.
title string The window title.
alignment DockWindowAlignment Window alignment, or floating.
id int An identifier for this docked window. /// The ID must be greater than zero.
Результат IDockWindow

FindColumn() публичный Метод

Gets the position that corresponds to a line and column.
public FindColumn ( int line, int column ) : TextLocation
line int The one-based line number.
column int The one-based column number.
Результат TextLocation

FocusEditor() публичный Метод

Sets the focus to the current editor window.
public FocusEditor ( ) : void
Результат void

GetActiveFileIndex() публичный Метод

Gets the current document index in the specified view.
public GetActiveFileIndex ( EditorView view ) : int
view EditorView The view in which the active file index will be retrieved.
Результат int

GetDockWindow() публичный Метод

Gets the dock window object for the specified ID.
public GetDockWindow ( int id ) : IDockWindow
id int The ID number for the dock window object.
Результат IDockWindow

GetFileNames() публичный Метод

Gets a list of open file names in the specified view.
To get a list of all open file names in both views, you can use the 'FileNames' property.
public GetFileNames ( EditorView view ) : IEnumerable
view EditorView The editor view to retrieve the list of open file names.
Результат IEnumerable

GetLanguageName() публичный Метод

Gets the name of a language, given the ID.
public GetLanguageName ( int langId ) : string
langId int The language ID.
Результат string

GetLineEndPos() публичный Метод

Gets the ending position of the specified line, before any line-end characters.
public GetLineEndPos ( int line ) : TextLocation
line int The one-based line number.
Результат TextLocation

GetLineLength() публичный Метод

Gets the length of the specified line (excluding line-end characters).
public GetLineLength ( int line ) : int
line int The one-based line number.
Результат int

GetLineStartPos() публичный Метод

Gets the starting position of the specified line.
public GetLineStartPos ( int line ) : TextLocation
line int The one-based line number.
Результат TextLocation

GetLineText() публичный Метод

Gets the text for the specified line.
public GetLineText ( int line ) : string
line int The one-based line number.
Результат string

GetLineText() публичный Метод

Gets the text for the specified line, optionally including line-end characters.
public GetLineText ( int line, bool includeLineEndChars ) : string
line int The one-based line number.
includeLineEndChars bool If true, the returned string will contain the line-end characters.
Результат string

GetText() публичный Метод

Gets the text for the specified range.
public GetText ( TextLocation start, TextLocation end ) : string
start TextLocation The starting position.
end TextLocation The ending position (exclusive).
Результат string

GetText() публичный Метод

Gets the text for the specified range.
public GetText ( TextLocation start, int numChars ) : string
start TextLocation The starting position.
numChars int The number of characters to retrieve.
Результат string

GetWordEndPos() публичный Метод

Gets the position at the end of the current word.
public GetWordEndPos ( TextLocation pos, bool onlyWordChars ) : TextLocation
pos TextLocation The starting position.
onlyWordChars bool If true, only word characters will be jumped. /// If false, all characters will be jumped.
Результат TextLocation

GetWordStartPos() публичный Метод

Gets the position at the start of the current word.
public GetWordStartPos ( TextLocation pos, bool onlyWordChars ) : TextLocation
pos TextLocation The starting position.
onlyWordChars bool If true, only word characters will be jumped. /// If false, all characters will be jumped.
Результат TextLocation

GoTo() публичный Метод

Goes to the specified position and ensures it is visible.
public GoTo ( TextLocation pos ) : void
pos TextLocation The position to go to.
Результат void

GoToLine() публичный Метод

Goes to the specified line and ensures it is visible.
public GoToLine ( int line ) : void
line int The line to go to.
Результат void

Insert() публичный Метод

Inserts text over the current selection. The caret is placed after the inserted text and scrolled into view.
public Insert ( string text ) : void
text string The text to be inserted.
Результат void

LaunchFindInFiles() публичный Метод

Launches the 'Find in Files' dialog.
public LaunchFindInFiles ( string dir, string filters ) : void
dir string The directory to be searched.
filters string The file filters to be searched.
Результат void

MenuCommand() публичный Метод

Triggers a menu item command.
public MenuCommand ( MenuCommand command ) : void
command MenuCommand The ID of the command to be triggered.
Результат void

MenuCommand() публичный Метод

Triggers a menu item command.
public MenuCommand ( int commandId ) : void
commandId int The ID of the command to be triggered.
Результат void

MoveCaretInsideView() публичный Метод

If the caret is outside the current view, it is moved to the nearest visible line. Any selection is lost.
public MoveCaretInsideView ( ) : void
Результат void

MoveSelectedLinesDown() публичный Метод

Moves the selected lines down one line, shifting the line below the selection.
public MoveSelectedLinesDown ( ) : void
Результат void

MoveSelectedLinesUp() публичный Метод

Moves the selected lines up one line, shifting the line above the selection.
public MoveSelectedLinesUp ( ) : void
Результат void

OnLoad() защищенный Метод

Called after the object has been created and initialized, but before the Notepad++ Ready notification.
protected OnLoad ( ) : void
Результат void

OpenFile() публичный Метод

Opens a new file. If the file is already open, it will be made active.
public OpenFile ( string fileName ) : bool
fileName string The pathname of the file to be opened.
Результат bool

Paste() публичный Метод

Pastes the clipboard text over the selection.
public Paste ( ) : void
Результат void

PointToPos() публичный Метод

Finds the position closest to a point on the screen.
public PointToPos ( Point pt ) : TextLocation
pt Point The client coordinates of the point to test.
Результат TextLocation

PointToPosClose() публичный Метод

Finds the position closest to a point on the screen.
public PointToPosClose ( Point pt, TextLocation &location ) : bool
pt Point The client coordinates of the point to test.
location TextLocation An out parameter to receive the found location.
Результат bool

PosToPoint() публичный Метод

Returns the x and y display location of the position.
public PosToPoint ( TextLocation pos ) : Point
pos TextLocation The position to find.
Результат Point

RefreshCustomLexers() публичный Метод

Refreshes the word-styles and folding on documents that use a custom lexer provided via NppSharp.
This function is useful if your lexers providing highlighting that can change, and need to be refreshed at certain events.
public RefreshCustomLexers ( ) : void
Результат void

ReloadFile() публичный Метод

Reloads the current file.
public ReloadFile ( bool withAlert ) : void
withAlert bool If true, Notepad++ will show an alert box to confirm.
Результат void

ReloadFile() публичный Метод

Reloads a file given the file name. If the file is not already open, then this has no effect.
public ReloadFile ( string fileName, bool withAlert ) : void
fileName string The pathname of the file to be reloaded.
withAlert bool If true, Notepad++ will show an alert box to confirm.
Результат void

SaveAllFiles() публичный Метод

Saves all open documents.
public SaveAllFiles ( ) : bool
Результат bool

SaveFile() публичный Метод

Saves the current document.
public SaveFile ( ) : bool
Результат bool

SaveFileAs() публичный Метод

Saves the current document to another file name.
public SaveFileAs ( string fileName ) : bool
fileName string The pathname of the file to be written.
Результат bool

SaveFileCopyAs() публичный Метод

Saves a copy of the current document to another file name.
public SaveFileCopyAs ( string fileName ) : bool
fileName string The pathname of the file to be written.
Результат bool

SelectAll() публичный Метод

Selects all text in the document. (The caret is not scrolled into view)
public SelectAll ( ) : void
Результат void

SetActiveFileIndex() публичный Метод

Switches to the file in the specified view.
public SetActiveFileIndex ( EditorView view, int index ) : void
view EditorView The view in which the file is to be switched.
index int Zero-based index of the view to switch to.
Результат void

SetEmptySelection() публичный Метод

Removes the selection and sets the caret at pos. (The caret is not scrolled into view)
public SetEmptySelection ( TextLocation pos ) : void
pos TextLocation The new start/end position for the selection.
Результат void

SetSelection() публичный Метод

Sets the selection range. (The caret is scrolled into view)
public SetSelection ( TextLocation anchorPos, TextLocation currentPos ) : void
anchorPos TextLocation The selection anchor position.
currentPos TextLocation The selection current position.
Результат void

ShowAutoCompletion() публичный Метод

Shows the AutoCompletion list.
public ShowAutoCompletion ( int lengthEntered, IEnumerable list ) : void
lengthEntered int The number of characters already entered by the user.
list IEnumerable The list of words.
Результат void

ShowAutoCompletion() публичный Метод

Shows the AutoCompletion list.
public ShowAutoCompletion ( int lengthEntered, IEnumerable list, bool ignoreCase ) : void
lengthEntered int The number of characters already entered by the user.
list IEnumerable The list of words.
ignoreCase bool Ignore case?
Результат void

ShowError() публичный Метод

Displays an error message caused by an exception.
public ShowError ( Exception ex ) : void
ex System.Exception The exception that caused the error.
Результат void

ShowError() публичный Метод

Displays an error message caused by an exception, with additional text.
public ShowError ( Exception ex, string message ) : void
ex System.Exception The exception that caused the error (will be displayed in details tab).
message string Additional text to be displayed in message tab.
Результат void

ShowError() публичный Метод

Displays an error message.
public ShowError ( string message ) : void
message string The message to be displayed.
Результат void

SwitchToFile() публичный Метод

Switches to a file given the file name.
public SwitchToFile ( string fileName ) : bool
fileName string The pathname of the file to be brought current.
Результат bool