Python API

The python API is in the N10X.Editor python module. For example:

N10X.Editor.OpenFile("file.txt")

For example python scripts see %appdata%\10X\PythonScripts\

General

ExecuteCommand

Execute a 10x command : ExecuteCommand(command_name)

Undo

Send an undo event to the currently focused file : Undo()

Redo

Send a redo event to the currently focused file : Redo()

SendKey

Send an key up/down press event to 10x : SendKey(string, (shift, control, alt))

SendKeyDown

Send an key down event to 10x : SendKeyDown(string, (shift, control, alt))

SendKeyUp

Send an key up event to 10x : SendKeyUp(string, (shift, control, alt))

SendCharKey

Send a char key event to 10x : SendCharKey(string)

CallOnMainThread

Add a function that will be called on the main thread : CallOnMainThread(function)

Exit

Shut down 10x - Exit(force)

SetWriteStateEnabled

Control whether 10x writes changes to the state file (for testing only) : SetWriteStateEnabled(bool)

GetCurrentPanelGridPos

Get the position of the currently focused file in the panel grid : (x, y) GetCurrentPanelGridPos()

SetStatusBarText

Show a message on the status bar : SetStatusBarText(text)

LogTo10XOutput

Log a message to the 10x output panel : LogTo10XOutput(string)

ShowMessageBox

Show a message box : ShowMessageBox(string, string)

ShowOutput

Show the output panel : ShowOutput()

Clear10xOutput

Clear the 10x output panel : Clear10xOutput()

CheckForModifiedFiles

Make 10x check all open files to see if any of them need to be reloaded : CheckForModifiedFiles()

ShowProjectInWorkspaceTree

Select the specified project in the workspace tree : ShowProjectInWorkspaceTree(filename)

SetStatusBarColour

Set the status bar colour : SetStatusBarColour((r, g, b))

ClearStatusBarColour

Clear the status bar colour : ClearStatusBarColour()

SetCursorColourOverride

Set the cursor colour override : SetCursorColourOverride((r, g, b))

ClearCursorColourOverride

Remove the cursor colour override : ClearCursorColourOverride()

ResetCursorBlink

Reset the cursor blink : ResetCursorBlink()

IsFindPanelOpen

Return true if the find text in file panel is open : bool IsFindPanelOpen()

IsFindReplacePanelOpen

Return true if the find/replace text in file panel is open : bool IsFindReplacePanelOpen()

IsOutputPanelOpen

Return True if the output panel is open : bool IsOutputPanelOpen()

IsFindFilePanelOpen

Return True if the find file panel is open : bool IsFindFilePanelOpen()

IsCommandPanelOpen

Return True if the command panel is open : bool IsCommandPanelOpen()

IsCommandLineArgSelectorPanelOpen

Return True if the command line arg selector panel is open : bool IsCommandLineArgSelectorPanelOpen()

ControlKeyHeld

Return True if the Control key is currently held down: bool ControlKeyHeld()

GetColumnCount

Return the number of columns in the panel grid : int GetColumnCount()

SetColumnCount

Set the number of columns in the panel grid : SetColumnCount(int)

CloseAllPanelsInColumn

Close all panels in the specified column : CloseAllPanelsInColumn(column_index)

GetColumnWidth

Return the width of the specified column : int GetColumnWidth(column_index)

SetColumnWidth

Set the width of the specified column : SetColumnCount(column_index, width)

SetCommandPanelText

Set the text in the command panel : SetCommandPanelText(string)

SetCursorMode

Set the cursor mode. Valid values: "Line", "Block", "Underscore", "HalfBlock" : SetCursorMode(string)

ResetCursorMode

Reset the cursor mode to the value in the settings file : ResetCursorMode()

TextEditorHasFocus

Return true if a text editor has focus : bool TextEditorHasFocus()

ExecuteVSCommand

Execute a command in Visual Studio. For more info see the EnvDTE.ExecuteCommand on MSDN : ExecuteVSCommand(command, args)

SetWindowSize

Set the main app window size : SetWindowSize(int, int)

SetForegroundWindow

Bring the 10x window to the front : SetForegroundWindow()

GetWindowRect

return the window rect : (x,y,w,h) GetwindowRect()

SetWindowRect

Set the window rect : SetwindowRect((x,y,w,h))

SetFocusedTab

Set the currently focused tab : SetFocusedTab(tab_index)

Build

ExecuteBuildCommand

Execute a build command : ExecuteBuildCommand(command, working_dir)

GetBuildConfig

Get the current build config : string GetBuildConfig()

SetBuildConfig

Set the current build config : SetBuildConfig(string)

GetBuildPlatform

Get the current build platform : string GetBuildPlatform()

SetBuildPlatform

Set the current build platform : SetBuildPlatform(string)

GetWorkspaceBuildConfig

Get the current build config for the active workspace : string GetWorkspaceBuildConfig()

GetWorkspaceBuildPlatform

Get the current build platform for the active workspace : string GetWorkspaceBuildPlatform()

LogToBuildOutput

Log a message to the build output : LogToBuildOutput(string)

ShowBuildOutput

Show the build output panel : ShowBuildOutput()

ClearBuildOutput

Clear the build output panel : ClearBuildOutput()

IsBuildPanelOpen

Return True if the build panel is open : bool IsBuildPanelOpen()

OnBuildFinished

If you have overridden the build command call this when the build has finished : void OnBuildFinished(bool build_succeeded)

Accessibility

TextToSpeech

Send text to the text to speech player : TextToSpeech(string)

SendBraille

Send braille to the accessibility app : SendBraille(string)

File

OpenFile

Open a file OpenFile(filename)

CloseFile

Close the current file

SaveFile

Save the current file

SaveAll

Save all files : bool SaveAll()

GetCurrentFilename

Get the filename of the currently focused file. Empty string if no file focused

DiscardUnsavedChanges

Discard unsaved changes for the current file : DiscardUnsavedChanges()

DiscardAllUnsavedChanges

Discard all unsaved changes : DiscardAllUnsavedChanges()

IsModified

Return true if the current file has been modified : bool IsModified()

IsFileReadOnly

Return true if the specified file is read only : bool IsFileReadOnly(filename)

FocusFile

If the file is open give it focus : Focusfile(filename)

Workspace

OpenWorkspace

Open a workspace : OpenWorkspace(filename)

CloseWorkspace

Close the current workspace : CloseWorkspace()

AddWorkspaceAdditionalInclude

Add an additional include path to the current workspace : AddWorkspaceAdditionalInclude(path)

GetWorkspaceFilename

Get the current workspace filename : filename GetWorkspaceFilename()

SetWorkspaceSettingsEnabled

Enable or disable the workspace settings file (used for testing only) : SetWorkspaceSettingsEnabled(bool)

GetWorkspaceFiles

Get all files in the current worksapce : list GetWorkspaceFiles()

GetWorkspaceProjectFiles

Get the project files in the current workspace : list GetWorkspaceProjectFiles()

GetWorkspaceExePath

Get the path to the executable that the workspace builds : string GetWorkspaceExePath()

IsWorkspaceTreeOpen

Return True if the workspace tree is open : bool IsWorkspaceTreeOpen()

GetAppDataWorkspacePath

Return the path of the local workspace settings path in appdata : string GetAppDataWorkspacePath()

GetWorkspaceOpenComplete

Returns true if the current workspace has finished opening : bool GetWorkspaceOpenComplete()

GetActiveProject

Return the filename of the currently active project : string GetActiveProject()

SetActiveProject

Set the current active project. Filename is the full path to the project : SetActiveProject(filename)

AddForceInclude

Add a force include to the current workspace : AddForceInclude(filename)

GetWorkspaceSetting

Get the value for the specified workspace setting : string GetWorkspaceSetting(string) Settings: BuildCommand RebuildCommand BuildFileCommand CleanCommand BuildWorkingDirectory CancelBuild RunCommand RunWorkingDirectory DebugCommand ExePath DebugSln UseVisualStudioEnvBat Configurations (comma separated array) Platforms (comma separated array)

SetWorkspaceSetting

Set the value for the specified workspace setting : SetWorkspaceSetting(string, string) Settings: BuildCommand RebuildCommand BuildFileCommand CleanCommand BuildWorkingDirectory CancelBuild RunCommand RunWorkingDirectory DebugCommand ExePath DebugSln UseVisualStudioEnvBat Configurations (comma separated array) Platforms (comma separated array)

Debugging

AddBreakpoint

Add a breakpoint and return its id : id AddBreakpoint(filename, line_index)

RemoveBreakpoint

Remove a breakpoint : RemoveBreakpoint(filename, line_index)

RemoveBreakpointById

Remove a breakpoint : RemoveBreakpointById(id)

UpdateBreakpoint

Update a breakpoint line : UpdateBreakpoint(id, line_index)

RemoveAllBreakpoints

Remove all breakpoints

GetDebugCommand

Get the command to run when starting debugging : string GetDebugCommand()

GetDebugCommandArgs

Get the arguments to pass into the debug command : string GetDebugCommandArgs()

GetDebugCommandCwd

Get the current working directory to use for the debug command : string GetDebugCommandCwd()

GetBreakpoints

Return a list of breakpoints (id, filename, line) : list GetBreakpoints()

SetDebuggerStepLine

Set the current debugger step line : SetDebuggerStepLine(filename, line_index)

ClearDebuggerStepLine

Remove the current debugger step line : ClearDebuggerStepLine()

OnDebuggerStarted

If you are overriding the debugger call this when the debugger has started : OnDebuggerStarted()

OnDebuggerStopped

If you are overriding the debugger call this when the debugger has stopped : OnDebuggerStopped()

OnDebuggerPaused

If you are overriding the debugger call this when the debugger has paused : OnDebuggerPaused()

OnDebuggerResumed

If you are overriding the debugger call this when the debugger has resumed : OnDebuggerResumed()

IsAutocompleteComplete

Return true if autocomplete has completed (even if it's not showing : bool IsAutocompleteComplete()

OverrideSetting

Temporarily override a setting (doesn't change the settings file) : OverrideSetting(name, value)

RemoveSettingOverride

Remove a setting override : RemoveSettingOverride(name)

Parser

GetPreprocessedLine

return the preprocessed line for the current line : string GetPreprocessedLine()

GetSymbolType

return the symbol type for the symbol at the specified position in the current file : string GetSymbolType(pos)

GetCurrentSymbolType

return the symbol type for the curent symbol : string GetCurrentSymbolType()

GetSymbolDefinition

return the symbol definition string for the symbol at the specified position in the current file : string GetSymbolDefinition(pos)

GetSymbolDefinitionFilename

return the filename for the symbol definition for the symbol at the specified position in the current file : string GetSymbolDefinitionFilename(pos)

GetCurrentScopeName

return the name of the current scope : string GetCurrentScopeName()

IsShowingAutocomplete

Return true if the autocomplete dropdown is currently showing : bool IsSHowingAutocomplete()

SetParserVerboseLoggingMode

Set the parser verbose logging mode : SetParserVerboseLoggingMode(mode)

Settings

GetSettingsFolderPath

Get the path to the settings folder : filename GetSettingsFolderPath()

SetSettingsFileName

Set the name of the settings file to use (for testing only) : SetSettingsFileName(file_name)

ResetSettingsToDefault

Reset all settings to the defaults : ResetSettingsToDefault()

ResetKeyMappingsToDefault

Reset all key mappings to the defaults : ResetKeyMappingsToDefault()

GetSetting

Get the value for the specified setting : string GetSetting(string)

SetSetting

Set the value for the specified setting : SetSetting(string, string)

GetKeyMappingsFilename

Get the name of the current key mappings file : string GetKeyMappingsFilename()

SetKeyMappingsFilename

Set the name of the key mappings file to use : SetKeyMappingsFilename(filename)

Perforce

PerforceOpenForEdit

Checkout a file in Perforce : PerforceOpenForEdit(filename)

Edit

PushUndoGroup

Push an undo group onto the undo stack : PushUndoGroup()

PopUndoGroup

Pop an undo group from the undo stack : PopUndoGroup()

BeginTextUpdate

For code that does lots of text updates wrap it in BeginTextUpdate/EndTextUpdate to make it go fast. It disables much of the internal updating until EndTextUpdate is called : BeginTextUpdate()

EndTextUpdate

For code that does lots of text updates wrap it in BeginTextUpdate/EndTextUpdate to make it go fast. It disables much of the internal updating until EndTextUpdate is called : EndTextUpdate()

GetFileText

Get the entire text for the currently focused file : string GetFileText()

SetFileText

Set the entire text for the currently focused file : SetFileText(text)

GetLineCount

Get the line count for the currently focused file : number GetLineCount()

GetVisibleLineCount

Get the number of lines that are currently visible : number GetVisibleLineCount()

InsertText

Insert text in the currently focused file at the cursor position : InsertText(text)

GetCursorPos

Get the cursor position for the currently focused file : (x, y) GetCursorPos()

SetCursorPos

Set the cursor position for the current focused file : SetCursorPos((x, y))

SetCursorX

Set the cursor X position in the current line : SetCursorX(x)

SetCursorY

Move the cursor to the specified line : SetCursorY(y)

GetSelectionStart

Get the current selection start position for the currently focused file : (x, y) GetSelectionStart()

GetSelectionEnd

Get the current selection end position for the currently focused file : (x, y) GetSelectionEnd()

SetCursorPosSelect

Set the cursor selection end position for the current focused file : SetCursorPosSelect((x, y))

SetCursorRectSelect

Set the cursor rectangular selection : SetCursorRectSelect((start_x, start_y), (end_x, end_y))

GetCurrentLine

Get the current line text for the currntly focused file : string GetCurrentLine()

GetSelection

Get the currently selected text : string GetSelection()

SetSelection

Set the cursor selection : SetSelection((start_x, start_y), (end_x, end_y), cursor_index=0)

GetCursorSelection

Get the cursor selection : (x,y), (x,y) GetCursorSelection(cursor_index=0)

RemoveCursor

Remove the cursor : RemoveCursor(cursor_index)

SetCursorVisible

Show or hide the specified cursor : SetCursorVisible(cursor_index, bool)

GetLine

Get the line text for the currently focused file : text GetLine(line_index)

SetLine

Set the line text for the currently focused file : SetLine(line_index, text)

ClearMultiCursors

Clears any multi-cursors : ClearMultiCursors()

ClearSelection

Clear the current text selection : ClearSelection()

CenterViewAtLinePos

Scroll so that the current line is centered vertically : CenterViewAtLinePos(line_index)

ScrollCursorIntoView

Scroll the cursor so that it is in view : ScrollCursorIntoView()

GetScrollLine

Get the current scroll line index : GetScrollLine()

SetScrollLine

Set the current scroll line index : SetScrollLine(line_index)

Callbacks

AddUpdateFunction

Add a function that will be called every frame : AddUpdateFunction(function)

RemoveUpdateFunction

Remove an update function : RemoveUpdateFunction(function)

AddOnCharKeyFunction

Add a function to be called when a char key is pressed : AddOnCharKeyFunction(function) : function(string)

AddOnInterceptCharKeyFunction

Add a function to be called before a char key is handled : AddOnInterceptCharKeyFunction(function) : bool function(string)

RemoveOnInterceptCharKeyFunction

Remove a function to be called before a char key is handled : RemoveOnInterceptCharKeyFunction(function) : bool function(string)

AddOnKeyFunction

Add a function to be called when an unmapped key is pressed before it is handled by 10x : AddOnKeyFunction(function) : function(string, shift, control, alt)

AddOnPostKeyFunction

Add a function to be called when after a key has been handled by 10x : AddOnPostKeyFunction(function) : function(string, shift, control, alt)

RemoveOnPostKeyFunction

Remove a function added by AddOnPostKeyFunction : RemoveOnPostKeyFunction(function) : function(string, shift, control, alt)

AddOnInterceptKeyFunction

Add a function to be called before a key press is handled. Return true if handled : AddOnInterceptKeyFunction(function) : bool function(string, shift, control, alt)

RemoveOnInterceptKeyFunction

Add a function to be called before a key press is handled. Return true if handled : RemoveOnInterceptKeyFunction(function) : bool function(string, shift, control, alt)

AddOnReadOnlyFileModifiedFunction

Add a function to be called when a read only file is about to be modified : AddOnReadOnlyFileModifiedFunction(function) : function(filename)

AddOnWorkspaceCreatedFunction

Add a function to be called when a workspace is opened : AddOnWorkspaceCreatedFunction(function)

RemoveOnWorkspaceCreatedFunction

Remove an OnWorkspaceCreatedFunction function : RemoveOnWorkspaceCreatedFunction(function)

AddOnWorkspaceOpenedFunction

Add a function to be called when a workspace is opened : AddOnWorkspaceOpenedFunction(function)

RemoveOnWorkspaceOpenedFunction

Remove an OnWorkspaceOpenedFunction function : RemoveOnWorkspaceOpenedFunction(function)

AddOnFileOpenedFunction

Add a function to be called when a file is opened : AddOnFileOpenedFunction(function)

RemoveOnFileOpenedFunction

Remove an OnFileOpenedFunction function : RemoveOnFileOpenedFunction(function)

AddOnSettingsChangedFunction

Add a function to be called when the settings file has been saved : AddOnSettingsChanged(function)

AddOnFileLosingFocusFunction

Add a function to be called when the a file is about to lose focus : AddOnFileLosingFocusFunction(function)

AddCommandPanelHandlerFunction

Add a function that handles commands entered in the command panel. Function takes a string and returns true if command is handled : AddCommandPanelHandlerFunction(function)

AddCursorMovedFunction

Add a function that's called when the cursor moves : AddCursorMovedfunction(function)

RemoveCursorMovedFunction

Remove a function that was added by AddCursorMovedFunction : RemoveCursorMovedFunction(function)

AddParsersFinishedFunction

Add a function to be called when the parser has finished its main parse : AddParsersFinishedFunction(function)

RemoveParsersFinishedFunction

remove a parser finished function : RemoveParsersFinishedFunction(function)

AddDebugCommandLineChangedFunction

Add a function to be called when the debug command line changes : AddDebugCommandLineChangedFunction(function)

RemoveDebugCommandLineChangedFunction

remove a parser finished function : RemoveDebugCommandLineChangedFunction(function)

AddStartDebuggingFunction

Add a function to be called when the debugger is started : AddStartDebuggingFunction(function) : bool function() - return True if the debugging process has been overridden

AddStopDebuggingFunction

Add a function to be called when the debugger is stopped : AddStopDebuggingFunction(function) : bool function() - return True if the debugging process has been overridden

AddRestartDebuggingFunction

Add a function to be called when the debugger is Restartped : AddRestartDebuggingFunction(function) : bool function() - return True if the debugging process has been overridden

AddDebugStepOverFunction

Add a function to be called when the debug step over command is called : AddDebugStepOverFunction(function) : function()

AddDebugStepIntoFunction

Add a function to be called when the debug step into command is called : AddDebugStepIntoFunction(function) : function()

AddDebugStepOutFunction

Add a function to be called when the debug step out command is called : AddDebugStepOutFunction(function) : function()

AddProjectBuildFunction

Add a function to be called when the project is about to be built. If returning true you must call ExecuteBuildCommand or OnBuildFinished : AddProjectBuildFunction(function) : bool function(filename) - return True to override the build

AddProjectRebuildFunction

Add a function to be called when the project is about to be rebuilt. If returning true you must call ExecuteBuildCommand or OnBuildFinished : AddProjectRebuildFunction(function) : bool function(filename) - return True to override build

AddBuildFinishedFunction

Add a function to be called when a build has finished : AddBuildFinishedFunction(function) : function(build_result)

AddPreFileSaveFunction

Add a function to be called before a file is saved : AddPreFileSaveFunction(function) : function(filename)

AddPostFileSaveFunction

Add a function to be called after a file has been saved : AddPostFileSaveFunction(function) : function(filename)

AddBreakpointAddedFunction

Add a function to be called when a breakpoint is added : AddBreakpointAddedFunction(function) where function is function(id, filename, line)

AddBreakpointRemovedFunction

Add a function to be called when a breakpoint is removed : AddBreakpointRemovedFunction(function) where function is function(id, filename, line)

AddBreakpointUpdatedFunction

Add a function to be called when a breakpoint is updated : AddBreakpointUpdatedFunction(function) where function is function(id, filename, line)

AddMouseSelectStartedFunction

Add a function to be called when starting to select text with the mouse : AddMouseSelectStartedFunction(function) where function is function((i,i))

AddMouseSelectFinishedFunction

Add a function to be called when finishing selecting text with the mouse : AddMouseSelectFinishedFunction(function) where function is function((i,i))

Internal

DebugLog

Log to the attached debugger output : DebugLog(string)

InitialiseTestEnvironment

Initialise the test environment. Reset settings and disable settings write. Name can be anything : InitialiseTestEnvironment(name)

SetParserCacheEnabled

Enable or disable the parser cache (used for testing only) : SetParserCacheEnabled(bool)

SetUseLocalClipboard

Use a local clipboard instead of the OS clipboard (used for testing only) : SetUseLocalClipboard(bool)

SetUEPCHLogFilename

Log UE PCH file paths for this file : SetUEPCHLogFilename(filename)