<div dir="ltr">Thanks Simon,<div><br></div><div>Source code is include this time...</div><div><br></div><div>For now RInside::repl() works fine under Windows provided there is no</div><div>mouse feedback, and starting the main app using WIN32 GUI</div><div>framework is not trivial.</div><div><br></div><div>A simple work-around is to implement RInside::repl() as </div><div>system("Rterm"), which is what happens when R is</div><div>run, but this would make the repl an independent</div><div>application, not ideal.</div><div><br></div><div>It looks like rtest.c in the front-ends directory is most</div><div>applicable (as it uses embeddedR like RInside), but the loop </div><div>code there has problems under Windows that led</div><div>to the use of run_Rmainloop() instead. Also, this</div><div>code does not use WinMain.</div><div><br></div><div>I tried embedding the Rterm code (rterm.c,</div><div>graphappmain.c, etc.) into the RInside C++ code, but</div><div>there were quite a few technical challenges. A simpler </div><div>approach where selected parts are used is attached</div><div>as repl.cpp.</div><div><br></div><div>Here graphappmain.c from src/gnuwin32/front-ends</div><div>is embedded (as extern "C") in the original C++ file</div><div>repl.cpp, and the WinMain entry point is used (WIN32</div><div>API). When NO_WIN32_GRAPHICS_INIT is defined the main</div><div>is like it was before (no WIN32 init), and when it is not</div><div>defined, WinMain calls GA_startgraphapp(), then calls</div><div>AppMain, which calls main. This requires linking to</div><div>Rgraphapp.dll.</div><div><br></div><div>The repl() function itself is in RInside.cpp, and is</div><div>shown below. Several permutations of the init</div><div>and looping functions were tried, but with negative</div><div>results. Usually the app just terminates. </div><div><br></div><div>This is not too surprising given what has been omitted</div><div>from the original Rterm build (like rtico.rc resouce file). </div><div><br></div><div>repl() from RInside.cpp...</div><div><br></div><div>extern "C" {<br> extern int GA_initapp(int, char **);<br> void setup_Rmainloop(void);<br> void run_Rmainloop(void);<br> extern void Rf_mainloop(void);<br>}<br> <br>void RInside::repl() {<br> GA_initapp(0, NULL);<br> readconsolecfg();<br> //setup_Rmainloop();<br> //run_Rmainloop();<br> Rf_mainloop();<br><br> // Causes problems under Windows.<br> // For example, terminates after plot(0,0)<br> // R_ReplDLLinit();<br> // while (R_ReplDLLdo1() > 0) {}<br>}<br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 4, 2023 at 5:58 PM Simon Urbanek <<a href="mailto:simon.urbanek@r-project.org" target="_blank">simon.urbanek@r-project.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Dominick,<br>
<br>
again, it's hard to give you advice when you don't post the code, but note that for graphical Windows applications you may need to implement WinMain and make sure you setup the Windows event loop (which is separate from R's event loop) before you use RInside (see Win32 documentation). You may want to to have a look at src/gnuwin32/front-ends in R.<br>
<br>
Cheers,<br>
Simon<br>
<br>
<br>
> On Feb 4, 2023, at 2:02 PM, Dominick Samperi <<a href="mailto:djsamperi@gmail.com" target="_blank">djsamperi@gmail.com</a>> wrote:<br>
> <br>
> I'm sorry to say that the RInline::repl() issues are not resolved, and to<br>
> resolve them would likely require help from R core.<br>
> <br>
> Here's the test case:<br>
> library(sphereplot)<br>
> rgl.sphgrid(longtype="D")<br>
> <br>
> Under Linux there is no problem, a sphere is drawn, and you can<br>
> rotate with mouse motions.<br>
> <br>
> Under Windows using R, no problem.<br>
> <br>
> But under Windows in RInline::repl() when you click on the image it<br>
> freezes up.<br>
> <br>
> Apparently some kind of graphics<br>
> initialization is required, and perhaps callbacks as well to<br>
> handle mouse events. Just calling run_Rmainloop() is not<br>
> enough.<br>
> _______________________________________________<br>
> Rcpp-devel mailing list<br>
> <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
> <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<br>
</blockquote></div>