MCPcopy Create free account
hub / github.com/SpartanJ/eepp / onRegister

Method onRegister

src/tools/ecode/plugins/plugin.cpp:251–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void PluginBase::onRegister( UICodeEditor* editor ) {
252 Lock l( mMutex );
253
254 std::vector<Uint32> listeners;
255
256 listeners.push_back( editor->on( Event::OnDocumentLoaded, [this, editor]( const Event* event ) {
257 Lock l( mMutex );
258 const DocEvent* docEvent = static_cast<const DocEvent*>( event );
259 mDocs.insert( docEvent->getDoc() );
260 mEditorDocs[editor] = docEvent->getDoc();
261 onDocumentLoaded( docEvent->getDoc() );
262 } ) );
263
264 listeners.push_back( editor->on( Event::OnDocumentClosed, [this]( const Event* event ) {
265 {
266 Lock l( mMutex );
267 const DocEvent* docEvent = static_cast<const DocEvent*>( event );
268 TextDocument* doc = docEvent->getDoc();
269 onDocumentClosed( doc );
270 onUnregisterDocument( doc );
271 mDocs.erase( doc );
272 }
273 } ) );
274
275 listeners.push_back( editor->on( Event::OnDocumentChanged, [this, editor]( const Event* ) {
276 TextDocument* oldDoc = mEditorDocs[editor];
277 TextDocument* newDoc = editor->getDocumentRef().get();
278 Lock l( mMutex );
279 mDocs.erase( oldDoc );
280 mDocs.insert( newDoc );
281 mEditorDocs[editor] = newDoc;
282 onDocumentChanged( editor, oldDoc );
283 } ) );
284
285 onRegisterListeners( editor, listeners );
286
287 mEditors.insert( { editor, listeners } );
288 if ( mDocs.count( editor->getDocumentRef().get() ) == 0 ) {
289 mDocs.insert( editor->getDocumentRef().get() );
290 onRegisterDocument( editor->getDocumentRef().get() );
291 }
292 mEditorDocs[editor] = editor->getDocumentRef().get();
293
294 onRegisterEditor( editor );
295}
296
297void PluginBase::onUnregister( UICodeEditor* editor ) {
298 onBeforeUnregister( editor );

Callers

nothing calls this directly

Calls 8

push_backMethod · 0.80
getDocMethod · 0.80
getDocumentRefMethod · 0.80
onMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
getMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected