@@ -36,7 +36,7 @@ use stdext::spawn;
3636use stdext:: unwrap;
3737use uuid:: Uuid ;
3838
39- use crate :: interface :: RMain ;
39+ use crate :: console :: Console ;
4040use crate :: modules:: ARK_ENVS ;
4141use crate :: r_task;
4242
@@ -307,15 +307,15 @@ pub unsafe extern "C-unwind" fn ps_connection_opened(
307307 let id = Uuid :: new_v4 ( ) . to_string ( ) ;
308308 let id_r: RObject = id. clone ( ) . into ( ) ;
309309
310- if !RMain :: is_initialized ( ) {
311- // If RMain is not initialized, we are probably in unit tests, so we
310+ if !Console :: is_initialized ( ) {
311+ // If Console is not initialized, we are probably in unit tests, so we
312312 // just don't start the connection and let the testing code manually do
313- // it. Note that RMain could be initialized in integration tests.
314- log:: warn!( "Connection Pane: RMain is not initialized. Connection will not be started." ) ;
313+ // it. Note that Console could be initialized in integration tests.
314+ log:: warn!( "Connection Pane: Console is not initialized. Connection will not be started." ) ;
315315 return Ok ( id_r. sexp ) ;
316316 }
317317
318- let main = RMain :: get ( ) ;
318+ let console = Console :: get ( ) ;
319319
320320 let metadata = Metadata {
321321 name : RObject :: view ( name) . to :: < String > ( ) ?,
@@ -325,7 +325,7 @@ pub unsafe extern "C-unwind" fn ps_connection_opened(
325325 code : RObject :: view ( code) . to :: < Option < String > > ( ) . unwrap_or ( None ) ,
326326 } ;
327327
328- if let Err ( err) = RConnection :: start ( metadata, main . get_comm_manager_tx ( ) . clone ( ) , id) {
328+ if let Err ( err) = RConnection :: start ( metadata, console . get_comm_manager_tx ( ) . clone ( ) , id) {
329329 log:: error!( "Connection Pane: Failed to start connection: {err:?}" ) ;
330330 return Err ( err) ;
331331 }
@@ -335,45 +335,45 @@ pub unsafe extern "C-unwind" fn ps_connection_opened(
335335
336336#[ harp:: register]
337337pub unsafe extern "C-unwind" fn ps_connection_closed ( id : SEXP ) -> Result < SEXP , anyhow:: Error > {
338- let main = RMain :: get ( ) ;
339- let id_ = RObject :: view ( id) . to :: < String > ( ) ?;
338+ let id = RObject :: view ( id) . to :: < String > ( ) ?;
340339
341- main. get_comm_manager_tx ( )
342- . send ( CommManagerEvent :: Message ( id_, CommMsg :: Close ) ) ?;
340+ Console :: get ( )
341+ . get_comm_manager_tx ( )
342+ . send ( CommManagerEvent :: Message ( id, CommMsg :: Close ) ) ?;
343343
344344 Ok ( R_NilValue )
345345}
346346
347347#[ harp:: register]
348348pub unsafe extern "C-unwind" fn ps_connection_updated ( id : SEXP ) -> Result < SEXP , anyhow:: Error > {
349- let main = RMain :: get ( ) ;
350349 let comm_id: String = RObject :: view ( id) . to :: < String > ( ) ?;
351-
352350 let event = ConnectionsFrontendEvent :: Update ;
353351
354- main. get_comm_manager_tx ( ) . send ( CommManagerEvent :: Message (
355- comm_id,
356- CommMsg :: Data ( serde_json:: to_value ( event) ?) ,
357- ) ) ?;
352+ Console :: get ( )
353+ . get_comm_manager_tx ( )
354+ . send ( CommManagerEvent :: Message (
355+ comm_id,
356+ CommMsg :: Data ( serde_json:: to_value ( event) ?) ,
357+ ) ) ?;
358358
359359 Ok ( R_NilValue )
360360}
361361
362362#[ harp:: register]
363363pub unsafe extern "C-unwind" fn ps_connection_focus ( id : SEXP ) -> Result < SEXP , anyhow:: Error > {
364- if !RMain :: is_initialized ( ) {
364+ if !Console :: is_initialized ( ) {
365365 return Ok ( R_NilValue ) ;
366366 }
367367
368- let main = RMain :: get ( ) ;
369368 let comm_id: String = RObject :: view ( id) . to :: < String > ( ) ?;
370-
371369 let event = ConnectionsFrontendEvent :: Focus ;
372370
373- main. get_comm_manager_tx ( ) . send ( CommManagerEvent :: Message (
374- comm_id,
375- CommMsg :: Data ( serde_json:: to_value ( event) ?) ,
376- ) ) ?;
371+ Console :: get ( )
372+ . get_comm_manager_tx ( )
373+ . send ( CommManagerEvent :: Message (
374+ comm_id,
375+ CommMsg :: Data ( serde_json:: to_value ( event) ?) ,
376+ ) ) ?;
377377
378378 Ok ( R_NilValue )
379379}
0 commit comments