Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions drracket/drracket/private/language.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -405,21 +405,23 @@
(dyn pict-ascent)
(dyn pict-descent)
(dyn draw-pict)

(dyn convert-bounds-padding)

(define (mk-pict-snip convertible)
(define-values (l-pad t-pad r-pad b-pad) (apply values (convert-bounds-padding)))
(define pict (pict-convert convertible))
(define w (pict-width pict))
(define aw (abs w))
(define aw (+ (abs w) l-pad r-pad))
(define h (pict-height pict))
(define ah (abs h))
(define a (pict-ascent pict))
(define d (pict-descent pict))
(define ah (+ (abs h) t-pad b-pad))
(define a (+ (pict-ascent pict) t-pad))
(define d (+ (pict-descent pict) b-pad))
(define rdc (new record-dc%))
(send rdc set-smoothing 'aligned)
(send rdc set-clipping-rect 0 0 aw ah)
(draw-pict pict rdc
(if (< w 0) aw 0)
(if (< h 0) ah 0))
(+ (if (< w 0) aw 0) l-pad)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zero-comparison-to-negative?: This expression is equivalent to calling the negative? predicate.

Suggested change
(+ (if (< w 0) aw 0) l-pad)
(+ (if (negative? w) aw 0) l-pad)
Debugging details
Textual replacement
(line-replacement
  #:new-lines '#("                 (+ (if (negative? w) aw 0) l-pad)")
  #:original-lines '#("                 (+ (if (< w 0) aw 0) l-pad)")
  #:start-line 423)
Syntactic replacement
(syntax-replacement
  #:introduction-scope #<procedure:do-make-syntax-introducer>
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.15.0.11/pkgs/resyntax/default-recommendations/numeric-shortcuts.rkt:66:2 (negative? w)>
  #:original-syntax
    #<syntax:drracket/drracket/private/language.rkt:423:24 (< w 0)>
  #:source
    (file-source
     #<path:/home/runner/work/drracket/drracket/drracket/drracket/private/language.rkt>))

(+ (if (< h 0) ah 0) t-pad))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zero-comparison-to-negative?: This expression is equivalent to calling the negative? predicate.

Suggested change
(+ (if (< h 0) ah 0) t-pad))
(+ (if (negative? h) ah 0) t-pad))
Debugging details
Textual replacement
(line-replacement
  #:new-lines '#("                 (+ (if (negative? h) ah 0) t-pad))")
  #:original-lines '#("                 (+ (if (< h 0) ah 0) t-pad))")
  #:start-line 424)
Syntactic replacement
(syntax-replacement
  #:introduction-scope #<procedure:do-make-syntax-introducer>
  #:new-syntax
    #<syntax:/home/runner/.local/share/racket/8.15.0.11/pkgs/resyntax/default-recommendations/numeric-shortcuts.rkt:66:2 (negative? h)>
  #:original-syntax
    #<syntax:drracket/drracket/private/language.rkt:424:24 (< h 0)>
  #:source
    (file-source
     #<path:/home/runner/work/drracket/drracket/drracket/drracket/private/language.rkt>))

(define recorded-datum (send rdc get-recorded-datum))
(new pict-snip:pict-snip% [w aw] [h ah] [d d] [a a] [recorded-datum recorded-datum]))

Expand Down
7 changes: 4 additions & 3 deletions drracket/scribblings/drracket/languages.scrbl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#lang scribble/doc
@(require "common.rkt"
(for-label errortrace/errortrace-lib compiler/cm planet/config
racket/pretty drracket/tool drracket/tool-lib))
racket/pretty drracket/tool drracket/tool-lib pict))

@title[#:tag "languages" #:style 'toc]{Languages}

Expand All @@ -25,7 +25,7 @@ More generally, when using this mode, the
...)]; aside from comments, the @tech{definitions window}
must contain exactly one module.

@subsection{Initial Environment}
@subsection[#:tag "Initial Environment"]{Initial Environment}

DrRacket initializes the environment before it starts running the program in
ways slightly different than the @tt{racket} command-line binary does to reflect
Expand All @@ -37,7 +37,8 @@ in the next subsection.
DrRacket initializes the @racket[pretty-print-size-hook] and @racket[pretty-print-print-hook]
to specially recognize
@itemize[@item{@racket[snip%]s, which it just inserts into the editor}
@item{convertible values from @racketmodname[pict/convert]}
@item{convertible values from @racketmodname[pict/convert], which are rendered
with padding specified by @racket[convert-bounds-padding] around the bounding box to reduce edge effects}
@item{convertible values from @racketmodname[file/convertible] (which it converts to
png images)}
@item{numbers that are @racket[exact?] and @racket[real?], but not @racket[integer?],
Expand Down
3 changes: 2 additions & 1 deletion drracket/scribblings/drracket/printing.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ the booleans, it determines if there is a @litchar{#} prefix and for
the empty list, determines if it prints as @racket[empty] or @racket['()].

For any of the output styles, DrRacket sets the
@racket[global-port-print-handler] so that the @racket[print]
@racket[global-port-print-handler] (as described in @secref["Initial Environment"])
so that the @racket[print]
procedure produces output as selected.

Loading