Welcome, Guest. Please login or register.
Home Help Search Login Register

Codeweaver Forums  |  Codeweaver / TorqueDev  |  Codeweaver Announcements  |  Topic: TorqueDev SDK « previous next »
Pages: [1] Print
Author Topic: TorqueDev SDK  (Read 2679 times)
Sam Bacsa
Administrator

Posts: 268



TorqueDev SDK
« on: August 15, 2005, 03:32:12 am »

Please see this update to the SDK.

You can grab a sample SDK project here***.  It's written in C#.  Add a reference to PluginRes.dll in your TorqueDev directory, compile it, and stick it in the TorqueDev directory.  As long as the DLL starts with tdp_, it will be loaded on startup.

*** - This sample project does not work for the SDK release #2, but it's a good example to understand how the system works.

This sample plugin changes the icons of all the files in your project to "lock" icons.  It adds a tab (if you can't see it right away, go to Window->Show All Developer Tabs) to the left explorer, adds a main menu next to "help", and adds a page to the config window.  It's really straight-foward and not complex at all.  I plan to have a way better example down the line.

Here's some info about the SDK:
Code:
struct ConfigPage {
// The user-control you want displayed in the configuration tab
Control TabDisplay;

// The caption of the tab
string TabText;
}


struct ContextMenuHandler {
// A string that will be passed back as the object's Tag
// when the event is fired
string MenuItemKey

// The caption of your context menu item
string MenuItemName

// The event that should fire when the button is clicked
EventHandler MenuItemTrigger
}


struct DirectorySpec {
// The handle, or ID, of a directory in the project
int DirectoryHandle;

// The name of the directory
string DirectoryName;

// The handle of the parent of this directory (0 for none)
int DirectoryParent;
}


struct EditorPosition {
// The line number (0-based) on which the cursor is currently located
int LineNumber;

// The offset, from the beginning of the file (0-based)
int Offset;
}



struct EditorSelection {
// The offset, from the beginning of the file, where
// the selection ends
int EndOffset;

// The selected text
string SelText;

// The offset, from the beginning of the file, where
// the selection begins
int StartOffset;
}


struct FileSpec {
// The handle, or ID, of the file in the project
int FileHandle;

// The icon assigned to the file in the project explorer
// (-1 if not applicable)
int FileIcon;

// The "friendly name" or "simple name" of the file
string FriendlyName;

// The absolute path of the file
string FullPath;

// Whether the file has been saved since modified
bool isDirty;

// The handle, or ID, of the parent directory.  0 if none (root)
int ParentDirHandle;
}



struct MainMenuHandler {
// An array of submenu items
MainMenuItem[] MenuItems;

// The caption of the main menu
string MenuName;
}



struct MainMenuItem {
// The index of the icon to assign to the menu item (-1 for none)
int MainMenuItemIconIndex;

// A string that is passed back as the Tag of the object when
// the event is fired
string MenuItemKey;

// The caption of the menu item
string MenuItemName;

// The accelerator key of the menu item
Shortcut MenuItemShortcut;

// The event to fire when the menu item is clicked
EventHandler MenuItemTrigger;
}


struct ProjectSpec {
// Whether debugging is enabled
bool DebugEnabled;

// The full path to the project's EXE
string DebugExe;

// The parameters to run the project with, as defined
string DebugParams;

// The password to use for the debugger
string DebugPasswd;

// The port to connect to for debugging
int DebugPort;

// The name of the project
string ProjectName;

// The root path of the project
string RootPath;
}


class Infopop {
// The Infopop's fields are mainly used for informational purposes only.  The only field
// actively utilized is the FinalDisplay field, which is what gets parsed when the
// infopop is displayed.  The rest of the fields are for you to understand what function
// is being displayed (when the onBeforeDisplayInfopop event is fired).  If you are
// displaying custom Infopops, you need not set anything except the FinalDisplay field.
}



class IntellicodeEntry {
// The name of the entry displayed in the intellicode dropdown
string EntryName;

// The tooltip displayed when the entry is highlighted
string EntryDescription;

// The text to insert BEFORE the cursor when the entry is selected
string EntryInsertBefore;

// The text to insert AFTER the cursor when the entry is selected
string EntryInsertAfter;

// Not used
string EntryParams;

// The icon to assign the icon of the entry (see listing of icons below)
int IconEntryIndex;
}



Events:
Code:
onAfterDocumentOpen(FileSpec file);
// Fired after a file is opened
//
// FileSpec file -- The description of the file.



onAfterDocumentSave(FileSpec file);
// Fired after a document is saved
//
// FileSpec file -- The description of the file.



onAfterFileDelete(FileSpec file);
// Fired after a file is deleted.
//
// FileSpec file -- The description of the file.



onAfterRefreshProjectList();
// Fired after the project list is refreshed



onBeforeAddProjectListItem(FileSpec file, int image_index);
// Fired before a file is added to the project treeview.  This
// is mainly so you can change its icon.  Set image_index
// equal to the image index of the icon you want it to change
// to, or leave it as it is for the default.
//
// FileSpec file -- The description of the file.
// int image_index -- The image index of the icon to set


onBeforeConfigShow(out ConfigPage[] config_pages);
// Fired before the config window is shown.  Set config_pages
// equal to an array of tabs to add to the config page.
//
// ConfigPage[] config_pages -- Array of config pages to add



onBeforeDocumentOpen(FileSpec file, out bool cancel);
// Fired before a document is opened
//
// FileSpec file -- The description of the file.
// bool cancel -- Set to TRUE to stop trying to open a file.



onBeforeDocumentSave(FileSpec file, out bool cancel);
// Fired before a document is saved
//
// FileSpec file -- The description of the file.
// bool cancel -- Set to TRUE to stop the file from being saved.



onBeforeFileDelete(FileSpec file, out bool cancel);
// Fired before a file is deleted
//
// FileSpec file -- The description of the file.
// bool cancel -- Set to TRUE to prevent the file from being deleted.



onBeforeRefreshProjectList();
// Fired before the project listing is refreshed



onConfigClose(bool cancelled);
// Fired when the config window is closed
//
// bool cancelled -- TRUE if the user cancelled commit of config prefs



onDocumentDirty(FileSpec file);
// Fired when a document is changed after being saved
//
// FileSpec file -- The description of the file.



onDocumentNew(FileSpec file);
// Fired when a new file is created
//
// FileSpec file -- The description of the file.



onEditorSmartIndentExecute();
// Fired when the user presses } and executes a "smart indent"



onPluginDeinitialize();
// Fired when the program is about to close



bool onPluginInitialize(Version TorqueDevVersion, IDEControl ctrl);
// Fired when the plugin is loaded into memory
//
// Version TorqueDevVersion -- The version of the executing IDE
// IDEControl ctrl -- A special class used to send messages to
// the IDE.
//
// This is the ONLY event with a return value.  Return TRUE to
// allow the IDE to continue using your plugin or return FALSE
// to effectively disable your plugin from continuing execution.  This
// is useful in case of initialization failure or version conflict.
// FALSE will not unload the plugin from memory, but rather
// remove the plugin from the event firing queue, causing no
// events to fire.



onProjectClosed();
// Fired when a project is closed



onProjectContextMenu();
// Not implemented.


onProjectOpened();
// Fired when a project is opened.


onBeforeDisplayIntellicode(IntellicodeEntryCollection members, IntellicodeType type, string IdentifierValue, string MemberOfObject)
// members - Collection of intellicode entries (see class above)
// type - DeclaredVariableCompletion (autocomplete on __decl-s) or
// - DeclaredObjectCompletion (autocomplete on new Type(Object)-s)
// IdentifierValue - Name of the variable being completed
// MemberOfObject - Name of object being completed
//
//
// ** Changing the "members" class in any way will alter what is displayed to the user, so
// ** you can use this to add additional members or what-not.


onBeforeDisplayInfopop(InfopopCollection members, string InfopopFunctionName, string InfopopParentObject, string InfopopParentVariable, bool BuiltinFunction)
// members - Collection of infopop entries (see class above)
// InfopopFnuctionName - The function name being infopopped
// InfopopParentObject - The object to which the function belongs ("" if N/A)
// InfopopParentVariable- The variable to which the function belongs ("" if N/A)
// BuiltInFunction - True if the function is a built-in engine function
//
// ** Changing the "members" class in any way will alter what is displayed to the user, so
// ** you can use this to add additional members or what-not.


onTrigger(string TriggerKey)
// A custom trigger has been initiated.


onBeforeCloseTab(int TabHandle, out bool cancel)
// Fired before your custom workspace tab is closed. 
// Set cancel to TRUE to halt closing of tab.


onAfterCloseTab(int TabHandle)
// Fired after your custom workspace tab is closed.


onBeforeDocumentSwitch(int TabHandle, FileSpec file, out bool cancel)
// Fired before a tab switch.  If the tab being switched to is NOT an editor
// tab, "file" will contain blank data.  Set CANCEL to not commit the switch.


onAfterDocumentSwitch(int TabHandle, FileSpec file)
// Fired after a tab switch.  If the tab being switched to is NOT an editor
// tab, "file" will contain blank data.


Callable functions in the IDEControl object:
Code:
Version GetTorqueDevVersion()
// Retrieve the current version of TorqueDev that the user is running


int AddMenuIconResource(Image icon)
// Add an icon that can be used in defining a main menu item.  Returned
// INT is the ID of the icon.
//
// Image icon Icon Resource


int AddProjectTreeIconResource(Image icon)
// Add an icon that can be used in defining a file's icon in the
// project treeview.  Returned INT is the ID of the icon.
//
// Image icon Icon resource


void AddProjectContextMenuHandler(ContextMenuHandler handler)
// Add a context menu item to the project view's right-click
// menu.
//
// ContextMenuHandler handler Handler struct


int AddDirectory(string DirectoryName, int ParentDirectory)
// Add a directory to the project.  Returns new handle.
//
// string DirectoryName Name of the directory
// int ParentDirectory Handle of parent dir or 0 for none


bool DelDirectory(int DirectoryHandle)
// Delete a directory by handle


DirectorySpec GetDirectory(int Handle)
// Get a directory's details by handle.


ArrayList GetDirectories()
// Returns an arraylist of DirectorySpecs of all directories in project.


int AddFile(string FriendlyName, string RelativePath, int ParentDirectory)
// Add a file to the project.  Returned INT is handle.
//
// FriendlyName Name of the file
// RelativePath Path of file relative to Project Root
// ParentDirectory Handle of parent dir or 0 for none


bool DelFile(int FileHandle)
// Delete a file by handle


FileSpec GetFile(int FileHandle)
// Get file's details by handle


ArrayList GetFiles()
// Returns an arraylist of FileSpecs of all files in project


void OpenFile(int handle, int jumpToLine)
// Open a file by handle and jump to specified line (0 based)


void SaveFile(int handle)
// Save a file by handle (needs to be open)


bool IsFileOpen(int handle)
// Returns TRUE if the file is open


void NewProject(string name, string path)
// Create a new project with NAME and PATH.


ArrayList ImportFiles(string directory, string filter)
// Import files from DIRECTORY that match mask FILTER
// ** NOT IMPLEMENTED **


void OpenProject(string path)
// Open project from PATH


bool IsProjectOpen()
// Returns TRUE if a project is open


void CloseProject(SaveMode ProjectSaveMode)
// Close a project with specified save mode (prompt, discard, autosave)


void DebugAddBreakpoint(int handle, int line_num, int pass_count, bool clear_after_hit, string conditional)
// Not implemented yet


void DebugDelBreakpoint(int handle, int line_num)
// Not implemented


int GetActiveFile()
// Get the handle of the active file in the editor; 0 for none


EditorPosition GetCurrentPosition()
// Gets the position of the cursor in the active editor


EditorSelection GetCurrentSelection()
// Gets the selection in the active editor


void SetCursorPosition(int OpenFileHandle, EditorPosition CursorPosition)
// Set the cursor in file to position


void AddIndicator(string IndicatorName, int FileHandle, int LineNumber, Image MarginIcon, Color LineForeColor, Color LineBackColor, bool Bold, bool Italic, bool Underline)
// Create an indicator (which is like a breakpoint or bookmark) on FILEHANDLE
// named INDICATORNAME on line LINENUMBER with said properties


void DelIndicator(string IndicatorName, int FileHandle, int LineNumber)
// Delete indicator from file/line


void AddMainMenuHandler(MainMenuHandler menu)
// Add a dropdown menu in the main menu


void AddConfigTab(string TabText, Control tab)
// Deprecated by onBeforeConfigShow


void SaveProject()
// Save project


void SetFile(int handle, FileSpec spec)
// Set file HANDLE's details to SPEC


void SetDirectory(int handle, DirectorySpec spec)
// Set directory HANDLE's details to SPEC


void RegisterDockedControl(string TabName, Icon TabIcon, Control TabContents)
// Add a tab to the developer bar (usually on the left).  Set caption
// to TABNAME, icon to TabIcon (null for none), and set its contents
// control to TABCONTENTS.


ProjectSpec GetCurrentProject()
// Returns current project's specs


string GetDocumentText(int OpenFileHandle)
// Grab the editor's contents


void SetDocumentText(int OpenFileHandle, string DocumentText)
// Set editor for OPENFILEHANDLE's contents to DocumentText


void RefreshProjectList()
// Force-refresh the left project list


bool IsFileHandleValid(int handle)
// Checks if the file handle is valid


bool IsDirHandleValid(int handle)
// Checks if the directory handle is valid


int RegisterEditorTrigger(IPlugin _this, Keys TriggerKey, Keys TriggerModifiers, string TriggerName, TriggerStateWhen context)
// Register a trigger when the editor that will execute when the specific keys are
// pressed.
//
// _this -- Pass back "this"... as in, a reference to your plugin.
// TriggerKey -- The key to register
// TriggerModifiers -- Modifier keys to register (shift, alt, ctrl)
// context -- The context which the cursor must be in to allow the trigger to execute
//
// RETURNS handle to trigger


bool DeRegisterEditorTrigger(int EntryHandle)
// Deregister a registered trigger provided its handle; TRUE if success..


void DisplayIntellicode(IntellicodeEntryCollection entries)
// Display an intellicode (aka intellisense) dropdown on the active editor.  Doesn't
// do anything if there is no editor active (seamless error handling)


void DisplayInfopop(InfopopCollection entries)
// Display an infopop tooltop on the active editor.  Doesn't do anything
// if there is no editor active.


int CreateNewWorkspaceTab(IPlugin _this, string TabTitle, Icon TabIcon, Control TabContents)
// Create a new workspace tab
//
// _this -- A reference to "this"... as in, your plugin.
// TabTitle -- The title of the tab to set
// TabIcon -- The icon to use for the tab; null for none.
// TabContents -- The control to use on the tab
//
// RETURNS handle to tab


int ModifyWorkspaceTab(int TabHandle, string NewTabTitle, Icon NewTabIcon)
// Modify an existing tab
//
// TabHandle -- The handle of an existing tab
// NewTabTitle -- The new title to set for the tab (null for don't change)
// NewTabIcon -- The new icon for the tab (null for don't change)


bool DeleteWorkspaceTab(int TabHandle)
// Delete a workspace tab based on tab handle; TRUE if success.


void DeleteMenuItemHandler(string MenuItemKey)
// Delete a menu item (or main menu item) based on key


void ModifyMenuItemHandler(string KeyToModify, MainMenuItem ModifyTo)
// Set KEYTOMODIFY's menu to MODIFYTO's properties


bool IsShortcutUsed(Shortcut shortcut)
// Returns TRUE if the shortcut specified is already in use on the menus




These icons are available to choose for an intellicode item:
Code:
-1 - (None)
 0 - PrivateConstant
 1 - InternalConstant
 2 - ProtectedConstant
 3 - PublicConstant
 4 - PrivateEvent
 5 - InternalEvent
 6 - ProtectedEvent
 7 - PublicEvent
 8 - PrivateField
 9 - InternalField
10 - ProtectedField
11 - PublicField
12 - PrivateMethod
13 - InternalMethod
14 - ProtectedMethod
15 - PublicMethod
16 - PrivateProperty
17 - InternalProperty
18 - ProtectedProperty
19 - PublicProperty
20 - Operator
21 - Assembly
22 - Namespace
23 - PrivateClass
24 - InternalClass
25 - ProtectedClass
26 - PublicClass
27 - PrivateStructure
28 - InternalStructure
29 - ProtectedStructure
30 - PublicStructure
31 - PrivateInterface
32 - InternalInterface
33 - ProtectedInterface
34 - PublicInterface
35 - PrivateEnumeration
36 - InternalEnumeration
37 - ProtectedEnumeration
38 - PublicEnumeration
39 - PrivateDelegate
40 - InternalDelegate
41 - ProtectedDelegate
42 - PublicDelegate
43 - XmlTag
44 - XmlAttribute
45 - XmlComment
46 - XmlProcessingInstruction
47 - XmlCDataSection
48 - Warning
49 - EnumerationItem
50 - Keyword
51 - CodeSnippet
« Last Edit: August 25, 2005, 11:16:00 am by Sam Bacsa » Logged
Sam Bacsa
Administrator

Posts: 268



Re: TorqueDev SDK
« Reply #1 on: August 15, 2005, 03:33:31 am »

This API will be heavily expanded, but the currently implemented ones will not be modified, so feel free to develop on them in the meanwhile.
Logged
brainchildcm
Member

Posts: 6



Re: TorqueDev SDK
« Reply #2 on: August 19, 2005, 12:14:14 pm »

Sam,

I'm really enjoying your editor.  Nice work!  One question though.  I'm developing a plugin to delete all of my DSO files.  This works great, however I'd like some way to add my new menu item to an existing main menu like "file" or "edit". Any suggestions.  I've never used C# before.  I must say that I'm pleasently surprised.

Thanks
Logged
Sam Bacsa
Administrator

Posts: 268



Re: TorqueDev SDK
« Reply #3 on: August 19, 2005, 01:05:59 pm »

Greetings.  This is a coming option in the next release which should happen either today or tomorrow.

The release would be an optional update, mainly to plugin developers, which includes many enhancements, including the ability to add workspace tabs and hook onto the intellisense (aka intellicode, since intellisense is trademarked by Microsoft heh) and infopop.
Logged
brainchildcm
Member

Posts: 6



Re: TorqueDev SDK
« Reply #4 on: August 19, 2005, 01:27:17 pm »

Frigg'n SWEET!!! Grin
Logged
brainchildcm
Member

Posts: 6



Re: TorqueDev SDK
« Reply #5 on: August 23, 2005, 10:31:04 am »

Sam,

I'm having tons of fun writing plug-ins for this thing.  However I was wondering if it would be possible to add an event handler to catch the user switching documents.  Possibly something like this...

public void onBeforeDocumentSwitch( int TabHandle, FileSpec file, out bool cancel)
{
        cancel = false;
}

public void onAfterDocumentSwitch( int TabHandle, FileSpec file)
{   
       
}

My apologies if I missed an existing way of doing this!
« Last Edit: August 23, 2005, 07:30:15 pm by brainchildcm » Logged
Sam Bacsa
Administrator

Posts: 268



Re: TorqueDev SDK
« Reply #6 on: August 24, 2005, 06:46:45 am »

^ Hi brain,

Yeah, it appears I don't have one of those events.  I'd be glad to stick one in.

Thanks Smiley
Logged
Pages: [1] Print 
Codeweaver Forums  |  Codeweaver / TorqueDev  |  Codeweaver Announcements  |  Topic: TorqueDev SDK « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media Valid XHTML 1.0! Valid CSS!
Page created in 1.007 seconds with 18 queries.