Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

How to add a key definition to the editor

jonathanstrange edited this page Sep 4, 2007 · 3 revisions

{BR} Its quite straight forward to add some functionality to the SharpDevelop editor. But there are a few steps. Each key must be assigned to a class that inherits from AbstractEditCommand. So for each key you must define a class. In the addin file you will assign that key to the class. {BR}{BR} The following is an example of adding navigate back and forward to the test editor. {BR}{BR} The addin project name I use is MyKeySettings. These instructions are based off of that name.{BR}{BR}

  1. First you will need to create a SharpDevelop AddIn project.{BR}{BR}
  2. Edit the addin file ( in this case MyKeySettings.addin).{BR}{BR}
  3. Remove:{BR} {{ <esc><Path name = "/SharpDevelop/Workbench/Pads"> <Pad id = "MyKeySettingsPad" category = "Main" title = "MyKeySettingsPad" icon = "PadIcons.Output" shortcut = "Control|Alt|T" class = "MyKeySettingsPad.TestPad"/> </Path></esc>}}{BR}{BR}
  1. Add the following to the addin file:{BR} `{{
`}}{BR}{BR} 5. Delete the TestPad.cs and MyUserControl.cs files from the project{BR}{BR} 6. Add a class file to your project (I called mine MyKeyClasses.cs). However it holds 2 classes, not just one. You can organize your files/classes anyway you want. {BR}{BR} 7. Add the following using statements:{BR} using System;{BR} using System.Collections.Generic;{BR} using System.Drawing;{BR} using ICSharpCode.Core;{BR} using ICSharpCode.SharpDevelop.Gui;{BR} using ICSharpCode.TextEditor.Actions;{BR} using ICSharpCode.TextEditor.Document;{BR} using ICSharpCode.TextEditor;{BR} using ICSharpCode.SharpDevelop;{BR}{BR} 8. Add the necessary references to the project{BR}{BR} 9. Here is the text of my navigate forward and backward classes. They make use of an existing service "NavigationService" to implement the back and forth navigation:{BR}{BR} `{{ public class MyNavigateForward : AbstractEditAction { public override void Execute(TextArea textArea) { StatusBarService.SetMessage("forward"); NavigationService.Go(1); }
}

public class MyNavigateBackwards : AbstractEditAction { public override void Execute(TextArea textArea) { StatusBarService.SetMessage("back"); NavigationService.Go(-1); }

`}}}{BR}{BR}
  1. You will also need to set the output of your project to the sharpdevelop addin directory in a subdirectory named like your project. (Project properties, Compile tab). {BR}{BR} Works for me, if you have problems ask on the forums or email me.
Clone this wiki locally