[racket-users] Re: How to discover a struct's interface without Dr Racket?

2021-10-28 Thread jackh...@gmail.com
Are you intending to use the struct procedure names at compile time (such 
as in a macro) or runtime?

On Tuesday, October 26, 2021 at 5:02:46 PM UTC-7 bc.be...@gmail.com wrote:

> I understand why structs are opaque, by default, but I want to discover 
> the public interface of some struct type, that is, a list of the procedures 
> defined by the struct.
>
> Here is an example. Suppose I want to find out all the procedures defined 
> on an instance of the syntax struct
>
> #'42
>
> Dr. Racket shows an expander clicky that shows some formatted information 
> inside the instance :
>
> [image: Screenshot from 2021-10-26 16-51-37.png]
>
> Uncapitializing the names in the display reveals the interface:
>
> (syntax-position #'42) ~~> 790
> (syntax-span #'42) ~~> 2
> (syntax-original? #'42) ~~> #t
>
> etc.
>
> I want to discover those procedure names in my racket program, not 
> manually by visually inspecting graphics in Dr Racket. 
>
> I found this trick for structs that I define:
>
> #lang racket
> (require (for-syntax racket/struct-info))
> (require racket/pretty)
>
> (struct foo (a b))
> (begin-for-syntax
>   (displayln 
>(extract-struct-info
> (syntax-local-value
>  #'foo
>
> ~~>
>
> [image: Screenshot from 2021-10-26 16-59-19.png]
>
> but it doesn't work for the syntax type
>
> (begin-for-syntax
>   (displayln 
>(extract-struct-info
> (syntax-local-value
>  #'syntax
>
> ~~>
>
> [image: Screenshot from 2021-10-26 17-00-33.png]
>
> I'd be grateful for advice and an example of how to get the interface of 
> "syntax" without Dr Racket and without grovelling docs.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a7d7828e-7114-488c-877e-308ef3c9d068n%40googlegroups.com.


Re: [racket-users] Adding keybindings to debug

2021-10-28 Thread David Storrs
I don't know if this fills the need but it's a useful thing to know
regardless:  macOS will allow you to add a keyboard shortcut for any menu
item in any application.
https://support.apple.com/guide/mac-help/create-keyboard-shortcuts-for-apps-mchlp2271/mac

On Thu, Oct 28, 2021 at 1:10 PM James Zollinger  wrote:

> I'm a happy user of DrRacket, plowing through the MIT SICP (Structure and
> Interpretation of Computer Programs.) As I'm learning Scheme, I'm spending
> more time than I'd like to admit in the debugger. I'm more used to
> emacs/bash but really liking the DrRacket IDE (using graphical libs to
> display output, for example) and would really like to stick with it, but
> I'm struggling with the keybindings...
>
> I have seen the documentation:
> https://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html
> but I don't see a way to add keyboard shortcuts in the debugger. I'd like
> to add shortcuts for GUI buttons "Go", "Step", "Over", etc. as well as
> context menus "Print return value to console", "Pause at this point", etc.
>
> Any help would be greatly appreciated.
> James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/c429d210-7392-4ad3-90db-b1e9edba08b2n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAE8gKoeadmpRi2te0ez-Ey4B1deUYiXrUNJVjedrTWdNVdq8Sw%40mail.gmail.com.


Re: [racket-users] Adding keybindings to debug

2021-10-28 Thread Laurent
There may be a better way to do it, but here's at least a working solution:
https://gist.github.com/Metaxal/5c91eddafb86bb0c06b4d8322ad53045

It's a quickscript (https://docs.racket-lang.org/quickscript/index.html) so
it gives you a new submenu in the Scripts menu, with associated keybindings:
Shift-F1: Start Debug
Shift-F2: Step
Shift-F3: Over
Shift-F4: Out
Shift-F5: Go

It shouldn't be too hard to turn this is just keybindings into your
keybinding file if you only want keybindings and not additional Script menu
entries.

Sorry, I haven't tried too hard for "Print value..." and "Pause at this
point" because these are context menus and the corresponding actions are
not accessible programmatically as far as I can tell.

The script probably still needs some tweaking. Let me know if you improve
it, or if you have issues with it.

HTH,
Laurent

On Thu, Oct 28, 2021 at 6:10 PM James Zollinger  wrote:

> I'm a happy user of DrRacket, plowing through the MIT SICP (Structure and
> Interpretation of Computer Programs.) As I'm learning Scheme, I'm spending
> more time than I'd like to admit in the debugger. I'm more used to
> emacs/bash but really liking the DrRacket IDE (using graphical libs to
> display output, for example) and would really like to stick with it, but
> I'm struggling with the keybindings...
>
> I have seen the documentation:
> https://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html
> but I don't see a way to add keyboard shortcuts in the debugger. I'd like
> to add shortcuts for GUI buttons "Go", "Step", "Over", etc. as well as
> context menus "Print return value to console", "Pause at this point", etc.
>
> Any help would be greatly appreciated.
> James
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/c429d210-7392-4ad3-90db-b1e9edba08b2n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABNTSaFYyktHhbf2wscb40r2ejzHwrw%3DBzwKQOj6tuu_Emue1Q%40mail.gmail.com.


Re: [racket-users] Re: Typing lag with DrRacket on Linux

2021-10-28 Thread evdubs
Resurrecting this old thread.

This issue should now be resolved with this commit: 
https://github.com/racket/gui/commit/20e589c091998b0121505e25c7ff2f95e8116dcb

No need to use PLT_DISPLAY_BACKING_SCALE with this fix.

Evan

On Thursday, May 28, 2020 at 4:18:44 AM UTC-10 evdubs wrote:

> I suppose that may be helpful, but this performance issue extends to any 
> other Racket GUI application on Linux, including the simple editor example 
> from earlier in this thread. Maybe printing something to a console could 
> help, but it would be better if there was some fix to improve fractional 
> scaling performance :)
>
> Evan
>
> On Thursday, May 28, 2020 at 2:37:49 AM UTC-10, Jens Axel Søgaard wrote:
>
>> Slack users confirm the problem when the backing scale is 1.5.
>>
>> Should DrRacket give a warning dialog on Linux, when started with a 
>> non-integer backing scale?
>>
>> /Jens Axel
>>
>>
>> Den ons. 13. maj 2020 kl. 05.48 skrev evdubs :
>>
> I did some more digging and found locations in racket/draw that control 
>>> antialiasing. I tried changing them around, and saw no impact on 
>>> performance.
>>>
>>> However, I eventually stumbled upon the environment variable 
>>> PLT_DISPLAY_BACKING_SCALE. By using an integer value for this variable, 
>>> performance is nice and smooth (I tried 1 and 2; trying 1.25 and 1.5 hurt 
>>> performance). In Ubuntu, I do not have my display set to a fractional 
>>> scaling value, but I do have "Large Text" enabled. I am unsure if this 
>>> setting interferes with whatever PLT_DISPLAY_BACKING_SCALE defaults to.
>>>
>>> If you're having typing lag issues on Linux within Dr Racket or other 
>>> Racket GUI applications, you may want to try PLT_DISPLAY_BACKING_SCALE=1 to 
>>> see if that affects performance.
>>>
>>> Evan
>>>
>>> On Monday, May 11, 2020 at 2:05:06 PM UTC-10, evdubs wrote:

 I think what I have seen previously with setting the canvas style to 
 'transparent ultimately is turning off antialiasing in Cairo.

 Using the sample text editor from this thread, I ran the following:

 $ cairo-trace racket text-editor.rkt
 $ cairo-trace racket text-editor-transparent.rkt

 In the non-transparent version, we see these two lines:

 16 0 0 16 0 0 matrix 2 0 0 2 0 0 matrix << /antialias 
 //ANTIALIAS_SUBPIXEL /subpixel-order //SUBPIXEL_ORDER_RGB /hint-style 
 //HINT_STYLE_SLIGHT /hint-metrics //HINT_METRICS_ON >> scaled-font /sf0 
 exch def
 f0 32 0 0 32 0 0 matrix 2 0 0 2 0 0 matrix << /antialias 
 //ANTIALIAS_SUBPIXEL /subpixel-order //SUBPIXEL_ORDER_RGB /hint-style 
 //HINT_STYLE_SLIGHT /hint-metrics //HINT_METRICS_ON >> scaled-font /sf1 
 exch def

 These lines look like this in the transparent version:

 16 0 0 16 0 0 matrix 2 0 0 2 0 0 matrix << /hint-metrics 
 //HINT_METRICS_ON >> scaled-font /sf0 exch def
 f0 32 0 0 32 0 0 matrix 2 0 0 2 0 0 matrix << /hint-metrics 
 //HINT_METRICS_ON >> scaled-font /sf1 exch def

 I am not really sure how this initialization is happening. Can someone 
 help me poke through the code to see how I might disable antialiasing? 
 Should I try to make changes to gui-lib/mred/private/wx/gtk/gcwin.rkt?

 Evan

 On Friday, March 29, 2019 at 12:29:11 AM UTC-10, Bryan Lee wrote:
>
> I’m facing the same issues, and I came across an interesting 
> observation. 
>
> It seems that DrRacket mimics scrolling behaviour by literally 
> replacing each line of code with the line above or below, and uses a 
> really 
> inefficient method of tracking which lines should go where, thereby 
> limiting how fast you can “scroll”. 
>
> I realised that resizing the window horizontally does nothing to 
> improve performance, but shrinking the window height significantly 
> improved 
> performance, even if the canvas area is adjusted to remain the same. 
>
> In addition to some function definitions in unit.rkt describing the 
> transposing of lines, that leads me to my conclusion. 
>
> Thoughts? 
>
>
>
> On Friday, 2 November 2018 10:46:29 UTC+8, evdubs  wrote: 
> > Resurrecting an old thread. 
> > 
> > 
> > I recently tried to see what would happen if I changed the 
> interactions-canvas% and definitions-canvas% to be the following: 
> > 
> > 
> >   (define interactions-canvas% 
> > (class editor-canvas% 
> >   (init [style '(transparent)]) 
> >   (super-new (style (cons 'auto-hscroll style))) 
> >   (inherit set-scroll-via-copy) 
> >   (set-scroll-via-copy #t))) 
> > 
> > 
> > 
> >   (define definitions-canvas% 
> > (class editor-canvas% 
> >   (init [style '(transparent)]) 
> >   (super-new (style (cons 'auto-hscroll style))) 
> >   (inherit set-scroll-via-copy) 
> >   (set-scroll-via-copy #t))) 
> > 
> > 

[racket-users] Adding keybindings to debug

2021-10-28 Thread James Zollinger
I'm a happy user of DrRacket, plowing through the MIT SICP (Structure and 
Interpretation of Computer Programs.) As I'm learning Scheme, I'm spending 
more time than I'd like to admit in the debugger. I'm more used to 
emacs/bash but really liking the DrRacket IDE (using graphical libs to 
display output, for example) and would really like to stick with it, but 
I'm struggling with the keybindings...

I have seen the documentation:
https://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html
but I don't see a way to add keyboard shortcuts in the debugger. I'd like 
to add shortcuts for GUI buttons "Go", "Step", "Over", etc. as well as 
context menus "Print return value to console", "Pause at this point", etc.

Any help would be greatly appreciated.
James

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/c429d210-7392-4ad3-90db-b1e9edba08b2n%40googlegroups.com.