Snippit to remove the right side border on multi line text slots

Screen Shot 2022-04-24 at 5.46.08 PM
Screen Shot 2022-04-24 at 5.46.50 PM

Screen Shot 2022-04-24 at 5.49.48 PM
Screen Shot 2022-04-24 at 5.50.28 PM

snippit
TextMorph.prototype.parse = function () {
    var paragraphs = this.text.split('\n'),
        context = this.measureCtx,
        oldline = '',
        newline,
        w,
        slot = 0;

    context.font = this.font();
    this.maxLineWidth = 0;
    this.lines = [];
    this.lineSlots = [0];
    this.words = [];

    paragraphs.forEach(p => {
        this.words = this.words.concat(p.split(' '));
        this.words.push('\n');
    });

    this.words.forEach(word => {
        if (word === '\n') {
            this.lines.push(oldline);
            this.lineSlots.push(slot);
            this.maxLineWidth = Math.max(
                this.maxLineWidth,
                context.measureText(
                    (this.parent instanceof TextSlotMorph) ? oldline.slice(0, -1) : oldline
                ).width
            );
            oldline = '';
        } else {
            if (this.maxWidth > 0) {
                newline = oldline + word + ' ';
                w = context.measureText(newline).width;
                if (w > this.maxWidth) {
                    this.lines.push(oldline);
                    this.lineSlots.push(slot);
                    this.maxLineWidth = Math.max(
                        this.maxLineWidth,
                        context.measureText(oldline).width
                    );
                    oldline = word + ' ';
                } else {
                    oldline = newline;
                }
            } else {
                oldline = oldline + word + ' ';
            }
            slot += word.length + 1;
        }
    });
};

one-liner

TextMorph.prototype.parse=function(){var paragraphs=this.text.split('\n'),context=this.measureCtx,oldline='',newline,w,slot=0;context.font=this.font();this.maxLineWidth=0;this.lines=[];this.lineSlots=[0];this.words=[];paragraphs.forEach(p=>{this.words=this.words.concat(p.split(' '));this.words.push('\n');});this.words.forEach(word=>{if(word==='\n'){this.lines.push(oldline);this.lineSlots.push(slot);this.maxLineWidth=Math.max(this.maxLineWidth,context.measureText((this.parent instanceof TextSlotMorph)?oldline.slice(0,-1):oldline).width);oldline='';}else{if(this.maxWidth>0){newline=oldline+word+' ';w=context.measureText(newline).width;if(w>this.maxWidth){this.lines.push(oldline);this.lineSlots.push(slot);this.maxLineWidth=Math.max(this.maxLineWidth,context.measureText(oldline).width);oldline=word+' ';}else{oldline=newline;}}else{oldline=oldline+word+' ';}slot+=word.length+1;}});};

If you think this is what Snap! should do, file a PR. But I believe that the space on the right is at least in part deliberate to handle the case of text in italics in an option, e.g., untitled script pic (1). Used to be, the right edge of the "m" in "random" would be cut off. So your proposed solution would have to handle italics specially.

then

context.measureText(
    (this.parent instanceof TextSlotMorph && !this.isItalic) ? oldline.slice(0, -1) : oldline
).width

but id rather deal with this
untitled script pic(33) (which seems fine to me)
and have
untitled script pic(31)

than
untitled script pic(32)

and how will filing a pr help anyone im not sure what that is of how to do it

The code for Snap! is held on GitHub.

A PR is a pull-request which translates to a suggested amendment to the code.

So, if someone thinks they can help an OS project, they can offer their amendment to the project's maintainer and the maintainer can choose to accept (or ignore or reject) the amendment

It's a simple process but like anything, takes some getting used to

Please remember that it is entirely up to a projects maintainer as to whether they will accept a PR.

They could have much bigger priorities on their time and also might not agree that the issue is significant enough to bother with

Or they might be very grateful

It's up to them :slight_smile:

I agree that special-casing italics would be a better solution than the current extra space after everything. I'm guessing Jens doesn't want to slow things down by checking each time.

But I don't see how you aren't driven crazy by seeing the right edge of the "m" cut off! But when I was a kid my high school had a print shop, where I learned to be sensitive to such things, so maybe it doesn't bother the laity so much.

Never mind the PR, it's probably not worth your time to learn to use git, which is a well known fate worse than death.
git
(credit: xkcd)

haha yeah ive never quite got the hang of it and ive tried a few times to learn how to use it / understand what the big deal is. i even have an account set up with a couple of html / javascript projects i selected from my (ever-more unorganized) aaProjects folder, which was a pretty sad attempt at getting all my files together and in some order.

id probably be able to handle at least suggesting edits for bug fixes / improvements cause i find that stuff all the time (mostly little things) and im happy to find / fix the issue if i can. right now i usually just throw that stuff in a user script and forget about it.

and it does bug me, dont get me wrong, my ocd is what brought me here in the first place! but its also stopping me from doing anymore dirty work and i cant seem to find a clean solution rn so for the time being im just going to avoid putting m's at the end of my italic dropdowns :​)

Won't help; some other letters look even worse.

well like I said you can put

but im not quite satisfied. you could do

context.measureText(
     oldline.slice(0, -(
        this.parent instanceof TextSlotMorph &&
        !this.isItalic
    ))
).width

but I digress. feel like theres a better way but not up for it for now