Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 491792

Summary: codeEdit: Need a way to notify user when a command is invoked.
Product: [ECD] Orion Reporter: libing wang <libingw>
Component: EditorAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 12.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description libing wang CLA 2016-04-15 09:39:56 EDT
There are users requesting the need of this:
Is their an event listener or status service that can notify me when a command is invoked? For example, if i wanted to be notified when a user triggers toggleTabMode.
Comment 1 libing wang CLA 2016-04-27 11:38:57 EDT
The tab mode event is dispatched per the commit:
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=846e07512e1bc0d0ca91dab2d4b11d363ab5cd59
Comment 2 libing wang CLA 2016-04-27 11:40:47 EDT
I've also added the listener in the demo page on how to listen to the tab mode, wrap mode and overwrite mode change event.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=fa0497dd266a0f54c7f782bc71002527eb6f2323
Comment 3 libing wang CLA 2016-04-27 11:43:47 EDT
embeddedEditor.create(params}).then(function(editorViewer) {
editorViewer.editor.getTextView().addEventListener("Options",function(evt){
	if(evt.options) {
		if(evt.options.tabMode !== undefined) {
			//CTRL+m keys
			//True: you can tab inside the editor. False: Tab will get out of the editor DIV
			console.log("Tab mode has been changed to: " + evt.options.tabMode);
		} else if(evt.options.wrapMode !== undefined) {
			//CTRL+ALT+w keys
			console.log("Wrap mode has been changed to: " + evt.options.wrapMode);
		} else if(evt.options.overwriteMode !== undefined) {
			//Insert key
			console.log("Overwrite mode has been changed to: " + evt.options.overwriteMode);
		} else {
			console.log("Other options has been changed: ");
			console.log(evt.options);
		}
	}
});
}