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)

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

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)

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 : ExecuteVSCommand(command, args)

SetWindowSize

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

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)

Build

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

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

Parser

GetPreprocessedLine

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

GetCurrentSymbolType

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

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)

OverrideSetting

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

RemoveSettingOverride

Remove a setting override : RemoveSettingOverride(name)

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

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

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

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

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)

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 a key is pressed : AddOnKeyFunction(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)

AddOnWorkspaceOpenedFunction

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

RemoveOnWorkspaceOpenedFunction

Remove an OnWorkspaceOpenedFunction function : RemoveOnWorkspaceOpenedFunction(function)

AddOnSettingsChangedFunction

Add a function to be called when the settings file has been saved : AddOnSettingsChanged(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)

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)

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

AddProjectBuildFunction

Add a function to be called when the project is about to be built : AddProjectBuildFunction(function) : bool function(filename) - return True to cancel 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)

Internal

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)

SetUEPCHLogFolderName

Log UE PCH file paths for this folder : SetUEPCHLogFolderName(folder_name)