bsilverstrim
2022-3-14 14:32:25

I think this is a close representation of what I was trying to describe with running a separate executable within a window/widget…any way to do this?


chansey97
2022-3-14 16:18:42

Can I type #!eof in a Racket? For example, in Scheme I can mytest.scm My program #!eof My progaam, but I want to skip ...


chansey97
2022-3-14 16:19:41

What is #!eof equivalent in .rkt ?


samth
2022-3-14 16:21:41

There’s no racket equivalent of that.


chansey97
2022-3-14 16:22:23

Thanks.


soegaard2
2022-3-14 16:51:06

Hi @bsilverstrim

I can see see some security problems with embedding an external program into a new GUI. Consider the case where an user thinks he as opened a bank application, but in reality has opened an app that catches all keystrokes and sends them to an existing embedded bank app.

For that reason I was about to say, that your mission is impossible. But from the question you posted above, you get to the question [1] below. So it seems the QT framework has a solution to the problem.

But … I am pretty sure there is no standard macOS and Windows GUI elements that allow embedded another application.

That said - I can think of some terrible hacks. Consider this scenario:

  1. Make an extra screen (a virtual one - just a big canvas).
  2. Hide it from the user.
  3. Open the external application on the virtual screen.
  4. From you app copy screen shots from the virtual screen to a canvas in your app.

[1] https://stackoverflow.com/questions/33699258/qt-5-5-embed-external-application-into-qwidget


sorawee
2022-3-14 16:56:09

Note that you can just comment it out, using block comment, right?


sorawee
2022-3-14 16:56:29

So:

My program #!eof My progaam, but I want to skip ... =>

My program #\| My progaam, but I want to skip ... \|#


chansey97
2022-3-14 17:21:15

racket-mode doesn’t seem to handle well the programs inside #\| ... \|#. #\| (define (foo x) 1) \|# After indent #\| (define (foo x) 1) \|# But that is another quesion.


sorawee
2022-3-14 17:22:47

If you want to comment programs, perhaps use S-exp comment


sorawee
2022-3-14 17:23:09

My program #; (define (foo x) 1)


bsilverstrim
2022-3-14 17:29:46

In summary, something like this isn’t a standard or near standard ability in most OSs, even if it is somewhat possible under one.


bsilverstrim
2022-3-14 17:30:33

And Racket does not have a way to readily display an interactive session with an application, unless it’s terminal based (probably) since that’s just redirection of stdin/stdout/stderr


soegaard2
2022-3-14 17:33:30

A terminal plugin as a snip would be cool.

Maybe there is a terminal project that has special support for the “embed terminal in another application”? It’s worth looking for.


chansey97
2022-3-14 17:35:06

Yes, but it can only comment one sexp. I have just created an <https://github.com/greghendershott/racket-mode/issues/603|racket-mode issue>. It is not urgent.


sorawee
2022-3-14 17:35:57

I don’t think that’s a bug though. #\| ... \|# is not meant to exclusively comment code. It can comment anything, and I certainly don’t want to indent my prose with Racket indentation.


sorawee
2022-3-14 17:36:40

Yes, it can only comment one sexp, but note that you can chain them

#;#; (define (foo x) 1) (define (foo x) 1)


soegaard2
2022-3-14 17:41:07

Something like this: https://github.com/AndreRenaud/EmbeddedCLI

I have no ideas whether this particular project is suitable or not.


chansey97
2022-3-14 17:42:49

Nice. But it is not convenient, because I have a lot of code need to be commented.


chansey97
2022-3-14 17:43:10

What is the meaning of #\| ... \|# ? Is it part of racket? You said it is not meant to comment code…I am confused.


samth
2022-3-14 17:44:16

Yes, that comment syntax is built-in to racket


sorawee
2022-3-14 17:44:29

#\| ... \|# is a part of Racket. It’s just like /* ... */ in C. So you know, it can be used to comment anything, including regular text comment, license, etc.


sorawee
2022-3-14 17:44:58

And I definitely don’t want license and text comment to be indented as if they are code.


chansey97
2022-3-14 17:47:57

> And I definitely don’t want license and text comment to be indented as if they are code. I agree. But the current racket-mode will indent the text inside #\| ... \|# and the indent is incorrect. I hope the indent system of racket-mode doesn’t touch them at all.


sschwarzer
2022-3-14 22:12:35

> And I definitely don’t want license and text comment to be indented as if they are code. To that I agree, but I also think that the content between the #\| ... \|# should be left alone and “not (not-)indented” as if it wasn’t code.


sschwarzer
2022-3-14 22:13:09

Oh, that’s what Siyuan just said. :slightly_smiling_face:


sschwarzer
2022-3-14 22:13:50

By the way, different from /* ... */ in C, #\| ... \|# can be nested, if I remember correctly.


capfredf
2022-3-15 02:01:59

I believe you can roll your own by using a table that maps function names to hooks and providing your own #%app . But places that need advising or to run advising functions would need to import your module