sorawee
2020-7-11 14:02:16

Is it possible for a plugin to add a bar like the search bar or check syntax bar?


laurent.orseau
2020-7-11 14:05:35

Untested: It might even be possible with quickscript, since it has access to the frame if you add the #:frame fr in the lambda args, and then use change-children on the frame Quickscript can at least add a menu (tested).


laurent.orseau
2020-7-11 14:06:11

In last recourse you can always make a floating frame that’s always on top


laurent.orseau
2020-7-11 14:13:49

No need for change-children for something simple: #lang racket/gui (require quickscript) (define-script add-frame-child #:label "add-frame-child" (λ (selection #:frame fr) (define cont (send fr get-area-container)) (new button% [parent cont] [label "Press me"] [callback (λ (bt ev) (message-box "Slight annoyance" "The internet has disappeared.") ;; Remove the button (send cont delete-child bt))]) #f))


laurent.orseau
2020-7-11 14:14:50

Note that if you make your script #:persistent you can define globals in your script file that will persist from one call of the script to the next


sorawee
2020-7-11 14:20:09

I have to say writing quickscript is an absolute joy. No need to reload DrRacket. It Just Works™.


laurent.orseau
2020-7-11 14:47:12

I updated the script above to remove the button after pressing it.


laurent.orseau
2020-7-11 14:49:23

Initially I tried the previous script several times so there were many buttons in DrRacket. I modified the script to remove all buttons but… instead I kept all buttons, removing the editors :sweat_smile: (I still didn’t have to fully restart DrRacket per se, I just opened a new window and closed the other)


sorawee
2020-7-11 14:58:55

remove-child also works


sorawee
2020-7-11 14:59:02

No need to use the full change-children


laurent.orseau
2020-7-11 15:02:21

delete-child you mean? Yeah, but once the script has finished, I didn’t have the handle anymore, so needed to filter


laurent.orseau
2020-7-11 15:02:39

(though it can be used in the script directly, i’ll change that)


sorawee
2020-7-11 15:27:40

Yet another question


sorawee
2020-7-11 15:27:44

I need something from drracket/tool-lib


sorawee
2020-7-11 15:28:04

But it looks like require-ing it will instantiate a new DrRacket instance


sorawee
2020-7-11 15:29:29

which results in an error like:

initialization for menu-bar%: given parent already has a menu bar given: 'root


sorawee
2020-7-11 15:30:34

How can I successfully require drracket/tool-lib?


laurent.orseau
2020-7-11 15:42:10

What do you need from tool-lib?



sorawee
2020-7-11 15:44:16

Context: there’s this line in org.racket-lang.prefs.rktd:

(plt:framework-pref:drracket:language-settings ((-32768) (#6(#t print mixed-fraction-e #f #t debug) (default) #3("foo" "bar" "baz") #f #t #f ((test) (main)) #t)))


sorawee
2020-7-11 15:45:09

I want to extract information from it. Of course, I could just read it and search it myself, but using preference:get looks like the intended way to do it.


sorawee
2020-7-11 15:45:52

laurent.orseau
2020-7-11 15:54:36

I’m not sure I guess the only way to do it properly is for quickscript to expose these structs, though I’m not sure.


laurent.orseau
2020-7-11 15:55:07

At least you can still get some info ‘manually’: > (require framework) > (preferences:set-default 'drracket:language-settings #f (λ (x) #t)) > (preferences:get 'drracket:language-settings) ((-32768) (#(#t trad-write mixed-fraction-e #f #t debug) (default) #() "#lang racket\n" #t #t ((test) (drracket)) #t))


laurent.orseau
2020-7-11 15:55:43

If you define the struct yourself, and map the result above to the struct, you can do ‘as if’


sorawee
2020-7-11 15:56:49

This will do it for now, thanks!


laurent.orseau
2020-7-11 16:06:27

If you use the code above for writing to the prefs, you’ll need a better checker inset-default