From e89d82ca086cb3537c7621ad86d93bed56212e02 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Fri, 8 Aug 2025 00:00:45 +0200 Subject: [PATCH] ok --- main.rkt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/main.rkt b/main.rkt index b574e8d..c6c0e6d 100644 --- a/main.rkt +++ b/main.rkt @@ -19,19 +19,19 @@ (lambda (w h) w)))) ;(printf "label: ~a, max-w: ~a, w: ~a\n" l w ext) (if (or (< w 10) (<= ext w) (string=? l "")) - l + (if (eq? ellipsis 'right) + (string-append (str:string-drop-right l 3) "...") + (string-append "..." (str:string-drop l 3))) (let* ((factor (/ w ext)) (strl (string-length l)) (n-strl (round (* strl factor))) (drop (- strl n-strl))) (when (= drop 0) (set! drop 1)) - (if (eq? ellipsis 'right) + (if (eq? ellipsis 'left) (let ((nl (str:string-drop l drop))) - ;(printf "new-try ~a\n" nl) (ellipsize w (str:string-drop l drop))) (let ((nl (str:string-drop-right l drop))) - ;(printf "new-try ~a\n" nl) (ellipsize w (str:string-drop-right l drop)))))))) (define/override (set-label l . resize) @@ -60,11 +60,11 @@ my_label) )) -;(define win (new frame% [label "Hi there!"])) -;(define hp1 (new horizontal-pane% [parent win])) -;(define btn1 (new button% [label "Longer 1"] [parent hp1] [callback (lambda (b e) (send lbl1 set-label "This is a very long text, yes a longer text than we initial put"))])) -;(define lbl1 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp1] [ellipsis 'right])) -;(define hp2 (new horizontal-pane% [parent win])) -;(define btn2 (new button% [label "Longer 2"] [parent hp2] [callback (lambda (b e) (send lbl2 set-label "This is a very long second text, yes a longer text than we initial put"))])) -;(define lbl2 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp2] [ellipsis 'left])) -;(send win show #t) +(define win (new frame% [label "Hi there!"])) +(define hp1 (new horizontal-pane% [parent win])) +(define btn1 (new button% [label "Longer 1"] [parent hp1] [callback (lambda (b e) (send lbl1 set-label "This is a very long text, yes a longer text than we initial put"))])) +(define lbl1 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp1] [ellipsis 'right])) +(define hp2 (new horizontal-pane% [parent win])) +(define btn2 (new button% [label "Longer 2"] [parent hp2] [callback (lambda (b e) (send lbl2 set-label "This is a very long second text, yes a longer text than we initial put"))])) +(define lbl2 (new ellipsis-msg% [label "This is an ellipsis label"] [parent hp2] [ellipsis 'left])) +(send win show #t)